3v4l.org

run code in 300+ PHP versions simultaneously
<?php class House { /** * @var string */ private $size; public function __construct(string $size) { $this->size = $size; } public function getSize() : string { return $this->size; } public function withSize(string $newSize) : House { $clone = clone $this; $clone->size = $newSize; //note that $size field had to be changed to public return $clone; } } $house = new House('small'); $bigHouse = $house->withSize('big'); echo $house->getSize();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DjbP
function name:  (null)
number of ops:  12
compiled vars:  !0 = $house, !1 = $bigHouse
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $2      'House'
          1        SEND_VAL_EX                                              'small'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   25     4        INIT_METHOD_CALL                                         !0, 'withSize'
          5        SEND_VAL_EX                                              'big'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   27     8        INIT_METHOD_CALL                                         !0, 'getSize'
          9        DO_FCALL                                      0  $7      
         10        ECHO                                                     $7
         11      > RETURN                                                   1

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

End of function __construct

Function getsize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DjbP
function name:  getSize
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      'size'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   15     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getsize

Function withsize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2DjbP
function name:  withSize
number of ops:  10
compiled vars:  !0 = $newSize, !1 = $clone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        FETCH_THIS                                       ~2      
          2        CLONE                                            ~3      ~2
          3        ASSIGN                                                   !1, ~3
   19     4        ASSIGN_OBJ                                               !1, 'size'
          5        OP_DATA                                                  !0
   20     6        VERIFY_RETURN_TYPE                                       !1
          7      > RETURN                                                   !1
   21     8*       VERIFY_RETURN_TYPE                                       
          9*     > RETURN                                                   null

End of function withsize

End of class House.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.66 ms | 1007 KiB | 13 Q