3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Shiterator implements SeekableIterator { private $_array = array(); private $position; public function __construct(array $array) { $this->_array = $array; } public function seek($position) { if (!isset($this->_array[$position])) { throw new OutOfBoundsException("invalid seek position ($position)"); } $this->position = $position; } public function rewind() { $this->position = 0; } public function current() { return $this->array[$this->position]; } public function key() { return $this->position; } public function next() { ++$this->position; } public function valid() { return isset($this->array[$this->position]); } } $stdcls = new stdClass(); $stdcls->message = 'PHP, still a peice of shit.'; $i = new Shiterator(array($stdcls)); foreach ($i as $t) { echo $stdcls->message; $stdcls->message = 'Zend still produces garbage.'; } var_dump($i);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/tHueF
function name:  (null)
number of ops:  23
compiled vars:  !0 = $stdcls, !1 = $i, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'shiterator'
   40     1        NEW                                              $3      'stdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   41     4        ASSIGN_OBJ                                               !0, 'message'
          5        OP_DATA                                                  'PHP%2C+still+a+peice+of+shit.'
   43     6        NEW                                              $7      'Shiterator'
          7        INIT_ARRAY                                       ~8      !0
          8        SEND_VAL_EX                                              ~8
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $7
   45    11      > FE_RESET_R                                       $11     !1, ->18
         12    > > FE_FETCH_R                                               $11, !2, ->18
   46    13    >   FETCH_OBJ_R                                      ~12     !0, 'message'
         14        ECHO                                                     ~12
   48    15        ASSIGN_OBJ                                               !0, 'message'
         16        OP_DATA                                                  'Zend+still+produces+garbage.'
   45    17      > JMP                                                      ->12
         18    >   FE_FREE                                                  $11
   51    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class Shiterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tHueF
function name:  __construct
number of ops:  4
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               '_array'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function __construct

Function seek:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tHueF
function name:  seek
number of ops:  15
compiled vars:  !0 = $position
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        FETCH_OBJ_IS                                     ~1      '_array'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->12
   13     5    >   NEW                                              $4      'OutOfBoundsException'
          6        ROPE_INIT                                     3  ~6      'invalid+seek+position+%28'
          7        ROPE_ADD                                      1  ~6      ~6, !0
          8        ROPE_END                                      2  ~5      ~6, '%29'
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $4
   16    12    >   ASSIGN_OBJ                                               'position'
         13        OP_DATA                                                  !0
   17    14      > RETURN                                                   null

End of function seek

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

End of function rewind

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

End of function current

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

End of function key

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tHueF
function name:  next
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   PRE_INC_OBJ                                              'position'
   33     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/tHueF
function name:  valid
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_OBJ_R                                      ~1      'position'
          1        FETCH_OBJ_IS                                     ~0      'array'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~0, ~1
          3      > RETURN                                                   ~2
   37     4*     > RETURN                                                   null

End of function valid

End of class Shiterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.57 ms | 1404 KiB | 15 Q