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('Bar', 'traitMethod'); var_dump($reflection->getDeclaringClass());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TAO61
function name:  (null)
number of ops:  12
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        SEND_VAL_EX                                              'Bar'
          3        SEND_VAL_EX                                              'traitMethod'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   12     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FTAO61%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TAO61
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%2FTAO61%3A4%240

Function %00%7Bclosure%7D%2Fin%2FTAO61%3A8%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TAO61
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%2FTAO61%3A8%241

Class Bar:
Function traitmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TAO61
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%2FTAO61%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/TAO61
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%2FTAO61%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:
167.71 ms | 1400 KiB | 15 Q