3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $bar = 1; public function bar(?int $bar = null): Foo { $this->bar = $bar ?? $this->bar; return $this; } public function copy(?int $bar = null): Foo { return $this->fork()->bar($bar ?? $this->bar); } public function fork(): Foo { return clone $this; } } $a = new foo(); $a2 = $a->copy(); $b = $a->copy(2); $b2 = $a->copy(); $c = $b->copy(3); $c2 = $b->copy(); var_dump( $a->bar, $a2->bar, $b->bar, $b2->bar, $c->bar, $c2->bar );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fevli
function name:  (null)
number of ops:  35
compiled vars:  !0 = $a, !1 = $a2, !2 = $b, !3 = $b2, !4 = $c, !5 = $c2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $6      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   26     3        INIT_METHOD_CALL                                         !0, 'copy'
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !1, $9
   27     6        INIT_METHOD_CALL                                         !0, 'copy'
          7        SEND_VAL_EX                                              2
          8        DO_FCALL                                      0  $11     
          9        ASSIGN                                                   !2, $11
   28    10        INIT_METHOD_CALL                                         !0, 'copy'
         11        DO_FCALL                                      0  $13     
         12        ASSIGN                                                   !3, $13
   29    13        INIT_METHOD_CALL                                         !2, 'copy'
         14        SEND_VAL_EX                                              3
         15        DO_FCALL                                      0  $15     
         16        ASSIGN                                                   !4, $15
   30    17        INIT_METHOD_CALL                                         !2, 'copy'
         18        DO_FCALL                                      0  $17     
         19        ASSIGN                                                   !5, $17
   32    20        INIT_FCALL                                               'var_dump'
   33    21        FETCH_OBJ_R                                      ~19     !0, 'bar'
         22        SEND_VAL                                                 ~19
   34    23        FETCH_OBJ_R                                      ~20     !1, 'bar'
         24        SEND_VAL                                                 ~20
   35    25        FETCH_OBJ_R                                      ~21     !2, 'bar'
         26        SEND_VAL                                                 ~21
   36    27        FETCH_OBJ_R                                      ~22     !3, 'bar'
         28        SEND_VAL                                                 ~22
   37    29        FETCH_OBJ_R                                      ~23     !4, 'bar'
         30        SEND_VAL                                                 ~23
   38    31        FETCH_OBJ_R                                      ~24     !5, 'bar'
         32        SEND_VAL                                                 ~24
   32    33        DO_ICALL                                                 
   39    34      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fevli
function name:  bar
number of ops:  11
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      null
    9     1        COALESCE                                         ~2      !0
          2        FETCH_OBJ_R                                      ~3      'bar'
          3        QM_ASSIGN                                        ~2      ~3
          4        ASSIGN_OBJ                                               'bar'
          5        OP_DATA                                                  ~2
   11     6        FETCH_THIS                                       ~4      
          7        VERIFY_RETURN_TYPE                                       ~4
          8      > RETURN                                                   ~4
   12     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function bar

Function copy:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fevli
function name:  copy
number of ops:  13
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV_INIT                                        !0      null
   16     1        INIT_METHOD_CALL                                         'fork'
          2        DO_FCALL                                      0  $1      
          3        INIT_METHOD_CALL                                         $1, 'bar'
          4        COALESCE                                         ~2      !0
          5        FETCH_OBJ_R                                      ~3      'bar'
          6        QM_ASSIGN                                        ~2      ~3
          7        SEND_VAL_EX                                              ~2
          8        DO_FCALL                                      0  $4      
          9        VERIFY_RETURN_TYPE                                       $4
         10      > RETURN                                                   $4
   17    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function copy

Function fork:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fevli
function name:  fork
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_THIS                                       ~0      
          1        CLONE                                            ~1      ~0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   22     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function fork

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.5 ms | 1010 KiB | 14 Q