3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Jump found. Position 1 = -2
filename:       /in/W189r
function name:  (null)
number of ops:  42
compiled vars:  !0 = $obj, !1 = $obj2, !2 = $obj3
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
  17     1        NOP                                                      
  37     2        NEW                                              $5      :-6
         3        DO_FCALL                                      0          
         4        ASSIGN                                                   !0, $5
  40     5        NEW                                              $9      :-3
         6        DO_FCALL                                      0          
         7        ASSIGN_OBJ                                               !0, 'object1'
         8        OP_DATA                                                  $9
  42     9        NEW                                              $12     :0
        10        DO_FCALL                                      0          
        11        ASSIGN_OBJ                                               !0, 'object2'
        12        OP_DATA                                                  $12
  46    13        FETCH_CLASS                                 512  :14     !0
        14        NEW                                              $15     :14
        15        DO_FCALL                                      0          
        16        ASSIGN                                                   !1, $15
  47    17        NEW                                              $19     :3
        18        DO_FCALL                                      0          
        19        ASSIGN_OBJ                                               !1, 'object1'
        20        OP_DATA                                                  $19
  49    21        NEW                                              $22     :6
        22        DO_FCALL                                      0          
        23        ASSIGN_OBJ                                               !1, 'object2'
        24        OP_DATA                                                  $22
  51    25        CLONE                                            $24     !0
        26        ASSIGN                                                   !2, $24
  53    27        ECHO                                                     'Oggetto+originale%3A%0A'
  54    28        INIT_FCALL                                               'print_r'
        29        SEND_VAR                                                 !0
        30        DO_ICALL                                                 
  56    31        ECHO                                                     'Oggetto+originale%3A%0A'
  57    32        INIT_FCALL                                               'print_r'
        33        SEND_VAR                                                 !1
        34        DO_ICALL                                                 
  58    35        ECHO                                                     'Oggetto+clonato%3A%0A'
  59    36        INIT_FCALL                                               'print_r'
        37        SEND_VAR                                                 !2
        38        DO_ICALL                                                 
  60    39        FETCH_R                      static member       $29     'instances'
        40        ECHO                                                     $29
        41      > RETURN                                                   1

Class SubObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/W189r
function name:  __construct
number of ops:  9
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   8     0  E >   FETCH_CLASS                                 513  :1      
         1        FETCH_RW                     static member       $2      'instances'
         2        PRE_INC                                          $3      $2
         3        ASSIGN_OBJ                                               'instance'
         4        OP_DATA                                                  $3
   9     5        FETCH_CLASS                                 513  :4      
         6        FETCH_R                      static member       $5      'instances'
         7        ECHO                                                     $5
  10     8      > RETURN                                                   null

End of function __construct

Function __clone:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/W189r
function name:  __clone
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  12     0  E >   FETCH_CLASS                                 513  :1      
         1        FETCH_RW                     static member       $2      'instances'
         2        PRE_INC                                          $3      $2
         3        ASSIGN_OBJ                                               'instance'
         4        OP_DATA                                                  $3
  13     5      > RETURN                                                   null

End of function __clone

End of class SubObject.

Class MyCloneable:
Function __clone:
Finding entry points
Branch analysis from position: 0
Jump found. 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
Jump found. 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 7.3.0