@@ -78,7 +78,7 @@ |
||
78 | 78 | { |
79 | 79 | $standard = $this->option('standard', 'psr15'); |
80 | 80 | |
81 | - if (! in_array($standard, ['psr15', 'psr7'], true)) { |
|
81 | + if (!in_array($standard, ['psr15', 'psr7'], true)) { |
|
82 | 82 | // @codeCoverageIgnoreStart |
83 | 83 | $standard = $this->choice(lang('CLI.generator.middlewareStandard'), ['psr15', 'psr7'], 'psr15'); |
84 | 84 | $this->eol(); |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function registerHttpErrors(Run $debugger, array $config): Run |
37 | 37 | { |
38 | - return $debugger->pushHandler(static function (Throwable $exception, InspectorInterface $inspector, RunInterface $run) use ($config) { |
|
38 | + return $debugger->pushHandler(static function(Throwable $exception, InspectorInterface $inspector, RunInterface $run) use ($config) { |
|
39 | 39 | if (true === $config['log']) { |
40 | - if (! in_array($exception->getCode(), $config['ignore_codes'], true)) { |
|
40 | + if (!in_array($exception->getCode(), $config['ignore_codes'], true)) { |
|
41 | 41 | Services::logger()->error($exception); |
42 | 42 | } |
43 | 43 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $debugger->pushHandler(new PlainTextHandler()); |
91 | 91 | } |
92 | 92 | |
93 | - if (! is_online()) { |
|
93 | + if (!is_online()) { |
|
94 | 94 | if (Misc::isAjaxRequest() || Services::request()->isJson()) { |
95 | 95 | $debugger->pushHandler(new JsonResponseHandler()); |
96 | 96 | } else { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $this->config = (object) config('rest'); |
75 | 75 | |
76 | 76 | $locale = $this->config->language ?? null; |
77 | - $this->locale = ! empty($locale) ? $locale : $this->request->getLocale(); |
|
77 | + $this->locale = !empty($locale) ? $locale : $this->request->getLocale(); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function _remap(string $method, array $params = []) |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $class = static::class; |
83 | 83 | |
84 | 84 | // Bien sûr qu'il existe, mais peuvent-ils en faire quelque chose ? |
85 | - if (! method_exists($class, $method)) { |
|
85 | + if (!method_exists($class, $method)) { |
|
86 | 86 | return $this->respondNotImplemented($this->_translate('notImplemented', [$class, $method])); |
87 | 87 | } |
88 | 88 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | return $this->respondBadRequest($message, $ex->getCode(), $errors); |
130 | 130 | } |
131 | 131 | |
132 | - if (! on_dev()) { |
|
132 | + if (!on_dev()) { |
|
133 | 133 | $url = explode('?', $this->request->getRequestTarget())[0]; |
134 | 134 | |
135 | 135 | return $this->respondBadRequest($this->_translate('badUsed', [$url])); |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | final protected function respondFail(?string $message = "Une erreur s'est produite", ?int $status = StatusCode::INTERNAL_ERROR, null|int|string $code = null, array $errors = []) |
178 | 178 | { |
179 | 179 | $message = $message ?: "Une erreur s'est produite"; |
180 | - $code = ! empty($code) ? $code : $status; |
|
180 | + $code = !empty($code) ? $code : $status; |
|
181 | 181 | |
182 | 182 | $response = [ |
183 | 183 | $this->config->field['message'] ?? 'message' => $message, |
184 | 184 | ]; |
185 | - if (! empty($this->config->field['status'])) { |
|
185 | + if (!empty($this->config->field['status'])) { |
|
186 | 186 | $response[$this->config->field['status']] = false; |
187 | 187 | } |
188 | - if (! empty($this->config->field['code'])) { |
|
188 | + if (!empty($this->config->field['code'])) { |
|
189 | 189 | $response[$this->config->field['code']] = $code; |
190 | 190 | } |
191 | - if (! empty($errors)) { |
|
191 | + if (!empty($errors)) { |
|
192 | 192 | $response[$this->config->field['errors'] ?? 'errors'] = $errors; |
193 | 193 | } |
194 | 194 | |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | final protected function respondSuccess(?string $message = 'Resultat', $result = null, ?int $status = StatusCode::OK) |
210 | 210 | { |
211 | 211 | $message = $message ?: 'Resultat'; |
212 | - $status = ! empty($status) ? $status : StatusCode::OK; |
|
212 | + $status = !empty($status) ? $status : StatusCode::OK; |
|
213 | 213 | |
214 | 214 | $response = [ |
215 | 215 | $this->config->field['message'] ?? 'message' => $message, |
216 | 216 | ]; |
217 | - if (! empty($this->config->field['status'])) { |
|
217 | + if (!empty($this->config->field['status'])) { |
|
218 | 218 | $response[$this->config->field['status']] = true; |
219 | 219 | } |
220 | 220 | if (is_array($result)) { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | final protected function allowedMethods(string ...$methods): self |
323 | 323 | { |
324 | - if (! empty($methods)) { |
|
324 | + if (!empty($methods)) { |
|
325 | 325 | $this->config->allowed_methods = array_map(static fn ($str) => strtoupper($str), $methods); |
326 | 326 | } |
327 | 327 | |
@@ -419,13 +419,13 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | // Si la méthode de format existe, appelle et renvoie la sortie dans ce format |
422 | - if (! empty($mime)) { |
|
422 | + if (!empty($mime)) { |
|
423 | 423 | $output = Formatter::type($mime)->format($data); |
424 | 424 | |
425 | 425 | // Définit l'en-tête du format |
426 | 426 | // Ensuite, vérifiez si le client a demandé un rappel, et si la sortie contient ce rappel : |
427 | 427 | $callback = $this->request->getQuery('callback'); |
428 | - if (! empty($callback) && $mime === $this->mimes['json'] && preg_match('/^' . $callback . '/', $output)) { |
|
428 | + if (!empty($callback) && $mime === $this->mimes['json'] && preg_match('/^' . $callback . '/', $output)) { |
|
429 | 429 | $this->response = $this->response->withType($this->mimes['jsonp']); |
430 | 430 | } else { |
431 | 431 | $this->response = $this->response->withType($mime === $this->mimes['array'] ? $this->mimes['json'] : $mime); |
@@ -481,22 +481,22 @@ discard block |
||
481 | 481 | private function checkProcess(): bool|ResponseInterface |
482 | 482 | { |
483 | 483 | // Verifie si la requete est en ajax |
484 | - if (! $this->request->is('ajax') && $this->config->ajax_only) { |
|
484 | + if (!$this->request->is('ajax') && $this->config->ajax_only) { |
|
485 | 485 | return $this->respondNotAcceptable($this->_translate('ajaxOnly')); |
486 | 486 | } |
487 | 487 | |
488 | 488 | // Verifie si la requete est en https |
489 | - if (! $this->request->is('https') && $this->config->force_https) { |
|
489 | + if (!$this->request->is('https') && $this->config->force_https) { |
|
490 | 490 | return $this->respondForbidden($this->_translate('unsupported')); |
491 | 491 | } |
492 | 492 | |
493 | 493 | // Verifie si la methode utilisee pour la requete est autorisee |
494 | - if (! in_array(strtoupper($this->request->getMethod()), $this->config->allowed_methods, true)) { |
|
494 | + if (!in_array(strtoupper($this->request->getMethod()), $this->config->allowed_methods, true)) { |
|
495 | 495 | return $this->respondNotAcceptable($this->_translate('unknownMethod')); |
496 | 496 | } |
497 | 497 | |
498 | 498 | // Verifie que l'ip qui emet la requete n'est pas dans la blacklist |
499 | - if (! empty($this->config->ip_blacklis)) { |
|
499 | + if (!empty($this->config->ip_blacklis)) { |
|
500 | 500 | $this->config->ip_blacklist = implode(',', $this->config->ip_blacklist); |
501 | 501 | |
502 | 502 | // Correspond à une adresse IP dans une liste noire, par ex. 127.0.0.0, 0.0.0.0 |
@@ -509,20 +509,20 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | // Verifie que l'ip qui emet la requete est dans la whitelist |
512 | - if (! empty($this->config->ip_whitelist)) { |
|
512 | + if (!empty($this->config->ip_whitelist)) { |
|
513 | 513 | $whitelist = $this->config->ip_whitelist; |
514 | 514 | array_push($whitelist, '127.0.0.1', '0.0.0.0'); |
515 | 515 | |
516 | 516 | // coupez les espaces de début et de fin des ip |
517 | 517 | $whitelist = array_map('trim', $whitelist); |
518 | 518 | |
519 | - if (! in_array($this->request->clientIp(), $whitelist, true)) { |
|
519 | + if (!in_array($this->request->clientIp(), $whitelist, true)) { |
|
520 | 520 | return $this->respondUnauthorized($this->_translate('ipUnauthorized')); |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | 524 | // Verifie l'authentification du client |
525 | - if (false !== $this->config->auth && ! $this->request->is('options')) { |
|
525 | + if (false !== $this->config->auth && !$this->request->is('options')) { |
|
526 | 526 | if ('bearer' === strtolower($this->config->auth)) { |
527 | 527 | $token = $this->getBearerToken(); |
528 | 528 | if (empty($token)) { |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | defined('DS') || define('DS', DIRECTORY_SEPARATOR); |
17 | 17 | |
18 | 18 | // Se rassurer que le dossier courant pointe sur le dossier du front controller |
19 | -if (! defined('TEST_PATH')) { |
|
19 | +if (!defined('TEST_PATH')) { |
|
20 | 20 | // On doit aussi verifier qu'on n'est pas en phase de test, sinon khalan ne trouvera pas le dossier des specs |
21 | 21 | chdir(WEBROOT); |
22 | 22 | } |
23 | 23 | |
24 | -return function (array $paths, string $paths_config_file, bool $is_cli) { |
|
24 | +return function(array $paths, string $paths_config_file, bool $is_cli) { |
|
25 | 25 | // Le chemin d'accès vers le dossier de l'application |
26 | 26 | if (is_dir($paths['app'])) { |
27 | 27 | if (($_temp = realpath($paths['app'])) !== false) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $app = new Application(); |
105 | 105 | $app->init(); |
106 | 106 | |
107 | - if (! $is_cli) { |
|
107 | + if (!$is_cli) { |
|
108 | 108 | $app->run(); |
109 | 109 | } |
110 | 110 | }; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class {class} extends {extends} |
8 | 8 | { |
9 | -<?php if (! empty($invokable)): ?> |
|
9 | +<?php if (!empty($invokable)): ?> |
|
10 | 10 | /** |
11 | 11 | * Traitement |
12 | 12 | * |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function validation(array|string $rules, array $messages = []): Validation |
57 | 57 | { |
58 | 58 | if (is_string($rules)) { |
59 | - if (! class_exists($rules) || ! is_subclass_of($rules, DataValidation::class)) { |
|
59 | + if (!class_exists($rules) || !is_subclass_of($rules, DataValidation::class)) { |
|
60 | 60 | throw new InvalidArgumentException(); |
61 | 61 | } |
62 | 62 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function fullUrl(): string |
143 | 143 | { |
144 | - if (! empty($query = $this->getEnv('QUERY_STRING'))) { |
|
144 | + if (!empty($query = $this->getEnv('QUERY_STRING'))) { |
|
145 | 145 | return $this->url() . '?' . $query; |
146 | 146 | } |
147 | 147 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use BlitzPHP\Utilities\String\Inflector; |
13 | 13 | use BlitzPHP\Utilities\String\Text; |
14 | 14 | |
15 | -if (! function_exists('camelize')) { |
|
15 | +if (!function_exists('camelize')) { |
|
16 | 16 | /** |
17 | 17 | * Camelize |
18 | 18 | * |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -if (! function_exists('classify')) { |
|
29 | +if (!function_exists('classify')) { |
|
30 | 30 | /** |
31 | 31 | * Returns model class name ("Person" for the database table "people".) for given database table. |
32 | 32 | * |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -if (! function_exists('dasherize')) { |
|
43 | +if (!function_exists('dasherize')) { |
|
44 | 44 | /** |
45 | 45 | * Returns the input CamelCasedString as an dashed-string. |
46 | 46 | * |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | -if (! function_exists('delimit')) { |
|
59 | +if (!function_exists('delimit')) { |
|
60 | 60 | /** |
61 | 61 | * Expects a CamelCasedInputString, and produces a lower_case_delimited_string |
62 | 62 | * |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | -if (! function_exists('humanize')) { |
|
74 | +if (!function_exists('humanize')) { |
|
75 | 75 | /** |
76 | 76 | * Humanize |
77 | 77 | * |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | -if (! function_exists('plural')) { |
|
89 | +if (!function_exists('plural')) { |
|
90 | 90 | /** |
91 | 91 | * Plural |
92 | 92 | * |
@@ -96,30 +96,30 @@ discard block |
||
96 | 96 | { |
97 | 97 | $result = $string; |
98 | 98 | |
99 | - if (! is_pluralizable($result)) { |
|
99 | + if (!is_pluralizable($result)) { |
|
100 | 100 | return $result; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $plural_rules = [ |
104 | - '/(quiz)$/' => '\1zes', // quizzes |
|
105 | - '/^(ox)$/' => '\1\2en', // ox |
|
106 | - '/([m|l])ouse$/' => '\1ice', // mouse, louse |
|
107 | - '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index |
|
108 | - '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address |
|
109 | - '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency |
|
110 | - '/(hive)$/' => '\1s', // archive, hive |
|
111 | - '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife |
|
112 | - '/sis$/' => 'ses', // basis, diagnosis |
|
113 | - '/([ti])um$/' => '\1a', // datum, medium |
|
114 | - '/(p)erson$/' => '\1eople', // person, salesperson |
|
115 | - '/(m)an$/' => '\1en', // man, woman, spokesman |
|
116 | - '/(c)hild$/' => '\1hildren', // child |
|
117 | - '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato |
|
118 | - '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
119 | - '/(alias|status|virus)$/' => '\1es', // alias |
|
120 | - '/(octop)us$/' => '\1i', // octopus |
|
121 | - '/(ax|cris|test)is$/' => '\1es', // axis, crisis |
|
122 | - '/s$/' => 's', // no change (compatibility) |
|
104 | + '/(quiz)$/' => '\1zes', // quizzes |
|
105 | + '/^(ox)$/' => '\1\2en', // ox |
|
106 | + '/([m|l])ouse$/' => '\1ice', // mouse, louse |
|
107 | + '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index |
|
108 | + '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address |
|
109 | + '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency |
|
110 | + '/(hive)$/' => '\1s', // archive, hive |
|
111 | + '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife |
|
112 | + '/sis$/' => 'ses', // basis, diagnosis |
|
113 | + '/([ti])um$/' => '\1a', // datum, medium |
|
114 | + '/(p)erson$/' => '\1eople', // person, salesperson |
|
115 | + '/(m)an$/' => '\1en', // man, woman, spokesman |
|
116 | + '/(c)hild$/' => '\1hildren', // child |
|
117 | + '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato |
|
118 | + '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
119 | + '/(alias|status|virus)$/' => '\1es', // alias |
|
120 | + '/(octop)us$/' => '\1i', // octopus |
|
121 | + '/(ax|cris|test)is$/' => '\1es', // axis, crisis |
|
122 | + '/s$/' => 's', // no change (compatibility) |
|
123 | 123 | '/$/' => 's', |
124 | 124 | ]; |
125 | 125 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | -if (! function_exists('pluralize')) { |
|
137 | +if (!function_exists('pluralize')) { |
|
138 | 138 | /** |
139 | 139 | * Return $word in plural form. |
140 | 140 | * |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | -if (! function_exists('singular')) { |
|
151 | +if (!function_exists('singular')) { |
|
152 | 152 | /** |
153 | 153 | * Singular |
154 | 154 | * |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | $result = $string; |
160 | 160 | |
161 | - if (! is_pluralizable($result)) { |
|
161 | + if (!is_pluralizable($result)) { |
|
162 | 162 | return $result; |
163 | 163 | } |
164 | 164 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
207 | -if (! function_exists('singularize')) { |
|
207 | +if (!function_exists('singularize')) { |
|
208 | 208 | /** |
209 | 209 | * Return $word in singular form. |
210 | 210 | * |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | -if (! function_exists('tableize')) { |
|
221 | +if (!function_exists('tableize')) { |
|
222 | 222 | /** |
223 | 223 | * Returns corresponding table name for given model $className. ("people" for the model class "Person"). |
224 | 224 | * |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -if (! function_exists('underscore')) { |
|
235 | +if (!function_exists('underscore')) { |
|
236 | 236 | /** |
237 | 237 | * Underscore |
238 | 238 | * |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | -if (! function_exists('variable')) { |
|
249 | +if (!function_exists('variable')) { |
|
250 | 250 | /** |
251 | 251 | * Returns camelBacked version of an underscored string. |
252 | 252 | * |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | -if (! function_exists('counted')) { |
|
263 | +if (!function_exists('counted')) { |
|
264 | 264 | /** |
265 | 265 | * Counted |
266 | 266 | * |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | -if (! function_exists('pascalize')) { |
|
281 | +if (!function_exists('pascalize')) { |
|
282 | 282 | /** |
283 | 283 | * Pascalize |
284 | 284 | * |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
297 | -if (! function_exists('is_pluralizable')) { |
|
297 | +if (!function_exists('is_pluralizable')) { |
|
298 | 298 | /** |
299 | 299 | * Checks if the given word has a plural version. |
300 | 300 | * |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | function is_pluralizable(string $word): bool |
304 | 304 | { |
305 | - return ! in_array( |
|
305 | + return !in_array( |
|
306 | 306 | strtolower($word), |
307 | 307 | [ |
308 | 308 | 'advice', |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | -if (! function_exists('ordinal')) { |
|
380 | +if (!function_exists('ordinal')) { |
|
381 | 381 | /** |
382 | 382 | * Returns the suffix that should be added to a |
383 | 383 | * number to denote the position in an ordered |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | -if (! function_exists('ordinalize')) { |
|
407 | +if (!function_exists('ordinalize')) { |
|
408 | 408 | /** |
409 | 409 | * Turns a number into an ordinal string used |
410 | 410 | * to denote the position in an ordered sequence |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $response = $handler->handle($request); |
28 | 28 | |
29 | - if (! empty($body = $response->getBody()->getContents())) { |
|
29 | + if (!empty($body = $response->getBody()->getContents())) { |
|
30 | 30 | $benchmark = Services::timer(); |
31 | 31 | |
32 | 32 | $output = str_replace( |
@@ -37,7 +37,7 @@ |
||
37 | 37 | $response = $handler->handle($request); |
38 | 38 | $content = $response->getBody()->getContents(); |
39 | 39 | |
40 | - if (! $response instanceof Redirection) { |
|
40 | + if (!$response instanceof Redirection) { |
|
41 | 41 | // Mettez-le en cache sans remplacer les mesures de performances afin que nous puissions avoir des mises à jour de vitesse en direct en cours de route. |
42 | 42 | // Doit être exécuté après les filtres pour conserver les en-têtes de réponse. |
43 | 43 | $this->pageCache->make($request, $response->withBody(to_stream($content))); |