3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private static $foo = 123; protected static function bar() { echo 'scope is: ', static::class, ' value of self::$foo is: ', self::$foo, PHP_EOL; } } class B extends A { private static $foo = 456; public static function bar() { $closure = self::getStaticInvoker('A', 'bar')->bindTo(null, B::class); $closure(); } private static function getStaticInvoker($className, $method) { return function (array $args) use ($className, $method) { return forward_static_call_array(array($className, $method), $args); }; } } B::bar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25GLe
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_STATIC_METHOD_CALL                                  'B', 'bar'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F25GLe%3A20%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25GLe
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $args, !1 = $className, !2 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   21     3        INIT_FCALL                                               'forward_static_call_array'
          4        INIT_ARRAY                                       ~3      !1
          5        ADD_ARRAY_ELEMENT                                ~3      !2
          6        SEND_VAL                                                 ~3
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $4      
          9      > RETURN                                                   $4
   22    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F25GLe%3A20%240

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

End of function bar

End of class A.

Class B:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25GLe
function name:  bar
number of ops:  12
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_STATIC_METHOD_CALL                                  'getStaticInvoker'
          1        SEND_VAL_EX                                              'A'
          2        SEND_VAL_EX                                              'bar'
          3        DO_FCALL                                      0  $1      
          4        INIT_METHOD_CALL                                         $1, 'bindTo'
          5        SEND_VAL_EX                                              null
          6        SEND_VAL_EX                                              'B'
          7        DO_FCALL                                      0  $2      
          8        ASSIGN                                                   !0, $2
   15     9        INIT_DYNAMIC_CALL                                        !0
         10        DO_FCALL                                      0          
   16    11      > RETURN                                                   null

End of function bar

Function getstaticinvoker:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25GLe
function name:  getStaticInvoker
number of ops:  7
compiled vars:  !0 = $className, !1 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F25GLe%3A20%240'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
   22     5      > RETURN                                                   ~2
   23     6*     > RETURN                                                   null

End of function getstaticinvoker

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.81 ms | 1400 KiB | 15 Q