3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thing { private $foo; private $bar; private $qux; public function __construct($foo, $bar, $qux) { $this->foo = $foo; $this->bar = $bar; $this->qux = $qux; } } class Builder { private $foo; private $bar; public function withFoo($foo) { $this->foo = $foo; return $this; } public function withBar($bar) { $this->bar = $bar; return $this; } public function withQux($qux) { try { return new Thing($this->foo, $this->bar, $qux); } finally { $this->reset(); } } private function reset() { $this->foo = null; $this->bar = null; } } function test(Builder $builder) { return [ $builder->withFoo('a')->withBar('b')->withQux('c'), $builder->withFoo('d')->withQux('e'), $builder->withQux('f'), ]; } var_dump(test(new Builder()));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tos6Z
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'test'
          2        NEW                                              $0      'Builder'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tos6Z
function name:  test
number of ops:  24
compiled vars:  !0 = $builder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
   58     1        INIT_METHOD_CALL                                         !0, 'withFoo'
          2        SEND_VAL_EX                                              'a'
          3        DO_FCALL                                      0  $1      
          4        INIT_METHOD_CALL                                         $1, 'withBar'
          5        SEND_VAL_EX                                              'b'
          6        DO_FCALL                                      0  $2      
          7        INIT_METHOD_CALL                                         $2, 'withQux'
          8        SEND_VAL_EX                                              'c'
          9        DO_FCALL                                      0  $3      
         10        INIT_ARRAY                                       ~4      $3
   59    11        INIT_METHOD_CALL                                         !0, 'withFoo'
         12        SEND_VAL_EX                                              'd'
         13        DO_FCALL                                      0  $5      
         14        INIT_METHOD_CALL                                         $5, 'withQux'
         15        SEND_VAL_EX                                              'e'
         16        DO_FCALL                                      0  $6      
         17        ADD_ARRAY_ELEMENT                                ~4      $6
   60    18        INIT_METHOD_CALL                                         !0, 'withQux'
         19        SEND_VAL_EX                                              'f'
         20        DO_FCALL                                      0  $7      
         21        ADD_ARRAY_ELEMENT                                ~4      $7
         22      > RETURN                                                   ~4
   62    23*     > RETURN                                                   null

End of function test

Class Thing:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tos6Z
function name:  __construct
number of ops:  10
compiled vars:  !0 = $foo, !1 = $bar, !2 = $qux
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   12     3        ASSIGN_OBJ                                               'foo'
          4        OP_DATA                                                  !0
   13     5        ASSIGN_OBJ                                               'bar'
          6        OP_DATA                                                  !1
   14     7        ASSIGN_OBJ                                               'qux'
          8        OP_DATA                                                  !2
   15     9      > RETURN                                                   null

End of function __construct

End of class Thing.

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

End of function withfoo

Function withbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tos6Z
function name:  withBar
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   33     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   34     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   35     5*     > RETURN                                                   null

End of function withbar

Function withqux:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 162) Position 1 = 14, Position 2 = 11
Branch analysis from position: 14
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tos6Z
function name:  withQux
number of ops:  18
compiled vars:  !0 = $qux
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   40     1        NEW                                              $2      'Thing'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $3      'foo'
          4        SEND_FUNC_ARG                                            $3
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $4      'bar'
          7        SEND_FUNC_ARG                                            $4
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
         10      > FAST_CALL                                                ->14
         11    > > RETURN                                                   $2
   42    12*       FAST_CALL                                                ->14
         13*       JMP                                                      ->17
   43    14    >   INIT_METHOD_CALL                                         'reset'
         15        DO_FCALL                                      0          
         16      > FAST_RET                                                 
   45    17*     > RETURN                                                   null

End of function withqux

Function reset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tos6Z
function name:  reset
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   ASSIGN_OBJ                                               'foo'
          1        OP_DATA                                                  null
   50     2        ASSIGN_OBJ                                               'bar'
          3        OP_DATA                                                  null
   51     4      > RETURN                                                   null

End of function reset

End of class Builder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.33 ms | 1009 KiB | 15 Q