3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute] class y { function foo() { return __METHOD__; } } #[X, Y] function f() { } $ref = new \ReflectionFunction('\f'); try { if ($ref->getAttributes()[0]->getName() === 'X') { print 'Look mom! No hands' . PHP_EOL; } if ($ref->getAttributes()[1]->getName() === 'Y') { print $ref->getAttributes()[1]->newInstance()->foo(); } } catch (\Error $e) { # other errors var_dump($e->getMessage()); } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 12
Found catch point at position: 28
Branch analysis from position: 28
2 jumps found. (Code = 107) Position 1 = 29, Position 2 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jc7gE
function name:  (null)
number of ops:  35
compiled vars:  !0 = $ref, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   NEW                                                  $2      'ReflectionFunction'
          1        SEND_VAL_EX                                                  '%5Cf'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   14     4        INIT_METHOD_CALL                                             !0, 'getAttributes'
          5        DO_FCALL                                          0  $5      
          6        FETCH_DIM_R                                          ~6      $5, 0
          7        INIT_METHOD_CALL                                             ~6, 'getName'
          8        DO_FCALL                                          0  $7      
          9        IS_IDENTICAL                                                 $7, 'X'
         10      > JMPZ                                                         ~8, ->12
   15    11    >   ECHO                                                         'Look+mom%21+No+hands%0A'
   18    12    >   INIT_METHOD_CALL                                             !0, 'getAttributes'
         13        DO_FCALL                                          0  $9      
         14        FETCH_DIM_R                                          ~10     $9, 1
         15        INIT_METHOD_CALL                                             ~10, 'getName'
         16        DO_FCALL                                          0  $11     
         17        IS_IDENTICAL                                                 $11, 'Y'
         18      > JMPZ                                                         ~12, ->27
   19    19    >   INIT_METHOD_CALL                                             !0, 'getAttributes'
         20        DO_FCALL                                          0  $13     
         21        FETCH_DIM_R                                          ~14     $13, 1
         22        INIT_METHOD_CALL                                             ~14, 'newInstance'
         23        DO_FCALL                                          0  $15     
         24        INIT_METHOD_CALL                                             $15, 'foo'
         25        DO_FCALL                                          0  $16     
         26        ECHO                                                         $16
         27    > > JMP                                                          ->34
   21    28  E > > CATCH                                           last         'Error'
   23    29    >   INIT_FCALL                                                   'var_dump'
         30        INIT_METHOD_CALL                                             !1, 'getMessage'
         31        DO_FCALL                                          0  $17     
         32        SEND_VAR                                                     $17
         33        DO_ICALL                                                     
   26    34    > > RETURN                                                       1

Function f:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jc7gE
function name:  f
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                       null

End of function f

Class y:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jc7gE
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                       'y%3A%3Afoo'
          1*     > RETURN                                                       null

End of function foo

End of class y.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
133.8 ms | 1540 KiB | 14 Q