@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $class = $this->translateURI($segment); |
| 162 | 162 | |
| 163 | 163 | // dès que nous rencontrons un segment qui n'est pas compatible PSR-4, arrêter la recherche |
| 164 | - if (! $this->isValidSegment($class)) { |
|
| 164 | + if (!$this->isValidSegment($class)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | throw new MethodNotFoundException(); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if (! $refMethod->isPublic()) { |
|
| 390 | + if (!$refMethod->isPublic()) { |
|
| 391 | 391 | throw new MethodNotFoundException(); |
| 392 | 392 | } |
| 393 | 393 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | return; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if (! in_array(ltrim($classname, '\\'), get_declared_classes(), true)) { |
|
| 452 | + if (!in_array(ltrim($classname, '\\'), get_declared_classes(), true)) { |
|
| 453 | 453 | throw new PageNotFoundException( |
| 454 | 454 | '"' . $classname . '" n\'a pas été trouvé.' |
| 455 | 455 | ); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | // Mais si un visiteur navigue vers l'URI `controller/somemethod`, `getSomemethod()` sera vérifié, et `method_exists()` retournera true parce que les noms de méthodes en PHP sont insensibles à la casse. |
| 474 | 474 | method_exists($this->controller, $method) |
| 475 | 475 | // Mais nous n'autorisons pas `controller/somemethod`, donc vérifiez le nom exact de la méthode. |
| 476 | - && ! in_array($method, get_class_methods($this->controller), true) |
|
| 476 | + && !in_array($method, get_class_methods($this->controller), true) |
|
| 477 | 477 | ) { |
| 478 | 478 | throw new PageNotFoundException( |
| 479 | 479 | '"' . $this->controller . '::' . $method . '()" n\'a pas été trouvé.' |
@@ -35,8 +35,8 @@ 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): int { |
|
| 39 | - if (true === $config['log'] && ! in_array($exception->getCode(), $config['ignore_codes'], true)) { |
|
| 38 | + return $debugger->pushHandler(static function(Throwable $exception, InspectorInterface $inspector, RunInterface $run) use ($config): int { |
|
| 39 | + if (true === $config['log'] && !in_array($exception->getCode(), $config['ignore_codes'], true)) { |
|
| 40 | 40 | Services::logger()->error($exception); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $debugger->pushHandler(new PlainTextHandler()); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if (! is_online()) { |
|
| 91 | + if (!is_online()) { |
|
| 92 | 92 | if (Misc::isAjaxRequest() || Services::request()->isJson()) { |
| 93 | 93 | $debugger->pushHandler(new JsonResponseHandler()); |
| 94 | 94 | } else { |
@@ -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 (): string { |
|
| 392 | + $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function(): string { |
|
| 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 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Sort to get the highest results first |
| 207 | - usort($results, static function ($a, $b): int { |
|
| 207 | + usort($results, static function($a, $b): int { |
|
| 208 | 208 | if ($a['q'] === $b['q']) { |
| 209 | 209 | $a_ast = substr_count($a['value'], '*'); |
| 210 | 210 | $b_ast = substr_count($b['value'], '*'); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | foreach ($supported['params'] as $label => $value) { |
| 277 | - if (! isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) { |
|
| 277 | + if (!isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) { |
|
| 278 | 278 | return false; |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public static function makeUploadedFile(array $spec): UploadedFile |
| 65 | 65 | { |
| 66 | - if (! isset($spec['tmp_name']) || ! isset($spec['size']) || ! isset($spec['error'])) { |
|
| 66 | + if (!isset($spec['tmp_name']) || !isset($spec['size']) || !isset($spec['error'])) { |
|
| 67 | 67 | throw new InvalidArgumentException(sprintf( |
| 68 | 68 | '$spec fourni à %s DOIT contenir chacune des clés "tmp_name", "size", et "error" ; une ou plusieurs étaient manquantes', |
| 69 | 69 | __FUNCTION__ |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return list<array>|list<UploadedFile> |
| 105 | 105 | */ |
| 106 | - $recursiveNormalize = static function ( |
|
| 106 | + $recursiveNormalize = static function( |
|
| 107 | 107 | array $tmpNameTree, |
| 108 | 108 | array $sizeTree, |
| 109 | 109 | array $errorTree, |
| 110 | 110 | ?array $nameTree = null, |
| 111 | 111 | ?array $typeTree = null |
| 112 | - ) use (&$recursiveNormalize): array { |
|
| 112 | + ) use (&$recursiveNormalize) : array { |
|
| 113 | 113 | $normalized = []; |
| 114 | 114 | |
| 115 | 115 | foreach ($tmpNameTree as $key => $value) { |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return list<UploadedFile> |
| 149 | 149 | */ |
| 150 | - $normalizeUploadedFileSpecification = static function (array $files = []) use (&$recursiveNormalize): array { |
|
| 150 | + $normalizeUploadedFileSpecification = static function(array $files = []) use (&$recursiveNormalize): array { |
|
| 151 | 151 | if ( |
| 152 | - ! isset($files['tmp_name']) || ! is_array($files['tmp_name']) |
|
| 153 | - || ! isset($files['size']) || ! is_array($files['size']) |
|
| 154 | - || ! isset($files['error']) || ! is_array($files['error']) |
|
| 152 | + !isset($files['tmp_name']) || !is_array($files['tmp_name']) |
|
| 153 | + || !isset($files['size']) || !is_array($files['size']) |
|
| 154 | + || !isset($files['error']) || !is_array($files['error']) |
|
| 155 | 155 | ) { |
| 156 | 156 | throw new InvalidArgumentException(sprintf( |
| 157 | 157 | 'Les fichiers fournis à %s DOIVENT contenir chacune des clés "tmp_name", "size" et "error", |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | return $models; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if (! self::isLoaded('models', $model)) { |
|
| 72 | + if (!self::isLoaded('models', $model)) { |
|
| 73 | 73 | self::loaded('models', $model, FileLocator::model($model, $connection)); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | private static function isLoaded(string $module, string $element): bool |
| 83 | 83 | { |
| 84 | - if (! isset(self::$loads[$module]) || ! is_array(self::$loads[$module])) { |
|
| 84 | + if (!isset(self::$loads[$module]) || !is_array(self::$loads[$module])) { |
|
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -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): string { |
|
| 283 | + static function($matchedPatterns) use ($loader): string { |
|
| 284 | 284 | $nestedVariable = $loader->getVariable($matchedPatterns[1]); |
| 285 | 285 | |
| 286 | 286 | if (null === $nestedVariable) { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $file = $this->viewPath . $view; |
| 99 | 99 | |
| 100 | - if (! is_file($file)) { |
|
| 100 | + if (!is_file($file)) { |
|
| 101 | 101 | $fileOrig = $file; |
| 102 | 102 | $file = ($this->locator ?: Services::locator())->locateFile($view, 'Views'); |
| 103 | 103 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | foreach ($matches as $match) { |
| 282 | 282 | // Loop over each piece of $data, replacing |
| 283 | 283 | // its contents so that we know what to replace in parse() |
| 284 | - $str = ''; // holds the new contents for this tag pair. |
|
| 284 | + $str = ''; // holds the new contents for this tag pair. |
|
| 285 | 285 | |
| 286 | 286 | foreach ($data as $row) { |
| 287 | 287 | // Objects that have a `toArray()` method should be |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | // Now replace our placeholders with the new content. |
| 325 | 325 | foreach ($temp as $pattern => $content) { |
| 326 | - $out = $this->replaceSingle($pattern, $content, $out, ! isset($pairs[$pattern])); |
|
| 326 | + $out = $this->replaceSingle($pattern, $content, $out, !isset($pairs[$pattern])); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $str .= $out; |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | protected function replaceSingle(array|string $pattern, string $content, string $template, bool $escape = false): string |
| 482 | 482 | { |
| 483 | 483 | // Replace the content in the template |
| 484 | - return preg_replace_callback($pattern, function ($matches) use ($content, $escape): string { |
|
| 484 | + return preg_replace_callback($pattern, function($matches) use ($content, $escape): string { |
|
| 485 | 485 | // Check for {! !} syntax to not escape this one. |
| 486 | 486 | if ( |
| 487 | 487 | str_starts_with($matches[0], $this->leftDelimiter . '!') |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | // Our regex earlier will leave all chained values on a single line |
| 505 | 505 | // so we need to break them apart so we can apply them all. |
| 506 | - $filters = ! empty($matches[1]) ? explode('|', $matches[1]) : []; |
|
| 506 | + $filters = !empty($matches[1]) ? explode('|', $matches[1]) : []; |
|
| 507 | 507 | |
| 508 | 508 | if ($escape && $filters === [] && ($context = $this->shouldAddEscaping($orig))) { |
| 509 | 509 | $filters[] = "esc({$context})"; |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | // No pipes, then we know we need to escape |
| 534 | - elseif (! str_contains($key, '|')) { |
|
| 534 | + elseif (!str_contains($key, '|')) { |
|
| 535 | 535 | $escape = 'html'; |
| 536 | 536 | } |
| 537 | 537 | // If there's a `noescape` then we're definitely false. |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $escape = false; |
| 540 | 540 | } |
| 541 | 541 | // If no `esc` filter is found, then we'll need to add one. |
| 542 | - elseif (! preg_match('/\s+esc/u', $key)) { |
|
| 542 | + elseif (!preg_match('/\s+esc/u', $key)) { |
|
| 543 | 543 | $escape = 'html'; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | $filter = $param !== [] ? trim(strtolower(substr($filter, 0, strpos($filter, '(')))) : trim($filter); |
| 577 | 577 | |
| 578 | 578 | $this->config['filters'] ??= []; |
| 579 | - if (! array_key_exists($filter, $this->config['filters'])) { |
|
| 579 | + if (!array_key_exists($filter, $this->config['filters'])) { |
|
| 580 | 580 | continue; |
| 581 | 581 | } |
| 582 | 582 | |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | * $matches[1] = all parameters string in opening tag |
| 614 | 614 | * $matches[2] = content between the tags to send to the plugin. |
| 615 | 615 | */ |
| 616 | - if (! preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) { |
|
| 616 | + if (!preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) { |
|
| 617 | 617 | continue; |
| 618 | 618 | } |
| 619 | 619 | |
@@ -84,14 +84,14 @@ |
||
| 84 | 84 | $command = is_string($command) ? $command : 'command:name'; |
| 85 | 85 | $type = is_string($type) ? $type : 'basic'; |
| 86 | 86 | |
| 87 | - if (! in_array($type, ['basic', 'generator'], true)) { |
|
| 87 | + if (!in_array($type, ['basic', 'generator'], true)) { |
|
| 88 | 88 | // @codeCoverageIgnoreStart |
| 89 | 89 | $type = $this->choice(lang('CLI.generator.commandType'), ['basic', 'generator'], 'basic'); |
| 90 | 90 | $this->eol(); |
| 91 | 91 | // @codeCoverageIgnoreEnd |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if (! is_string($group)) { |
|
| 94 | + if (!is_string($group)) { |
|
| 95 | 95 | $group = $type === 'generator' ? config('app.name', 'App') . ':Generateurs' : config('app.name', 'App'); |
| 96 | 96 | } |
| 97 | 97 | |