3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SubObject { static $instances = 0; public $instance; public function __construct() { $this->instance = ++self::$instances; echo 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(); $obj2=new $obj; $obj2->object1 = new SubObject(); $obj2->object2 = new SubObject(); $obj3 = clone $obj; print("Oggetto originale:\n"); print_r($obj); print("Oggetto originale:\n"); print_r($obj2); print("Oggetto clonato:\n"); print_r($obj3); echo SubObject::$instances; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W189r
function name:  (null)
number of ops:  40
compiled vars:  !0 = $obj, !1 = $obj2, !2 = $obj3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $3      'MyCloneable'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   40     3        NEW                                              $7      'SubObject'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'object1'
          6        OP_DATA                                                  $7
   42     7        NEW                                              $10     'SubObject'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'object2'
         10        OP_DATA                                                  $10
   46    11        FETCH_CLASS                                   0  $12     !0
         12        NEW                                              $13     $12
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $13
   47    15        NEW                                              $17     'SubObject'
         16        DO_FCALL                                      0          
         17        ASSIGN_OBJ                                               !1, 'object1'
         18        OP_DATA                                                  $17
   49    19        NEW                                              $20     'SubObject'
         20        DO_FCALL                                      0          
         21        ASSIGN_OBJ                                               !1, 'object2'
         22        OP_DATA                                                  $20
   51    23        CLONE                                            ~22     !0
         24        ASSIGN                                                   !2, ~22
   53    25        ECHO                                                     'Oggetto+originale%3A%0A'
   54    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
   56    29        ECHO                                                     'Oggetto+originale%3A%0A'
   57    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
   58    33        ECHO                                                     'Oggetto+clonato%3A%0A'
   59    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
   60    37        FETCH_STATIC_PROP_R          unknown             ~27     'instances'
         38        ECHO                                                     ~27
   61    39      > RETURN                                                   1

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

End of function __clone

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W189r
function name:  __invoke
number of ops:  7
compiled vars:  !0 = $object1, !1 = $object2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        ASSIGN_OBJ                                               'oject1'
          3        OP_DATA                                                  !0
   33     4        ASSIGN_OBJ                                               'oject2'
          5        OP_DATA                                                  !1
   34     6      > RETURN                                                   null

End of function __invoke

End of class MyCloneable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.41 ms | 1400 KiB | 15 Q