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

Class Item:
Function newwithparent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mIuW0
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                                                   !1
    9     7*     > RETURN                                                   null

End of function newwithparent

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

End of function getparent

End of class Item.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.18 ms | 1392 KiB | 15 Q