3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public static function bar(array $ids) { return array_map(function($id) { return static::foo($id); }, $ids); } public static function foo($id) { return "halo {$id}"; } } class Test1 extends Test { public static function foo($id) { return "hi {$id}"; } } $className = Test1::class; //Let's say line above is input from user or some other code. $ids = [1, 2, 3, 4, 5]; print_r(call_user_func([$className, 'bar'], $ids));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BiYk2
function name:  (null)
number of ops:  11
compiled vars:  !0 = $className, !1 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, 'Test1'
   25     1        ASSIGN                                                   !1, <array>
   26     2        INIT_FCALL                                               'print_r'
          3        INIT_ARRAY                                       ~4      !0
          4        ADD_ARRAY_ELEMENT                                ~4      'bar'
          5        INIT_USER_CALL                                1          'call_user_func', ~4
          6        SEND_USER                                                !1
          7        DO_FCALL                                      0  $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class Test:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BiYk2
function name:  bar
number of ops:  8
compiled vars:  !0 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
    8     3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
    6     5        DO_ICALL                                         $2      
    8     6      > RETURN                                                   $2
    9     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BiYk2
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_STATIC_METHOD_CALL                                  'foo'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    8     5*     > RETURN                                                   null

End of Dynamic Function 0

End of function bar

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BiYk2
function name:  foo
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'halo+', !0
          3      > RETURN                                                   ~1
   13     4*     > RETURN                                                   null

End of function foo

End of class Test.

Class Test1:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BiYk2
function name:  foo
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'hi+', !0
          3      > RETURN                                                   ~1
   20     4*     > 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/BiYk2
function name:  bar
number of ops:  8
compiled vars:  !0 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
    8     3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
    6     5        DO_ICALL                                         $2      
    8     6      > RETURN                                                   $2
    9     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BiYk2
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_STATIC_METHOD_CALL                                  'foo'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    8     5*     > RETURN                                                   null

End of Dynamic Function 0

End of function bar

End of class Test1.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.62 ms | 1016 KiB | 15 Q