@@ -24,15 +24,15 @@ class FieldValidation extends AbstractValidation
2424 /**
2525 * @return array
2626 */
27- public function rules ()
28- {
29- return [
27+ // public function rules()
28+ // {
29+ // return [
3030 // ['field', 'required|string:5,10|...', ...],
3131 // ['field0', ['required', 'string:5,10'], ...],
3232 // ['field1', 'rule1|rule2|...', ...],
3333 // ['field2', 'rule1|rule3|...', ...],
34- ];
35- }
34+ // ];
35+ // }
3636
3737 /**
3838 * @return \Generator
@@ -70,14 +70,14 @@ protected function collectRules()
7070 }
7171
7272 $ this ->_usedRules [] = $ rule ;
73- $ field = array_shift ($ rule );
73+ $ field = \ array_shift ($ rule );
7474
7575 // if is a Closure
7676 if (\is_object ($ rule [0 ])) {
7777 yield $ field => $ rule ;
7878 } else {
7979 // 'required|string:5,10;' OR 'required|in:5,10'
80- $ rules = \is_array ($ rule [0 ]) ? $ rule [0 ] : array_map ('trim ' , explode ('| ' , $ rule [0 ]));
80+ $ rules = \is_array ($ rule [0 ]) ? $ rule [0 ] : \ array_map ('trim ' , \ explode ('| ' , $ rule [0 ]));
8181
8282 foreach ($ rules as $ aRule ) {
8383 $ rule = $ this ->parseRule ($ aRule , $ rule );
@@ -93,38 +93,38 @@ protected function collectRules()
9393 * @param array $row
9494 * @return array
9595 */
96- protected function parseRule ($ rule , $ row )
96+ protected function parseRule (string $ rule , array $ row ): array
9797 {
9898 $ rule = trim ($ rule , ': ' );
9999
100- if (false === strpos ($ rule , ': ' )) {
100+ if (false === \ strpos ($ rule , ': ' )) {
101101 $ row [0 ] = $ rule ;
102102 return $ row ;
103103 }
104104
105- list ($ name , $ args ) = explode (': ' , $ rule , 2 );
105+ list ($ name , $ args ) = \ explode (': ' , $ rule , 2 );
106106 $ args = trim ($ args , ', ' );
107107 $ row [0 ] = $ name ;
108108
109109 switch ($ name ) {
110110 case 'in ' :
111111 case 'enum ' :
112112 case 'ontIn ' :
113- $ row [] = array_map ('trim ' , explode (', ' , $ args ));
113+ $ row [] = \ array_map ('trim ' , explode (', ' , $ args ));
114114 break ;
115115
116116 case 'size ' :
117117 case 'range ' :
118118 case 'string ' :
119119 case 'between ' :
120120 if (strpos ($ args , ', ' )) {
121- list ($ row ['min ' ], $ row ['max ' ]) = array_map ('trim ' , explode (', ' , $ args , 2 ));
121+ list ($ row ['min ' ], $ row ['max ' ]) = \ array_map ('trim ' , explode (', ' , $ args , 2 ));
122122 } else {
123123 $ row ['min ' ] = $ args ;
124124 }
125125 break ;
126126 default :
127- $ args = strpos ($ args , ', ' ) ? array_map ('trim ' , explode (', ' , $ args )) : [$ args ];
127+ $ args = strpos ($ args , ', ' ) ? \ array_map ('trim ' , explode (', ' , $ args )) : [$ args ];
128128 $ row = array_merge ($ row , $ args );
129129 break ;
130130 }
0 commit comments