3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $hello; public function __construct() { $this->hello = function(){ echo 'hello from callable'; }; } public function hello() { echo 'hello from object'; } public function __call($method, $args) { if(is_callable(array($this, $method))) { return call_user_func_array($this->$method, $args); } } } $foo = new Foo(); call_user_func($foo->hello);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Bkc6
function name:  (null)
number of ops:  7
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        FETCH_OBJ_R                                      ~4      !0, 'hello'
          4        INIT_USER_CALL                                0          'call_user_func', ~4
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F7Bkc6%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Bkc6
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ECHO                                                     'hello+from+callable'
   11     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7Bkc6%3A9%240

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Bkc6
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7Bkc6%3A9%240'
          1        ASSIGN_OBJ                                               'hello'
   11     2        OP_DATA                                                  ~1
   12     3      > RETURN                                                   null

End of function __construct

Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Bkc6
function name:  hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     'hello+from+object'
   17     1      > RETURN                                                   null

End of function hello

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Bkc6
function name:  __call
number of ops:  16
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        INIT_FCALL                                               'is_callable'
          3        FETCH_THIS                                       ~2      
          4        INIT_ARRAY                                       ~3      ~2
          5        ADD_ARRAY_ELEMENT                                ~3      !0
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8      > JMPZ                                                     $4, ->15
   22     9    >   FETCH_OBJ_R                                      ~5      !0
         10        INIT_USER_CALL                                0          'call_user_func_array', ~5
         11        SEND_ARRAY                                               !1
         12        CHECK_UNDEF_ARGS                                         
         13        DO_FCALL                                      0  $6      
         14      > RETURN                                                   $6
   24    15    > > RETURN                                                   null

End of function __call

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.14 ms | 1400 KiB | 15 Q