3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_CLASS_CONSTANT)] class TestAttribute { public function __construct(public string $value) { } } enum TestNum { #[TestAttribute('alpha value')] case ALPHA; #[TestAttribute('beta value')] case BETA; } $obj = TestNum::ALPHA; $reflection = new ReflectionClass($obj); $classAttributes = $reflection->getAttributes(TestAttribute::class); var_dump($classAttributes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uLDVQ
function name:  (null)
number of ops:  15
compiled vars:  !0 = $obj, !1 = $reflection, !2 = $classAttributes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'testnum'
   20     1        FETCH_CLASS_CONSTANT                             ~3      'TestNum', 'ALPHA'
          2        ASSIGN                                                   !0, ~3
   21     3        NEW                                              $5      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   22     7        INIT_METHOD_CALL                                         !1, 'getAttributes'
          8        SEND_VAL_EX                                              'TestAttribute'
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !2, $8
   23    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class TestAttribute:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uLDVQ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

End of class TestAttribute.

Class TestNum: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.51 ms | 1009 KiB | 14 Q