3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { private $prop; public function __construct($prop) { $this->prop = $prop; } public function withProp($prop) { // immutable $copy = clone $this; $copy->prop = $prop; return $copy; } public function setProp($prop) { // mutable $this->prop = $prop; } public function getProp() { return $this->prop; } } $obj = new MyClass('A'); $obj = $obj->withProp('B'); echo $obj->getProp();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/598bk
function name:  (null)
number of ops:  12
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $1      'MyClass'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   23     4        INIT_METHOD_CALL                                         !0, 'withProp'
          5        SEND_VAL_EX                                              'B'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !0, $4
   24     8        INIT_METHOD_CALL                                         !0, 'getProp'
          9        DO_FCALL                                      0  $6      
         10        ECHO                                                     $6
         11      > RETURN                                                   1

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

End of function __construct

Function withprop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/598bk
function name:  withProp
number of ops:  8
compiled vars:  !0 = $prop, !1 = $copy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_THIS                                       ~2      
          2        CLONE                                            ~3      ~2
          3        ASSIGN                                                   !1, ~3
   10     4        ASSIGN_OBJ                                               !1, 'prop'
          5        OP_DATA                                                  !0
   11     6      > RETURN                                                   !1
   12     7*     > RETURN                                                   null

End of function withprop

Function setprop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/598bk
function name:  setProp
number of ops:  4
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN_OBJ                                               'prop'
          2        OP_DATA                                                  !0
   15     3      > RETURN                                                   null

End of function setprop

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

End of function getprop

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.75 ms | 1399 KiB | 13 Q