@@ -146,8 +146,9 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function getErrors(string $lang = null): array |
| 148 | 148 | { |
| 149 | - if (null === $lang) |
|
| 150 | - $lang = $this->getDefaultLang(); |
|
| 149 | + if (null === $lang) { |
|
| 150 | + $lang = $this->getDefaultLang(); |
|
| 151 | + } |
|
| 151 | 152 | |
| 152 | 153 | $error_results = []; |
| 153 | 154 | $default_error_texts = $this->getDefaultErrorTexts($lang); |
@@ -178,9 +179,10 @@ discard block |
||
| 178 | 179 | /** |
| 179 | 180 | * handle :params(..) |
| 180 | 181 | */ |
| 181 | - if (preg_match_all("#:params\((.+?)\)#", $error_message, $param_indexes)) |
|
| 182 | - foreach ($param_indexes[1] as $param_index) { |
|
| 182 | + if (preg_match_all("#:params\((.+?)\)#", $error_message, $param_indexes)) { |
|
| 183 | + foreach ($param_indexes[1] as $param_index) { |
|
| 183 | 184 | $error_message = str_replace(":params(" . $param_index . ")", $result['params'][$param_index], $error_message); |
| 185 | + } |
|
| 184 | 186 | } |
| 185 | 187 | $error_results[] = str_replace(":attribute", $named_input, $error_message); |
| 186 | 188 | } |
@@ -195,8 +197,9 @@ discard block |
||
| 195 | 197 | */ |
| 196 | 198 | public function has(string $input_name, string $rule_name = null): bool |
| 197 | 199 | { |
| 198 | - if (null !== $rule_name) |
|
| 199 | - return isset($this->errors[$input_name][$rule_name]); |
|
| 200 | + if (null !== $rule_name) { |
|
| 201 | + return isset($this->errors[$input_name][$rule_name]); |
|
| 202 | + } |
|
| 200 | 203 | return isset($this->errors[$input_name]); |
| 201 | 204 | } |
| 202 | 205 | |
@@ -256,10 +259,11 @@ discard block |
||
| 256 | 259 | foreach ($rules as $input => $input_rules) { |
| 257 | 260 | if (is_array($input_rules)) { |
| 258 | 261 | foreach ($input_rules as $rule => $closure) { |
| 259 | - if (!isset($inputs[(string)$input])) |
|
| 260 | - $input_value = null; |
|
| 261 | - else |
|
| 262 | - $input_value = $inputs[(string)$input]; |
|
| 262 | + if (!isset($inputs[(string)$input])) { |
|
| 263 | + $input_value = null; |
|
| 264 | + } else { |
|
| 265 | + $input_value = $inputs[(string)$input]; |
|
| 266 | + } |
|
| 263 | 267 | /** |
| 264 | 268 | * if the key of the $input_rules is numeric that means |
| 265 | 269 | * it's neither an anonymous nor an user function. |