3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SubObject { static $instances = 1; public $instance; public function __construct() { $this->instance = ++self::$instances; } public function __clone() { $this->instance = ++self::$instances; } } class MyCloneable { public $object1; public $object2; function _clone() { $this->object1 = clone ($this->object1); } } $obj = new MyCloneable(); $obj->object1 = new SubObject(); $obj->object2 = new SubObject(); $obj2 = clone $obj; function iterateObject($input) { if (is_int($input)) echo "[instance] => ".$input."\n"; else foreach ($input as $val) iterateObject($val); } iterateObject($obj); iterateObject($obj2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHaj7
function name:  (null)
number of ops:  20
compiled vars:  !0 = $obj, !1 = $obj2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $2      'MyCloneable'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   27     3        NEW                                              $6      'SubObject'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'object1'
          6        OP_DATA                                                  $6
   28     7        NEW                                              $9      'SubObject'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'object2'
         10        OP_DATA                                                  $9
   29    11        CLONE                                            ~11     !0
         12        ASSIGN                                                   !1, ~11
   35    13        INIT_FCALL                                               'iterateobject'
         14        SEND_VAR                                                 !0
         15        DO_FCALL                                      0          
   36    16        INIT_FCALL                                               'iterateobject'
         17        SEND_VAR                                                 !1
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function iterateobject:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/EHaj7
function name:  iterateObject
number of ops:  15
compiled vars:  !0 = $input, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        TYPE_CHECK                                   16          !0
          2      > JMPZ                                                     ~2, ->7
          3    >   CONCAT                                           ~3      '%5Binstance%5D+%3D%3E+', !0
          4        CONCAT                                           ~4      ~3, '%0A'
          5        ECHO                                                     ~4
          6      > JMP                                                      ->14
   32     7    > > FE_RESET_R                                       $5      !0, ->13
          8    > > FE_FETCH_R                                               $5, !1, ->13
          9    >   INIT_FCALL_BY_NAME                                       'iterateObject'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12      > JMP                                                      ->8
         13    >   FE_FREE                                                  $5
   33    14    > > RETURN                                                   null

End of function iterateobject

Class SubObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHaj7
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   PRE_INC_STATIC_PROP                              ~1      'instances'
          1        ASSIGN_OBJ                                               'instance'
          2        OP_DATA                                                  ~1
    9     3      > RETURN                                                   null

End of function __construct

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHaj7
function name:  __clone
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   PRE_INC_STATIC_PROP                              ~1      'instances'
          1        ASSIGN_OBJ                                               'instance'
          2        OP_DATA                                                  ~1
   13     3      > RETURN                                                   null

End of function __clone

End of class SubObject.

Class MyCloneable:
Function _clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHaj7
function name:  _clone
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~1      'object1'
          1        CLONE                                            ~2      ~1
          2        ASSIGN_OBJ                                               'object1'
          3        OP_DATA                                                  ~2
   23     4      > RETURN                                                   null

End of function _clone

End of class MyCloneable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.55 ms | 1403 KiB | 15 Q