3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { static function bar() { echo self::class, ' vs ', static::class, PHP_EOL; } static function bar1() { echo self::class, ' vs ', static::class, PHP_EOL; } } class baz extends foo { static function bar() { echo self::class, ' vs ', static::class, PHP_EOL; } } $r = new ReflectionClass('baz'); $m = $r->getMethod('bar1'); // without overriden method - it's ok, our static scope is preserved. Out: foo vs baz $m->invoke(null); $r = new ReflectionClass('baz'); $m = $r->getMethod('bar'); // with overriden method it's impossible to call parent static method. Out: baz vs baz $m->invoke(null); // how to statically call the parent static method bar() with scope == baz??
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ASntq
function name:  (null)
number of ops:  23
compiled vars:  !0 = $r, !1 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $2      'ReflectionClass'
          1        SEND_VAL_EX                                              'baz'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   25     4        INIT_METHOD_CALL                                         !0, 'getMethod'
          5        SEND_VAL_EX                                              'bar1'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   26     8        INIT_METHOD_CALL                                         !1, 'invoke'
          9        SEND_VAL_EX                                              null
         10        DO_FCALL                                      0          
   28    11        NEW                                              $8      'ReflectionClass'
         12        SEND_VAL_EX                                              'baz'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !0, $8
   29    15        INIT_METHOD_CALL                                         !0, 'getMethod'
         16        SEND_VAL_EX                                              'bar'
         17        DO_FCALL                                      0  $11     
         18        ASSIGN                                                   !1, $11
   30    19        INIT_METHOD_CALL                                         !1, 'invoke'
         20        SEND_VAL_EX                                              null
         21        DO_FCALL                                      0          
   31    22      > RETURN                                                   1

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

End of function bar

Function bar1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ASntq
function name:  bar1
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'foo'
          1        ECHO                                                     '+vs+'
          2        FETCH_CLASS_NAME                                 ~0      
          3        ECHO                                                     ~0
          4        ECHO                                                     '%0A'
   13     5      > RETURN                                                   null

End of function bar1

End of class foo.

Class baz:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ASntq
function name:  bar
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     'baz'
          1        ECHO                                                     '+vs+'
          2        FETCH_CLASS_NAME                                 ~0      
          3        ECHO                                                     ~0
          4        ECHO                                                     '%0A'
   21     5      > RETURN                                                   null

End of function bar

Function bar1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ASntq
function name:  bar1
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'foo'
          1        ECHO                                                     '+vs+'
          2        FETCH_CLASS_NAME                                 ~0      
          3        ECHO                                                     ~0
          4        ECHO                                                     '%0A'
   13     5      > RETURN                                                   null

End of function bar1

End of class baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.53 ms | 1000 KiB | 13 Q