3v4l.org

run code in 300+ PHP versions simultaneously
<?php class InfiniteNumbers implements Iterator { public $start; public $current; public function __construct($start) { $this->start = $start; $this->current = $start; } public function next() { echo "next called\n"; $this->current++; } public function current() { echo "current called\n"; return $this->current; } public function key() { echo "key called\n"; return $this->current; } public function rewind() { echo "rewind called\n"; $this->current = $this->start; } public function valid() { echo "valid called\n"; return true; } } $infinite = new InfiniteNumbers(1); var_dump($infinite); foreach($infinite as $number) { if($number > 10) { break; } echo $number."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
Branch analysis from position: 16
filename:       /in/NSZoi
function name:  (null)
number of ops:  18
compiled vars:  !0 = $infinite, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'infinitenumbers'
   37     1        NEW                                              $2      'InfiniteNumbers'
          2        SEND_VAL_EX                                              1
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   39     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   42     8      > FE_RESET_R                                       $6      !0, ->16
          9    > > FE_FETCH_R                                               $6, !1, ->16
   43    10    >   IS_SMALLER                                               10, !1
         11      > JMPZ                                                     ~7, ->13
   44    12    > > JMP                                                      ->16
   46    13    >   CONCAT                                           ~8      !1, '%0A'
         14        ECHO                                                     ~8
   42    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $6
   47    17      > RETURN                                                   1

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

End of function __construct

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSZoi
function name:  next
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'next+called%0A'
   13     1        PRE_INC_OBJ                                              'current'
   14     2      > RETURN                                                   null

End of function next

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSZoi
function name:  current
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     'current+called%0A'
   18     1        FETCH_OBJ_R                                      ~0      'current'
          2      > RETURN                                                   ~0
   19     3*     > 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/NSZoi
function name:  key
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ECHO                                                     'key+called%0A'
   23     1        FETCH_OBJ_R                                      ~0      'current'
          2      > RETURN                                                   ~0
   24     3*     > 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/NSZoi
function name:  rewind
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ECHO                                                     'rewind+called%0A'
   28     1        FETCH_OBJ_R                                      ~1      'start'
          2        ASSIGN_OBJ                                               'current'
          3        OP_DATA                                                  ~1
   29     4      > RETURN                                                   null

End of function rewind

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSZoi
function name:  valid
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ECHO                                                     'valid+called%0A'
   33     1      > RETURN                                                   <true>
   34     2*     > RETURN                                                   null

End of function valid

End of class InfiniteNumbers.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.43 ms | 1404 KiB | 15 Q