3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyFoo { public function __construct( #[Inject('baz-value')] public readonly int $bar, ){} } $ref = new ReflectionClass(MyFoo::class); var_dump($ref->getConstructor()->getParameters()[0]->getAttributes()); var_dump($ref->getProperty('bar')->getAttributes());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gdbCY
function name:  (null)
number of ops:  23
compiled vars:  !0 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $1      'ReflectionClass'
          1        SEND_VAL_EX                                              'MyFoo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   12     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'getConstructor'
          6        DO_FCALL                                      0  $4      
          7        INIT_METHOD_CALL                                         $4, 'getParameters'
          8        DO_FCALL                                      0  $5      
          9        FETCH_DIM_R                                      ~6      $5, 0
         10        INIT_METHOD_CALL                                         ~6, 'getAttributes'
         11        DO_FCALL                                      0  $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                                 
   13    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'getProperty'
         16        SEND_VAL_EX                                              'bar'
         17        DO_FCALL                                      0  $9      
         18        INIT_METHOD_CALL                                         $9, 'getAttributes'
         19        DO_FCALL                                      0  $10     
         20        SEND_VAR                                                 $10
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

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

End of function __construct

End of class MyFoo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.74 ms | 1006 KiB | 14 Q