3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Because lol: https://github.com/alvaropinot/circular-iterator function circularIterator(Iterator $t) { foreach ($t as $v) { yield $v; if (!$t->valid()) { $t->rewind(); } } } $iter = circularIterator( SplFixedArray::fromArray([1, 2, 3]) ); $iter->rewind(); var_dump($iter->current()); $iter->next(); var_dump($iter->current()); $iter->next(); var_dump($iter->current()); $iter->next(); var_dump($iter->current()); $iter->next();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2arts
function name:  (null)
number of ops:  38
compiled vars:  !0 = $iter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'circulariterator'
   16     1        INIT_STATIC_METHOD_CALL                                  'SplFixedArray', 'fromArray'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $1      
          4        SEND_VAR                                                 $1
          5        DO_FCALL                                      0  $2      
   15     6        ASSIGN                                                   !0, $2
   19     7        INIT_METHOD_CALL                                         !0, 'rewind'
          8        DO_FCALL                                      0          
   21     9        INIT_FCALL                                               'var_dump'
         10        INIT_METHOD_CALL                                         !0, 'current'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14        INIT_METHOD_CALL                                         !0, 'next'
         15        DO_FCALL                                      0          
   22    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !0, 'current'
         18        DO_FCALL                                      0  $8      
         19        SEND_VAR                                                 $8
         20        DO_ICALL                                                 
         21        INIT_METHOD_CALL                                         !0, 'next'
         22        DO_FCALL                                      0          
   23    23        INIT_FCALL                                               'var_dump'
         24        INIT_METHOD_CALL                                         !0, 'current'
         25        DO_FCALL                                      0  $11     
         26        SEND_VAR                                                 $11
         27        DO_ICALL                                                 
         28        INIT_METHOD_CALL                                         !0, 'next'
         29        DO_FCALL                                      0          
   24    30        INIT_FCALL                                               'var_dump'
         31        INIT_METHOD_CALL                                         !0, 'current'
         32        DO_FCALL                                      0  $14     
         33        SEND_VAR                                                 $14
         34        DO_ICALL                                                 
         35        INIT_METHOD_CALL                                         !0, 'next'
         36        DO_FCALL                                      0          
         37      > RETURN                                                   1

Function circulariterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 12
filename:       /in/2arts
function name:  circularIterator
number of ops:  14
compiled vars:  !0 = $t, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    6     2      > FE_RESET_R                                       $2      !0, ->12
          3    > > FE_FETCH_R                                               $2, !1, ->12
    7     4    >   YIELD                                                    !1
    9     5        INIT_METHOD_CALL                                         !0, 'valid'
          6        DO_FCALL                                      0  $4      
          7        BOOL_NOT                                         ~5      $4
          8      > JMPZ                                                     ~5, ->11
   10     9    >   INIT_METHOD_CALL                                         !0, 'rewind'
         10        DO_FCALL                                      0          
    6    11    > > JMP                                                      ->3
         12    >   FE_FREE                                                  $2
   13    13      > GENERATOR_RETURN                                         

End of function circulariterator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.86 ms | 1407 KiB | 16 Q