3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Controller { public function testAction() { } public static function staticAction() { } public function __call($method, $arguments) { } } $calls = array( array('Controller', 'testAction'), array('Controller', 'staticAction'), array('Controller', 'fooAction'), array(new Controller, 'testAction'), array(new Controller, 'staticAction'), array(new Controller, 'fooAction'), ); foreach($calls as $controller) { $data = array(); try { $r = new ReflectionMethod($controller[0], $controller[1]); $data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getStartLine(), ); } catch (ReflectionException $re) { if (is_callable($controller) || method_exists($controller[0], '__call')) { $r = new ReflectionClass($controller[0]); // using __call magic $data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getMethod('__call')->getStartLine(), ); } } var_dump($data); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 97
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 97
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
Found catch point at position: 52
Branch analysis from position: 52
2 jumps found. (Code = 107) Position 1 = 53, Position 2 = -2
Branch analysis from position: 53
2 jumps found. (Code = 47) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 93
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 77
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 93
Branch analysis from position: 63
filename:       /in/tmC0X
function name:  (null)
number of ops:  99
compiled vars:  !0 = $calls, !1 = $controller, !2 = $data, !3 = $r, !4 = $re
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_ARRAY                                       ~5      <array>
          1        ADD_ARRAY_ELEMENT                                ~5      <array>
          2        ADD_ARRAY_ELEMENT                                ~5      <array>
   27     3        NEW                                              $6      'Controller'
          4        DO_FCALL                                      0          
          5        INIT_ARRAY                                       ~8      $6
          6        ADD_ARRAY_ELEMENT                                ~8      'testAction'
          7        ADD_ARRAY_ELEMENT                                ~5      ~8
   28     8        NEW                                              $9      'Controller'
          9        DO_FCALL                                      0          
         10        INIT_ARRAY                                       ~11     $9
         11        ADD_ARRAY_ELEMENT                                ~11     'staticAction'
         12        ADD_ARRAY_ELEMENT                                ~5      ~11
   29    13        NEW                                              $12     'Controller'
         14        DO_FCALL                                      0          
         15        INIT_ARRAY                                       ~14     $12
         16        ADD_ARRAY_ELEMENT                                ~14     'fooAction'
         17        ADD_ARRAY_ELEMENT                                ~5      ~14
   23    18        ASSIGN                                                   !0, ~5
   32    19      > FE_RESET_R                                       $16     !0, ->97
         20    > > FE_FETCH_R                                               $16, !1, ->97
   34    21    >   ASSIGN                                                   !2, <array>
   37    22        NEW                                              $18     'ReflectionMethod'
         23        CHECK_FUNC_ARG                                           
         24        FETCH_DIM_FUNC_ARG                               $19     !1, 0
         25        SEND_FUNC_ARG                                            $19
         26        CHECK_FUNC_ARG                                           
         27        FETCH_DIM_FUNC_ARG                               $20     !1, 1
         28        SEND_FUNC_ARG                                            $20
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !3, $18
   39    31        FETCH_DIM_R                                      ~24     !1, 0
         32        TYPE_CHECK                                  256          ~24
         33      > JMPZ                                                     ~25, ->38
         34    >   FETCH_DIM_R                                      ~26     !1, 0
         35        GET_CLASS                                        ~27     ~26
         36        QM_ASSIGN                                        ~28     ~27
         37      > JMP                                                      ->40
         38    >   FETCH_DIM_R                                      ~29     !1, 0
         39        QM_ASSIGN                                        ~28     ~29
         40    >   INIT_ARRAY                                       ~30     ~28, 'class'
   40    41        FETCH_DIM_R                                      ~31     !1, 1
         42        ADD_ARRAY_ELEMENT                                ~30     ~31, 'method'
   41    43        INIT_METHOD_CALL                                         !3, 'getFilename'
         44        DO_FCALL                                      0  $32     
         45        ADD_ARRAY_ELEMENT                                ~30     $32, 'file'
   42    46        INIT_METHOD_CALL                                         !3, 'getStartLine'
         47        DO_FCALL                                      0  $33     
         48        ADD_ARRAY_ELEMENT                                ~30     $33, 'line'
   38    49        ASSIGN_DIM                                               !2, 'controller'
   42    50        OP_DATA                                                  ~30
         51      > JMP                                                      ->93
   44    52  E > > CATCH                                       last         'ReflectionException'
   47    53    >   INIT_FCALL                                               'is_callable'
         54        SEND_VAR                                                 !1
         55        DO_ICALL                                         $34     
         56      > JMPNZ_EX                                         ~35     $34, ->63
         57    >   INIT_FCALL                                               'method_exists'
         58        FETCH_DIM_R                                      ~36     !1, 0
         59        SEND_VAL                                                 ~36
         60        SEND_VAL                                                 '__call'
         61        DO_ICALL                                         $37     
         62        BOOL                                             ~35     $37
         63    > > JMPZ                                                     ~35, ->93
   49    64    >   NEW                                              $38     'ReflectionClass'
         65        CHECK_FUNC_ARG                                           
         66        FETCH_DIM_FUNC_ARG                               $39     !1, 0
         67        SEND_FUNC_ARG                                            $39
         68        DO_FCALL                                      0          
         69        ASSIGN                                                   !3, $38
   53    70        FETCH_DIM_R                                      ~43     !1, 0
         71        TYPE_CHECK                                  256          ~43
         72      > JMPZ                                                     ~44, ->77
         73    >   FETCH_DIM_R                                      ~45     !1, 0
         74        GET_CLASS                                        ~46     ~45
         75        QM_ASSIGN                                        ~47     ~46
         76      > JMP                                                      ->79
         77    >   FETCH_DIM_R                                      ~48     !1, 0
         78        QM_ASSIGN                                        ~47     ~48
         79    >   INIT_ARRAY                                       ~49     ~47, 'class'
   54    80        FETCH_DIM_R                                      ~50     !1, 1
         81        ADD_ARRAY_ELEMENT                                ~49     ~50, 'method'
   55    82        INIT_METHOD_CALL                                         !3, 'getFilename'
         83        DO_FCALL                                      0  $51     
         84        ADD_ARRAY_ELEMENT                                ~49     $51, 'file'
   56    85        INIT_METHOD_CALL                                         !3, 'getMethod'
         86        SEND_VAL_EX                                              '__call'
         87        DO_FCALL                                      0  $52     
         88        INIT_METHOD_CALL                                         $52, 'getStartLine'
         89        DO_FCALL                                      0  $53     
         90        ADD_ARRAY_ELEMENT                                ~49     $53, 'line'
   52    91        ASSIGN_DIM                                               !2, 'controller'
   56    92        OP_DATA                                                  ~49
   63    93    >   INIT_FCALL                                               'var_dump'
         94        SEND_VAR                                                 !2
         95        DO_ICALL                                                 
   32    96      > JMP                                                      ->20
         97    >   FE_FREE                                                  $16
   64    98      > RETURN                                                   1

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

End of function testaction

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

End of function staticaction

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tmC0X
function name:  __call
number of ops:  3
compiled vars:  !0 = $method, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2      > RETURN                                                   null

End of function __call

End of class Controller.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.45 ms | 1409 KiB | 19 Q