3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait StaticCall { protected function callStatic($className, $methodName) { $parameters = func_get_args(); $parameters = array_slice($parameters, 2); return call_user_func_array($className . '::' . $methodName, $parameters); } } class ParentClass { public function foo() { echo __METHOD__; } } class ChildClass extends ParentClass { use StaticCall; public function foo() { $this->callStatic('parent', 'foo'); } } class GrandChildClass extends ChildClass { use StaticCall; } $c = new GrandChildClass(); $c->foo();

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s5t3s
function name:  (null)
number of ops:  8
compiled vars:  !0 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                                'childclass', 'parentclass'
   23     1        DECLARE_CLASS                                                'grandchildclass', 'childclass'
   27     2        NEW                                                  $1      'GrandChildClass'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $1
   28     5        INIT_METHOD_CALL                                             !0, 'foo'
          6        DO_FCALL                                          0          
          7      > RETURN                                                       1

Class StaticCall:
Function callstatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s5t3s
function name:  callStatic
number of ops:  17
compiled vars:  !0 = $className, !1 = $methodName, !2 = $parameters
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        FUNC_GET_ARGS                                        ~3      
          3        ASSIGN                                                       !2, ~3
    6     4        INIT_FCALL                                                   'array_slice'
          5        SEND_VAR                                                     !2
          6        SEND_VAL                                                     2
          7        DO_ICALL                                             $5      
          8        ASSIGN                                                       !2, $5
    7     9        CONCAT                                               ~7      !0, '%3A%3A'
         10        CONCAT                                               ~8      ~7, !1
         11        INIT_USER_CALL                                    0          'call_user_func_array', ~8
         12        SEND_ARRAY                                                   !2
         13        CHECK_UNDEF_ARGS                                             
         14        DO_FCALL                                          1  $9      
         15      > RETURN                                                       $9
    8    16*     > RETURN                                                       null

End of function callstatic

End of class StaticCall.

Class ParentClass:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s5t3s
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                         'ParentClass%3A%3Afoo'
          1      > RETURN                                                       null

End of function foo

End of class ParentClass.

Class ChildClass:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s5t3s
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   INIT_METHOD_CALL                                             'callStatic'
          1        SEND_VAL_EX                                                  'parent'
          2        SEND_VAL_EX                                                  'foo'
          3        DO_FCALL                                          0          
   20     4      > RETURN                                                       null

End of function foo

End of class ChildClass.

Class GrandChildClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.66 ms | 3843 KiB | 14 Q