3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ // ['order' => null, 'seriesId' => 2], // ['order' => 0, 'seriesId' => 1], ]; function validateOrderUniqueness(array $data) { $orders = array_filter(array_column($data, 'order')); $uniqueOrders = array_unique($orders); if ($orders !== $uniqueOrders) { throw new \Exception('validateOrderUniqueness fail'); } } function validateSeriesUniqueness(array $data) { $seriesIds = array_column($data, 'seriesId'); $uniqueSeriesIds = array_unique($seriesIds); if ($seriesIds !== $uniqueSeriesIds) { throw new \Exception('validateSeriesUniqueness fail'); } } $existing = [1, 2, 3]; validateOrderUniqueness($data); validateSeriesUniqueness($data); if (count(array_diff($existing, $seriesIds)) > 0) { $this->error(self::MISSING_ORDER_OF_SERIES); } if (count(array_diff($seriesIds, $existing)) > 0) { $this->error(self::NON_EXISTING_SERIES); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 20
filename:       /in/cYSUR
function name:  (null)
number of ops:  33
compiled vars:  !0 = $data, !1 = $existing, !2 = $seriesIds
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   28     1        ASSIGN                                                   !1, <array>
   30     2        INIT_FCALL                                               'validateorderuniqueness'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0          
   31     5        INIT_FCALL                                               'validateseriesuniqueness'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0          
   33     8        INIT_FCALL                                               'array_diff'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $7      
         12        COUNT                                            ~8      $7
         13        IS_SMALLER                                               0, ~8
         14      > JMPZ                                                     ~9, ->20
   34    15    >   FETCH_THIS                                       $10     
         16        INIT_METHOD_CALL                                         $10, 'error'
         17        FETCH_CLASS_CONSTANT                             ~11     'MISSING_ORDER_OF_SERIES'
         18        SEND_VAL_EX                                              ~11
         19        DO_FCALL                                      0          
   37    20    >   INIT_FCALL                                               'array_diff'
         21        SEND_VAR                                                 !2
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $13     
         24        COUNT                                            ~14     $13
         25        IS_SMALLER                                               0, ~14
         26      > JMPZ                                                     ~15, ->32
   38    27    >   FETCH_THIS                                       $16     
         28        INIT_METHOD_CALL                                         $16, 'error'
         29        FETCH_CLASS_CONSTANT                             ~17     'NON_EXISTING_SERIES'
         30        SEND_VAL_EX                                              ~17
         31        DO_FCALL                                      0          
   39    32    > > RETURN                                                   1

Function validateorderuniqueness:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cYSUR
function name:  validateOrderUniqueness
number of ops:  20
compiled vars:  !0 = $data, !1 = $orders, !2 = $uniqueOrders
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'array_filter'
          2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'order'
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
   11     9        INIT_FCALL                                               'array_unique'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !2, $6
   13    13        IS_NOT_IDENTICAL                                         !1, !2
         14      > JMPZ                                                     ~8, ->19
   14    15    >   NEW                                              $9      'Exception'
         16        SEND_VAL_EX                                              'validateOrderUniqueness+fail'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $9
   16    19    > > RETURN                                                   null

End of function validateorderuniqueness

Function validateseriesuniqueness:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cYSUR
function name:  validateSeriesUniqueness
number of ops:  17
compiled vars:  !0 = $data, !1 = $seriesIds, !2 = $uniqueSeriesIds
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'array_column'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'seriesId'
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   21     6        INIT_FCALL                                               'array_unique'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !2, $5
   23    10        IS_NOT_IDENTICAL                                         !1, !2
         11      > JMPZ                                                     ~7, ->16
   24    12    >   NEW                                              $8      'Exception'
         13        SEND_VAL_EX                                              'validateSeriesUniqueness+fail'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $8
   26    16    > > RETURN                                                   null

End of function validateseriesuniqueness

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.53 ms | 1403 KiB | 23 Q