3v4l.org

run code in 500+ PHP versions simultaneously
<?php function generate(int $elementsCount, int $maxValue, array $current = []): \Generator { for ($value = 1; $value <= $maxValue; $value++) { yield [...$current, $value]; } if ($elementsCount > 1) { for ($value = 1; $value <= $maxValue; $value++) { yield from generate($elementsCount - 1, $maxValue, [...$current, $value]); } } } print_r(iterator_to_array(generate(3, 3), false));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E5NRK
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                                   'print_r'
          1        INIT_FCALL                                                   'iterator_to_array'
          2        INIT_FCALL                                                   'generate'
          3        SEND_VAL                                                     3
          4        SEND_VAL                                                     3
          5        DO_FCALL                                          0  $0      
          6        SEND_VAR                                                     $0
          7        SEND_VAL                                                     <false>
          8        DO_ICALL                                             $1      
          9        SEND_VAR                                                     $1
         10        DO_ICALL                                                     
         11      > RETURN                                                       1

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 17
Branch analysis from position: 31
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 17
Branch analysis from position: 31
Branch analysis from position: 17
Branch analysis from position: 31
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
Branch analysis from position: 6
filename:       /in/E5NRK
function name:  generate
number of ops:  32
compiled vars:  !0 = $elementsCount, !1 = $maxValue, !2 = $current, !3 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV_INIT                                            !2      <array>
          3        GENERATOR_CREATE                                             
    5     4        ASSIGN                                                       !3, 1
          5      > JMP                                                          ->11
    6     6    >   INIT_ARRAY                                           ~5      
          7        ADD_ARRAY_UNPACK                                     ~5      !2
          8        ADD_ARRAY_ELEMENT                                    ~5      !3
          9        YIELD                                                        ~5
    5    10        PRE_INC                                                      !3
         11    >   IS_SMALLER_OR_EQUAL                                          !3, !1
         12      > JMPNZ                                                        ~8, ->6
    8    13    >   IS_SMALLER                                                   1, !0
         14      > JMPZ                                                         ~9, ->31
    9    15    >   ASSIGN                                                       !3, 1
         16      > JMP                                                          ->29
   10    17    >   INIT_FCALL_BY_NAME                                           'generate'
         18        SUB                                                  ~11     !0, 1
         19        SEND_VAL_EX                                                  ~11
         20        SEND_VAR_EX                                                  !1
         21        INIT_ARRAY                                           ~12     
         22        ADD_ARRAY_UNPACK                                     ~12     !2
         23        ADD_ARRAY_ELEMENT                                    ~12     !3
         24        SEND_VAL_EX                                                  ~12
         25        DO_FCALL                                          0  $13     
         26        YIELD_FROM                                           ~14     $13
         27        FREE                                                         ~14
    9    28        PRE_INC                                                      !3
         29    >   IS_SMALLER_OR_EQUAL                                          !3, !1
         30      > JMPNZ                                                        ~16, ->17
   13    31    > > GENERATOR_RETURN                                             

End of function generate

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.41 ms | 2825 KiB | 16 Q