3v4l.org

run code in 300+ PHP versions simultaneously
<?php class b { protected $object; public function __construct() { $this->object = new stdClass(); $this->object->name = "default"; } public function setObject(stdClass $object) { $this->object = $object; } public function getObject() { return $this->object; } public function __clone() { $this->object = clone $this->object; } } class runner { public function run() { $object1 = new stdClass(); $object1->name = "object1"; $object2 = new stdClass(); $object2->name = "object2"; $b1 = new b(); $b1->setObject($object2); if ($object1 instanceof $b1->object) { $b2 = clone $b1; $b2->object = $object1; echo $b2->getObject()->name; } } } $runner = new runner(); $runner->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqXfP
function name:  (null)
number of ops:  6
compiled vars:  !0 = $runner
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   NEW                                              $1      'runner'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   46     3        INIT_METHOD_CALL                                         !0, 'run'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class b:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqXfP
function name:  __construct
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $1      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'object'
          3        OP_DATA                                                  $1
    8     4        FETCH_OBJ_W                                      $3      'object'
          5        ASSIGN_OBJ                                               $3, 'name'
          6        OP_DATA                                                  'default'
    9     7      > RETURN                                                   null

End of function __construct

Function setobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqXfP
function name:  setObject
number of ops:  4
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ASSIGN_OBJ                                               'object'
          2        OP_DATA                                                  !0
   13     3      > RETURN                                                   null

End of function setobject

Function getobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqXfP
function name:  getObject
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'object'
          1      > RETURN                                                   ~0
   17     2*     > RETURN                                                   null

End of function getobject

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

End of function __clone

End of class b.

Class runner:
Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/eqXfP
function name:  run
number of ops:  29
compiled vars:  !0 = $object1, !1 = $object2, !2 = $b1, !3 = $b2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $4      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   29     3        ASSIGN_OBJ                                               !0, 'name'
          4        OP_DATA                                                  'object1'
   30     5        NEW                                              $8      'stdClass'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $8
   31     8        ASSIGN_OBJ                                               !1, 'name'
          9        OP_DATA                                                  'object2'
   33    10        NEW                                              $12     'b'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $12
   34    13        INIT_METHOD_CALL                                         !2, 'setObject'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
   36    16        FETCH_OBJ_R                                      ~16     !2, 'object'
         17        FETCH_CLASS                                   0  $17     ~16
         18        INSTANCEOF                                               !0, $17
         19      > JMPZ                                                     ~18, ->28
   37    20    >   CLONE                                            ~19     !2
         21        ASSIGN                                                   !3, ~19
   38    22        ASSIGN_OBJ                                               !3, 'object'
         23        OP_DATA                                                  !0
   39    24        INIT_METHOD_CALL                                         !3, 'getObject'
         25        DO_FCALL                                      0  $22     
         26        FETCH_OBJ_R                                      ~23     $22, 'name'
         27        ECHO                                                     ~23
   41    28    > > RETURN                                                   null

End of function run

End of class runner.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.1 ms | 1390 KiB | 13 Q