3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute()] class Foo { public function __construct( public int $a, public string $b ) { } } // With ordered arguments #[Foo(123, 'abc')] class Bar { } // With named arguments #[Foo( a: 123, b: 'abc' )] class Baz { } var_dump((new ReflectionClass(Bar::class))->getAttributes(Foo::class)[0]->newInstance()); var_dump((new ReflectionClass(Baz::class))->getAttributes(Foo::class)[0]->newInstance());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/veQIX
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                                   'var_dump'
          1        NEW                                                  $0      'ReflectionClass'
          2        SEND_VAL_EX                                                  'Bar'
          3        DO_FCALL                                          0          
          4        INIT_METHOD_CALL                                             $0, 'getAttributes'
          5        SEND_VAL_EX                                                  'Foo'
          6        DO_FCALL                                          0  $2      
          7        FETCH_DIM_R                                          ~3      $2, 0
          8        INIT_METHOD_CALL                                             ~3, 'newInstance'
          9        DO_FCALL                                          0  $4      
         10        SEND_VAR                                                     $4
         11        DO_ICALL                                                     
   32    12        INIT_FCALL                                                   'var_dump'
         13        NEW                                                  $6      'ReflectionClass'
         14        SEND_VAL_EX                                                  'Baz'
         15        DO_FCALL                                          0          
         16        INIT_METHOD_CALL                                             $6, 'getAttributes'
         17        SEND_VAL_EX                                                  'Foo'
         18        DO_FCALL                                          0  $8      
         19        FETCH_DIM_R                                          ~9      $8, 0
         20        INIT_METHOD_CALL                                             ~9, 'newInstance'
         21        DO_FCALL                                          0  $10     
         22        SEND_VAR                                                     $10
         23        DO_ICALL                                                     
         24      > RETURN                                                       1

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

End of function __construct

End of class Foo.

Class Bar: [no user functions]
Class Baz: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.8 ms | 1911 KiB | 14 Q