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 do { $prev = &$item; $item = $item->getParent(); if ($item->getParent() === null) { $prev =& Item::newWithParent($item); break; } } while (true); var_dump($item);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 12
Branch analysis from position: 26
Branch analysis from position: 12
filename:       /in/uYhIV
function name:  (null)
number of ops:  30
compiled vars:  !0 = $item, !1 = $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                                              $2      'Item'
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $2
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !0, $6
   23    12    >   ASSIGN_REF                                               !1, !0
   24    13        INIT_METHOD_CALL                                         !0, 'getParent'
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !0, $9
   25    16        INIT_METHOD_CALL                                         !0, 'getParent'
         17        DO_FCALL                                      0  $11     
         18        TYPE_CHECK                                    2          $11
         19      > JMPZ                                                     ~12, ->25
   26    20    >   INIT_STATIC_METHOD_CALL                                  'Item', 'newWithParent'
         21        SEND_VAR                                                 !0
         22        DO_FCALL                                      0  $13     
         23        ASSIGN_REF                                               !1, $13
   27    24      > JMP                                                      ->26
   29    25    > > JMPNZ                                                    <true>, ->12
   30    26    >   INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Class Item:
Function newwithparent:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/uYhIV
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/uYhIV
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:
154.45 ms | 1400 KiB | 15 Q