3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Bar { public function traitMethod () { return function () { var_dump(__FUNCTION__, __METHOD__); };} } class Foo { use Bar; public function method () { return function () { var_dump(__FUNCTION__, __METHOD__); };} } $reflection = new ReflectionMethod(new Foo(), 'traitMethod'); var_dump($reflection->getDeclaringClass());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9ffm
function name:  (null)
number of ops:  14
compiled vars:  !0 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'foo'
   11     1        NEW                                              $1      'ReflectionMethod'
          2        NEW                                              $2      'Foo'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $2
          5        SEND_VAL_EX                                              'traitMethod'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $1
   12     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
         10        DO_FCALL                                      0  $6      
         11        SEND_VAR                                                 $6
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FF9ffm%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9ffm
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '%7Bclosure%7D'
          2        SEND_VAL                                                 '%7Bclosure%7D'
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FF9ffm%3A4%240

Function %00%7Bclosure%7D%2Fin%2FF9ffm%3A8%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9ffm
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '%7Bclosure%7D'
          2        SEND_VAL                                                 '%7Bclosure%7D'
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FF9ffm%3A8%241

Class Bar:
Function traitmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9ffm
function name:  traitMethod
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FF9ffm%3A4%240'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function traitmethod

End of class Bar.

Class Foo:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9ffm
function name:  method
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FF9ffm%3A8%241'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function method

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.97 ms | 1405 KiB | 15 Q