3v4l.org

run code in 300+ 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 Base { public function foo() { echo __METHOD__; } } class First extends Base { use StaticCall; public function foo() { #$this->callStatic('parent', 'foo'); call_user_func_array('parent::foo', array()); } } class Second extends First { use StaticCall; } $s = new Second(); $s->foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H2Qc0
function name:  (null)
number of ops:  8
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'first', 'base'
   24     1        DECLARE_CLASS                                            'second', 'first'
   28     2        NEW                                              $1      'Second'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   29     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/H2Qc0
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                                      0  $9      
         15      > RETURN                                                   $9
    8    16*     > RETURN                                                   null

End of function callstatic

End of class StaticCall.

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

End of function foo

End of class Base.

Class First:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H2Qc0
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_USER_CALL                                0          'call_user_func_array', 'parent%3A%3Afoo'
          1        SEND_ARRAY                                               <array>
          2        CHECK_UNDEF_ARGS                                         
          3        DO_FCALL                                      0          
   21     4      > RETURN                                                   null

End of function foo

End of class First.

Class Second: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.15 ms | 1400 KiB | 15 Q