3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dataFormat = array( "dateTimeOfData" => "DateTime", "open" => "double", "high" => "double", "low" => "double", "close" => "double", "volume" => "integer", "isCritical" => "boolean"//Temporary ); function validateFormat($data){ //Check that all the required fields exist $missing = array_diff_key($dataFormat, $data); $extra = array_diff_key($data, $dataFormat); if(!empty($missing) || !empty($extra)){ throw new InvalidArgumentException("Incorrect data format provided"); } //Check that all the data is of the correct type foreach($data as $k => $v){ $type = gettype($v) === "object" ? get_class($v) : gettype($v); $correctType = $dataFormat[$k]; if($type !== $correctType){ throw new InvalidArgumentException("Data is of an incorrect type."); } } } $arr = array("dateTimeOfData" => new DateTime(), "open" => 10.1, "high" => 10.1, "low" => 10.1, "close" => 10.1, "volume" => 10, "isCritical" => true); validateFormat($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qn14L
function name:  (null)
number of ops:  15
compiled vars:  !0 = $dataFormat, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   29     1        NEW                                              $3      'DateTime'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~5      $3, 'dateTimeOfData'
   30     4        ADD_ARRAY_ELEMENT                                ~5      10.1, 'open'
   31     5        ADD_ARRAY_ELEMENT                                ~5      10.1, 'high'
   32     6        ADD_ARRAY_ELEMENT                                ~5      10.1, 'low'
   33     7        ADD_ARRAY_ELEMENT                                ~5      10.1, 'close'
   34     8        ADD_ARRAY_ELEMENT                                ~5      10, 'volume'
   29     9        ADD_ARRAY_ELEMENT                                ~5      <true>, 'isCritical'
         10        ASSIGN                                                   !1, ~5
   36    11        INIT_FCALL                                               'validateformat'
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function validateformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 43
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 43
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
Branch analysis from position: 42
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 17
filename:       /in/qn14L
function name:  validateFormat
number of ops:  45
compiled vars:  !0 = $data, !1 = $missing, !2 = $dataFormat, !3 = $extra, !4 = $v, !5 = $k, !6 = $type, !7 = $correctType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'array_diff_key'
          2        SEND_VAR                                                 !2
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   16     6        INIT_FCALL                                               'array_diff_key'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $10     
         10        ASSIGN                                                   !3, $10
   17    11        ISSET_ISEMPTY_CV                                 ~12     !1
         12        BOOL_NOT                                         ~13     ~12
         13      > JMPNZ_EX                                         ~13     ~13, ->17
         14    >   ISSET_ISEMPTY_CV                                 ~14     !3
         15        BOOL_NOT                                         ~15     ~14
         16        BOOL                                             ~13     ~15
         17    > > JMPZ                                                     ~13, ->22
   18    18    >   NEW                                              $16     'InvalidArgumentException'
         19        SEND_VAL_EX                                              'Incorrect+data+format+provided'
         20        DO_FCALL                                      0          
         21      > THROW                                         0          $16
   21    22    > > FE_RESET_R                                       $18     !0, ->43
         23    > > FE_FETCH_R                                       ~19     $18, !4, ->43
         24    >   ASSIGN                                                   !5, ~19
   22    25        GET_TYPE                                         ~21     !4
         26        IS_IDENTICAL                                             ~21, 'object'
         27      > JMPZ                                                     ~22, ->31
         28    >   GET_CLASS                                        ~23     !4
         29        QM_ASSIGN                                        ~24     ~23
         30      > JMP                                                      ->33
         31    >   GET_TYPE                                         ~25     !4
         32        QM_ASSIGN                                        ~24     ~25
         33    >   ASSIGN                                                   !6, ~24
   23    34        FETCH_DIM_R                                      ~27     !2, !5
         35        ASSIGN                                                   !7, ~27
   24    36        IS_NOT_IDENTICAL                                         !6, !7
         37      > JMPZ                                                     ~29, ->42
   25    38    >   NEW                                              $30     'InvalidArgumentException'
         39        SEND_VAL_EX                                              'Data+is+of+an+incorrect+type.'
         40        DO_FCALL                                      0          
         41      > THROW                                         0          $30
   21    42    > > JMP                                                      ->23
         43    >   FE_FREE                                                  $18
   28    44      > RETURN                                                   null

End of function validateformat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.54 ms | 1394 KiB | 16 Q