3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 'firstName' => null, 'lastName' => null, 'category' => [ 'name' => null, 'service' => [ 'foo' => [ 'bar' => null ] ] ] ]; function prepareFields(array $array): array { return array_reduce(array_keys($array), function ($result, $key) use ($array) { $result[] = $key; if (is_array($array[$key])) { $result[$key] = prepareFields($array[$key]); } return $result; }); } print_r(prepareFields($input));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3BfKD
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'preparefields'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function preparefields:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3BfKD
function name:  prepareFields
number of ops:  14
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'array_reduce'
          2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          7        BIND_LEXICAL                                             ~2, !0
   24     8        SEND_VAL                                                 ~2
   18     9        DO_ICALL                                         $3      
   24    10        VERIFY_RETURN_TYPE                                       $3
         11      > RETURN                                                   $3
   25    12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/3BfKD
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $result, !1 = $key, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   19     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  !1
   20     5        FETCH_DIM_R                                      ~4      !2, !1
          6        TYPE_CHECK                                  128          ~4
          7      > JMPZ                                                     ~5, ->15
   21     8    >   INIT_FCALL_BY_NAME                                       'prepareFields'
          9        CHECK_FUNC_ARG                                           
         10        FETCH_DIM_FUNC_ARG                               $7      !2, !1
         11        SEND_FUNC_ARG                                            $7
         12        DO_FCALL                                      0  $8      
         13        ASSIGN_DIM                                               !0, !1
         14        OP_DATA                                                  $8
   23    15    > > RETURN                                                   !0
   24    16*     > RETURN                                                   null

End of Dynamic Function 0

End of function preparefields

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.73 ms | 1020 KiB | 17 Q