3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! function iterator_compose() { foreach (array_reverse(func_get_args()) as $it) { if (is_callable($it)) { $prev = $it; } } } function iterator_chunk($it, $chunkSize) { $chunk = []; $steps = range(0, $chunkSize); while (true) { foreach ($steps as $_) { $chunk[] = $it->current(); $it->next(); if (!$it->valid()) { break 1; } } yield $chunk; $chunk = []; } if ($chunk) { yield $chunk; } } foreach (iterator_chunk(range(0, 125), 32) as $i => $c) { echo "====== Chunk $i ======\n"; var_export($c); echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/l88tL
function name:  (null)
number of ops:  22
compiled vars:  !0 = $c, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'iterator_chunk'
          1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 125
          4        DO_ICALL                                         $2      
          5        SEND_VAR                                                 $2
          6        SEND_VAL                                                 32
          7        DO_FCALL                                      0  $3      
          8      > FE_RESET_R                                       $4      $3, ->20
          9    > > FE_FETCH_R                                       ~5      $4, !0, ->20
         10    >   ASSIGN                                                   !1, ~5
   38    11        ROPE_INIT                                     3  ~8      '%3D%3D%3D%3D%3D%3D+Chunk+'
         12        ROPE_ADD                                      1  ~8      ~8, !1
         13        ROPE_END                                      2  ~7      ~8, '+%3D%3D%3D%3D%3D%3D%0A'
         14        ECHO                                                     ~7
   39    15        INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
   40    18        ECHO                                                     '%0A'
   37    19      > JMP                                                      ->9
         20    >   FE_FREE                                                  $4
   41    21      > RETURN                                                   1

Function iterator_compose:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/l88tL
function name:  iterator_compose
number of ops:  14
compiled vars:  !0 = $it, !1 = $prev
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'array_reverse'
          1        FUNC_GET_ARGS                                    ~2      
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4      > FE_RESET_R                                       $4      $3, ->12
          5    > > FE_FETCH_R                                               $4, !0, ->12
    7     6    >   INIT_FCALL                                               'is_callable'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9      > JMPZ                                                     $5, ->11
    8    10    >   ASSIGN                                                   !1, !0
    6    11    > > JMP                                                      ->5
         12    >   FE_FREE                                                  $4
   11    13      > RETURN                                                   null

End of function iterator_compose

Function iterator_chunk:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 10
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 24
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 10
Branch analysis from position: 28
Branch analysis from position: 10
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 24
Branch analysis from position: 24
filename:       /in/l88tL
function name:  iterator_chunk
number of ops:  31
compiled vars:  !0 = $it, !1 = $chunkSize, !2 = $chunk, !3 = $steps, !4 = $_
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        GENERATOR_CREATE                                         
   15     3        ASSIGN                                                   !2, <array>
   16     4        INIT_FCALL                                               'range'
          5        SEND_VAL                                                 0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !3, $6
   18     9      > JMP                                                      ->27
   19    10    > > FE_RESET_R                                       $8      !3, ->24
         11    > > FE_FETCH_R                                               $8, !4, ->24
   20    12    >   INIT_METHOD_CALL                                         !0, 'current'
         13        DO_FCALL                                      0  $10     
         14        ASSIGN_DIM                                               !2
         15        OP_DATA                                                  $10
   21    16        INIT_METHOD_CALL                                         !0, 'next'
         17        DO_FCALL                                      0          
   23    18        INIT_METHOD_CALL                                         !0, 'valid'
         19        DO_FCALL                                      0  $12     
         20        BOOL_NOT                                         ~13     $12
         21      > JMPZ                                                     ~13, ->23
   24    22    > > JMP                                                      ->24
   19    23    > > JMP                                                      ->11
         24    >   FE_FREE                                                  $8
   28    25        YIELD                                                    !2
   29    26        ASSIGN                                                   !2, <array>
   18    27    > > JMPNZ                                                    <true>, ->10
   32    28    > > JMPZ                                                     !2, ->30
   33    29    >   YIELD                                                    !2
   35    30    > > GENERATOR_RETURN                                         

End of function iterator_chunk

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.04 ms | 1407 KiB | 22 Q