3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute(\Attribute::TARGET_PARAMETER)] class Inject { public function __construct( public readonly string $id ) { } } class MyFoo { public function __construct( #[Inject('baz-value')] public readonly int $bar, ){} } $ref = new ReflectionClass(MyFoo::class); echo "Checking Parameters : "; $parameters = $ref->getConstructor()->getParameters(); foreach ($parameters as $parameter) { foreach ($parameter->getAttributes() as $attribute) { $attribute->newInstance(); } } echo "✅\n\n"; echo "Checking Properties : "; $properties = $ref->getProperties(); foreach ($properties as $property) { foreach ($property->getAttributes() as $attribute) { $attribute->newInstance(); } } echo "✅\n\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 19
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 38
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 36
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 36
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 21
filename:       /in/rMqqA
function name:  (null)
number of ops:  41
compiled vars:  !0 = $ref, !1 = $parameters, !2 = $parameter, !3 = $attribute, !4 = $properties, !5 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $6      'ReflectionClass'
          1        SEND_VAL_EX                                              'MyFoo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
   17     4        ECHO                                                     'Checking+Parameters+%3A+'
   18     5        INIT_METHOD_CALL                                         !0, 'getConstructor'
          6        DO_FCALL                                      0  $9      
          7        INIT_METHOD_CALL                                         $9, 'getParameters'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !1, $10
   19    10      > FE_RESET_R                                       $12     !1, ->21
         11    > > FE_FETCH_R                                               $12, !2, ->21
   20    12    >   INIT_METHOD_CALL                                         !2, 'getAttributes'
         13        DO_FCALL                                      0  $13     
         14      > FE_RESET_R                                       $14     $13, ->19
         15    > > FE_FETCH_R                                               $14, !3, ->19
   21    16    >   INIT_METHOD_CALL                                         !3, 'newInstance'
         17        DO_FCALL                                      0          
   20    18      > JMP                                                      ->15
         19    >   FE_FREE                                                  $14
   19    20      > JMP                                                      ->11
         21    >   FE_FREE                                                  $12
   24    22        ECHO                                                     '%E2%9C%85%0A%0A'
   26    23        ECHO                                                     'Checking+Properties+%3A+'
   27    24        INIT_METHOD_CALL                                         !0, 'getProperties'
         25        DO_FCALL                                      0  $16     
         26        ASSIGN                                                   !4, $16
   28    27      > FE_RESET_R                                       $18     !4, ->38
         28    > > FE_FETCH_R                                               $18, !5, ->38
   29    29    >   INIT_METHOD_CALL                                         !5, 'getAttributes'
         30        DO_FCALL                                      0  $19     
         31      > FE_RESET_R                                       $20     $19, ->36
         32    > > FE_FETCH_R                                               $20, !3, ->36
   30    33    >   INIT_METHOD_CALL                                         !3, 'newInstance'
         34        DO_FCALL                                      0          
   29    35      > JMP                                                      ->32
         36    >   FE_FREE                                                  $20
   28    37      > JMP                                                      ->28
         38    >   FE_FREE                                                  $18
   33    39        ECHO                                                     '%E2%9C%85%0A%0A'
         40      > RETURN                                                   1

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

End of function __construct

End of class Inject.

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

End of function __construct

End of class MyFoo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.83 ms | 968 KiB | 13 Q