3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Qux { public static function bar() { return __CLASS__; } } class Foo { use Qux; } class Baz extends Foo { } $reflectionTrait = new ReflectionMethod('Qux', 'bar'); $reflectionClass = new ReflectionMethod('Foo', 'bar'); $reflectionExtended = new ReflectionMethod('Baz', 'bar'); var_dump(Qux::bar(), $reflectionTrait->getDeclaringClass()->getName(), $reflectionTrait->invoke(null)); var_dump(Foo::bar(), $reflectionClass->getPrototype()->getDeclaringClass()->getName(), $reflectionClass->invoke(null)); var_dump(Baz::bar(), $reflectionExtended->getDeclaringClass()->getName(), $reflectionExtended->invoke(null));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b9Hro
function name:  (null)
number of ops:  62
compiled vars:  !0 = $reflectionTrait, !1 = $reflectionClass, !2 = $reflectionExtended
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'foo'
   16     1        DECLARE_CLASS                                            'baz', 'foo'
   21     2        NEW                                              $3      'ReflectionMethod'
          3        SEND_VAL_EX                                              'Qux'
          4        SEND_VAL_EX                                              'bar'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   22     7        NEW                                              $6      'ReflectionMethod'
          8        SEND_VAL_EX                                              'Foo'
          9        SEND_VAL_EX                                              'bar'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $6
   23    12        NEW                                              $9      'ReflectionMethod'
         13        SEND_VAL_EX                                              'Baz'
         14        SEND_VAL_EX                                              'bar'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $9
   25    17        INIT_FCALL                                               'var_dump'
         18        INIT_STATIC_METHOD_CALL                                  'Qux', 'bar'
         19        DO_FCALL                                      0  $12     
         20        SEND_VAR                                                 $12
         21        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
         22        DO_FCALL                                      0  $13     
         23        INIT_METHOD_CALL                                         $13, 'getName'
         24        DO_FCALL                                      0  $14     
         25        SEND_VAR                                                 $14
         26        INIT_METHOD_CALL                                         !0, 'invoke'
         27        SEND_VAL_EX                                              null
         28        DO_FCALL                                      0  $15     
         29        SEND_VAR                                                 $15
         30        DO_ICALL                                                 
   26    31        INIT_FCALL                                               'var_dump'
         32        INIT_STATIC_METHOD_CALL                                  'Foo', 'bar'
         33        DO_FCALL                                      0  $17     
         34        SEND_VAR                                                 $17
         35        INIT_METHOD_CALL                                         !1, 'getPrototype'
         36        DO_FCALL                                      0  $18     
         37        INIT_METHOD_CALL                                         $18, 'getDeclaringClass'
         38        DO_FCALL                                      0  $19     
         39        INIT_METHOD_CALL                                         $19, 'getName'
         40        DO_FCALL                                      0  $20     
         41        SEND_VAR                                                 $20
         42        INIT_METHOD_CALL                                         !1, 'invoke'
         43        SEND_VAL_EX                                              null
         44        DO_FCALL                                      0  $21     
         45        SEND_VAR                                                 $21
         46        DO_ICALL                                                 
   27    47        INIT_FCALL                                               'var_dump'
         48        INIT_STATIC_METHOD_CALL                                  'Baz', 'bar'
         49        DO_FCALL                                      0  $23     
         50        SEND_VAR                                                 $23
         51        INIT_METHOD_CALL                                         !2, 'getDeclaringClass'
         52        DO_FCALL                                      0  $24     
         53        INIT_METHOD_CALL                                         $24, 'getName'
         54        DO_FCALL                                      0  $25     
         55        SEND_VAR                                                 $25
         56        INIT_METHOD_CALL                                         !2, 'invoke'
         57        SEND_VAL_EX                                              null
         58        DO_FCALL                                      0  $26     
         59        SEND_VAR                                                 $26
         60        DO_ICALL                                                 
         61      > RETURN                                                   1

Class Qux:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b9Hro
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]
Class Baz: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.96 ms | 1400 KiB | 15 Q