3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('VALIDTYPES', [ 'double' => 'd', 'integer' => 'i', 'resource' => 'b', // I haven't actually researched/tested this 'string' => 's', ]); $params = [1, -3.5, 'stringy', (object)[]]; $params = [1, -3.5, 'stringy']; $types = array_reduce( $params, function($carry, $item) { $type = gettype($item); if (!isset(VALIDTYPES[$type])) { throw new Exception('unexpected data type'); } else { return $carry . VALIDTYPES[$type]; } }, ''); var_export($types);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/alenU
function name:  (null)
number of ops:  22
compiled vars:  !0 = $params, !1 = $types
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'VALIDTYPES'
    3     2        SEND_VAL                                                 <array>
          3        DO_ICALL                                                 
    9     4        INIT_ARRAY                                       ~3      1
          5        ADD_ARRAY_ELEMENT                                ~3      -3.5
          6        ADD_ARRAY_ELEMENT                                ~3      'stringy'
          7        CAST                                          8  ~4      <array>
          8        ADD_ARRAY_ELEMENT                                ~3      ~4
          9        ASSIGN                                                   !0, ~3
   10    10        ASSIGN                                                   !0, <array>
   12    11        INIT_FCALL                                               'array_reduce'
   13    12        SEND_VAR                                                 !0
   14    13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FalenU%3A14%240'
   21    14        SEND_VAL                                                 ~7
   22    15        SEND_VAL                                                 ''
         16        DO_ICALL                                         $8      
   12    17        ASSIGN                                                   !1, $8
   24    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FalenU%3A14%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/alenU
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $carry, !1 = $item, !2 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        GET_TYPE                                         ~3      !1
          3        ASSIGN                                                   !2, ~3
   16     4        FETCH_CONSTANT                                   ~5      'VALIDTYPES'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      ~5, !2
          6        BOOL_NOT                                         ~7      ~6
          7      > JMPZ                                                     ~7, ->13
   17     8    >   NEW                                              $8      'Exception'
          9        SEND_VAL_EX                                              'unexpected+data+type'
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $8
         12*       JMP                                                      ->17
   19    13    >   FETCH_CONSTANT                                   ~10     'VALIDTYPES'
         14        FETCH_DIM_R                                      ~11     ~10, !2
         15        CONCAT                                           ~12     !0, ~11
         16      > RETURN                                                   ~12
   21    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FalenU%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.83 ms | 1400 KiB | 19 Q