3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Validate { public static $_Exceptions; public static function Run($o) { if($o->_HtmlOut == true) { $o->HtmlOutput(false); $Was_Html = true; } try { if(!is_array($o->_Fields)) throw new Exception("Os campos ainda não foram definidos."); foreach($o->_Fields as $Field) { if(is_empty($o->{$Field}) && in_array($Field, $o->_NotNull)); throw new Exception("O campo ". $Field ." da tabela ". $o->_Table ." não pode ser vazio."); switch(strtolower($o->_Meta[$Field])) { case('date') : if(!self::Date($o->{$Field}, Format::DATE)) self::$Errors[] = $Field; break; case('datetime') : if(!self::Date($o->{$Field}, Format::DATETIME)) self::$Errors[] = $Field; break; case('string') : if(!is_string($o->{$Field})) self::$Errors[] = $Field; break; case('int') : if(!is_int($o->{$Field})) if((int)($o->{$Field}) == $o->{$Field}) self::$Errors[] = $Field; break; } } } catch(Exception $e) { throw $e; } finally { if($Was_Html == true) $o->HtmlOutput(false); } if(is_array($Errors)) foreach($Errors as $Field) self::$_Exceptions[] = "Valor '". $o->{$Field} ."' para o campo ". $Field ."(".$o->_Meta[$Field].") da tabela ". $o->_Table ." é inválido"; return true; } public static function Date($data, Validate $type) { switch($type) { case(self::DATE) : if (date(DATE, strtotime($data)) == $data) return true; break; case(self::DATE_TIME) : if (date(DATE, strtotime($data)) == $data) return true; break; } return false; } public static function Throw() { $Exception = implode('<br />', self::$_Exceptions); unset(self::$_Exceptions); throw new Exception($Exception); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TYpFY
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   97     0  E > > RETURN                                                   1

Class Validate:
Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
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
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 105
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 105
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 32
Branch analysis from position: 32
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 31
Branch analysis from position: 105
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
2 jumps found. (Code = 162) Position 1 = 111, Position 2 = 110
Branch analysis from position: 111
2 jumps found. (Code = 43) Position 1 = 113, Position 2 = 116
Branch analysis from position: 113
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 116
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 117
Branch analysis from position: 117
2 jumps found. (Code = 43) Position 1 = 119, Position 2 = 138
Branch analysis from position: 119
2 jumps found. (Code = 77) Position 1 = 120, Position 2 = 137
Branch analysis from position: 120
2 jumps found. (Code = 78) Position 1 = 121, Position 2 = 137
Branch analysis from position: 121
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
Branch analysis from position: 137
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 137
Branch analysis from position: 138
Branch analysis from position: 105
Branch analysis from position: 8
Found catch point at position: 107
Branch analysis from position: 107
2 jumps found. (Code = 107) Position 1 = 108, Position 2 = -2
Branch analysis from position: 108
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/TYpFY
function name:  Run
number of ops:  140
compiled vars:  !0 = $o, !1 = $Was_Html, !2 = $Field, !3 = $e, !4 = $Errors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        FETCH_OBJ_R                                      ~5      !0, '_HtmlOut'
          2        BOOL                                             ~6      ~5
          3      > JMPZ                                                     ~6, ->8
   10     4    >   INIT_METHOD_CALL                                         !0, 'HtmlOutput'
          5        SEND_VAL_EX                                              <false>
          6        DO_FCALL                                      0          
   11     7        ASSIGN                                                   !1, <true>
   16     8    >   FETCH_OBJ_R                                      ~10     !0, '_Fields'
          9        TYPE_CHECK                                  128  ~11     ~10
         10        BOOL_NOT                                         ~12     ~11
         11      > JMPZ                                                     ~12, ->16
   17    12    >   NEW                                              $13     'Exception'
         13        SEND_VAL_EX                                              'Os+campos+ainda+n%C3%A3o+foram+definidos.'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $13
   19    16    >   FETCH_OBJ_R                                      ~15     !0, '_Fields'
         17      > FE_RESET_R                                       $16     ~15, ->105
         18    > > FE_FETCH_R                                               $16, !2, ->105
   21    19    >   INIT_FCALL_BY_NAME                                       'is_empty'
         20        CHECK_FUNC_ARG                                           
         21        FETCH_OBJ_FUNC_ARG                               $17     !0, !2
         22        SEND_FUNC_ARG                                            $17
         23        DO_FCALL                                      0  $18     
         24      > JMPZ_EX                                          ~19     $18, ->31
         25    >   INIT_FCALL                                               'in_array'
         26        SEND_VAR                                                 !2
         27        FETCH_OBJ_R                                      ~20     !0, '_NotNull'
         28        SEND_VAL                                                 ~20
         29        DO_ICALL                                         $21     
         30        BOOL                                             ~19     $21
         31    > > JMPZ                                                     ~19, ->32
   22    32    >   NEW                                              $22     'Exception'
         33        CONCAT                                           ~23     'O+campo+', !2
         34        CONCAT                                           ~24     ~23, '+da+tabela+'
         35        FETCH_OBJ_R                                      ~25     !0, '_Table'
         36        CONCAT                                           ~26     ~24, ~25
         37        CONCAT                                           ~27     ~26, '+n%C3%A3o+pode+ser+vazio.'
         38        SEND_VAL_EX                                              ~27
         39        DO_FCALL                                      0          
         40      > THROW                                         0          $22
   24    41*       INIT_FCALL                                               'strtolower'
         42*       FETCH_OBJ_R                                      ~29     !0, '_Meta'
         43*       FETCH_DIM_R                                      ~30     ~29, !2
         44*       SEND_VAL                                                 ~30
         45*       DO_ICALL                                         $31     
         46*       SWITCH_STRING                                            $31, [ 'date':->56, 'datetime':->69, 'string':->82, 'int':->90, ], ->103
   26    47*       CASE                                                     $31, 'date'
         48*       JMPNZ                                                    ~32, ->56
   32    49*       CASE                                                     $31, 'datetime'
         50*       JMPNZ                                                    ~32, ->69
   38    51*       CASE                                                     $31, 'string'
         52*       JMPNZ                                                    ~32, ->82
   44    53*       CASE                                                     $31, 'int'
         54*       JMPNZ                                                    ~32, ->90
         55*       JMP                                                      ->103
   27    56*       INIT_STATIC_METHOD_CALL                                  'Date'
         57*       CHECK_FUNC_ARG                                           
         58*       FETCH_OBJ_FUNC_ARG                               $33     !0, !2
         59*       SEND_FUNC_ARG                                            $33
         60*       FETCH_CLASS_CONSTANT                             ~34     'Format', 'DATE'
         61*       SEND_VAL_EX                                              ~34
         62*       DO_FCALL                                      0  $35     
         63*       BOOL_NOT                                         ~36     $35
         64*       JMPZ                                                     ~36, ->68
   28    65*       FETCH_STATIC_PROP_W          unknown             $37     'Errors'
         66*       ASSIGN_DIM                                               $37
         67*       OP_DATA                                                  !2
   30    68*       JMP                                                      ->103
   33    69*       INIT_STATIC_METHOD_CALL                                  'Date'
         70*       CHECK_FUNC_ARG                                           
         71*       FETCH_OBJ_FUNC_ARG                               $39     !0, !2
         72*       SEND_FUNC_ARG                                            $39
         73*       FETCH_CLASS_CONSTANT                             ~40     'Format', 'DATETIME'
         74*       SEND_VAL_EX                                              ~40
         75*       DO_FCALL                                      0  $41     
         76*       BOOL_NOT                                         ~42     $41
         77*       JMPZ                                                     ~42, ->81
   34    78*       FETCH_STATIC_PROP_W          unknown             $43     'Errors'
         79*       ASSIGN_DIM                                               $43
         80*       OP_DATA                                                  !2
   36    81*       JMP                                                      ->103
   39    82*       FETCH_OBJ_R                                      ~45     !0, !2
         83*       TYPE_CHECK                                   64  ~46     ~45
         84*       BOOL_NOT                                         ~47     ~46
         85*       JMPZ                                                     ~47, ->89
   40    86*       FETCH_STATIC_PROP_W          unknown             $48     'Errors'
         87*       ASSIGN_DIM                                               $48
         88*       OP_DATA                                                  !2
   42    89*       JMP                                                      ->103
   45    90*       FETCH_OBJ_R                                      ~50     !0, !2
         91*       TYPE_CHECK                                   16  ~51     ~50
         92*       BOOL_NOT                                         ~52     ~51
         93*       JMPZ                                                     ~52, ->102
   46    94*       FETCH_OBJ_R                                      ~53     !0, !2
         95*       CAST                                          4  ~54     ~53
         96*       FETCH_OBJ_R                                      ~55     !0, !2
         97*       IS_EQUAL                                                 ~54, ~55
         98*       JMPZ                                                     ~56, ->102
   47    99*       FETCH_STATIC_PROP_W          unknown             $57     'Errors'
        100*       ASSIGN_DIM                                               $57
        101*       OP_DATA                                                  !2
   49   102*       JMP                                                      ->103
        103*       FREE                                                     $31
   19   104*       JMP                                                      ->18
        105    >   FE_FREE                                                  $16
        106      > JMP                                                      ->109
   53   107  E > > CATCH                                       last         'Exception'
   54   108    > > THROW                                         0          !3
   56   109    > > FAST_CALL                                                ->111
        110    > > JMP                                                      ->117
   57   111    >   BOOL                                             ~59     !1
        112      > JMPZ                                                     ~59, ->116
   58   113    >   INIT_METHOD_CALL                                         !0, 'HtmlOutput'
        114        SEND_VAL_EX                                              <false>
        115        DO_FCALL                                      0          
        116    > > FAST_RET                                                 
   61   117    >   TYPE_CHECK                                  128          !4
        118      > JMPZ                                                     ~61, ->138
   62   119    > > FE_RESET_R                                       $62     !4, ->137
        120    > > FE_FETCH_R                                               $62, !2, ->137
   63   121    >   FETCH_OBJ_R                                      ~65     !0, !2
        122        CONCAT                                           ~66     'Valor+%27', ~65
        123        CONCAT                                           ~67     ~66, '%27+para+o+campo+'
        124        CONCAT                                           ~68     ~67, !2
        125        CONCAT                                           ~69     ~68, '%28'
        126        FETCH_OBJ_R                                      ~70     !0, '_Meta'
        127        FETCH_DIM_R                                      ~71     ~70, !2
        128        CONCAT                                           ~72     ~69, ~71
        129        CONCAT                                           ~73     ~72, '%29+da+tabela+'
        130        FETCH_OBJ_R                                      ~74     !0, '_Table'
        131        CONCAT                                           ~75     ~73, ~74
        132        CONCAT                                           ~76     ~75, '+%C3%A9+inv%C3%A1lido'
        133        FETCH_STATIC_PROP_W          unknown             $63     '_Exceptions'
        134        ASSIGN_DIM                                               $63
        135        OP_DATA                                                  ~76
   62   136      > JMP                                                      ->120
        137    >   FE_FREE                                                  $62
   66   138    > > RETURN                                                   <true>
   67   139*     > RETURN                                                   null

End of function run

Function date:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
filename:       /in/TYpFY
function name:  Date
number of ops:  35
compiled vars:  !0 = $data, !1 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   72     2        FETCH_CLASS_CONSTANT                             ~3      'DATE'
          3        IS_EQUAL                                                 !1, ~3
          4      > JMPNZ                                                    ~2, ->9
   77     5    >   FETCH_CLASS_CONSTANT                             ~4      'DATE_TIME'
          6        IS_EQUAL                                                 !1, ~4
          7      > JMPNZ                                                    ~2, ->21
          8    > > JMP                                                      ->33
   73     9    >   INIT_FCALL                                               'date'
         10        FETCH_CONSTANT                                   ~5      'DATE'
         11        SEND_VAL                                                 ~5
         12        INIT_FCALL                                               'strtotime'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                         $7      
         17        IS_EQUAL                                                 !0, $7
         18      > JMPZ                                                     ~8, ->20
   74    19    > > RETURN                                                   <true>
   75    20    > > JMP                                                      ->33
   78    21    >   INIT_FCALL                                               'date'
         22        FETCH_CONSTANT                                   ~9      'DATE'
         23        SEND_VAL                                                 ~9
         24        INIT_FCALL                                               'strtotime'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $10     
         27        SEND_VAR                                                 $10
         28        DO_ICALL                                         $11     
         29        IS_EQUAL                                                 !0, $11
         30      > JMPZ                                                     ~12, ->32
   79    31    > > RETURN                                                   <true>
   80    32    > > JMP                                                      ->33
   83    33    > > RETURN                                                   <false>
   84    34*     > RETURN                                                   null

End of function date

Function throw:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/TYpFY
function name:  Throw
number of ops:  12
compiled vars:  !0 = $Exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   INIT_FCALL                                               'implode'
          1        SEND_VAL                                                 '%3Cbr+%2F%3E'
          2        FETCH_STATIC_PROP_R          global lock         ~1      '_Exceptions'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
   90     6        UNSET_STATIC_PROP                                        '_Exceptions'
   92     7        NEW                                              $4      'Exception'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $4
   94    11*     > RETURN                                                   null

End of function throw

End of class Validate.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.47 ms | 1412 KiB | 23 Q