3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class a { } class b extends a { 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 $target; public function __construct() { $this->target = new b(); } public function run() { $object1 = new stdClass(); $object1->name = "object1"; $object2 = new stdClass(); $object2->name = "object2"; if (1 == 2) { // } elseif ($object1 instanceof $this->target->object) { $b2 = clone $this->target; $b2->object = $object1; echo $b2->getObject()->name; } } } $runner = new runner(); $runner->run();
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/RAj2H
function name:  (null)
number of ops:  10
compiled vars:  !0 = $runner
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   7     1        NOP                                                      
         2        NOP                                                      
  29     3        NOP                                                      
  56     4        NEW                                              $5      :-4
         5        DO_FCALL                                      0          
         6        ASSIGN                                                   !0, $5
  57     7        INIT_METHOD_CALL                                         !0, 'run'
         8        DO_FCALL                                      0          
         9      > RETURN                                                   1

Class a: [no user functions]
Class b:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/RAj2H
function name:  __construct
number of ops:  8
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  11     0  E >   NEW                                              $1      :-5
         1        DO_FCALL                                      0          
         2        ASSIGN_OBJ                                               'object'
         3        OP_DATA                                                  $1
  12     4        FETCH_OBJ_W                                      $3      'object'
         5        ASSIGN_OBJ                                               $3, 'name'
         6        OP_DATA                                                  'default'
  13     7      > RETURN                                                   null

End of function __construct

Function setobject:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/RAj2H
function name:  setObject
number of ops:  4
compiled vars:  !0 = $object
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   RECV                                             !0      
  16     1        ASSIGN_OBJ                                               'object'
         2        OP_DATA                                                  !0
  17     3      > RETURN                                                   null

End of function setobject

Function getobject:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/RAj2H
function name:  getObject
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  20     0  E >   FETCH_OBJ_R                                      $0      'object'
         1      > RETURN                                                   $0
  21     2*     > RETURN                                                   null

End of function getobject

Function __clone:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/RAj2H
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      'object'
         1        CLONE                                            $2      $1
         2        ASSIGN_OBJ                                               'object'
         3        OP_DATA                                                  $2
  25     4      > RETURN                                                   null

End of function __clone

End of class b.

Class runner:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/RAj2H
function name:  __construct
number of ops:  5
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  34     0  E >   NEW                                              $1      :-5
         1        DO_FCALL                                      0          
         2        ASSIGN_OBJ                                               'target'
         3        OP_DATA                                                  $1
  35     4      > RETURN                                                   null

End of function __construct

Function run:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
Jump found. Position 1 = 26
Branch analysis from position: 26
Jump found. Position 1 = -2
Branch analysis from position: 12
Jump found. Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
Jump found. Position 1 = -2
Branch analysis from position: 26
filename:       /in/RAj2H
function name:  run
number of ops:  27
compiled vars:  !0 = $object1, !1 = $object2, !2 = $b2
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  39     0  E >   NEW                                              $3      :-6
         1        DO_FCALL                                      0          
         2        ASSIGN                                                   !0, $3
  40     3        ASSIGN_OBJ                                               !0, 'name'
         4        OP_DATA                                                  'object1'
  41     5        NEW                                              $7      :-2
         6        DO_FCALL                                      0          
         7        ASSIGN                                                   !1, $7
  42     8        ASSIGN_OBJ                                               !1, 'name'
         9        OP_DATA                                                  'object2'
  45    10      > JMPZ                                                     <false>, ->12
        11    > > JMP                                                      ->26
  47    12    >   FETCH_OBJ_R                                      $11     'target'
        13        FETCH_OBJ_R                                      $12     $11, 'object'
        14        FETCH_CLASS                                 128  :13     $12
        15        INSTANCEOF                                       ~14     !0, $13
        16      > JMPZ                                                     ~14, ->26
  48    17    >   FETCH_OBJ_R                                      $15     'target'
        18        CLONE                                            $16     $15
        19        ASSIGN                                                   !2, $16
  49    20        ASSIGN_OBJ                                               !2, 'object'
        21        OP_DATA                                                  !0
  50    22        INIT_METHOD_CALL                                         !2, 'getObject'
        23        DO_FCALL                                      0  $19     
        24        FETCH_OBJ_R                                      $20     $19, 'name'
        25        ECHO                                                     $20
  52    26    > > RETURN                                                   null

End of function run

End of class runner.

Generated using Vulcan Logic Dumper, using php 7.2.0