3v4l.org

run code in 300+ PHP versions simultaneously
l<?php function callStatic($class, $method, $args, $ref, $defined, $called) { var_dump($class, $defined, $called); $ref = new \ReflectionMethod($class, $method); $ref->setAccessible(true); return $ref->invokeArgs(null, array($args)); } class n_0d19ad5d1a89cbbf06a49f56e9dcb11d { public static function foo() { var_dump(get_called_class()); return callStatic('static', 'bar', array(), array(), __CLASS__, call_user_func(function () { set_error_handler(function () { }); $called = get_called_class(); restore_error_handler(); return $called; })); } } class n_1c54f3f5b4e9e0fc521faa21fe127ad8 extends n_0d19ad5d1a89cbbf06a49f56e9dcb11d { protected static function bar() { return __CLASS__; } } echo callStatic('n_1c54f3f5b4e9e0fc521faa21fe127ad8', 'foo', array(), array(), __CLASS__, call_user_func(function () { set_error_handler(function () { }); $called = get_called_class(); restore_error_handler(); return $called; }));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     'l'
   32     1        INIT_FCALL                                               'callstatic'
          2        SEND_VAL                                                 'n_1c54f3f5b4e9e0fc521faa21fe127ad8'
          3        SEND_VAL                                                 'foo'
          4        SEND_VAL                                                 <array>
          5        SEND_VAL                                                 <array>
          6        SEND_VAL                                                 ''
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNPJ8p%3A32%242'
   39     8        INIT_USER_CALL                                0          'call_user_func', ~0
          9        DO_FCALL                                      0  $1      
         10        SEND_VAR                                                 $1
         11        DO_FCALL                                      0  $2      
         12        ECHO                                                     $2
         13      > RETURN                                                   1

Function callstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  callStatic
number of ops:  26
compiled vars:  !0 = $class, !1 = $method, !2 = $args, !3 = $ref, !4 = $defined, !5 = $called
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
    4     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !4
          9        SEND_VAR                                                 !5
         10        DO_ICALL                                                 
    5    11        NEW                                              $7      'ReflectionMethod'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !3, $7
    6    16        INIT_METHOD_CALL                                         !3, 'setAccessible'
         17        SEND_VAL_EX                                              <true>
         18        DO_FCALL                                      0          
    7    19        INIT_METHOD_CALL                                         !3, 'invokeArgs'
         20        SEND_VAL_EX                                              null
         21        INIT_ARRAY                                       ~11     !2
         22        SEND_VAL_EX                                              ~11
         23        DO_FCALL                                      0  $12     
         24      > RETURN                                                   $12
    8    25*     > RETURN                                                   null

End of function callstatic

Function %00%7Bclosure%7D%2Fin%2FNPJ8p%3A15%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $called
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'set_error_handler'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNPJ8p%3A16%241'
   18     2        SEND_VAL                                                 ~1
          3        DO_ICALL                                                 
   19     4        GET_CALLED_CLASS                                 ~3      
          5        ASSIGN                                                   !0, ~3
   20     6        INIT_FCALL                                               'restore_error_handler'
          7        DO_ICALL                                                 
   21     8      > RETURN                                                   !0
   22     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNPJ8p%3A15%240

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

End of function %00%7Bclosure%7D%2Fin%2FNPJ8p%3A16%241

Function %00%7Bclosure%7D%2Fin%2FNPJ8p%3A32%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $called
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'set_error_handler'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNPJ8p%3A33%243'
   35     2        SEND_VAL                                                 ~1
          3        DO_ICALL                                                 
   36     4        GET_CALLED_CLASS                                 ~3      
          5        ASSIGN                                                   !0, ~3
   37     6        INIT_FCALL                                               'restore_error_handler'
          7        DO_ICALL                                                 
   38     8      > RETURN                                                   !0
   39     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNPJ8p%3A32%242

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

End of function %00%7Bclosure%7D%2Fin%2FNPJ8p%3A33%243

Class n_0d19ad5d1a89cbbf06a49f56e9dcb11d:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  foo
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        GET_CALLED_CLASS                                 ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   15     4        INIT_FCALL                                               'callstatic'
          5        SEND_VAL                                                 'static'
          6        SEND_VAL                                                 'bar'
          7        SEND_VAL                                                 <array>
          8        SEND_VAL                                                 <array>
          9        SEND_VAL                                                 'n_0d19ad5d1a89cbbf06a49f56e9dcb11d'
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNPJ8p%3A15%240'
   22    11        INIT_USER_CALL                                0          'call_user_func', ~2
         12        DO_FCALL                                      0  $3      
         13        SEND_VAR                                                 $3
         14        DO_FCALL                                      0  $4      
         15      > RETURN                                                   $4
   23    16*     > RETURN                                                   null

End of function foo

End of class n_0d19ad5d1a89cbbf06a49f56e9dcb11d.

Class n_1c54f3f5b4e9e0fc521faa21fe127ad8:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  bar
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E > > RETURN                                                   'n_1c54f3f5b4e9e0fc521faa21fe127ad8'
   30     1*     > RETURN                                                   null

End of function bar

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPJ8p
function name:  foo
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        GET_CALLED_CLASS                                 ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   15     4        INIT_FCALL                                               'callstatic'
          5        SEND_VAL                                                 'static'
          6        SEND_VAL                                                 'bar'
          7        SEND_VAL                                                 <array>
          8        SEND_VAL                                                 <array>
          9        SEND_VAL                                                 'n_0d19ad5d1a89cbbf06a49f56e9dcb11d'
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNPJ8p%3A15%240'
   22    11        INIT_USER_CALL                                0          'call_user_func', ~2
         12        DO_FCALL                                      0  $3      
         13        SEND_VAR                                                 $3
         14        DO_FCALL                                      0  $4      
         15      > RETURN                                                   $4
   23    16*     > RETURN                                                   null

End of function foo

End of class n_1c54f3f5b4e9e0fc521faa21fe127ad8.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.51 ms | 1411 KiB | 22 Q