@@ -72,7 +72,7 @@ |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @param string $lang |
| 75 | - * @return null |
|
| 75 | + * @return string |
|
| 76 | 76 | */ |
| 77 | 77 | protected function getErrorFilePath(string $lang) |
| 78 | 78 | { |
@@ -101,8 +101,9 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | /* handle error text file for custom validators */ |
| 103 | 103 | $custom_error_texts = []; |
| 104 | - if (file_exists($this->getErrorFilePath($lang))) |
|
| 105 | - $custom_error_texts = include($this->getErrorFilePath($lang)); |
|
| 104 | + if (file_exists($this->getErrorFilePath($lang))) { |
|
| 105 | + $custom_error_texts = include($this->getErrorFilePath($lang)); |
|
| 106 | + } |
|
| 106 | 107 | return $custom_error_texts; |
| 107 | 108 | } |
| 108 | 109 | |
@@ -128,10 +129,11 @@ discard block |
||
| 128 | 129 | { |
| 129 | 130 | foreach ($params as $key => $param) { |
| 130 | 131 | if (preg_match("#^:([a-zA-Z0-9_]+)$#", $param, $param_type)) { |
| 131 | - if (isset($this->namings[(string)$param_type[1]])) |
|
| 132 | - $params[$key] = $this->namings[(string)$param_type[1]]; |
|
| 133 | - else |
|
| 134 | - $params[$key] = $param_type[1]; |
|
| 132 | + if (isset($this->namings[(string)$param_type[1]])) { |
|
| 133 | + $params[$key] = $this->namings[(string)$param_type[1]]; |
|
| 134 | + } else { |
|
| 135 | + $params[$key] = $param_type[1]; |
|
| 136 | + } |
|
| 135 | 137 | } |
| 136 | 138 | } |
| 137 | 139 | return $params; |
@@ -144,8 +146,9 @@ discard block |
||
| 144 | 146 | */ |
| 145 | 147 | public function getErrors(string $lang = null): array |
| 146 | 148 | { |
| 147 | - if ($lang == null) |
|
| 148 | - $lang = $this->getDefaultLang(); |
|
| 149 | + if ($lang == null) { |
|
| 150 | + $lang = $this->getDefaultLang(); |
|
| 151 | + } |
|
| 149 | 152 | |
| 150 | 153 | $error_results = []; |
| 151 | 154 | $default_error_texts = $this->getDefaultErrorTexts($lang); |
@@ -175,9 +178,10 @@ discard block |
||
| 175 | 178 | /** |
| 176 | 179 | * handle :params(..) |
| 177 | 180 | */ |
| 178 | - if (preg_match_all("#:params\((.+?)\)#", $error_message, $param_indexes)) |
|
| 179 | - foreach ($param_indexes[1] as $param_index) { |
|
| 181 | + if (preg_match_all("#:params\((.+?)\)#", $error_message, $param_indexes)) { |
|
| 182 | + foreach ($param_indexes[1] as $param_index) { |
|
| 180 | 183 | $error_message = str_replace(":params(" . $param_index . ")", $result['params'][$param_index], $error_message); |
| 184 | + } |
|
| 181 | 185 | } |
| 182 | 186 | $error_results[] = str_replace(":attribute", $named_input, $error_message); |
| 183 | 187 | } |
@@ -192,8 +196,9 @@ discard block |
||
| 192 | 196 | */ |
| 193 | 197 | public function has(string $input_name, string $rule_name = null): bool |
| 194 | 198 | { |
| 195 | - if ($rule_name != null) |
|
| 196 | - return isset($this->errors[$input_name][$rule_name]); |
|
| 199 | + if ($rule_name != null) { |
|
| 200 | + return isset($this->errors[$input_name][$rule_name]); |
|
| 201 | + } |
|
| 197 | 202 | return isset($this->errors[$input_name]); |
| 198 | 203 | } |
| 199 | 204 | |
@@ -253,10 +258,11 @@ discard block |
||
| 253 | 258 | foreach ($rules as $input => $input_rules) { |
| 254 | 259 | if (is_array($input_rules)) { |
| 255 | 260 | foreach ($input_rules as $rule => $closure) { |
| 256 | - if (!isset($inputs[(string)$input])) |
|
| 257 | - $input_value = null; |
|
| 258 | - else |
|
| 259 | - $input_value = $inputs[(string)$input]; |
|
| 261 | + if (!isset($inputs[(string)$input])) { |
|
| 262 | + $input_value = null; |
|
| 263 | + } else { |
|
| 264 | + $input_value = $inputs[(string)$input]; |
|
| 265 | + } |
|
| 260 | 266 | /** |
| 261 | 267 | * if the key of the $input_rules is numeric that means |
| 262 | 268 | * it's neither an anonymous nor an user function. |