3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Reader extends IteratorIterator { private $is_first = true; public function current() { $this->is_first = false; return parent::current(); } public function valid() { $res = parent::valid(); if (!$res) $this->is_first = true; } public function rewind() { if (!$this->is_first) return; $this->is_first = true; parent::rewind(); } } $a = new Reader(new ArrayIterator(range(1, 10))); foreach ($a as $v) { echo $v . PHP_EOL; break; } foreach ($a as $v) { echo $v . PHP_EOL; break; } foreach ($a as $v) { echo $v . PHP_EOL; break; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 31
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 17
Branch analysis from position: 17
filename:       /in/XumML
function name:  (null)
number of ops:  33
compiled vars:  !0 = $a, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $2      'Reader'
          1        NEW                                              $3      'ArrayIterator'
          2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 10
          5        DO_ICALL                                         $4      
          6        SEND_VAR_NO_REF_EX                                       $4
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $3
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $2
   28    11      > FE_RESET_R                                       $8      !0, ->17
         12    > > FE_FETCH_R                                               $8, !1, ->17
   29    13    >   CONCAT                                           ~9      !1, '%0A'
         14        ECHO                                                     ~9
   30    15      > JMP                                                      ->17
   28    16*       JMP                                                      ->12
         17    >   FE_FREE                                                  $8
   32    18      > FE_RESET_R                                       $10     !0, ->24
         19    > > FE_FETCH_R                                               $10, !1, ->24
   33    20    >   CONCAT                                           ~11     !1, '%0A'
         21        ECHO                                                     ~11
   34    22      > JMP                                                      ->24
   32    23*       JMP                                                      ->19
         24    >   FE_FREE                                                  $10
   36    25      > FE_RESET_R                                       $12     !0, ->31
         26    > > FE_FETCH_R                                               $12, !1, ->31
   37    27    >   CONCAT                                           ~13     !1, '%0A'
         28        ECHO                                                     ~13
   38    29      > JMP                                                      ->31
   36    30*       JMP                                                      ->26
         31    >   FE_FREE                                                  $12
   39    32      > RETURN                                                   1

Class Reader:
Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XumML
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN_OBJ                                               'is_first'
          1        OP_DATA                                                  <false>
    9     2        INIT_STATIC_METHOD_CALL                                  'current'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   10     5*     > RETURN                                                   null

End of function current

Function valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/XumML
function name:  valid
number of ops:  8
compiled vars:  !0 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_STATIC_METHOD_CALL                                  'valid'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   14     3        BOOL_NOT                                         ~3      !0
          4      > JMPZ                                                     ~3, ->7
   15     5    >   ASSIGN_OBJ                                               'is_first'
          6        OP_DATA                                                  <true>
   16     7    > > RETURN                                                   null

End of function valid

Function rewind:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XumML
function name:  rewind
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'is_first'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->4
   20     3    > > RETURN                                                   null
   21     4    >   ASSIGN_OBJ                                               'is_first'
          5        OP_DATA                                                  <true>
   22     6        INIT_STATIC_METHOD_CALL                                  'rewind'
          7        DO_FCALL                                      0          
   23     8      > RETURN                                                   null

End of function rewind

End of class Reader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.73 ms | 1405 KiB | 15 Q