3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Items implements \Iterator { private $items = []; private $index = 0; public function current() { return $this->items[$this->index]; } public function next() { $this->index++; } public function valid() { return isset($this->items[$this->index]); } public function key() { return $this->index; } public function rewind() { $this->index = 0; } public function add($item) { $this->items[] = $item; } public function remove($index) { unset($this->items[$index]); } } //------------------- $items = new Items(); $items->add('foo'); $items->add('bar'); $items->add('baz'); $items->remove(0); // Expected that the loop would start with the first index of "1" // but it doesn't output anything foreach($items as $item) { echo $item."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/UXF3A
function name:  (null)
number of ops:  23
compiled vars:  !0 = $items, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'items'
   40     1        NEW                                              $2      'Items'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   42     4        INIT_METHOD_CALL                                         !0, 'add'
          5        SEND_VAL_EX                                              'foo'
          6        DO_FCALL                                      0          
   43     7        INIT_METHOD_CALL                                         !0, 'add'
          8        SEND_VAL_EX                                              'bar'
          9        DO_FCALL                                      0          
   44    10        INIT_METHOD_CALL                                         !0, 'add'
         11        SEND_VAL_EX                                              'baz'
         12        DO_FCALL                                      0          
   46    13        INIT_METHOD_CALL                                         !0, 'remove'
         14        SEND_VAL_EX                                              0
         15        DO_FCALL                                      0          
   50    16      > FE_RESET_R                                       $9      !0, ->21
         17    > > FE_FETCH_R                                               $9, !1, ->21
   51    18    >   CONCAT                                           ~10     !1, '%0A'
         19        ECHO                                                     ~10
   50    20      > JMP                                                      ->17
         21    >   FE_FREE                                                  $9
   52    22      > RETURN                                                   1

Class Items:
Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UXF3A
function name:  current
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~1      'index'
          1        FETCH_OBJ_R                                      ~0      'items'
          2        FETCH_DIM_R                                      ~2      ~0, ~1
          3      > RETURN                                                   ~2
   12     4*     > RETURN                                                   null

End of function current

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

End of function next

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UXF3A
function name:  valid
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~1      'index'
          1        FETCH_OBJ_IS                                     ~0      'items'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~0, ~1
          3      > RETURN                                                   ~2
   20     4*     > RETURN                                                   null

End of function valid

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

End of function key

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UXF3A
function name:  rewind
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN_OBJ                                               'index'
          1        OP_DATA                                                  0
   28     2      > RETURN                                                   null

End of function rewind

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UXF3A
function name:  add
number of ops:  5
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        FETCH_OBJ_W                                      $1      'items'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   33     4      > RETURN                                                   null

End of function add

Function remove:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UXF3A
function name:  remove
number of ops:  4
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        FETCH_OBJ_UNSET                                  $1      'items'
          2        UNSET_DIM                                                $1, !0
   37     3      > RETURN                                                   null

End of function remove

End of class Items.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.13 ms | 1403 KiB | 13 Q