3v4l.org

run code in 300+ PHP versions simultaneously
<?php function popUnshift(array $indexedArray, int $popShiftsCount): array { $count = count($indexedArray); if ($count < 2) { return $indexedArray; } $remainder = $popShiftsCount % $count; if (!$remainder) { return $indexedArray; } return array_merge( array_splice($indexedArray, -$remainder), $indexedArray ); } $A = [1, 2, 3, 4]; foreach (range(0, 9) as $K) { var_export(popUnshift($A, $K)); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/QdIUh
function name:  (null)
number of ops:  18
compiled vars:  !0 = $A, !1 = $K
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 9
          4        DO_ICALL                                         $3      
          5      > FE_RESET_R                                       $4      $3, ->16
          6    > > FE_FETCH_R                                               $4, !1, ->16
   21     7    >   INIT_FCALL                                               'var_export'
          8        INIT_FCALL                                               'popunshift'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   22    14        ECHO                                                     '%0A---%0A'
   20    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $4
   23    17      > RETURN                                                   1

Function popunshift:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QdIUh
function name:  popUnshift
number of ops:  27
compiled vars:  !0 = $indexedArray, !1 = $popShiftsCount, !2 = $count, !3 = $remainder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        COUNT                                            ~4      !0
          3        ASSIGN                                                   !2, ~4
    6     4        IS_SMALLER                                               !2, 2
          5      > JMPZ                                                     ~6, ->8
    7     6    >   VERIFY_RETURN_TYPE                                       !0
          7      > RETURN                                                   !0
    9     8    >   MOD                                              ~7      !1, !2
          9        ASSIGN                                                   !3, ~7
   10    10        BOOL_NOT                                         ~9      !3
         11      > JMPZ                                                     ~9, ->14
   11    12    >   VERIFY_RETURN_TYPE                                       !0
         13      > RETURN                                                   !0
   13    14    >   INIT_FCALL                                               'array_merge'
   14    15        INIT_FCALL                                               'array_splice'
         16        SEND_REF                                                 !0
         17        MUL                                              ~10     !3, -1
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
   15    21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $12     
         23        VERIFY_RETURN_TYPE                                       $12
         24      > RETURN                                                   $12
   17    25*       VERIFY_RETURN_TYPE                                       
         26*     > RETURN                                                   null

End of function popunshift

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.09 ms | 1403 KiB | 22 Q