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]); } } $i = new myIterator; foreach ($i as $t) { echo $t; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/v9Qck
function name:  (null)
number of ops:  10
compiled vars:  !0 = $i, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'myiterator'
   41     1        NEW                                              $2      'myIterator'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   43     4      > FE_RESET_R                                       $5      !0, ->8
          5    > > FE_FETCH_R                                               $5, !1, ->8
   44     6    >   ECHO                                                     !1
   43     7      > JMP                                                      ->5
          8    >   FE_FREE                                                  $5
   45     9      > RETURN                                                   1

Class myIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v9Qck
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/v9Qck
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/v9Qck
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/v9Qck
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/v9Qck
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/v9Qck
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:
150.72 ms | 1392 KiB | 15 Q