@@ -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))); |
@@ -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 | |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @param array|Closure|string $to |
1025 | 1025 | */ |
1026 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
1026 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
1027 | 1027 | { |
1028 | 1028 | if (empty($from) || empty($to)) { |
1029 | 1029 | throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.'); |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | $from = $route['from']; |
1215 | 1215 | |
1216 | 1216 | // on ignore les closures |
1217 | - if (! is_string($to)) { |
|
1217 | + if (!is_string($to)) { |
|
1218 | 1218 | continue; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | |
1226 | 1226 | // S'il y a une chance de correspondance, alors ce sera |
1227 | 1227 | // soit avec $search au début de la chaîne $to. |
1228 | - if (! str_starts_with($to, $search)) { |
|
1228 | + if (!str_starts_with($to, $search)) { |
|
1229 | 1229 | continue; |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | |
1302 | 1302 | // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés. |
1303 | 1303 | foreach ($matches[0] as $index => $placeholder) { |
1304 | - if (! isset($params[$index])) { |
|
1304 | + if (!isset($params[$index])) { |
|
1305 | 1305 | throw new InvalidArgumentException( |
1306 | 1306 | 'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".' |
1307 | 1307 | ); |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex. |
1313 | 1313 | $pattern = $this->placeholders[$placeholderName] ?? $placeholder; |
1314 | 1314 | |
1315 | - if (! preg_match('#^' . $pattern . '$#u', (string) $params[$index])) { |
|
1315 | + if (!preg_match('#^' . $pattern . '$#u', (string) $params[$index])) { |
|
1316 | 1316 | throw RouterException::invalidParameterType(); |
1317 | 1317 | } |
1318 | 1318 | |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | $from = trim($from, '/'); |
1370 | 1370 | } |
1371 | 1371 | |
1372 | - if (is_string($to) && ! str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
1372 | + if (is_string($to) && !str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
1373 | 1373 | $to = [$to, '__invoke']; |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | $options = array_merge($this->currentOptions ?? [], $options ?? []); |
1382 | 1382 | |
1383 | 1383 | if (isset($options['middleware'])) { |
1384 | - if (! isset($options['middlewares'])) { |
|
1384 | + if (!isset($options['middlewares'])) { |
|
1385 | 1385 | $options['middlewares'] = (array) $options['middleware']; |
1386 | 1386 | } |
1387 | 1387 | unset($options['middleware']); |
@@ -1402,9 +1402,9 @@ discard block |
||
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | // Limitation du nom d'hôte ? |
1405 | - if (! empty($options['hostname'])) { |
|
1405 | + if (!empty($options['hostname'])) { |
|
1406 | 1406 | // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ? |
1407 | - if (! $this->checkHostname($options['hostname'])) { |
|
1407 | + if (!$this->checkHostname($options['hostname'])) { |
|
1408 | 1408 | return; |
1409 | 1409 | } |
1410 | 1410 | |
@@ -1412,10 +1412,10 @@ discard block |
||
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | // Limitation du nom sous-domaine ? |
1415 | - elseif (! empty($options['subdomain'])) { |
|
1415 | + elseif (!empty($options['subdomain'])) { |
|
1416 | 1416 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
1417 | 1417 | // nous n'avons pas besoin d'ajouter la route. |
1418 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
1418 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
1419 | 1419 | return; |
1420 | 1420 | } |
1421 | 1421 | |
@@ -1448,9 +1448,9 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | // S'il s'agit d'une redirection, aucun traitement |
1451 | - if (! isset($options['redirect']) && is_string($to)) { |
|
1451 | + if (!isset($options['redirect']) && is_string($to)) { |
|
1452 | 1452 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
1453 | - if (! str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
1453 | + if (!str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
1454 | 1454 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
1455 | 1455 | $to = trim($namespace, '\\') . '\\' . $to; |
1456 | 1456 | } |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
1468 | 1468 | // pour tenter de router la requête. |
1469 | 1469 | $routeKeyExists = isset($this->routes[$verb][$routeKey]); |
1470 | - if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) { |
|
1470 | + if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) { |
|
1471 | 1471 | return; |
1472 | 1472 | } |
1473 | 1473 | |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | private function checkHostname(string $hostname): bool |
1494 | 1494 | { |
1495 | 1495 | // Les appels CLI ne peuvent pas être sur le nom d'hôte. |
1496 | - if (! isset($this->httpHost)) { |
|
1496 | + if (!isset($this->httpHost)) { |
|
1497 | 1497 | return false; |
1498 | 1498 | } |
1499 | 1499 | |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | private function checkSubdomains($subdomains): bool |
1510 | 1510 | { |
1511 | 1511 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
1512 | - if (! isset($this->httpHost)) { |
|
1512 | + if (!isset($this->httpHost)) { |
|
1513 | 1513 | return false; |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1517,13 +1517,13 @@ discard block |
||
1517 | 1517 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
1518 | 1518 | } |
1519 | 1519 | |
1520 | - if (! is_array($subdomains)) { |
|
1520 | + if (!is_array($subdomains)) { |
|
1521 | 1521 | $subdomains = [$subdomains]; |
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
1525 | 1525 | // il nécessite la présence d'un sous-domaine. |
1526 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1526 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1527 | 1527 | return true; |
1528 | 1528 | } |
1529 | 1529 | |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | // sur l'URL sinon parse_url sera mal interprété |
1546 | 1546 | // 'hôte' comme 'chemin'. |
1547 | 1547 | $url = $this->httpHost; |
1548 | - if (! str_starts_with($url, 'http')) { |
|
1548 | + if (!str_starts_with($url, 'http')) { |
|
1549 | 1549 | $url = 'http://' . $url; |
1550 | 1550 | } |
1551 | 1551 | |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | |
1587 | 1587 | private function getControllerName(Closure|string $handler): ?string |
1588 | 1588 | { |
1589 | - if (! is_string($handler)) { |
|
1589 | + if (!is_string($handler)) { |
|
1590 | 1590 | return null; |
1591 | 1591 | } |
1592 | 1592 | |
@@ -1645,13 +1645,13 @@ discard block |
||
1645 | 1645 | */ |
1646 | 1646 | private function replaceLocale(string $route, ?string $locale = null): string |
1647 | 1647 | { |
1648 | - if (! str_contains($route, '{locale}')) { |
|
1648 | + if (!str_contains($route, '{locale}')) { |
|
1649 | 1649 | return $route; |
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | // Vérifier les paramètres régionaux non valides |
1653 | 1653 | if ($locale !== null) { |
1654 | - if (! in_array($locale, config('app.supported_locales'), true)) { |
|
1654 | + if (!in_array($locale, config('app.supported_locales'), true)) { |
|
1655 | 1655 | $locale = null; |
1656 | 1656 | } |
1657 | 1657 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $controller = $routes->getDefaultController(); |
176 | 176 | } |
177 | 177 | |
178 | - if (! $fullName && is_string($controller)) { |
|
178 | + if (!$fullName && is_string($controller)) { |
|
179 | 179 | $controller = str_replace($routes->getDefaultNamespace(), '', $controller); |
180 | 180 | } |
181 | 181 | |
@@ -301,14 +301,14 @@ discard block |
||
301 | 301 | return; |
302 | 302 | } |
303 | 303 | |
304 | - if (is_cli() && ! on_test()) { |
|
304 | + if (is_cli() && !on_test()) { |
|
305 | 305 | // @codeCoverageIgnoreStart |
306 | 306 | // $this->request = Services::clirequest($this->config); |
307 | 307 | // @codeCoverageIgnoreEnd |
308 | 308 | } |
309 | 309 | |
310 | 310 | $version = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1'; |
311 | - if (! is_numeric($version)) { |
|
311 | + if (!is_numeric($version)) { |
|
312 | 312 | $version = substr($version, strpos($version, '/') + 1); |
313 | 313 | } |
314 | 314 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | // Supposons le succès jusqu'à preuve du contraire. |
328 | 328 | $this->response = Services::response()->withStatus(200); |
329 | 329 | |
330 | - if (! is_cli() || on_test()) { |
|
330 | + if (!is_cli() || on_test()) { |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | $this->response = $this->response->withProtocolVersion($this->request->getProtocolVersion()); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | } |
425 | 425 | |
426 | 426 | // Essayez de charger automatiquement la classe |
427 | - if (! class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
427 | + if (!class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
428 | 428 | throw PageNotFoundException::controllerNotFound($this->controller, $this->method); |
429 | 429 | } |
430 | 430 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | |
514 | 514 | $this->outputBufferingEnd(); |
515 | 515 | |
516 | - throw PageNotFoundException::pageNotFound(! on_prod() || is_cli() ? $e->getMessage() : ''); |
|
516 | + throw PageNotFoundException::pageNotFound(!on_prod() || is_cli() ? $e->getMessage() : ''); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | public function storePreviousURL($uri) |
556 | 556 | { |
557 | 557 | // Ignorer les requêtes CLI |
558 | - if (is_cli() && ! on_test()) { |
|
558 | + if (is_cli() && !on_test()) { |
|
559 | 559 | return; // @codeCoverageIgnore |
560 | 560 | } |
561 | 561 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | // Ignorer les reponses non-HTML |
568 | - if (! str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) { |
|
568 | + if (!str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) { |
|
569 | 569 | return; |
570 | 570 | } |
571 | 571 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | */ |
590 | 590 | protected function sendResponse() |
591 | 591 | { |
592 | - if (! ($this->request->expectsJson() || $this->request->isJson() || Text::contains($this->response->getType(), ['/json', '+json']))) { |
|
592 | + if (!($this->request->expectsJson() || $this->request->isJson() || Text::contains($this->response->getType(), ['/json', '+json']))) { |
|
593 | 593 | $this->response = Services::toolbar()->prepare( |
594 | 594 | $this->getPerformanceStats(), |
595 | 595 | $this->request, |
@@ -682,11 +682,11 @@ discard block |
||
682 | 682 | */ |
683 | 683 | private function spoofRequestMethod(): callable |
684 | 684 | { |
685 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
685 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
686 | 686 | $post = $request->getParsedBody(); |
687 | 687 | |
688 | 688 | // Ne fonctionne qu'avec les formulaires POST |
689 | - if ($request->getMethod() === 'POST' && ! empty($post['_method'])) { |
|
689 | + if ($request->getMethod() === 'POST' && !empty($post['_method'])) { |
|
690 | 690 | // Accepte seulement PUT, PATCH, DELETE |
691 | 691 | if (in_array($post['_method'], ['PUT', 'PATCH', 'DELETE'], true)) { |
692 | 692 | $request = $request->withMethod($post['_method']); |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | private function bootApp(): callable |
701 | 701 | { |
702 | - return function (ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
|
702 | + return function(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
|
703 | 703 | Services::set(Request::class, $request); |
704 | 704 | Services::set(Response::class, $response); |
705 | 705 | |
@@ -707,10 +707,10 @@ discard block |
||
707 | 707 | $returned = $this->startController(); |
708 | 708 | |
709 | 709 | // Les controleur sous forme de Closure sont executes dans startController(). |
710 | - if (! is_callable($this->controller)) { |
|
710 | + if (!is_callable($this->controller)) { |
|
711 | 711 | $controller = $this->createController($request, $response); |
712 | 712 | |
713 | - if (! method_exists($controller, '_remap') && ! is_callable([$controller, $this->method], false)) { |
|
713 | + if (!method_exists($controller, '_remap') && !is_callable([$controller, $this->method], false)) { |
|
714 | 714 | throw PageNotFoundException::methodNotFound($this->method); |
715 | 715 | } |
716 | 716 |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | $this->_streamMode = $options['streamMode'] ?? $this->_streamMode; |
460 | 460 | |
461 | 461 | if (isset($options['stream'])) { |
462 | - if (! $options['stream'] instanceof StreamInterface) { |
|
462 | + if (!$options['stream'] instanceof StreamInterface) { |
|
463 | 463 | throw new InvalidArgumentException('Stream option must be an object that implements StreamInterface'); |
464 | 464 | } |
465 | 465 | $this->stream = $options['stream']; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $this->_setStatus($options['status']); |
476 | 476 | } |
477 | 477 | |
478 | - if (! isset($options['charset'])) { |
|
478 | + if (!isset($options['charset'])) { |
|
479 | 479 | $options['charset'] = config('app.charset'); |
480 | 480 | } |
481 | 481 | $this->_charset = $options['charset']; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $charset = true; |
524 | 524 | } |
525 | 525 | |
526 | - if ($charset && ! str_contains($type, ';')) { |
|
526 | + if ($charset && !str_contains($type, ';')) { |
|
527 | 527 | $this->_setHeader('Content-Type', "{$type}; charset={$this->_charset}"); |
528 | 528 | } else { |
529 | 529 | $this->_setHeader('Content-Type', $type); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | protected function _clearHeader(string $header): void |
604 | 604 | { |
605 | 605 | $normalized = strtolower($header); |
606 | - if (! isset($this->headerNames[$normalized])) { |
|
606 | + if (!isset($this->headerNames[$normalized])) { |
|
607 | 607 | return; |
608 | 608 | } |
609 | 609 | $original = $this->headerNames[$normalized]; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | throw HttpException::invalidStatusCode($code); |
671 | 671 | } |
672 | 672 | |
673 | - if (! array_key_exists($code, $this->_statusCodes) && empty($reasonPhrase)) { |
|
673 | + if (!array_key_exists($code, $this->_statusCodes) && empty($reasonPhrase)) { |
|
674 | 674 | throw HttPException::unkownStatusCode($code); |
675 | 675 | } |
676 | 676 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | if ($mapped) { |
764 | 764 | return is_array($mapped) ? current($mapped) : $mapped; |
765 | 765 | } |
766 | - if (! str_contains($contentType, '/')) { |
|
766 | + if (!str_contains($contentType, '/')) { |
|
767 | 767 | throw new InvalidArgumentException(sprintf('"%s" is an invalid content type.', $contentType)); |
768 | 768 | } |
769 | 769 | |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | */ |
847 | 847 | public function withCache($since, $time = '+1 day'): static |
848 | 848 | { |
849 | - if (! is_int($time)) { |
|
849 | + if (!is_int($time)) { |
|
850 | 850 | $time = strtotime($time); |
851 | 851 | if ($time === false) { |
852 | 852 | throw new InvalidArgumentException( |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | */ |
1315 | 1315 | public function getCookie(string $name): ?array |
1316 | 1316 | { |
1317 | - if (! $this->hasCookie($name)) { |
|
1317 | + if (!$this->hasCookie($name)) { |
|
1318 | 1318 | return null; |
1319 | 1319 | } |
1320 | 1320 | |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | */ |
1327 | 1327 | public function hasCookie(string $name, ?string $value = null): bool |
1328 | 1328 | { |
1329 | - if (! $this->_cookies->has($name)) { |
|
1329 | + if (!$this->_cookies->has($name)) { |
|
1330 | 1330 | return false; |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1403,7 +1403,7 @@ discard block |
||
1403 | 1403 | |
1404 | 1404 | $extension = strtolower($file->getExtension()); |
1405 | 1405 | $mapped = $this->getMimeType($extension); |
1406 | - if ((! $extension || ! $mapped) && $options['download'] === null) { |
|
1406 | + if ((!$extension || !$mapped) && $options['download'] === null) { |
|
1407 | 1407 | $options['download'] = true; |
1408 | 1408 | } |
1409 | 1409 | |
@@ -1465,12 +1465,12 @@ discard block |
||
1465 | 1465 | if (str_contains($path, '../') || str_contains($path, '..\\')) { |
1466 | 1466 | throw new LoadException('The requested file contains `..` and will not be read.'); |
1467 | 1467 | } |
1468 | - if (! is_file($path)) { |
|
1468 | + if (!is_file($path)) { |
|
1469 | 1469 | $path = APP_PATH . $path; |
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | $file = new SplFileInfo($path); |
1473 | - if (! $file->isFile() || ! $file->isReadable()) { |
|
1473 | + if (!$file->isFile() || !$file->isReadable()) { |
|
1474 | 1474 | if (on_dev()) { |
1475 | 1475 | throw new LoadException(sprintf('The requested file %s was not found or not readable', $path)); |
1476 | 1476 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function download(SplFileInfo|string $file, ?string $name = null, array $headers = []): static |
168 | 168 | { |
169 | - if (is_string($file) && ! is_file($file)) { |
|
169 | + if (is_string($file) && !is_file($file)) { |
|
170 | 170 | throw new LoadException('The requested file was not found'); |
171 | 171 | } |
172 | 172 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function streamDownload(callable|StreamInterface|string $stream, string $name, array $headers = []): static |
180 | 180 | { |
181 | - if (! ($stream instanceof StreamInterface)) { |
|
181 | + if (!($stream instanceof StreamInterface)) { |
|
182 | 182 | $stream = to_stream($stream); |
183 | 183 | } |
184 | 184 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | helper('assets'); |
80 | 80 | |
81 | - if (! empty($viewPathLocator)) { |
|
81 | + if (!empty($viewPathLocator)) { |
|
82 | 82 | if (is_string($viewPathLocator)) { |
83 | 83 | $this->viewPath = rtrim($viewPathLocator, '\\/ ') . DS; |
84 | 84 | } elseif ($viewPathLocator instanceof LocatorInterface) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - if (empty($this->locator) && ! is_dir($this->viewPath)) { |
|
89 | + if (empty($this->locator) && !is_dir($this->viewPath)) { |
|
90 | 90 | $this->viewPath = ''; |
91 | 91 | $this->locator = Services::locator(); |
92 | 92 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $ext ??= $this->ext; |
262 | 262 | |
263 | 263 | $viewPath = $options['viewPath'] ?? $this->viewPath; |
264 | - if (! empty($viewPath)) { |
|
264 | + if (!empty($viewPath)) { |
|
265 | 265 | $file = str_replace('/', DS, rtrim($viewPath, '/\\') . DS . ltrim($view, '/\\')); |
266 | 266 | } else { |
267 | 267 | $file = $view; |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | |
270 | 270 | $file = Helpers::ensureExt($file, $ext); |
271 | 271 | |
272 | - if (! is_file($file) && $this->locator instanceof LocatorInterface) { |
|
272 | + if (!is_file($file) && $this->locator instanceof LocatorInterface) { |
|
273 | 273 | $file = $this->locator->locateFile($view, 'Views', $ext); |
274 | 274 | } |
275 | 275 | |
276 | 276 | $file = realpath($file); |
277 | 277 | |
278 | 278 | // locateFile renverra une chaîne vide si le fichier est introuvable. |
279 | - if (! is_file($file)) { |
|
279 | + if (!is_file($file)) { |
|
280 | 280 | throw ViewException::invalidFile($view); |
281 | 281 | } |
282 | 282 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | $this->renderVars['file'] = $this->getRenderedFile($options, $this->renderVars['view'], $this->ext); |
67 | 67 | |
68 | - if (! empty($layout = $this->layout)) { |
|
68 | + if (!empty($layout = $this->layout)) { |
|
69 | 69 | if (empty(pathinfo($layout, PATHINFO_EXTENSION))) { |
70 | 70 | $layout .= '.' . $this->ext; |
71 | 71 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->engine->assign($this->data); |
76 | 76 | |
77 | 77 | // Doit-on mettre en cache? |
78 | - if (! empty($this->renderVars['options']['cache_name']) || ! empty($this->renderVars['options']['cache'])) { |
|
78 | + if (!empty($this->renderVars['options']['cache_name']) || !empty($this->renderVars['options']['cache'])) { |
|
79 | 79 | $this->enableCache(); |
80 | 80 | $this->engine->setCacheLifetime(60 * ($this->renderVars['options']['cache'] ?? 60)); |
81 | 81 | $this->engine->setCompileId($this->renderVars['options']['cache_name'] ?? null); |
@@ -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 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function setData(array $data = [], ?string $context = null): static |
173 | 173 | { |
174 | - if (! empty($context)) { |
|
174 | + if (!empty($context)) { |
|
175 | 175 | foreach ($data as $key => &$value) { |
176 | 176 | if (is_array($value)) { |
177 | 177 | foreach ($value as &$obj) { |
@@ -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 |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | if (is_array($val)) { |
304 | 304 | $pair = $this->parsePair($key, $val, $match[1]); |
305 | 305 | |
306 | - if (! empty($pair)) { |
|
306 | + if (!empty($pair)) { |
|
307 | 307 | $pairs[array_keys($pair)[0]] = true; |
308 | 308 | |
309 | 309 | $temp = array_merge($temp, $pair); |
@@ -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; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | $content = (string) $content; |
494 | 494 | |
495 | 495 | // Replace the content in the template |
496 | - return preg_replace_callback($pattern, function ($matches) use ($content, $escape) { |
|
496 | + return preg_replace_callback($pattern, function($matches) use ($content, $escape) { |
|
497 | 497 | // Check for {! !} syntax to not escape this one. |
498 | 498 | if ( |
499 | 499 | str_starts_with($matches[0], $this->leftDelimiter . '!') |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | |
516 | 516 | // Our regex earlier will leave all chained values on a single line |
517 | 517 | // so we need to break them apart so we can apply them all. |
518 | - $filters = ! empty($matches[1]) ? explode('|', $matches[1]) : []; |
|
518 | + $filters = !empty($matches[1]) ? explode('|', $matches[1]) : []; |
|
519 | 519 | |
520 | 520 | if ($escape && empty($filters) && ($context = $this->shouldAddEscaping($orig))) { |
521 | 521 | $filters[] = "esc({$context})"; |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | } |
544 | 544 | } |
545 | 545 | // No pipes, then we know we need to escape |
546 | - elseif (! str_contains($key, '|')) { |
|
546 | + elseif (!str_contains($key, '|')) { |
|
547 | 547 | $escape = 'html'; |
548 | 548 | } |
549 | 549 | // If there's a `noescape` then we're definitely false. |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $escape = false; |
552 | 552 | } |
553 | 553 | // If no `esc` filter is found, then we'll need to add one. |
554 | - elseif (! preg_match('/\s+esc/u', $key)) { |
|
554 | + elseif (!preg_match('/\s+esc/u', $key)) { |
|
555 | 555 | $escape = 'html'; |
556 | 556 | } |
557 | 557 | |
@@ -570,10 +570,10 @@ discard block |
||
570 | 570 | preg_match('/\([\w<>=\/\\\,:.\-\s\+]+\)/u', $filter, $param); |
571 | 571 | |
572 | 572 | // Remove the () and spaces to we have just the parameter left |
573 | - $param = ! empty($param) ? trim($param[0], '() ') : null; |
|
573 | + $param = !empty($param) ? trim($param[0], '() ') : null; |
|
574 | 574 | |
575 | 575 | // Params can be separated by commas to allow multiple parameters for the filter |
576 | - if (! empty($param)) { |
|
576 | + if (!empty($param)) { |
|
577 | 577 | $param = explode(',', $param); |
578 | 578 | |
579 | 579 | // Clean it up |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | } |
586 | 586 | |
587 | 587 | // Get our filter name |
588 | - $filter = ! empty($param) ? trim(strtolower(substr($filter, 0, strpos($filter, '(')))) : trim($filter); |
|
588 | + $filter = !empty($param) ? trim(strtolower(substr($filter, 0, strpos($filter, '(')))) : trim($filter); |
|
589 | 589 | |
590 | 590 | $this->config['filters'] ??= []; |
591 | - if (! array_key_exists($filter, $this->config['filters'])) { |
|
591 | + if (!array_key_exists($filter, $this->config['filters'])) { |
|
592 | 592 | continue; |
593 | 593 | } |
594 | 594 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * $matches[1] = all parameters string in opening tag |
628 | 628 | * $matches[2] = content between the tags to send to the plugin. |
629 | 629 | */ |
630 | - if (! preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) { |
|
630 | + if (!preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) { |
|
631 | 631 | continue; |
632 | 632 | } |
633 | 633 |
@@ -21,7 +21,7 @@ |
||
21 | 21 | protected function decorate(string $output): string |
22 | 22 | { |
23 | 23 | foreach (config('view.decorators') as $decorator) { |
24 | - if (! is_subclass_of($decorator, ViewDecoratorInterface::class, true)) { |
|
24 | + if (!is_subclass_of($decorator, ViewDecoratorInterface::class, true)) { |
|
25 | 25 | throw ViewException::invalidDecorator($decorator); |
26 | 26 | } |
27 | 27 |