3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyMethod extends \ReflectionMethod { public function hasPrototype() { try { parent::getPrototype(); return true; } catch (\ReflectionException $e) { return false; } } public function getPrototype() { return $this->hasPrototype() ? parent::getPrototype() : "Method {$this->getName()} does not have a prototype"; } } trait TestTrait { public function getKernel() { } } class BaseTest { public function getKernel() { } } class Test extends BaseTest { use TestTrait; } $refl = new MyMethod('Test', 'getKernel'); var_dump($refl->getPrototype()); var_dump($refl->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WJATl
function name:  (null)
number of ops:  37
compiled vars:  !0 = $refl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   DECLARE_CLASS                                            'test', 'basetest'
   39     1        NEW                                              $1      'MyMethod'
          2        SEND_VAL_EX                                              'Test'
          3        SEND_VAL_EX                                              'getKernel'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   41     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'getPrototype'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
   43    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getPrototype'
         13        DO_FCALL                                      0  $6      
         14        INIT_METHOD_CALL                                         $6, 'getPrototype'
         15        DO_FCALL                                      0  $7      
         16        INIT_METHOD_CALL                                         $7, 'getPrototype'
         17        DO_FCALL                                      0  $8      
         18        INIT_METHOD_CALL                                         $8, 'getPrototype'
         19        DO_FCALL                                      0  $9      
         20        INIT_METHOD_CALL                                         $9, 'getPrototype'
         21        DO_FCALL                                      0  $10     
         22        INIT_METHOD_CALL                                         $10, 'getPrototype'
         23        DO_FCALL                                      0  $11     
         24        INIT_METHOD_CALL                                         $11, 'getPrototype'
         25        DO_FCALL                                      0  $12     
         26        INIT_METHOD_CALL                                         $12, 'getPrototype'
         27        DO_FCALL                                      0  $13     
         28        INIT_METHOD_CALL                                         $13, 'getPrototype'
         29        DO_FCALL                                      0  $14     
         30        INIT_METHOD_CALL                                         $14, 'getPrototype'
         31        DO_FCALL                                      0  $15     
         32        INIT_METHOD_CALL                                         $15, 'getPrototype'
         33        DO_FCALL                                      0  $16     
         34        SEND_VAR                                                 $16
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Class MyMethod:
Function hasprototype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 4
Branch analysis from position: 4
2 jumps found. (Code = 107) Position 1 = 5, Position 2 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WJATl
function name:  hasPrototype
number of ops:  7
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  'getPrototype'
          1        DO_FCALL                                      0          
    8     2      > RETURN                                                   <true>
          3*       JMP                                                      ->6
   10     4  E > > CATCH                                       last         'ReflectionException'
   11     5    > > RETURN                                                   <false>
   13     6*     > RETURN                                                   null

End of function hasprototype

Function getprototype:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WJATl
function name:  getPrototype
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_METHOD_CALL                                         'hasPrototype'
          1        DO_FCALL                                      0  $0      
          2      > JMPZ                                                     $0, ->7
          3    >   INIT_STATIC_METHOD_CALL                                  'getPrototype'
          4        DO_FCALL                                      0  $1      
          5        QM_ASSIGN                                        ~2      $1
          6      > JMP                                                      ->13
          7    >   ROPE_INIT                                     3  ~5      'Method+'
          8        INIT_METHOD_CALL                                         'getName'
          9        DO_FCALL                                      0  $3      
         10        ROPE_ADD                                      1  ~5      ~5, $3
         11        ROPE_END                                      2  ~4      ~5, '+does+not+have+a+prototype'
         12        QM_ASSIGN                                        ~2      ~4
         13    > > RETURN                                                   ~2
   17    14*     > RETURN                                                   null

End of function getprototype

End of class MyMethod.

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

End of function getkernel

End of class TestTrait.

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

End of function getkernel

End of class BaseTest.

Class Test: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.77 ms | 1400 KiB | 15 Q