3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Container { /** @var \stdClass|null */ public $referencedProperty; public function __clone() { $this->referencedProperty = clone $this->referencedProperty; } } $references = []; $container = new Container(); $loadFieldByReference = function (& $referencedProperty) use (& $references) { $referencedProperty = new \stdClass(); $references[] = & $referencedProperty; }; $loadFieldByReference($container->referencedProperty); $container->referencedProperty->publicProperty = 123; $clone = clone $container; $clone->referencedProperty->publicProperty = 234; echo $container->referencedProperty->publicProperty, "\n"; echo $clone->referencedProperty->publicProperty, "\n"; echo $container->referencedProperty === $clone->referencedProperty ? "same\n" : "not same\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WojlB
function name:  (null)
number of ops:  37
compiled vars:  !0 = $references, !1 = $container, !2 = $loadFieldByReference, !3 = $clone
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   16     1        NEW                                              $5      'Container'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   18     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWojlB%3A18%240'
          5        BIND_LEXICAL                                             ~8, !0
          6        ASSIGN                                                   !2, ~8
   23     7        INIT_DYNAMIC_CALL                                        !2
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $10     !1, 'referencedProperty'
         10        SEND_FUNC_ARG                                            $10
         11        DO_FCALL                                      0          
   25    12        FETCH_OBJ_W                                      $12     !1, 'referencedProperty'
         13        ASSIGN_OBJ                                               $12, 'publicProperty'
         14        OP_DATA                                                  123
   26    15        CLONE                                            ~14     !1
         16        ASSIGN                                                   !3, ~14
   27    17        FETCH_OBJ_W                                      $16     !3, 'referencedProperty'
         18        ASSIGN_OBJ                                               $16, 'publicProperty'
         19        OP_DATA                                                  234
   29    20        FETCH_OBJ_R                                      ~18     !1, 'referencedProperty'
         21        FETCH_OBJ_R                                      ~19     ~18, 'publicProperty'
         22        ECHO                                                     ~19
         23        ECHO                                                     '%0A'
   30    24        FETCH_OBJ_R                                      ~20     !3, 'referencedProperty'
         25        FETCH_OBJ_R                                      ~21     ~20, 'publicProperty'
         26        ECHO                                                     ~21
         27        ECHO                                                     '%0A'
   31    28        FETCH_OBJ_R                                      ~22     !1, 'referencedProperty'
         29        FETCH_OBJ_R                                      ~23     !3, 'referencedProperty'
         30        IS_IDENTICAL                                             ~22, ~23
         31      > JMPZ                                                     ~24, ->34
         32    >   QM_ASSIGN                                        ~25     'same%0A'
         33      > JMP                                                      ->35
         34    >   QM_ASSIGN                                        ~25     'not+same%0A'
         35    >   ECHO                                                     ~25
   33    36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FWojlB%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WojlB
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $referencedProperty, !1 = $references
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   19     2        NEW                                              $2      'stdClass'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   20     5        FETCH_DIM_W                                      $5      !1
          6        ASSIGN_REF                                               $5, !0
   21     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FWojlB%3A18%240

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

End of function __clone

End of class Container.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.87 ms | 1399 KiB | 13 Q