3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_kosher($data, $colonne, $pos, $id_compte, $verbose=false) {//$type_data, $pos, $default=false) { global $tabTVA; global $tabEtat; $default_value = false; switch($colonne['data_type']) { case 'string': if(empty($data) === true) { $data = false; } $default_value = ''; break; case 'integer': //$data = filter_var($data, FILTER_VALIDATE_INT); if(ctype_digit($data) === false && is_int($data) === false) { $data = false; } $default_value = 0; break; case 'decimal': //$data = filter_var($data, FILTER_VALIDATE_FLOAT); if(is_numeric($data) === false) { $data = false; } $default_value = 0; break; case 'decimal.5': $data = str_replace(",",".",$data); //$data = filter_var($data, FILTER_VALIDATE_FLOAT); if(is_numeric($data) === false) { $data = false; } if($data !== false) { $data = number_format($data, 5, '.', ''); } $default_value = 0; break; case 'datetime': if(empty($data) === false) { $datetime = explode('/',$data); if(count($datetime) == 3) { $data = date('Y-m-d H:i:s', strtotime($datetime[2].'/'.$datetime[1].'/'.$datetime[0])); } else { $data = false; } } else { $data = false; } $default_value = "0000-00-00 00:00:00"; break; case 'ean': //id_compte 14 : Pieces Auto Tuning n'a pas d'EAN if($id_compte != 14 && (strlen($data) != 13 || substr($data, -6) == '000000')) { $data = false; } $default_value = 0; break; case 'boolean': if(($data === '0' || $data === '1') === false) { $data = false; } //$data = filter_var($data, FILTER_VALIDATE_BOOLEAN); $default_value = 0; break; case 'boolean_true': //echo 'boolean true #'.$data.'# -- *'.($data === '0' || $data === '1').'* -- *'.(($data === '0' || $data === '1') === false).'* -- *'.($data === false).'* '.gettype($data).'<br/>'; if(($data === '0' || $data === '1') === false) { $data = false; } //$data = filter_var($data, FILTER_VALIDATE_BOOLEAN); $default_value = 1; break; case 'tva': if(in_array($data, $tabTVA) === false) { $data = false; } $default_value = 20; //TVA a 20% par defaut break; case 'etat_produit': if(in_array($data, $tabEtat) === false) { $data = false; } $default_value = 1; //Etat neuf par defaut break; } //echo 'default value: '.$default_value.'<br/>'; $data = get_default($data, $colonne, $pos, $default_value ); //echo $data."*\r\n"; return $data; } function get_default($data, $colonne, $pos, $default_value) { if($data === false && $colonne['default'] === true && $default_value !== false) { $data = $default_value; //echo ' - default! - '; //set_erreur($colonne, $pos); } return $data; } echo is_kosher('13', array('data_type'=>'decimal.5','default'=>true), 0, 1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/26Grl
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  106     0  E >   INIT_FCALL                                               'is_kosher'
          1        SEND_VAL                                                 '13'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 1
          5        DO_FCALL                                      0  $0      
          6        ECHO                                                     $0
          7      > RETURN                                                   1

Function is_kosher:
Finding entry points
Branch analysis from position: 0
12 jumps found. (Code = 188) Position 1 = 31, Position 2 = 37, Position 3 = 49, Position 4 = 57, Position 5 = 80, Position 6 = 112, Position 7 = 128, Position 8 = 137, Position 9 = 146, Position 10 = 155, Position 11 = 164, Position 12 = 10
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 42, Position 2 = 45
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 47
Branch analysis from position: 45
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 55
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 55
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 69
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 78
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 78
Branch analysis from position: 69
Branch analysis from position: 80
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 109
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 91, Position 2 = 107
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 110
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 107
1 jumps found. (Code = 42) Position 1 = 110
Branch analysis from position: 110
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 112
2 jumps found. (Code = 46) Position 1 = 114, Position 2 = 124
Branch analysis from position: 114
2 jumps found. (Code = 47) Position 1 = 117, Position 2 = 123
Branch analysis from position: 117
2 jumps found. (Code = 43) Position 1 = 125, Position 2 = 126
Branch analysis from position: 125
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 126
Branch analysis from position: 123
Branch analysis from position: 124
Branch analysis from position: 128
2 jumps found. (Code = 47) Position 1 = 130, Position 2 = 132
Branch analysis from position: 130
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 135
Branch analysis from position: 134
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 135
Branch analysis from position: 132
Branch analysis from position: 137
2 jumps found. (Code = 47) Position 1 = 139, Position 2 = 141
Branch analysis from position: 139
2 jumps found. (Code = 43) Position 1 = 143, Position 2 = 144
Branch analysis from position: 143
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 144
Branch analysis from position: 141
Branch analysis from position: 146
2 jumps found. (Code = 43) Position 1 = 152, Position 2 = 153
Branch analysis from position: 152
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 153
Branch analysis from position: 155
2 jumps found. (Code = 43) Position 1 = 161, Position 2 = 162
Branch analysis from position: 161
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 162
Branch analysis from position: 164
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 37
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 49
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 57
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 80
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 112
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 128
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 137
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 146
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 155
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 155
Branch analysis from position: 146
Branch analysis from position: 137
Branch analysis from position: 128
Branch analysis from position: 112
Branch analysis from position: 80
Branch analysis from position: 57
Branch analysis from position: 49
Branch analysis from position: 37
Branch analysis from position: 31
filename:       /in/26Grl
function name:  is_kosher
number of ops:  174
compiled vars:  !0 = $data, !1 = $colonne, !2 = $pos, !3 = $id_compte, !4 = $verbose, !5 = $tabTVA, !6 = $tabEtat, !7 = $default_value, !8 = $datetime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV_INIT                                        !4      <false>
    3     5        BIND_GLOBAL                                              !5, 'tabTVA'
    4     6        BIND_GLOBAL                                              !6, 'tabEtat'
    5     7        ASSIGN                                                   !7, <false>
    6     8        FETCH_DIM_R                                      ~10     !1, 'data_type'
          9      > SWITCH_STRING                                            ~10, [ 'string':->31, 'integer':->37, 'decimal':->49, 'decimal.5':->57, 'datetime':->80, 'ean':->112, 'boolean':->128, 'boolean_true':->137, 'tva':->146, 'etat_produit':->155, ], ->164
    7    10    >   CASE                                                     ~10, 'string'
         11      > JMPNZ                                                    ~11, ->31
   13    12    >   CASE                                                     ~10, 'integer'
         13      > JMPNZ                                                    ~11, ->37
   20    14    >   CASE                                                     ~10, 'decimal'
         15      > JMPNZ                                                    ~11, ->49
   27    16    >   CASE                                                     ~10, 'decimal.5'
         17      > JMPNZ                                                    ~11, ->57
   38    18    >   CASE                                                     ~10, 'datetime'
         19      > JMPNZ                                                    ~11, ->80
   53    20    >   CASE                                                     ~10, 'ean'
         21      > JMPNZ                                                    ~11, ->112
   60    22    >   CASE                                                     ~10, 'boolean'
         23      > JMPNZ                                                    ~11, ->128
   68    24    >   CASE                                                     ~10, 'boolean_true'
         25      > JMPNZ                                                    ~11, ->137
   77    26    >   CASE                                                     ~10, 'tva'
         27      > JMPNZ                                                    ~11, ->146
   83    28    >   CASE                                                     ~10, 'etat_produit'
         29      > JMPNZ                                                    ~11, ->155
         30    > > JMP                                                      ->164
    8    31    >   ISSET_ISEMPTY_CV                                 ~12     !0
         32        TYPE_CHECK                                    8          ~12
         33      > JMPZ                                                     ~13, ->35
    9    34    >   ASSIGN                                                   !0, <false>
   11    35    >   ASSIGN                                                   !7, ''
   12    36      > JMP                                                      ->164
   15    37    >   INIT_FCALL                                               'ctype_digit'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                         $16     
         40        TYPE_CHECK                                    4  ~17     $16
         41      > JMPZ_EX                                          ~17     ~17, ->45
         42    >   TYPE_CHECK                                   16  ~18     !0
         43        TYPE_CHECK                                    4  ~19     ~18
         44        BOOL                                             ~17     ~19
         45    > > JMPZ                                                     ~17, ->47
   16    46    >   ASSIGN                                                   !0, <false>
   18    47    >   ASSIGN                                                   !7, 0
   19    48      > JMP                                                      ->164
   22    49    >   INIT_FCALL                                               'is_numeric'
         50        SEND_VAR                                                 !0
         51        DO_ICALL                                         $22     
         52        TYPE_CHECK                                    4          $22
         53      > JMPZ                                                     ~23, ->55
   23    54    >   ASSIGN                                                   !0, <false>
   25    55    >   ASSIGN                                                   !7, 0
   26    56      > JMP                                                      ->164
   28    57    >   INIT_FCALL                                               'str_replace'
         58        SEND_VAL                                                 '%2C'
         59        SEND_VAL                                                 '.'
         60        SEND_VAR                                                 !0
         61        DO_ICALL                                         $26     
         62        ASSIGN                                                   !0, $26
   30    63        INIT_FCALL                                               'is_numeric'
         64        SEND_VAR                                                 !0
         65        DO_ICALL                                         $28     
         66        TYPE_CHECK                                    4          $28
         67      > JMPZ                                                     ~29, ->69
   31    68    >   ASSIGN                                                   !0, <false>
   33    69    >   TYPE_CHECK                                  1018          !0
         70      > JMPZ                                                     ~31, ->78
   34    71    >   INIT_FCALL                                               'number_format'
         72        SEND_VAR                                                 !0
         73        SEND_VAL                                                 5
         74        SEND_VAL                                                 '.'
         75        SEND_VAL                                                 ''
         76        DO_ICALL                                         $32     
         77        ASSIGN                                                   !0, $32
   36    78    >   ASSIGN                                                   !7, 0
   37    79      > JMP                                                      ->164
   39    80    >   ISSET_ISEMPTY_CV                                 ~35     !0
         81        TYPE_CHECK                                    4          ~35
         82      > JMPZ                                                     ~36, ->109
   40    83    >   INIT_FCALL                                               'explode'
         84        SEND_VAL                                                 '%2F'
         85        SEND_VAR                                                 !0
         86        DO_ICALL                                         $37     
         87        ASSIGN                                                   !8, $37
   41    88        COUNT                                            ~39     !8
         89        IS_EQUAL                                                 ~39, 3
         90      > JMPZ                                                     ~40, ->107
   42    91    >   INIT_FCALL                                               'date'
         92        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         93        INIT_FCALL                                               'strtotime'
         94        FETCH_DIM_R                                      ~41     !8, 2
         95        CONCAT                                           ~42     ~41, '%2F'
         96        FETCH_DIM_R                                      ~43     !8, 1
         97        CONCAT                                           ~44     ~42, ~43
         98        CONCAT                                           ~45     ~44, '%2F'
         99        FETCH_DIM_R                                      ~46     !8, 0
        100        CONCAT                                           ~47     ~45, ~46
        101        SEND_VAL                                                 ~47
        102        DO_ICALL                                         $48     
        103        SEND_VAR                                                 $48
        104        DO_ICALL                                         $49     
        105        ASSIGN                                                   !0, $49
        106      > JMP                                                      ->108
   45   107    >   ASSIGN                                                   !0, <false>
        108    > > JMP                                                      ->110
   49   109    >   ASSIGN                                                   !0, <false>
   51   110    >   ASSIGN                                                   !7, '0000-00-00+00%3A00%3A00'
   52   111      > JMP                                                      ->164
   55   112    >   IS_NOT_EQUAL                                     ~54     !3, 14
        113      > JMPZ_EX                                          ~54     ~54, ->124
        114    >   STRLEN                                           ~55     !0
        115        IS_NOT_EQUAL                                     ~56     ~55, 13
        116      > JMPNZ_EX                                         ~56     ~56, ->123
        117    >   INIT_FCALL                                               'substr'
        118        SEND_VAR                                                 !0
        119        SEND_VAL                                                 -6
        120        DO_ICALL                                         $57     
        121        IS_EQUAL                                         ~58     $57, '000000'
        122        BOOL                                             ~56     ~58
        123    >   BOOL                                             ~54     ~56
        124    > > JMPZ                                                     ~54, ->126
   56   125    >   ASSIGN                                                   !0, <false>
   58   126    >   ASSIGN                                                   !7, 0
   59   127      > JMP                                                      ->164
   61   128    >   IS_IDENTICAL                                     ~61     !0, '0'
        129      > JMPNZ_EX                                         ~61     ~61, ->132
        130    >   IS_IDENTICAL                                     ~62     !0, '1'
        131        BOOL                                             ~61     ~62
        132    >   TYPE_CHECK                                    4          ~61
        133      > JMPZ                                                     ~63, ->135
   62   134    >   ASSIGN                                                   !0, <false>
   66   135    >   ASSIGN                                                   !7, 0
   67   136      > JMP                                                      ->164
   70   137    >   IS_IDENTICAL                                     ~66     !0, '0'
        138      > JMPNZ_EX                                         ~66     ~66, ->141
        139    >   IS_IDENTICAL                                     ~67     !0, '1'
        140        BOOL                                             ~66     ~67
        141    >   TYPE_CHECK                                    4          ~66
        142      > JMPZ                                                     ~68, ->144
   71   143    >   ASSIGN                                                   !0, <false>
   75   144    >   ASSIGN                                                   !7, 1
   76   145      > JMP                                                      ->164
   78   146    >   INIT_FCALL                                               'in_array'
        147        SEND_VAR                                                 !0
        148        SEND_VAR                                                 !5
        149        DO_ICALL                                         $71     
        150        TYPE_CHECK                                    4          $71
        151      > JMPZ                                                     ~72, ->153
   79   152    >   ASSIGN                                                   !0, <false>
   81   153    >   ASSIGN                                                   !7, 20
   82   154      > JMP                                                      ->164
   84   155    >   INIT_FCALL                                               'in_array'
        156        SEND_VAR                                                 !0
        157        SEND_VAR                                                 !6
        158        DO_ICALL                                         $75     
        159        TYPE_CHECK                                    4          $75
        160      > JMPZ                                                     ~76, ->162
   85   161    >   ASSIGN                                                   !0, <false>
   87   162    >   ASSIGN                                                   !7, 1
   88   163      > JMP                                                      ->164
        164    >   FREE                                                     ~10
   91   165        INIT_FCALL_BY_NAME                                       'get_default'
        166        SEND_VAR_EX                                              !0
        167        SEND_VAR_EX                                              !1
        168        SEND_VAR_EX                                              !2
        169        SEND_VAR_EX                                              !7
        170        DO_FCALL                                      0  $79     
        171        ASSIGN                                                   !0, $79
   93   172      > RETURN                                                   !0
   94   173*     > RETURN                                                   null

End of function is_kosher

Function get_default:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 12
Branch analysis from position: 9
filename:       /in/26Grl
function name:  get_default
number of ops:  16
compiled vars:  !0 = $data, !1 = $colonne, !2 = $pos, !3 = $default_value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   98     4        TYPE_CHECK                                    4  ~4      !0
          5      > JMPZ_EX                                          ~4      ~4, ->9
          6    >   FETCH_DIM_R                                      ~5      !1, 'default'
          7        TYPE_CHECK                                    8  ~6      ~5
          8        BOOL                                             ~4      ~6
          9    > > JMPZ_EX                                          ~4      ~4, ->12
         10    >   TYPE_CHECK                                  1018  ~7      !3
         11        BOOL                                             ~4      ~7
         12    > > JMPZ                                                     ~4, ->14
   99    13    >   ASSIGN                                                   !0, !3
  103    14    > > RETURN                                                   !0
  104    15*     > RETURN                                                   null

End of function get_default

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.2 ms | 1419 KiB | 32 Q