3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Item { public $name; public $parent; public function __construct($name, $parent = null) { $this->name = $name; $this->parent = $parent; } } function render(Item $item) { yield $item; if (is_object($item) && $item->parent) { yield from render($item->parent); } } $a = new Item('a'); $b = new Item('b', $a); $c = new Item('c', $b); $d = new Item('d', $c); $e = new Item('e', $d); foreach (render($e) as $item) { var_dump($item); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/MlYOb
function name:  (null)
number of ops:  35
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d, !4 = $e, !5 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $6      'Item'
          1        SEND_VAL_EX                                              'a'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
   26     4        NEW                                              $9      'Item'
          5        SEND_VAL_EX                                              'b'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $9
   27     9        NEW                                              $12     'Item'
         10        SEND_VAL_EX                                              'c'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $12
   28    14        NEW                                              $15     'Item'
         15        SEND_VAL_EX                                              'd'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $15
   29    19        NEW                                              $18     'Item'
         20        SEND_VAL_EX                                              'e'
         21        SEND_VAR_EX                                              !3
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !4, $18
   31    24        INIT_FCALL                                               'render'
         25        SEND_VAR                                                 !4
         26        DO_FCALL                                      0  $21     
         27      > FE_RESET_R                                       $22     $21, ->33
         28    > > FE_FETCH_R                                               $22, !5, ->33
   32    29    >   INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !5
         31        DO_ICALL                                                 
   31    32      > JMP                                                      ->28
         33    >   FE_FREE                                                  $22
   33    34      > RETURN                                                   1

Function render:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 7
filename:       /in/MlYOb
function name:  render
number of ops:  16
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   18     2        YIELD                                                    !0
   20     3        TYPE_CHECK                                  256  ~2      !0
          4      > JMPZ_EX                                          ~2      ~2, ->7
          5    >   FETCH_OBJ_R                                      ~3      !0, 'parent'
          6        BOOL                                             ~2      ~3
          7    > > JMPZ                                                     ~2, ->15
   21     8    >   INIT_FCALL_BY_NAME                                       'render'
          9        CHECK_FUNC_ARG                                           
         10        FETCH_OBJ_FUNC_ARG                               $4      !0, 'parent'
         11        SEND_FUNC_ARG                                            $4
         12        DO_FCALL                                      0  $5      
         13        YIELD_FROM                                       ~6      $5
         14        FREE                                                     ~6
   23    15    > > GENERATOR_RETURN                                         

End of function render

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

End of function __construct

End of class Item.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.67 ms | 1403 KiB | 16 Q