3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Because lol: https://github.com/alvaropinot/circular-iterator function circularIterator(Iterator $t) { while (true) { yield $t->current(); $t->next(); 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/5cg8t
function name:  (null)
number of ops:  38
compiled vars:  !0 = $iter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'circulariterator'
   18     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      
   17     6        ASSIGN                                                   !0, $2
   21     7        INIT_METHOD_CALL                                         !0, 'rewind'
          8        DO_FCALL                                      0          
   23     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          
   24    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          
   25    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          
   26    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
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
Branch analysis from position: 3
Branch analysis from position: 14
filename:       /in/5cg8t
function name:  circularIterator
number of ops:  16
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    6     2      > JMP                                                      ->14
    7     3    >   INIT_METHOD_CALL                                         !0, 'current'
          4        DO_FCALL                                      0  $1      
          5        YIELD                                                    $1
    9     6        INIT_METHOD_CALL                                         !0, 'next'
          7        DO_FCALL                                      0          
   11     8        INIT_METHOD_CALL                                         !0, 'valid'
          9        DO_FCALL                                      0  $4      
         10        BOOL_NOT                                         ~5      $4
         11      > JMPZ                                                     ~5, ->14
   12    12    >   INIT_METHOD_CALL                                         !0, 'rewind'
         13        DO_FCALL                                      0          
    6    14    > > JMPNZ                                                    <true>, ->3
   15    15    > > GENERATOR_RETURN                                         

End of function circulariterator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.85 ms | 1403 KiB | 16 Q