3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruitpacks = [ ['apples', 3], ['pears', 1], ['apples', 6], ['grapes', 22], ]; abstract class ArrayTools { public static function integerAppend(array $array, $key, int $value) : array { return [$key => $value + ($array[$key] ?? 0)] + $array; } public static function integerAppendFromTuple(array $array, array $keyIntValuePair) : array { return self::integerAppend($array, ...$keyIntValuePair); } } var_dump(array_reduce($fruitpacks, [ArrayTools::class, 'integerAppendFromTuple'], []));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZJcom
function name:  (null)
number of ops:  10
compiled vars:  !0 = $fruitpacks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <array>
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   21     9      > RETURN                                                   1

Class ArrayTools:
Function integerappend:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZJcom
function name:  integerAppend
number of ops:  13
compiled vars:  !0 = $array, !1 = $key, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   12     3        FETCH_DIM_IS                                     ~3      !0, !1
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      0
          6        ADD                                              ~5      !2, ~4
          7        INIT_ARRAY                                       ~6      ~5, !1
          8        ADD                                              ~7      ~6, !0
          9        VERIFY_RETURN_TYPE                                       ~7
         10      > RETURN                                                   ~7
   13    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function integerappend

Function integerappendfromtuple:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZJcom
function name:  integerAppendFromTuple
number of ops:  11
compiled vars:  !0 = $array, !1 = $keyIntValuePair
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        INIT_STATIC_METHOD_CALL                                  'integerAppend'
          3        SEND_VAR                                                 !0
          4        SEND_UNPACK                                              !1
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      1  $2      
          7        VERIFY_RETURN_TYPE                                       $2
          8      > RETURN                                                   $2
   17     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function integerappendfromtuple

End of class ArrayTools.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.67 ms | 1400 KiB | 17 Q