3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_FUNCTION)] class Test {} class Foo { #[Test] public int $test; } echo "Creating foo: "; $f = new Foo(); echo "done\n"; echo "Performing reflection: "; $foo = new ReflectionClass($f); $test = $foo->getProperty('test'); $attributes = $test->getAttributes(); echo "done\n"; echo "instantiating attribute ["; foreach ($attributes as $attribute) { echo $attribute->getName() . ']: '; $attribute->newInstance(); } echo "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/UqQKi
function name:  (null)
number of ops:  31
compiled vars:  !0 = $f, !1 = $foo, !2 = $test, !3 = $attributes, !4 = $attribute
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                         'Creating+foo%3A+'
   12     1        NEW                                                  $5      'Foo'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $5
   13     4        ECHO                                                         'done%0A'
   15     5        ECHO                                                         'Performing+reflection%3A+'
   16     6        NEW                                                  $8      'ReflectionClass'
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !1, $8
   17    10        INIT_METHOD_CALL                                             !1, 'getProperty'
         11        SEND_VAL_EX                                                  'test'
         12        DO_FCALL                                          0  $11     
         13        ASSIGN                                                       !2, $11
   18    14        INIT_METHOD_CALL                                             !2, 'getAttributes'
         15        DO_FCALL                                          0  $13     
         16        ASSIGN                                                       !3, $13
   19    17        ECHO                                                         'done%0A'
   21    18        ECHO                                                         'instantiating+attribute+%5B'
   22    19      > FE_RESET_R                                           $15     !3, ->28
         20    > > FE_FETCH_R                                                   $15, !4, ->28
   23    21    >   INIT_METHOD_CALL                                             !4, 'getName'
         22        DO_FCALL                                          0  $16     
         23        CONCAT                                               ~17     $16, '%5D%3A+'
         24        ECHO                                                         ~17
   24    25        INIT_METHOD_CALL                                             !4, 'newInstance'
         26        DO_FCALL                                          0          
   22    27      > JMP                                                          ->20
         28    >   FE_FREE                                                      $15
   26    29        ECHO                                                         '%0A'
         30      > RETURN                                                       1

Class Test: [no user functions]
Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.86 ms | 1470 KiB | 13 Q