3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Name; function Boo() { var_dump('func:', __FUNCTION__, __METHOD__); } trait Constants { public static function classConst () { return function () { return [__CLASS__, __TRAIT__]; }; } public static function traitC () {var_dump('trait_method:', __FUNCTION__, __METHOD__, __CLASS__);call_user_func(function () { var_dump('trait_closure:', __FUNCTION__, __METHOD__, __CLASS__); }); } } class Foo { use Constants; public static function method () {var_dump('method:', __FUNCTION__, __METHOD__);call_user_func(function () { var_dump('closure:', __FUNCTION__, __METHOD__); }); } } //Boo(); //Foo::method(); //Foo::traitC(); //var_dump(__METHOD__); $closure = Foo::classConst(); var_dump($closure()); $closure = \Closure::bind($closure, null, '\\stdClass'); var_dump($closure());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  (null)
number of ops:  21
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_CLASS                                            'name%5Cfoo'
   21     1        INIT_STATIC_METHOD_CALL                                  'Name%5CFoo', 'classConst'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   22     4        INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
          5        INIT_DYNAMIC_CALL                                        !0
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR_NO_REF_EX                                       $3
          8        DO_FCALL                                      0          
   23     9        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 null
         12        SEND_VAL                                                 '%5CstdClass'
         13        DO_FCALL                                      0  $5      
         14        ASSIGN                                                   !0, $5
   24    15        INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
         16        INIT_DYNAMIC_CALL                                        !0
         17        DO_FCALL                                      0  $7      
         18        SEND_VAR_NO_REF_EX                                       $7
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Function name%5Cboo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  Name\Boo
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
          1        SEND_VAL_EX                                              'func%3A'
          2        SEND_VAL_EX                                              'Name%5CBoo'
          3        SEND_VAL_EX                                              'Name%5CBoo'
          4        DO_FCALL                                      0          
    6     5      > RETURN                                                   null

End of function name%5Cboo

Function %00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  Name\{closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_CLASS_NAME                                 ~0      
          1        INIT_ARRAY                                       ~1      ~0
          2        ADD_ARRAY_ELEMENT                                ~1      'Name%5CConstants'
          3      > RETURN                                                   ~1
          4*     > RETURN                                                   null

End of function %00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A8%240

Function %00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  Name\{closure}
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
          1        SEND_VAL_EX                                              'trait_closure%3A'
          2        SEND_VAL_EX                                              'Name%5C%7Bclosure%7D'
          3        SEND_VAL_EX                                              'Name%5C%7Bclosure%7D'
          4        FETCH_CLASS_NAME                                 ~0      
          5        SEND_VAL_EX                                              ~0
          6        DO_FCALL                                      0          
          7      > RETURN                                                   null

End of function %00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A9%241

Function %00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A14%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  Name\{closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
          1        SEND_VAL_EX                                              'closure%3A'
          2        SEND_VAL_EX                                              'Name%5C%7Bclosure%7D'
          3        SEND_VAL_EX                                              'Name%5C%7Bclosure%7D'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   null

End of function %00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A14%242

Class Name\Constants:
Function classconst:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  classConst
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A8%240'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function classconst

Function traitc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  traitC
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
          1        SEND_VAL_EX                                              'trait_method%3A'
          2        SEND_VAL_EX                                              'traitC'
          3        SEND_VAL_EX                                              'Name%5CConstants%3A%3AtraitC'
          4        FETCH_CLASS_NAME                                 ~0      
          5        SEND_VAL_EX                                              ~0
          6        DO_FCALL                                      0          
          7        INIT_NS_FCALL_BY_NAME                                    'Name%5Ccall_user_func'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A9%241'
          9        SEND_VAL_EX                                              ~2
         10        DO_FCALL                                      0          
         11      > RETURN                                                   null

End of function traitc

End of class Name\Constants.

Class Name\Foo:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MT4Ma
function name:  method
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_NS_FCALL_BY_NAME                                    'Name%5Cvar_dump'
          1        SEND_VAL_EX                                              'method%3A'
          2        SEND_VAL_EX                                              'method'
          3        SEND_VAL_EX                                              'Name%5CFoo%3A%3Amethod'
          4        DO_FCALL                                      0          
          5        INIT_NS_FCALL_BY_NAME                                    'Name%5Ccall_user_func'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00name%5C%7Bclosure%7D%2Fin%2FMT4Ma%3A14%242'
          7        SEND_VAL_EX                                              ~1
          8        DO_FCALL                                      0          
          9      > RETURN                                                   null

End of function method

End of class Name\Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.95 ms | 1396 KiB | 17 Q