3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SubObject { static $instances = 0; public $instance; public function __construct() { $this->instance = ++self::$instances; } public function __clone() { $this->instance = ++self::$instances; } } class MyCloneable { public $object1; public $object2; function __clone() { // forza la copia di $this->object1, che altrimenti // punterebbe alla stessa istanza. $this->object1 = clone $this->object1; } /*public function __invoke($object1,$object2) { $this->oject1=$object1; $this->oject2=$object2; } */ } $obj = new MyCloneable(); $obj->object1 = new SubObject(); $obj->object2 = new SubObject(); $obj3 = clone $obj; $obj2=new $obj; $obj2->object1 = new SubObject(); $obj2->object2 = new SubObject(); print("Oggetto originale:\n"); print_r($obj); print("Oggetto originale:\n"); print_r($obj2); print("Oggetto originale:\n"); print_r($obj3); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMuNY
function name:  (null)
number of ops:  38
compiled vars:  !0 = $obj, !1 = $obj3, !2 = $obj2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   NEW                                              $3      'MyCloneable'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   37     3        NEW                                              $7      'SubObject'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'object1'
          6        OP_DATA                                                  $7
   38     7        NEW                                              $10     'SubObject'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'object2'
         10        OP_DATA                                                  $10
   40    11        CLONE                                            ~12     !0
         12        ASSIGN                                                   !1, ~12
   41    13        FETCH_CLASS                                   0  $14     !0
         14        NEW                                              $15     $14
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $15
   42    17        NEW                                              $19     'SubObject'
         18        DO_FCALL                                      0          
         19        ASSIGN_OBJ                                               !2, 'object1'
         20        OP_DATA                                                  $19
   43    21        NEW                                              $22     'SubObject'
         22        DO_FCALL                                      0          
         23        ASSIGN_OBJ                                               !2, 'object2'
         24        OP_DATA                                                  $22
   45    25        ECHO                                                     'Oggetto+originale%3A%0A'
   46    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
   48    29        ECHO                                                     'Oggetto+originale%3A%0A'
   49    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                                 
   50    33        ECHO                                                     'Oggetto+originale%3A%0A'
   51    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                                 
   52    37      > RETURN                                                   1

Class SubObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMuNY
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/tMuNY
function name:  __clone
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   PRE_INC_STATIC_PROP                              ~1      'instances'
          1        ASSIGN_OBJ                                               'instance'
          2        OP_DATA                                                  ~1
   12     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/tMuNY
function name:  __clone
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~1      'object1'
          1        CLONE                                            ~2      ~1
          2        ASSIGN_OBJ                                               'object1'
          3        OP_DATA                                                  ~2
   25     4      > RETURN                                                   null

End of function __clone

End of class MyCloneable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.77 ms | 1392 KiB | 15 Q