3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Item { public static function &newWithParent(Item &$parent) { $item = new Item(); $item->parent = $parent; return $item; } private $parent; public function &getParent() { return $this->parent; } } $item = Item::newWithParent(Item::newWithParent(Item::newWithParent(new Item()))); // Basically it's this now: {"parent":{"parent":{"parent":{"parent":null}}}} // I want to set that null value $list = $item; do { $prev = &$item; $item = $item->getParent(); if ($item->getParent() === null) { $prev =& Item::newWithParent($item); break; } } while (true); var_dump($list);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 13
Branch analysis from position: 27
Branch analysis from position: 13
filename:       /in/0et6r
function name:  (null)
number of ops:  31
compiled vars:  !0 = $item, !1 = $list, !2 = $prev
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_STATIC_METHOD_CALL                                  'Item', 'newWithParent'
          1        INIT_STATIC_METHOD_CALL                                  'Item', 'newWithParent'
          2        INIT_STATIC_METHOD_CALL                                  'Item', 'newWithParent'
          3        NEW                                              $3      'Item'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF                               0          $3
          6        DO_FCALL                                      0  $5      
          7        SEND_VAR_NO_REF                               0          $5
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR_NO_REF                               0          $6
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !0, $7
   22    12        ASSIGN                                                   !1, !0
   24    13    >   ASSIGN_REF                                               !2, !0
   25    14        INIT_METHOD_CALL                                         !0, 'getParent'
         15        DO_FCALL                                      0  $11     
         16        ASSIGN                                                   !0, $11
   26    17        INIT_METHOD_CALL                                         !0, 'getParent'
         18        DO_FCALL                                      0  $13     
         19        TYPE_CHECK                                    2          $13
         20      > JMPZ                                                     ~14, ->26
   27    21    >   INIT_STATIC_METHOD_CALL                                  'Item', 'newWithParent'
         22        SEND_REF                                                 !0
         23        DO_FCALL                                      0  $15     
         24        ASSIGN_REF                                               !2, $15
   28    25      > JMP                                                      ->27
   30    26    > > JMPNZ                                                    <true>, ->13
   31    27    >   INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Class Item:
Function newwithparent:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/0et6r
function name:  newWithParent
number of ops:  8
compiled vars:  !0 = $parent, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        NEW                                              $2      'Item'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
    7     4        ASSIGN_OBJ                                               !1, 'parent'
          5        OP_DATA                                                  !0
    8     6      > RETURN_BY_REF                                            !1
    9     7*     > RETURN_BY_REF                                            null

End of function newwithparent

Function getparent:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/0et6r
function name:  getParent
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_W                                      $0      'parent'
          1      > RETURN_BY_REF                                            $0
   16     2*     > RETURN_BY_REF                                            null

End of function getparent

End of class Item.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.11 ms | 1400 KiB | 15 Q