3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static $someFunction; // Throws error. static function foo() { static::$someFunction(); } // Works static function bar() { $func = static::$someFunction; $func(); } } A::$someFunction = function() { print "wtf\n";}; A::bar(); A::foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SPfW
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0SPfW%3A18%240'
          1        ASSIGN_STATIC_PROP                                       'someFunction', 'A'
          2        OP_DATA                                                  ~1
   20     3        INIT_STATIC_METHOD_CALL                                  'A', 'bar'
          4        DO_FCALL                                      0          
   21     5        INIT_STATIC_METHOD_CALL                                  'A', 'foo'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F0SPfW%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SPfW
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'wtf%0A'
          1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F0SPfW%3A18%240

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SPfW
function name:  foo
number of ops:  3
compiled vars:  !0 = $someFunction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_STATIC_METHOD_CALL                                  !0
          1        DO_FCALL                                      0          
    9     2      > RETURN                                                   null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SPfW
function name:  bar
number of ops:  5
compiled vars:  !0 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_STATIC_PROP_R          unknown             ~1      'someFunction'
          1        ASSIGN                                                   !0, ~1
   14     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   15     4      > RETURN                                                   null

End of function bar

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.68 ms | 1395 KiB | 13 Q