@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function exists(string $key): bool |
57 | 57 | { |
58 | - if (! $this->configurator->exists($key)) { |
|
58 | + if (!$this->configurator->exists($key)) { |
|
59 | 59 | $config = explode('.', $key); |
60 | 60 | $this->load($config[0]); |
61 | 61 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function missing(string $key): bool |
80 | 80 | { |
81 | - return ! $this->exists($key); |
|
81 | + return !$this->exists($key); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | if (is_array($config)) { |
122 | 122 | foreach ($config as $key => $value) { |
123 | - if (! is_string($value) || empty($value)) { |
|
123 | + if (!is_string($value) || empty($value)) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | if (is_string($key)) { |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | } |
133 | 133 | self::load($conf, $file); |
134 | 134 | } |
135 | - } elseif (is_string($config) && ! isset(self::$loaded[$config])) { |
|
135 | + } elseif (is_string($config) && !isset(self::$loaded[$config])) { |
|
136 | 136 | if (empty($file)) { |
137 | 137 | $file = self::path($config); |
138 | 138 | } |
139 | 139 | |
140 | 140 | $configurations = []; |
141 | - if (file_exists($file) && ! in_array($file, get_included_files(), true)) { |
|
141 | + if (file_exists($file) && !in_array($file, get_included_files(), true)) { |
|
142 | 142 | $configurations = (array) require $file; |
143 | 143 | } |
144 | 144 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | if (is_array($accepts_values)) { |
167 | 167 | $accepts_values = '(Accept values: ' . implode('/', $accepts_values) . ')'; |
168 | - } elseif (! is_string($accepts_values)) { |
|
168 | + } elseif (!is_string($accepts_values)) { |
|
169 | 169 | throw new InvalidArgumentException('Misuse of the method ' . __METHOD__); |
170 | 170 | } |
171 | 171 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $schema = require $app_schema; |
208 | 208 | } |
209 | 209 | |
210 | - if (empty($schema) || ! ($schema instanceof Schema)) { |
|
210 | + if (empty($schema) || !($schema instanceof Schema)) { |
|
211 | 211 | $schema = Expect::mixed(); |
212 | 212 | } |
213 | 213 | |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | $class = new ReflectionClass($classname); |
256 | - $methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC); |
|
256 | + $methods = $class->getMethods(ReflectionMethod::IS_STATIC|ReflectionMethod::IS_PUBLIC); |
|
257 | 257 | |
258 | 258 | foreach ($methods as $method) { |
259 | - if (! ($method->isPublic() && $method->isStatic())) { |
|
259 | + if (!($method->isPublic() && $method->isStatic())) { |
|
260 | 260 | continue; |
261 | 261 | } |
262 | 262 | |
263 | - if (! is_array($result = $method->invoke(null))) { |
|
263 | + if (!is_array($result = $method->invoke(null))) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | { |
330 | 330 | $config = $this->get('app.show_debugbar', 'auto'); |
331 | 331 | |
332 | - if (! in_array($config, ['auto', true, false], true)) { |
|
332 | + if (!in_array($config, ['auto', true, false], true)) { |
|
333 | 333 | self::exceptBadConfigValue('show_debugbar', ['auto', true, false], 'app'); |
334 | 334 | } |
335 | 335 | |
336 | 336 | if ($config === 'auto') { |
337 | - $this->set('app.show_debugbar', ! is_online()); |
|
337 | + $this->set('app.show_debugbar', !is_online()); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | // Incluez le fichier routesFile s'il n'existe pas. |
264 | 264 | // Ne conserver que pour les fins BC pour l'instant. |
265 | 265 | $routeFiles = $this->routeFiles; |
266 | - if (! in_array($routesFile, $routeFiles, true)) { |
|
266 | + if (!in_array($routesFile, $routeFiles, true)) { |
|
267 | 267 | $routeFiles[] = $routesFile; |
268 | 268 | } |
269 | 269 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $routes = $this; |
272 | 272 | |
273 | 273 | foreach ($routeFiles as $routesFile) { |
274 | - if (! is_file($routesFile)) { |
|
274 | + if (!is_file($routesFile)) { |
|
275 | 275 | logger()->warning(sprintf('Fichier de route introuvable : "%s"', $routesFile)); |
276 | 276 | |
277 | 277 | continue; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function placeholder(array|string $placeholder, ?string $pattern = null): self |
322 | 322 | { |
323 | - if (! is_array($placeholder)) { |
|
323 | + if (!is_array($placeholder)) { |
|
324 | 324 | $placeholder = [$placeholder => $pattern]; |
325 | 325 | } |
326 | 326 | |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | * |
1023 | 1023 | * @param array|Closure|string $to |
1024 | 1024 | */ |
1025 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
1025 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
1026 | 1026 | { |
1027 | 1027 | if (empty($from) || empty($to)) { |
1028 | 1028 | throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.'); |
@@ -1211,7 +1211,7 @@ discard block |
||
1211 | 1211 | $from = $route['from']; |
1212 | 1212 | |
1213 | 1213 | // on ignore les closures |
1214 | - if (! is_string($to)) { |
|
1214 | + if (!is_string($to)) { |
|
1215 | 1215 | continue; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | |
1223 | 1223 | // S'il y a une chance de correspondance, alors ce sera |
1224 | 1224 | // soit avec $search au début de la chaîne $to. |
1225 | - if (! str_starts_with($to, $search)) { |
|
1225 | + if (!str_starts_with($to, $search)) { |
|
1226 | 1226 | continue; |
1227 | 1227 | } |
1228 | 1228 | |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | |
1299 | 1299 | // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés. |
1300 | 1300 | foreach ($matches[0] as $index => $placeholder) { |
1301 | - if (! isset($params[$index])) { |
|
1301 | + if (!isset($params[$index])) { |
|
1302 | 1302 | throw new InvalidArgumentException( |
1303 | 1303 | 'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".' |
1304 | 1304 | ); |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex. |
1310 | 1310 | $pattern = $this->placeholders[$placeholderName] ?? $placeholder; |
1311 | 1311 | |
1312 | - if (! preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1312 | + if (!preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1313 | 1313 | throw RouterException::invalidParameterType(); |
1314 | 1314 | } |
1315 | 1315 | |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | $from = trim($from, '/'); |
1367 | 1367 | } |
1368 | 1368 | |
1369 | - if (is_string($to) && ! str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
1369 | + if (is_string($to) && !str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
1370 | 1370 | $to = [$to, '__invoke']; |
1371 | 1371 | } |
1372 | 1372 | |
@@ -1378,7 +1378,7 @@ discard block |
||
1378 | 1378 | $options = array_merge($this->currentOptions ?? [], $options ?? []); |
1379 | 1379 | |
1380 | 1380 | if (isset($options['middleware'])) { |
1381 | - if (! isset($options['middlewares'])) { |
|
1381 | + if (!isset($options['middlewares'])) { |
|
1382 | 1382 | $options['middlewares'] = (array) $options['middleware']; |
1383 | 1383 | } |
1384 | 1384 | unset($options['middleware']); |
@@ -1399,9 +1399,9 @@ discard block |
||
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | // Limitation du nom d'hôte ? |
1402 | - if (! empty($options['hostname'])) { |
|
1402 | + if (!empty($options['hostname'])) { |
|
1403 | 1403 | // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ? |
1404 | - if (! $this->checkHostname($options['hostname'])) { |
|
1404 | + if (!$this->checkHostname($options['hostname'])) { |
|
1405 | 1405 | return; |
1406 | 1406 | } |
1407 | 1407 | |
@@ -1409,10 +1409,10 @@ discard block |
||
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | // Limitation du nom sous-domaine ? |
1412 | - elseif (! empty($options['subdomain'])) { |
|
1412 | + elseif (!empty($options['subdomain'])) { |
|
1413 | 1413 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
1414 | 1414 | // nous n'avons pas besoin d'ajouter la route. |
1415 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
1415 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
1416 | 1416 | return; |
1417 | 1417 | } |
1418 | 1418 | |
@@ -1445,9 +1445,9 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | // S'il s'agit d'une redirection, aucun traitement |
1448 | - if (! isset($options['redirect']) && is_string($to)) { |
|
1448 | + if (!isset($options['redirect']) && is_string($to)) { |
|
1449 | 1449 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
1450 | - if (! str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
1450 | + if (!str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
1451 | 1451 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
1452 | 1452 | $to = trim($namespace, '\\') . '\\' . $to; |
1453 | 1453 | } |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
1465 | 1465 | // pour tenter de router la requête. |
1466 | 1466 | $routeKeyExists = isset($this->routes[$verb][$routeKey]); |
1467 | - if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) { |
|
1467 | + if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) { |
|
1468 | 1468 | return; |
1469 | 1469 | } |
1470 | 1470 | |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | private function checkHostname(string $hostname): bool |
1491 | 1491 | { |
1492 | 1492 | // Les appels CLI ne peuvent pas être sur le nom d'hôte. |
1493 | - if (! isset($this->httpHost) || is_cli()) { |
|
1493 | + if (!isset($this->httpHost) || is_cli()) { |
|
1494 | 1494 | return false; |
1495 | 1495 | } |
1496 | 1496 | |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | private function checkSubdomains($subdomains): bool |
1507 | 1507 | { |
1508 | 1508 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
1509 | - if (! isset($this->httpHost)) { |
|
1509 | + if (!isset($this->httpHost)) { |
|
1510 | 1510 | return false; |
1511 | 1511 | } |
1512 | 1512 | |
@@ -1514,13 +1514,13 @@ discard block |
||
1514 | 1514 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
1515 | 1515 | } |
1516 | 1516 | |
1517 | - if (! is_array($subdomains)) { |
|
1517 | + if (!is_array($subdomains)) { |
|
1518 | 1518 | $subdomains = [$subdomains]; |
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
1522 | 1522 | // il nécessite la présence d'un sous-domaine. |
1523 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1523 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1524 | 1524 | return true; |
1525 | 1525 | } |
1526 | 1526 | |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | // sur l'URL sinon parse_url sera mal interprété |
1543 | 1543 | // 'hôte' comme 'chemin'. |
1544 | 1544 | $url = $this->httpHost; |
1545 | - if (! str_starts_with($url, 'http')) { |
|
1545 | + if (!str_starts_with($url, 'http')) { |
|
1546 | 1546 | $url = 'http://' . $url; |
1547 | 1547 | } |
1548 | 1548 | |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | |
1584 | 1584 | private function getControllerName(Closure|string $handler): ?string |
1585 | 1585 | { |
1586 | - if (! is_string($handler)) { |
|
1586 | + if (!is_string($handler)) { |
|
1587 | 1587 | return null; |
1588 | 1588 | } |
1589 | 1589 | |
@@ -1642,13 +1642,13 @@ discard block |
||
1642 | 1642 | */ |
1643 | 1643 | private function replaceLocale(string $route, ?string $locale = null): string |
1644 | 1644 | { |
1645 | - if (! str_contains($route, '{locale}')) { |
|
1645 | + if (!str_contains($route, '{locale}')) { |
|
1646 | 1646 | return $route; |
1647 | 1647 | } |
1648 | 1648 | |
1649 | 1649 | // Vérifier les paramètres régionaux non valides |
1650 | 1650 | if ($locale !== null) { |
1651 | - if (! in_array($locale, config('app.supported_locales'), true)) { |
|
1651 | + if (!in_array($locale, config('app.supported_locales'), true)) { |
|
1652 | 1652 | $locale = null; |
1653 | 1653 | } |
1654 | 1654 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | helper('assets'); |
72 | 72 | |
73 | - if (! empty($viewPathLocator)) { |
|
73 | + if (!empty($viewPathLocator)) { |
|
74 | 74 | if (is_string($viewPathLocator)) { |
75 | 75 | $this->viewPath = rtrim($viewPathLocator, '\\/ ') . DS; |
76 | 76 | } elseif ($viewPathLocator instanceof LocatorInterface) { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $options = (array) $options; |
236 | 236 | |
237 | 237 | $viewPath = $options['viewPath'] ?? $this->viewPath; |
238 | - if (! empty($viewPath)) { |
|
238 | + if (!empty($viewPath)) { |
|
239 | 239 | $file = str_replace('/', DS, rtrim($viewPath, '/\\') . DS . ltrim($view, '/\\')); |
240 | 240 | } else { |
241 | 241 | $file = $view; |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | |
244 | 244 | $file = Helpers::ensureExt($file, $ext); |
245 | 245 | |
246 | - if (! is_file($file) && $this->locator instanceof LocatorInterface) { |
|
246 | + if (!is_file($file) && $this->locator instanceof LocatorInterface) { |
|
247 | 247 | $file = $this->locator->locateFile($view, 'Views', empty($ext) ? 'php' : $ext); |
248 | 248 | } |
249 | 249 | |
250 | 250 | $file = realpath($file); |
251 | 251 | |
252 | 252 | // locateFile renverra une chaîne vide si le fichier est introuvable. |
253 | - if (! is_file($file)) { |
|
253 | + if (!is_file($file)) { |
|
254 | 254 | throw ViewException::invalidFile($view); |
255 | 255 | } |
256 | 256 |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | foreach ($files as $file) { |
191 | 191 | $className = $locator->findQualifiedNameFromPath($file); |
192 | 192 | |
193 | - if ($className === false || ! class_exists($className)) { |
|
193 | + if ($className === false || !class_exists($className)) { |
|
194 | 194 | continue; |
195 | 195 | } |
196 | 196 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $class = new ReflectionClass($className); |
217 | 217 | $logger = $logger ?: Services::logger(); |
218 | 218 | |
219 | - if (! $class->isInstantiable() || ! $class->isSubclassOf(Command::class)) { |
|
219 | + if (!$class->isInstantiable() || !$class->isSubclassOf(Command::class)) { |
|
220 | 220 | throw CLIException::invalidCommand($className); |
221 | 221 | } |
222 | 222 | |
@@ -243,13 +243,13 @@ discard block |
||
243 | 243 | $value = (array) $value; |
244 | 244 | |
245 | 245 | $description = $value[0]; |
246 | - if (! is_string($description)) { |
|
246 | + if (!is_string($description)) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | 250 | $default = $value[1] ?? null; |
251 | 251 | $filter = $value[2] ?? null; |
252 | - if ($filter !== null && ! is_callable($filter)) { |
|
252 | + if ($filter !== null && !is_callable($filter)) { |
|
253 | 253 | $filter = null; |
254 | 254 | } |
255 | 255 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $value = (array) $value; |
262 | 262 | |
263 | 263 | $description = $value[0]; |
264 | - if (! is_string($description)) { |
|
264 | + if (!is_string($description)) { |
|
265 | 265 | continue; |
266 | 266 | } |
267 | 267 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | $console = $this; |
274 | - $action = static function (?array $arguments = [], ?array $options = [], ?bool $suppress = null) use ($instance, $command, $console) { |
|
274 | + $action = static function(?array $arguments = [], ?array $options = [], ?bool $suppress = null) use ($instance, $command, $console) { |
|
275 | 275 | foreach ($instance->required as $package) { |
276 | 276 | $package = explode(':', $package); |
277 | 277 | $version = $package[1] ?? null; |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | /** @var \Ahc\Cli\IO\Interactor $io */ |
281 | 281 | $io = $console->io(); |
282 | 282 | |
283 | - if (! InstalledVersions::isInstalled($package)) { |
|
283 | + if (!InstalledVersions::isInstalled($package)) { |
|
284 | 284 | $io->info('Cette commande nécessite le package "' . $package . '" mais vous ne l\'avez pas', true); |
285 | - if (! $io->confirm('Voulez-vous l\'installer maintenant ?')) { |
|
285 | + if (!$io->confirm('Voulez-vous l\'installer maintenant ?')) { |
|
286 | 286 | return; |
287 | 287 | } |
288 | 288 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | $suppress = $suppress ?: $console->suppress; |
301 | - if (! $suppress) { |
|
301 | + if (!$suppress) { |
|
302 | 302 | $console->start($instance->service); |
303 | 303 | } |
304 | 304 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | $result = $instance->setOptions($options)->setArguments($arguments)->execute($parameters); |
315 | 315 | |
316 | - if (! $suppress) { |
|
316 | + if (!$suppress) { |
|
317 | 317 | $console->end(); |
318 | 318 | } |
319 | 319 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | private function registerException(Logger $logger) |
330 | 330 | { |
331 | - $this->onException(static function (Throwable $e, int $exitCode) use ($logger) { |
|
331 | + $this->onException(static function(Throwable $e, int $exitCode) use ($logger) { |
|
332 | 332 | $logger->error((string) $e, ['exitCode' => $exitCode, 'klinge' => true]); |
333 | 333 | |
334 | 334 | throw new CLIException($e->getMessage(), $exitCode, $e); |