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(Qux::bar(), $reflectionTrait->getDeclaringClass()->getName(), $reflectionTrait->invoke(null)); var_dump($reflectionClass->getDeclaringClass()->getName(), $reflectionClass->invoke(null));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W25a8
function name:  (null)
number of ops:  37
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_STATIC_METHOD_CALL                                  'Qux', 'bar'
         13        DO_FCALL                                      0  $8      
         14        SEND_VAR                                                 $8
         15        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
         16        DO_FCALL                                      0  $9      
         17        INIT_METHOD_CALL                                         $9, 'getName'
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        INIT_METHOD_CALL                                         !0, 'invoke'
         21        SEND_VAL_EX                                              null
         22        DO_FCALL                                      0  $11     
         23        SEND_VAR                                                 $11
         24        DO_ICALL                                                 
   20    25        INIT_FCALL                                               'var_dump'
         26        INIT_METHOD_CALL                                         !1, 'getDeclaringClass'
         27        DO_FCALL                                      0  $13     
         28        INIT_METHOD_CALL                                         $13, 'getName'
         29        DO_FCALL                                      0  $14     
         30        SEND_VAR                                                 $14
         31        INIT_METHOD_CALL                                         !1, 'invoke'
         32        SEND_VAL_EX                                              null
         33        DO_FCALL                                      0  $15     
         34        SEND_VAR                                                 $15
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Class Qux:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W25a8
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:
145.82 ms | 1400 KiB | 15 Q