@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $loader = Services::locator(); |
| 39 | 39 | |
| 40 | - if (! is_array($filenames)) { |
|
| 40 | + if (!is_array($filenames)) { |
|
| 41 | 41 | $filenames = [$filenames]; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Les helpers au niveau de l'application doivent remplacer tous les autres |
| 84 | - if (! empty($appHelper)) { |
|
| 84 | + if (!empty($appHelper)) { |
|
| 85 | 85 | $includes[] = $appHelper; |
| 86 | 86 | $loaded[] = $filename; |
| 87 | 87 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $includes = [...$includes, ...$localIncludes]; |
| 91 | 91 | |
| 92 | 92 | // Et celui par défaut du système doit être ajouté en dernier. |
| 93 | - if (! empty($systemHelper)) { |
|
| 93 | + if (!empty($systemHelper)) { |
|
| 94 | 94 | $includes[] = $systemHelper; |
| 95 | 95 | $loaded[] = $filename; |
| 96 | 96 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // Si le fichier est dans un espace de noms, nous allons simplement saisir ce fichier et ne pas en rechercher d'autres |
| 130 | 130 | if (str_contains($name, '\\')) { |
| 131 | - if (! empty($path = $loader->locateFile($name, 'schemas'))) { |
|
| 131 | + if (!empty($path = $loader->locateFile($name, 'schemas'))) { |
|
| 132 | 132 | $file = $path; |
| 133 | 133 | } |
| 134 | 134 | } else { |
@@ -146,18 +146,18 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Les schema des vendor sont prioritaire, ensuite vienne ceux de l'application |
| 149 | - if (! empty($vendorSchema)) { |
|
| 149 | + if (!empty($vendorSchema)) { |
|
| 150 | 150 | $file = $vendorSchema; |
| 151 | - } elseif (! empty($appSchema)) { |
|
| 151 | + } elseif (!empty($appSchema)) { |
|
| 152 | 152 | $file = $appSchema; |
| 153 | - } elseif (! empty($systemSchema)) { |
|
| 153 | + } elseif (!empty($systemSchema)) { |
|
| 154 | 154 | $file = $systemSchema; |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $schema = ! empty($file) ? require $file : null; |
|
| 158 | + $schema = !empty($file) ? require $file : null; |
|
| 159 | 159 | |
| 160 | - if (empty($schema) || ! ($schema instanceof Schema)) { |
|
| 160 | + if (empty($schema) || !($schema instanceof Schema)) { |
|
| 161 | 161 | $schema = Expect::mixed(); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public static function model(string $model, ?ConnectionInterface $connection = null) |
| 177 | 177 | { |
| 178 | - if (! class_exists($model) && ! Text::endsWith($model, 'Model')) { |
|
| 178 | + if (!class_exists($model) && !Text::endsWith($model, 'Model')) { |
|
| 179 | 179 | $model .= 'Model'; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if (! class_exists($model)) { |
|
| 182 | + if (!class_exists($model)) { |
|
| 183 | 183 | $model = str_replace(APP_NAMESPACE . '\\Models\\', '', $model); |
| 184 | 184 | $model = APP_NAMESPACE . '\\Models\\' . $model; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (! class_exists($model)) { |
|
| 187 | + if (!class_exists($model)) { |
|
| 188 | 188 | throw LoadException::modelNotFound($model); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | protected static function verifyPreferApp(array $options, string $name): bool |
| 214 | 214 | { |
| 215 | 215 | // Tout element sans restriction passe |
| 216 | - if (! $options['preferApp']) { |
|
| 216 | + if (!$options['preferApp']) { |
|
| 217 | 217 | return true; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | foreach ($data as $key => $value) { |
| 74 | 74 | $replacementKey = "\n{$key} = {$value}"; |
| 75 | - if (! str_contains($oldFileContents, $key)) { |
|
| 75 | + if (!str_contains($oldFileContents, $key)) { |
|
| 76 | 76 | if (file_put_contents($this->path, $replacementKey, FILE_APPEND) === false) { |
| 77 | 77 | return false; |
| 78 | 78 | } |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | public function parse(): ?array |
| 140 | 140 | { |
| 141 | 141 | // Nous ne voulons pas imposer la présence d'un fichier .env, ils devraient être facultatifs. |
| 142 | - if (! is_file($this->path)) { |
|
| 142 | + if (!is_file($this->path)) { |
|
| 143 | 143 | return null; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Assurez-vous que le fichier est lisible |
| 147 | - if (! is_readable($this->path)) { |
|
| 147 | + if (!is_readable($this->path)) { |
|
| 148 | 148 | throw new InvalidArgumentException("The .env file is not readable: {$this->path}"); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $vars = []; |
| 152 | 152 | |
| 153 | - $lines = file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
| 153 | + $lines = file($this->path, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); |
|
| 154 | 154 | |
| 155 | 155 | foreach ($lines as $line) { |
| 156 | 156 | // C'est un commentaire? |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function setVariable(string $name, string $value = '') |
| 177 | 177 | { |
| 178 | - if (! getenv($name, true)) { |
|
| 178 | + if (!getenv($name, true)) { |
|
| 179 | 179 | putenv("{$name}={$value}"); |
| 180 | 180 | } |
| 181 | 181 | if (empty($_ENV[$name])) { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | $value = preg_replace_callback( |
| 282 | 282 | '/\${([a-zA-Z0-9_]+)}/', |
| 283 | - static function ($matchedPatterns) use ($loader) { |
|
| 283 | + static function($matchedPatterns) use ($loader) { |
|
| 284 | 284 | $nestedVariable = $loader->getVariable($matchedPatterns[1]); |
| 285 | 285 | |
| 286 | 286 | if (null === $nestedVariable) { |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $options = (array) $options; |
| 46 | 46 | |
| 47 | 47 | // N'est-il pas namespaced ? on cherche le dossier en fonction du controleur |
| 48 | - if (! str_contains($view, '\\')) { |
|
| 48 | + if (!str_contains($view, '\\')) { |
|
| 49 | 49 | $reflection = new ReflectionClass(static::class); |
| 50 | 50 | ['dirname' => $dirname, 'filename' => $filename] = pathinfo($reflection->getFileName()); |
| 51 | 51 | $dirname = str_ireplace('Controllers', 'Views', $dirname); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $dirname = implode('Views', $parts); |
| 60 | 60 | $path = implode(DS, [$dirname, $filename]) . DS; |
| 61 | 61 | |
| 62 | - if (! is_dir($path)) { |
|
| 62 | + if (!is_dir($path)) { |
|
| 63 | 63 | $path = implode(DS, [$dirname]) . DS; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | if (empty($data['title'])) { |
| 80 | - if (! is_string($controllerName = Dispatcher::getController(false))) { |
|
| 80 | + if (!is_string($controllerName = Dispatcher::getController(false))) { |
|
| 81 | 81 | $controllerName = static::class; |
| 82 | 82 | } |
| 83 | 83 | $controllerName = str_ireplace(['App\Controllers', 'Controller'], '', $controllerName); |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | $this->modelName = is_object($which) ? null : $which; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if (empty($this->model) && ! empty($this->modelName) && class_exists($this->modelName)) { |
|
| 165 | + if (empty($this->model) && !empty($this->modelName) && class_exists($this->modelName)) { |
|
| 166 | 166 | $this->model = model($this->modelName); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if (! empty($this->model) && empty($this->modelName)) { |
|
| 169 | + if (!empty($this->model) && empty($this->modelName)) { |
|
| 170 | 170 | $this->modelName = $this->model::class; |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | private function getModel() |
| 206 | 206 | { |
| 207 | - $model = ! empty($this->modelName) ? $this->modelName : str_replace('Controller', 'Model', static::class); |
|
| 207 | + $model = !empty($this->modelName) ? $this->modelName : str_replace('Controller', 'Model', static::class); |
|
| 208 | 208 | |
| 209 | 209 | if (class_exists($model)) { |
| 210 | 210 | $this->setModel($model); |
@@ -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,15 +177,15 @@ 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 | 191 | if ($errors !== []) { |
@@ -214,7 +214,7 @@ discard block |
||
| 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)) { |
@@ -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,7 +509,7 @@ 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 | $whitelist[] = '127.0.0.1'; |
| 515 | 515 | $whitelist[] = '0.0.0.0'; |
@@ -517,13 +517,13 @@ discard block |
||
| 517 | 517 | // coupez les espaces de début et de fin des ip |
| 518 | 518 | $whitelist = array_map('trim', $whitelist); |
| 519 | 519 | |
| 520 | - if (! in_array($this->request->clientIp(), $whitelist, true)) { |
|
| 520 | + if (!in_array($this->request->clientIp(), $whitelist, true)) { |
|
| 521 | 521 | return $this->respondUnauthorized($this->_translate('ipUnauthorized')); |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | // Verifie l'authentification du client |
| 526 | - if (false !== $this->config->auth && ! $this->request->is('options') && 'bearer' === strtolower($this->config->auth)) { |
|
| 526 | + if (false !== $this->config->auth && !$this->request->is('options') && 'bearer' === strtolower($this->config->auth)) { |
|
| 527 | 527 | $token = $this->getBearerToken(); |
| 528 | 528 | if ($token === null || $token === '' || $token === '0') { |
| 529 | 529 | return $this->respondInvalidToken($this->_translate('tokenNotFound')); |
@@ -583,7 +583,7 @@ |
||
| 583 | 583 | |
| 584 | 584 | protected static function cacheServices(): void |
| 585 | 585 | { |
| 586 | - if (! static::$discovered) { |
|
| 586 | + if (!static::$discovered) { |
|
| 587 | 587 | $locator = static::locator(); |
| 588 | 588 | $files = $locator->search('Config/Services'); |
| 589 | 589 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function exists(string $key): bool |
| 63 | 63 | { |
| 64 | - if (! $this->configurator->exists($key)) { |
|
| 64 | + if (!$this->configurator->exists($key)) { |
|
| 65 | 65 | $config = explode('.', $key); |
| 66 | 66 | $this->load($config[0]); |
| 67 | 67 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function missing(string $key): bool |
| 86 | 86 | { |
| 87 | - return ! $this->exists($key); |
|
| 87 | + return !$this->exists($key); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | $this->load($conf, $file, null, $allow_empty); |
| 167 | 167 | } |
| 168 | - } elseif (! isset(self::$loaded[$config])) { |
|
| 168 | + } elseif (!isset(self::$loaded[$config])) { |
|
| 169 | 169 | $file ??= self::path($config); |
| 170 | 170 | $schema ??= self::schema($config); |
| 171 | 171 | |
| 172 | 172 | $configurations = []; |
| 173 | - if (file_exists($file) && ! in_array($file, get_included_files(), true)) { |
|
| 173 | + if (file_exists($file) && !in_array($file, get_included_files(), true)) { |
|
| 174 | 174 | $configurations = (array) require $file; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $configurations = Arr::merge(self::$registrars[$config] ?? [], $configurations); |
| 178 | 178 | |
| 179 | - if (empty($configurations) && ! $allow_empty && ! is_a($schema, Schema::class, true)) { |
|
| 179 | + if (empty($configurations) && !$allow_empty && !is_a($schema, Schema::class, true)) { |
|
| 180 | 180 | return; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $class = new ReflectionClass($classname); |
| 286 | - $methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC); |
|
| 286 | + $methods = $class->getMethods(ReflectionMethod::IS_STATIC|ReflectionMethod::IS_PUBLIC); |
|
| 287 | 287 | |
| 288 | 288 | foreach ($methods as $method) { |
| 289 | - if (! ($method->isPublic() && $method->isStatic())) { |
|
| 289 | + if (!($method->isPublic() && $method->isStatic())) { |
|
| 290 | 290 | continue; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if (! is_array($result = $method->invoke(null))) { |
|
| 293 | + if (!is_array($result = $method->invoke(null))) { |
|
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -359,12 +359,12 @@ discard block |
||
| 359 | 359 | { |
| 360 | 360 | $config = $this->get('app.show_debugbar', 'auto'); |
| 361 | 361 | |
| 362 | - if (! in_array($config, ['auto', true, false], true)) { |
|
| 362 | + if (!in_array($config, ['auto', true, false], true)) { |
|
| 363 | 363 | self::exceptBadConfigValue('show_debugbar', ['auto', true, false], 'app'); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | if ($config === 'auto') { |
| 367 | - $this->set('app.show_debugbar', ! is_online()); |
|
| 367 | + $this->set('app.show_debugbar', !is_online()); |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec |
| 189 | 189 | // Contrôleurs/répertoires, mais l'application peut ne pas |
| 190 | 190 | // vouloir ceci, comme dans le cas des API. |
| 191 | - if (! $this->collection->shouldAutoRoute()) { |
|
| 191 | + if (!$this->collection->shouldAutoRoute()) { |
|
| 192 | 192 | throw new PageNotFoundException("Impossible de trouver une route pour '{$this->collection->getHTTPVerb()}: {$uri}'."); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function controllerName() |
| 220 | 220 | { |
| 221 | - if (! is_string($this->controller)) { |
|
| 221 | + if (!is_string($this->controller)) { |
|
| 222 | 222 | return $this->controller; |
| 223 | 223 | } |
| 224 | 224 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | return [ |
| 265 | 265 | $routeArray[0], // Controleur |
| 266 | - $routeArray[1] ?? 'index', // Methode |
|
| 266 | + $routeArray[1] ?? 'index', // Methode |
|
| 267 | 267 | ]; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | // Cette route est-elle censée rediriger vers une autre ? |
| 390 | 390 | if ($this->collection->isRedirect($routeKey)) { |
| 391 | 391 | // remplacement des groupes de routes correspondants par des références : post/([0-9]+) -> post/$1 |
| 392 | - $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () { |
|
| 392 | + $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function() { |
|
| 393 | 393 | static $i = 1; |
| 394 | 394 | |
| 395 | 395 | return '$' . $i++; |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | ); |
| 410 | 410 | |
| 411 | 411 | if ($this->collection->shouldUseSupportedLocalesOnly() |
| 412 | - && ! in_array($matched['locale'], config('app.supported_locales'), true)) { |
|
| 412 | + && !in_array($matched['locale'], config('app.supported_locales'), true)) { |
|
| 413 | 413 | // Lancer une exception pour empêcher l'autorouteur, |
| 414 | 414 | // si activé, essayer de trouver une route |
| 415 | 415 | throw PageNotFoundException::localeNotSupported($matched['locale']); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | // Utilisons-nous Closures ? Si tel est le cas, nous devons collecter les paramètres dans un tableau |
| 423 | 423 | // afin qu'ils puissent être transmis ultérieurement à la méthode du contrôleur. |
| 424 | - if (! is_string($handler) && is_callable($handler)) { |
|
| 424 | + if (!is_string($handler) && is_callable($handler)) { |
|
| 425 | 425 | $this->controller = $handler; |
| 426 | 426 | |
| 427 | 427 | // Supprime la chaîne d'origine du tableau matches |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | return preg_replace_callback( |
| 500 | 500 | $pattern, |
| 501 | - static function ($match) use ($matches) { |
|
| 501 | + static function($match) use ($matches) { |
|
| 502 | 502 | $index = (int) $match[1]; |
| 503 | 503 | |
| 504 | 504 | return $matches[$index] ?? ''; |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | // $this->method contient déjà le nom de la méthode par défaut, |
| 540 | 540 | // donc ne l'écrasez pas avec le vide. |
| 541 | - if (! empty($method)) { |
|
| 541 | + if (!empty($method)) { |
|
| 542 | 542 | $this->setMethod($method); |
| 543 | 543 | } |
| 544 | 544 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // Incluez le fichier routesFile s'il n'existe pas. |
| 257 | 257 | // Ne conserver que pour les fins BC pour l'instant. |
| 258 | 258 | $routeFiles = $this->routeFiles; |
| 259 | - if (! in_array($routesFile, $routeFiles, true)) { |
|
| 259 | + if (!in_array($routesFile, $routeFiles, true)) { |
|
| 260 | 260 | $routeFiles[] = $routesFile; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $routes = $this; |
| 265 | 265 | |
| 266 | 266 | foreach ($routeFiles as $routesFile) { |
| 267 | - if (! is_file($routesFile)) { |
|
| 267 | + if (!is_file($routesFile)) { |
|
| 268 | 268 | logger()->warning(sprintf('Fichier de route introuvable : "%s"', $routesFile)); |
| 269 | 269 | |
| 270 | 270 | continue; |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function placeholder(array|string $placeholder, ?string $pattern = null): self |
| 315 | 315 | { |
| 316 | - if (! is_array($placeholder)) { |
|
| 316 | + if (!is_array($placeholder)) { |
|
| 317 | 317 | $placeholder = [$placeholder => $pattern]; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | * |
| 1026 | 1026 | * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to |
| 1027 | 1027 | */ |
| 1028 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
| 1028 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
| 1029 | 1029 | { |
| 1030 | 1030 | if ($from === '' || empty($to)) { |
| 1031 | 1031 | throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.'); |
@@ -1210,8 +1210,8 @@ discard block |
||
| 1210 | 1210 | // Ajoutez l'espace de noms par défaut si nécessaire. |
| 1211 | 1211 | $namespace = trim($this->defaultNamespace, '\\') . '\\'; |
| 1212 | 1212 | if ( |
| 1213 | - ! str_starts_with($search, '\\') |
|
| 1214 | - && ! str_starts_with($search, $namespace) |
|
| 1213 | + !str_starts_with($search, '\\') |
|
| 1214 | + && !str_starts_with($search, $namespace) |
|
| 1215 | 1215 | ) { |
| 1216 | 1216 | $search = $namespace . $search; |
| 1217 | 1217 | } |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | $from = $route['from']; |
| 1225 | 1225 | |
| 1226 | 1226 | // on ignore les closures |
| 1227 | - if (! is_string($to)) { |
|
| 1227 | + if (!is_string($to)) { |
|
| 1228 | 1228 | continue; |
| 1229 | 1229 | } |
| 1230 | 1230 | |
@@ -1235,7 +1235,7 @@ discard block |
||
| 1235 | 1235 | |
| 1236 | 1236 | // S'il y a une chance de correspondance, alors ce sera |
| 1237 | 1237 | // soit avec $search au début de la chaîne $to. |
| 1238 | - if (! str_starts_with($to, $search)) { |
|
| 1238 | + if (!str_starts_with($to, $search)) { |
|
| 1239 | 1239 | continue; |
| 1240 | 1240 | } |
| 1241 | 1241 | |
@@ -1315,7 +1315,7 @@ discard block |
||
| 1315 | 1315 | |
| 1316 | 1316 | // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés. |
| 1317 | 1317 | foreach ($matches[0] as $index => $placeholder) { |
| 1318 | - if (! isset($params[$index])) { |
|
| 1318 | + if (!isset($params[$index])) { |
|
| 1319 | 1319 | throw new InvalidArgumentException( |
| 1320 | 1320 | 'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".' |
| 1321 | 1321 | ); |
@@ -1326,7 +1326,7 @@ discard block |
||
| 1326 | 1326 | // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex. |
| 1327 | 1327 | $pattern = $this->placeholders[$placeholderName] ?? $placeholder; |
| 1328 | 1328 | |
| 1329 | - if (! preg_match('#^' . $pattern . '$#u', (string) $params[$index])) { |
|
| 1329 | + if (!preg_match('#^' . $pattern . '$#u', (string) $params[$index])) { |
|
| 1330 | 1330 | throw RouterException::invalidParameterType(); |
| 1331 | 1331 | } |
| 1332 | 1332 | |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | $from = trim($from, '/'); |
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | - if (is_string($to) && ! str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
| 1390 | + if (is_string($to) && !str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
| 1391 | 1391 | $to = [$to, '__invoke']; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | if (isset($options['middleware'])) { |
| 1402 | 1402 | $options['middleware'] = (array) $options['middleware']; |
| 1403 | 1403 | |
| 1404 | - if (! isset($options['middlewares'])) { |
|
| 1404 | + if (!isset($options['middlewares'])) { |
|
| 1405 | 1405 | $options['middlewares'] = $options['middleware']; |
| 1406 | 1406 | } else { |
| 1407 | 1407 | $options['middlewares'] = array_merge($options['middlewares'], $options['middleware']); |
@@ -1429,9 +1429,9 @@ discard block |
||
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | // Limitation du nom d'hôte ? |
| 1432 | - if (! empty($options['hostname'])) { |
|
| 1432 | + if (!empty($options['hostname'])) { |
|
| 1433 | 1433 | // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ? |
| 1434 | - if (! $this->checkHostname($options['hostname'])) { |
|
| 1434 | + if (!$this->checkHostname($options['hostname'])) { |
|
| 1435 | 1435 | return; |
| 1436 | 1436 | } |
| 1437 | 1437 | |
@@ -1439,10 +1439,10 @@ discard block |
||
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | // Limitation du nom sous-domaine ? |
| 1442 | - elseif (! empty($options['subdomain'])) { |
|
| 1442 | + elseif (!empty($options['subdomain'])) { |
|
| 1443 | 1443 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
| 1444 | 1444 | // nous n'avons pas besoin d'ajouter la route. |
| 1445 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
| 1445 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
| 1446 | 1446 | return; |
| 1447 | 1447 | } |
| 1448 | 1448 | |
@@ -1475,9 +1475,9 @@ discard block |
||
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | 1477 | // S'il s'agit d'une redirection, aucun traitement |
| 1478 | - if (! isset($options['redirect']) && is_string($to)) { |
|
| 1478 | + if (!isset($options['redirect']) && is_string($to)) { |
|
| 1479 | 1479 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
| 1480 | - if (! str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
| 1480 | + if (!str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
| 1481 | 1481 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
| 1482 | 1482 | $to = trim($namespace, '\\') . '\\' . $to; |
| 1483 | 1483 | } |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
| 1495 | 1495 | // pour tenter de router la requête. |
| 1496 | 1496 | $routeKeyExists = isset($this->routes[$verb][$routeKey]); |
| 1497 | - if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) { |
|
| 1497 | + if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) { |
|
| 1498 | 1498 | return; |
| 1499 | 1499 | } |
| 1500 | 1500 | |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | private function checkHostname(string $hostname): bool |
| 1521 | 1521 | { |
| 1522 | 1522 | // Les appels CLI ne peuvent pas être sur le nom d'hôte. |
| 1523 | - if (! isset($this->httpHost)) { |
|
| 1523 | + if (!isset($this->httpHost)) { |
|
| 1524 | 1524 | return false; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
@@ -1536,7 +1536,7 @@ discard block |
||
| 1536 | 1536 | private function checkSubdomains($subdomains): bool |
| 1537 | 1537 | { |
| 1538 | 1538 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
| 1539 | - if (! isset($this->httpHost)) { |
|
| 1539 | + if (!isset($this->httpHost)) { |
|
| 1540 | 1540 | return false; |
| 1541 | 1541 | } |
| 1542 | 1542 | |
@@ -1544,13 +1544,13 @@ discard block |
||
| 1544 | 1544 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | - if (! is_array($subdomains)) { |
|
| 1547 | + if (!is_array($subdomains)) { |
|
| 1548 | 1548 | $subdomains = [$subdomains]; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
| 1552 | 1552 | // il nécessite la présence d'un sous-domaine. |
| 1553 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
| 1553 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
| 1554 | 1554 | return true; |
| 1555 | 1555 | } |
| 1556 | 1556 | |
@@ -1572,7 +1572,7 @@ discard block |
||
| 1572 | 1572 | // sur l'URL sinon parse_url sera mal interprété |
| 1573 | 1573 | // 'hôte' comme 'chemin'. |
| 1574 | 1574 | $url = $this->httpHost; |
| 1575 | - if (! str_starts_with($url, 'http')) { |
|
| 1575 | + if (!str_starts_with($url, 'http')) { |
|
| 1576 | 1576 | $url = 'http://' . $url; |
| 1577 | 1577 | } |
| 1578 | 1578 | |
@@ -1616,7 +1616,7 @@ discard block |
||
| 1616 | 1616 | */ |
| 1617 | 1617 | private function getControllerName(Closure|string $handler): ?string |
| 1618 | 1618 | { |
| 1619 | - if (! is_string($handler)) { |
|
| 1619 | + if (!is_string($handler)) { |
|
| 1620 | 1620 | return null; |
| 1621 | 1621 | } |
| 1622 | 1622 | |
@@ -1675,12 +1675,12 @@ discard block |
||
| 1675 | 1675 | */ |
| 1676 | 1676 | private function replaceLocale(string $route, ?string $locale = null): string |
| 1677 | 1677 | { |
| 1678 | - if (! str_contains($route, '{locale}')) { |
|
| 1678 | + if (!str_contains($route, '{locale}')) { |
|
| 1679 | 1679 | return $route; |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | // Vérifier les paramètres régionaux non valides |
| 1683 | - if ($locale !== null && ! in_array($locale, config('app.supported_locales'), true)) { |
|
| 1683 | + if ($locale !== null && !in_array($locale, config('app.supported_locales'), true)) { |
|
| 1684 | 1684 | $locale = null; |
| 1685 | 1685 | } |
| 1686 | 1686 | |