3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tap($target) { return new HigherOrderTapProxy($target); } class HigherOrderTapProxy { public $target; public function __construct($target) { $this->target = $target; } public function __call($method, $parameters) { $this->target->{$method}(...$parameters); return $this->target; } } class Number { public $value; public function __construct($value) { $this->value = $value; } public function add($value) { $this->value += $value; } public function get() { return $this->value; } } tap($number = new Number(5)) ->add(10) ->add(20); var_dump($number);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j5Hmo
function name:  (null)
number of ops:  17
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'tap'
          1        NEW                                              $1      'Number'
          2        SEND_VAL_EX                                              5
          3        DO_FCALL                                      0          
          4        ASSIGN                                           ~3      !0, $1
          5        SEND_VAL                                                 ~3
          6        DO_FCALL                                      0  $4      
   34     7        INIT_METHOD_CALL                                         $4, 'add'
          8        SEND_VAL_EX                                              10
          9        DO_FCALL                                      0  $5      
   35    10        INIT_METHOD_CALL                                         $5, 'add'
         11        SEND_VAL_EX                                              20
         12        DO_FCALL                                      0          
   37    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function tap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j5Hmo
function name:  tap
number of ops:  6
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        NEW                                              $1      'HigherOrderTapProxy'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
    5     5*     > RETURN                                                   null

End of function tap

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

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j5Hmo
function name:  __call
number of ops:  10
compiled vars:  !0 = $method, !1 = $parameters
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        FETCH_OBJ_R                                      ~2      'target'
          3        INIT_METHOD_CALL                                         ~2, !0
          4        SEND_UNPACK                                              !1
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      1          
   18     7        FETCH_OBJ_R                                      ~4      'target'
          8      > RETURN                                                   ~4
   19     9*     > RETURN                                                   null

End of function __call

End of class HigherOrderTapProxy.

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

End of function __construct

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j5Hmo
function name:  add
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ_OP                                 1          'value'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function add

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j5Hmo
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function get

End of class Number.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.24 ms | 1007 KiB | 15 Q