3v4l.org

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

Class RandomValue:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hv5N4
function name:  __construct
number of ops:  9
compiled vars:  !0 = $prefix
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    7     1        INIT_FCALL                                                   'random_int'
          2        SEND_VAL                                                     1
          3        SEND_VAL                                                     100
          4        DO_ICALL                                             $2      
          5        CONCAT                                               ~3      !0, $2
          6        ASSIGN_OBJ                                                   'value'
          7        OP_DATA                                                      ~3
    8     8      > RETURN                                                       null

End of function __construct

End of class RandomValue.

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

End of function __construct

End of class Foo.

Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.87 ms | 492 KiB | 11 Q