3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { private $holder; private $children; public function __construct($content = '', array $children = []) { $this->holder = $content; $this->setChildren($children); } public function setChildren(array $children) { $this->children = $children; foreach ($children as $child) { $child->setParent($this); } } } class Bar { private $holder; private $parent; public function __construct($content = '', Foo $parent = null) { $this->holder = $content; $this->setParent($parent); } public function setParent(Foo $parent = null) { $this->parent = $parent; } } $child0 = new Bar('child#0'); $child1 = new Bar('child#1'); //same $child2 = new Bar('child#0'); $child3 = new Bar('child#1'); $parent0 = new Foo('parent', [$child0, $child1]); $parent1 = new Foo('parent', [$child2, $child3]); //Fatal: var_dump($parent0 == $parent1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Huqf
function name:  (null)
number of ops:  35
compiled vars:  !0 = $child0, !1 = $child1, !2 = $child2, !3 = $child3, !4 = $parent0, !5 = $parent1
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   41     0  E >   NEW                                                  $6      'Bar'
          1        SEND_VAL_EX                                                  'child%230'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $6
   42     4        NEW                                                  $9      'Bar'
          5        SEND_VAL_EX                                                  'child%231'
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !1, $9
   44     8        NEW                                                  $12     'Bar'
          9        SEND_VAL_EX                                                  'child%230'
         10        DO_FCALL                                          0          
         11        ASSIGN                                                       !2, $12
   45    12        NEW                                                  $15     'Bar'
         13        SEND_VAL_EX                                                  'child%231'
         14        DO_FCALL                                          0          
         15        ASSIGN                                                       !3, $15
   47    16        NEW                                                  $18     'Foo'
         17        SEND_VAL_EX                                                  'parent'
         18        INIT_ARRAY                                           ~19     !0
         19        ADD_ARRAY_ELEMENT                                    ~19     !1
         20        SEND_VAL_EX                                                  ~19
         21        DO_FCALL                                          0          
         22        ASSIGN                                                       !4, $18
   48    23        NEW                                                  $22     'Foo'
         24        SEND_VAL_EX                                                  'parent'
         25        INIT_ARRAY                                           ~23     !2
         26        ADD_ARRAY_ELEMENT                                    ~23     !3
         27        SEND_VAL_EX                                                  ~23
         28        DO_FCALL                                          0          
         29        ASSIGN                                                       !5, $22
   51    30        INIT_FCALL                                                   'var_dump'
         31        IS_EQUAL                                             ~26     !4, !5
         32        SEND_VAL                                                     ~26
         33        DO_ICALL                                                     
         34      > RETURN                                                       1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Huqf
function name:  __construct
number of ops:  8
compiled vars:  !0 = $content, !1 = $children
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV_INIT                                            !0      ''
          1        RECV_INIT                                            !1      <array>
   11     2        ASSIGN_OBJ                                                   'holder'
          3        OP_DATA                                                      !0
   12     4        INIT_METHOD_CALL                                             'setChildren'
          5        SEND_VAR_EX                                                  !1
          6        DO_FCALL                                          0          
   13     7      > RETURN                                                       null

End of function __construct

Function setchildren:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/6Huqf
function name:  setChildren
number of ops:  12
compiled vars:  !0 = $children, !1 = $child
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
   17     1        ASSIGN_OBJ                                                   'children'
          2        OP_DATA                                                      !0
   18     3      > FE_RESET_R                                           $3      !0, ->10
          4    > > FE_FETCH_R                                                   $3, !1, ->10
   19     5    >   INIT_METHOD_CALL                                             !1, 'setParent'
          6        FETCH_THIS                                           $4      
          7        SEND_VAR_EX                                                  $4
          8        DO_FCALL                                          0          
   18     9      > JMP                                                          ->4
         10    >   FE_FREE                                                      $3
   21    11      > RETURN                                                       null

End of function setchildren

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Huqf
function name:  __construct
number of ops:  8
compiled vars:  !0 = $content, !1 = $parent
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV_INIT                                            !0      ''
          1        RECV_INIT                                            !1      null
   31     2        ASSIGN_OBJ                                                   'holder'
          3        OP_DATA                                                      !0
   32     4        INIT_METHOD_CALL                                             'setParent'
          5        SEND_VAR_EX                                                  !1
          6        DO_FCALL                                          0          
   33     7      > RETURN                                                       null

End of function __construct

Function setparent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Huqf
function name:  setParent
number of ops:  4
compiled vars:  !0 = $parent
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   RECV_INIT                                            !0      null
   37     1        ASSIGN_OBJ                                                   'parent'
          2        OP_DATA                                                      !0
   38     3      > RETURN                                                       null

End of function setparent

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.64 ms | 3027 KiB | 14 Q