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; var_dump((new \ReflectionClassConstant($obj::class, $obj->name))->getAttributes(TestAttribute::class)[0]->newInstance());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YY6Oa
function name:  (null)
number of ops:  20
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'testnum'
   20     1        FETCH_CLASS_CONSTANT                             ~1      'TestNum', 'ALPHA'
          2        ASSIGN                                                   !0, ~1
   21     3        INIT_FCALL                                               'var_dump'
          4        NEW                                              $3      'ReflectionClassConstant'
          5        FETCH_CLASS_NAME                                 ~4      !0
          6        SEND_VAL_EX                                              ~4
          7        CHECK_FUNC_ARG                                           
          8        FETCH_OBJ_FUNC_ARG                               $5      !0, 'name'
          9        SEND_FUNC_ARG                                            $5
         10        DO_FCALL                                      0          
         11        INIT_METHOD_CALL                                         $3, 'getAttributes'
         12        SEND_VAL_EX                                              'TestAttribute'
         13        DO_FCALL                                      0  $7      
         14        FETCH_DIM_R                                      ~8      $7, 0
         15        INIT_METHOD_CALL                                         ~8, 'newInstance'
         16        DO_FCALL                                      0  $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class TestAttribute:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YY6Oa
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:
148.39 ms | 1005 KiB | 14 Q