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

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