3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __invoke($a, $b) { echo "$a - $b\n"; } } class Bar { public $f; public function __construct() { $this->f = new Foo; } } $b = new Bar; $f = $b->f; $f('hello', 'world'); call_user_func($b->f, 'hello', 'world'); // i assume php assumes that f is a method here, // so this fails! Bar::f() does not exist... // $b->f('hello', 'world'); // php simply cannot parse this for whatever // reason. seems like it shoudl be able to. :) // ($b->f)('hello', 'world');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LBGQO
function name:  (null)
number of ops:  15
compiled vars:  !0 = $b, !1 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $2      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   22     3        FETCH_OBJ_R                                      ~5      !0, 'f'
          4        ASSIGN                                                   !1, ~5
   24     5        INIT_DYNAMIC_CALL                                        !1
          6        SEND_VAL_EX                                              'hello'
          7        SEND_VAL_EX                                              'world'
          8        DO_FCALL                                      0          
   26     9        FETCH_OBJ_R                                      ~8      !0, 'f'
         10        INIT_USER_CALL                                2          'call_user_func', ~8
         11        SEND_USER                                                'hello'
         12        SEND_USER                                                'world'
         13        DO_FCALL                                      0          
   34    14      > RETURN                                                   1

Class Foo:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LBGQO
function name:  __invoke
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ROPE_INIT                                     4  ~3      !0
          3        ROPE_ADD                                      1  ~3      ~3, '+-+'
          4        ROPE_ADD                                      2  ~3      ~3, !1
          5        ROPE_END                                      3  ~2      ~3, '%0A'
          6        ECHO                                                     ~2
    8     7      > RETURN                                                   null

End of function __invoke

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LBGQO
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'f'
          3        OP_DATA                                                  $1
   17     4      > RETURN                                                   null

End of function __construct

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.42 ms | 1395 KiB | 13 Q