3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Gen implements Iterator { private $myArray; public function __construct( $n ) { $this->myArray = range(0,$n-1); } function rewind() { return reset($this->myArray); } function current() { return current($this->myArray); } function key() { return key($this->myArray); } function next() { return next($this->myArray); } function valid() { return key($this->myArray) !== null; } function __destruct(){ return '<BR>Gen is data drained!'; } } $gen = new Gen(3); // iterable object can be used in foreach foreach ($gen as $g) { echo $gen->current(); // sequentially making data available }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/AkQjb
function name:  (null)
number of ops:  13
compiled vars:  !0 = $gen, !1 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'gen'
   30     1        NEW                                              $2      'Gen'
          2        SEND_VAL_EX                                              3
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   33     5      > FE_RESET_R                                       $5      !0, ->11
          6    > > FE_FETCH_R                                               $5, !1, ->11
   34     7    >   INIT_METHOD_CALL                                         !0, 'current'
          8        DO_FCALL                                      0  $6      
          9        ECHO                                                     $6
   33    10      > JMP                                                      ->6
         11    >   FE_FREE                                                  $5
   35    12      > RETURN                                                   1

Class Gen:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AkQjb
function name:  __construct
number of ops:  9
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SUB                                              ~2      !0, 1
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        ASSIGN_OBJ                                               'myArray'
          7        OP_DATA                                                  $3
    8     8      > 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/AkQjb
function name:  rewind
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'reset'
          1        FETCH_OBJ_W                                      $0      'myArray'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   11     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/AkQjb
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~0      'myArray'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   14     5*     > 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/AkQjb
function name:  key
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      'myArray'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   17     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/AkQjb
function name:  next
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $0      'myArray'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   20     5*     > 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/AkQjb
function name:  valid
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      'myArray'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4        TYPE_CHECK                                  1020  ~2      $1
          5      > RETURN                                                   ~2
   23     6*     > RETURN                                                   null

End of function valid

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AkQjb
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E > > RETURN                                                   '%3CBR%3EGen+is+data+drained%21'
   26     1*     > RETURN                                                   null

End of function __destruct

End of class Gen.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.54 ms | 1392 KiB | 23 Q