3v4l.org

run code in 300+ PHP versions simultaneously
<?php class myIterator implements Iterator { private $position = 0; private $array = array( "firstelement", "secondelement", "lastelement", ); public function __construct() { $this->position = 0; } function rewind() { var_dump(__METHOD__); $this->position = 0; } function current() { var_dump(__METHOD__); return $this->array[$this->position]; } function key() { var_dump(__METHOD__); return $this->position; } function next() { var_dump(__METHOD__); ++$this->position; } function valid() { var_dump(__METHOD__); return isset($this->array[$this->position]); } } $it = new myIterator; foreach($it as $key => $value) { var_dump($key, $value); echo "\n"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/K1HvN
function name:  (null)
number of ops:  15
compiled vars:  !0 = $it, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'myiterator'
   41     1        NEW                                              $3      'myIterator'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   43     4      > FE_RESET_R                                       $6      !0, ->13
          5    > > FE_FETCH_R                                       ~7      $6, !1, ->13
          6    >   ASSIGN                                                   !2, ~7
   44     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   45    11        ECHO                                                     '%0A'
   43    12      > JMP                                                      ->5
         13    >   FE_FREE                                                  $6
   47    14      > RETURN                                                   1

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

End of function __construct

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/K1HvN
function name:  rewind
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'myIterator%3A%3Arewind'
          2        DO_ICALL                                                 
   17     3        ASSIGN_OBJ                                               'position'
          4        OP_DATA                                                  0
   18     5      > 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/K1HvN
function name:  current
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'myIterator%3A%3Acurrent'
          2        DO_ICALL                                                 
   22     3        FETCH_OBJ_R                                      ~2      'position'
          4        FETCH_OBJ_R                                      ~1      'array'
          5        FETCH_DIM_R                                      ~3      ~1, ~2
          6      > RETURN                                                   ~3
   23     7*     > 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/K1HvN
function name:  key
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'myIterator%3A%3Akey'
          2        DO_ICALL                                                 
   27     3        FETCH_OBJ_R                                      ~1      'position'
          4      > RETURN                                                   ~1
   28     5*     > 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/K1HvN
function name:  next
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'myIterator%3A%3Anext'
          2        DO_ICALL                                                 
   32     3        PRE_INC_OBJ                                              'position'
   33     4      > 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/K1HvN
function name:  valid
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'myIterator%3A%3Avalid'
          2        DO_ICALL                                                 
   37     3        FETCH_OBJ_R                                      ~2      'position'
          4        FETCH_OBJ_IS                                     ~1      'array'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      ~1, ~2
          6      > RETURN                                                   ~3
   38     7*     > RETURN                                                   null

End of function valid

End of class myIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.31 ms | 1400 KiB | 15 Q