3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Qux { public static function bar() { return __CLASS__; } } class Foo { use Qux; } $reflectionTrait = new ReflectionMethod('Qux', 'bar'); $reflectionClass = new ReflectionMethod('Foo', 'bar'); var_dump($reflectionTrait->getDeclaringClass()->getName(), $reflectionTrait->invoke()); var_dump($reflectionClass->getDeclaringClass()->getName(), $reflectionClass->invoke());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k0VaR
function name:  (null)
number of ops:  32
compiled vars:  !0 = $reflectionTrait, !1 = $reflectionClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'foo'
   16     1        NEW                                              $2      'ReflectionMethod'
          2        SEND_VAL_EX                                              'Qux'
          3        SEND_VAL_EX                                              'bar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   17     6        NEW                                              $5      'ReflectionMethod'
          7        SEND_VAL_EX                                              'Foo'
          8        SEND_VAL_EX                                              'bar'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $5
   19    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
         13        DO_FCALL                                      0  $8      
         14        INIT_METHOD_CALL                                         $8, 'getName'
         15        DO_FCALL                                      0  $9      
         16        SEND_VAR                                                 $9
         17        INIT_METHOD_CALL                                         !0, 'invoke'
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                                 
   20    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !1, 'getDeclaringClass'
         23        DO_FCALL                                      0  $12     
         24        INIT_METHOD_CALL                                         $12, 'getName'
         25        DO_FCALL                                      0  $13     
         26        SEND_VAR                                                 $13
         27        INIT_METHOD_CALL                                         !1, 'invoke'
         28        DO_FCALL                                      0  $14     
         29        SEND_VAR                                                 $14
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Class Qux:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k0VaR
function name:  bar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_CLASS_NAME                                 ~0      
          1      > RETURN                                                   ~0
    7     2*     > RETURN                                                   null

End of function bar

End of class Qux.

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.05 ms | 1396 KiB | 15 Q