Completed
Pull Request — 6.0 (#2150)
by
unknown
06:31
created
src/think/Validate.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 // +----------------------------------------------------------------------
9 9
 // | Author: liu21st <[email protected]>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think;
14 14
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public function hasScene(string $name): bool
369 369
     {
370
-        return isset($this->scene[$name]) || method_exists($this, 'scene' . $name);
370
+        return isset($this->scene[$name]) || method_exists($this, 'scene'.$name);
371 371
     }
372 372
 
373 373
     /**
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
             if (strpos($field, '_confirm')) {
716 716
                 $rule = strstr($field, '_confirm', true);
717 717
             } else {
718
-                $rule = $field . '_confirm';
718
+                $rule = $field.'_confirm';
719 719
             }
720 720
         }
721 721
 
@@ -866,9 +866,9 @@  discard block
 block discarded – undo
866 866
                 if (isset($this->type[$rule])) {
867 867
                     // 注册的验证规则
868 868
                     $result = call_user_func_array($this->type[$rule], [$value]);
869
-                } elseif (function_exists('ctype_' . $rule)) {
869
+                } elseif (function_exists('ctype_'.$rule)) {
870 870
                     // ctype验证规则
871
-                    $ctypeFun = 'ctype_' . $rule;
871
+                    $ctypeFun = 'ctype_'.$rule;
872 872
                     $result   = $ctypeFun($value);
873 873
                 } elseif (isset($this->filter[$rule])) {
874 874
                     // Filter_var验证规则
@@ -1143,14 +1143,14 @@  discard block
 block discarded – undo
1143 1143
         } elseif (strpos($key, '=')) {
1144 1144
             // 支持复杂验证条件
1145 1145
             $fields = explode('&', $key);
1146
-            $map_arr=[];
1146
+            $map_arr = [];
1147 1147
             foreach ($fields as $key) {
1148
-                $str_map=explode('=', $key);
1148
+                $str_map = explode('=', $key);
1149 1149
                 $map[] = [$str_map[0], '=', $str_map[1]];
1150
-                $map_arr[]=$str_map[0];
1150
+                $map_arr[] = $str_map[0];
1151 1151
             }
1152
-            if(!in_array($field, $map_arr)){
1153
-                $map[]=[$field,'=',$data[$field]];
1152
+            if (!in_array($field, $map_arr)) {
1153
+                $map[] = [$field, '=', $data[$field]];
1154 1154
             }
1155 1155
         } elseif (isset($data[$field])) {
1156 1156
             $map[] = [$key, '=', $data[$field]];
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 
1519 1519
         if (is_string($rule) && 0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) {
1520 1520
             // 不是正则表达式则两端补上/
1521
-            $rule = '/^' . $rule . '$/';
1521
+            $rule = '/^'.$rule.'$/';
1522 1522
         }
1523 1523
 
1524 1524
         return is_scalar($value) && 1 === preg_match($rule, (string) $value);
@@ -1571,8 +1571,8 @@  discard block
 block discarded – undo
1571 1571
      */
1572 1572
     protected function getRuleMsg(string $attribute, string $title, string $type, $rule)
1573 1573
     {
1574
-        if (isset($this->message[$attribute . '.' . $type])) {
1575
-            $msg = $this->message[$attribute . '.' . $type];
1574
+        if (isset($this->message[$attribute.'.'.$type])) {
1575
+            $msg = $this->message[$attribute.'.'.$type];
1576 1576
         } elseif (isset($this->message[$attribute][$type])) {
1577 1577
             $msg = $this->message[$attribute][$type];
1578 1578
         } elseif (isset($this->message[$attribute])) {
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
         } elseif (0 === strpos($type, 'require')) {
1583 1583
             $msg = $this->typeMsg['require'];
1584 1584
         } else {
1585
-            $msg = $title . $this->lang->get('not conform to the rules');
1585
+            $msg = $title.$this->lang->get('not conform to the rules');
1586 1586
         }
1587 1587
 
1588 1588
         if (is_array($msg)) {
@@ -1661,8 +1661,8 @@  discard block
 block discarded – undo
1661 1661
     {
1662 1662
         $this->only = $this->append = $this->remove = [];
1663 1663
 
1664
-        if (method_exists($this, 'scene' . $scene)) {
1665
-            call_user_func([$this, 'scene' . $scene]);
1664
+        if (method_exists($this, 'scene'.$scene)) {
1665
+            call_user_func([$this, 'scene'.$scene]);
1666 1666
         } elseif (isset($this->scene[$scene])) {
1667 1667
             // 如果设置了验证适用场景
1668 1668
             $this->only = $this->scene[$scene];
Please login to merge, or discard this patch.