3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar() { var_dump(__METHOD__); } public function baz() { var_dump(__METHOD__); } } class FluentWrapper { private $instance; public function __construct($instance) { $this->instance = $instance; } public function __call($name, $args) { $result = $this->instance->{$name}(...$args); return null === $result ? $this->instance : $result; } } $foo = new FluentWrapper(new Foo()); $foo ->bar() ->baz() ->bar() ->baz();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtSDq
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $1      'FluentWrapper'
          1        NEW                                              $2      'Foo'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   36     6        INIT_METHOD_CALL                                         !0, 'bar'
          7        DO_FCALL                                      0  $6      
   37     8        INIT_METHOD_CALL                                         $6, 'baz'
          9        DO_FCALL                                      0  $7      
   38    10        INIT_METHOD_CALL                                         $7, 'bar'
         11        DO_FCALL                                      0  $8      
   39    12        INIT_METHOD_CALL                                         $8, 'baz'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtSDq
function name:  bar
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'Foo%3A%3Abar'
          2        DO_ICALL                                                 
    8     3      > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtSDq
function name:  baz
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'Foo%3A%3Abaz'
          2        DO_ICALL                                                 
   13     3      > RETURN                                                   null

End of function baz

End of class Foo.

Class FluentWrapper:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtSDq
function name:  __construct
number of ops:  4
compiled vars:  !0 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        ASSIGN_OBJ                                               'instance'
          2        OP_DATA                                                  !0
   22     3      > RETURN                                                   null

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtSDq
function name:  __call
number of ops:  16
compiled vars:  !0 = $name, !1 = $args, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        FETCH_OBJ_R                                      ~3      'instance'
          3        INIT_METHOD_CALL                                         ~3, !0
          4        SEND_UNPACK                                              !1
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      1  $4      
          7        ASSIGN                                                   !2, $4
   28     8        TYPE_CHECK                                    2          !2
          9      > JMPZ                                                     ~6, ->13
         10    >   FETCH_OBJ_R                                      ~7      'instance'
         11        QM_ASSIGN                                        ~8      ~7
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      !2
         14    > > RETURN                                                   ~8
   29    15*     > RETURN                                                   null

End of function __call

End of class FluentWrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.85 ms | 1400 KiB | 15 Q