@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use BlitzPHP\Utilities\String\Inflector; |
| 13 | 13 | use BlitzPHP\Utilities\String\Text; |
| 14 | 14 | |
| 15 | -if (! function_exists('camelize')) { |
|
| 15 | +if (!function_exists('camelize')) { |
|
| 16 | 16 | /** |
| 17 | 17 | * Camelize |
| 18 | 18 | * |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if (! function_exists('classify')) { |
|
| 29 | +if (!function_exists('classify')) { |
|
| 30 | 30 | /** |
| 31 | 31 | * Returns model class name ("Person" for the database table "people".) for given database table. |
| 32 | 32 | * |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -if (! function_exists('dasherize')) { |
|
| 43 | +if (!function_exists('dasherize')) { |
|
| 44 | 44 | /** |
| 45 | 45 | * Returns the input CamelCasedString as an dashed-string. |
| 46 | 46 | * |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -if (! function_exists('delimit')) { |
|
| 59 | +if (!function_exists('delimit')) { |
|
| 60 | 60 | /** |
| 61 | 61 | * Expects a CamelCasedInputString, and produces a lower_case_delimited_string |
| 62 | 62 | * |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -if (! function_exists('humanize')) { |
|
| 74 | +if (!function_exists('humanize')) { |
|
| 75 | 75 | /** |
| 76 | 76 | * Humanize |
| 77 | 77 | * |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | -if (! function_exists('plural')) { |
|
| 89 | +if (!function_exists('plural')) { |
|
| 90 | 90 | /** |
| 91 | 91 | * Plural |
| 92 | 92 | * |
@@ -96,30 +96,30 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $result = $string; |
| 98 | 98 | |
| 99 | - if (! is_pluralizable($result)) { |
|
| 99 | + if (!is_pluralizable($result)) { |
|
| 100 | 100 | return $result; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $plural_rules = [ |
| 104 | - '/(quiz)$/' => '\1zes', // quizzes |
|
| 105 | - '/^(ox)$/' => '\1\2en', // ox |
|
| 106 | - '/([m|l])ouse$/' => '\1ice', // mouse, louse |
|
| 107 | - '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index |
|
| 108 | - '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address |
|
| 109 | - '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency |
|
| 110 | - '/(hive)$/' => '\1s', // archive, hive |
|
| 111 | - '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife |
|
| 112 | - '/sis$/' => 'ses', // basis, diagnosis |
|
| 113 | - '/([ti])um$/' => '\1a', // datum, medium |
|
| 114 | - '/(p)erson$/' => '\1eople', // person, salesperson |
|
| 115 | - '/(m)an$/' => '\1en', // man, woman, spokesman |
|
| 116 | - '/(c)hild$/' => '\1hildren', // child |
|
| 117 | - '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato |
|
| 118 | - '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
| 119 | - '/(alias|status|virus)$/' => '\1es', // alias |
|
| 120 | - '/(octop)us$/' => '\1i', // octopus |
|
| 121 | - '/(ax|cris|test)is$/' => '\1es', // axis, crisis |
|
| 122 | - '/s$/' => 's', // no change (compatibility) |
|
| 104 | + '/(quiz)$/' => '\1zes', // quizzes |
|
| 105 | + '/^(ox)$/' => '\1\2en', // ox |
|
| 106 | + '/([m|l])ouse$/' => '\1ice', // mouse, louse |
|
| 107 | + '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index |
|
| 108 | + '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address |
|
| 109 | + '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency |
|
| 110 | + '/(hive)$/' => '\1s', // archive, hive |
|
| 111 | + '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife |
|
| 112 | + '/sis$/' => 'ses', // basis, diagnosis |
|
| 113 | + '/([ti])um$/' => '\1a', // datum, medium |
|
| 114 | + '/(p)erson$/' => '\1eople', // person, salesperson |
|
| 115 | + '/(m)an$/' => '\1en', // man, woman, spokesman |
|
| 116 | + '/(c)hild$/' => '\1hildren', // child |
|
| 117 | + '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato |
|
| 118 | + '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
| 119 | + '/(alias|status|virus)$/' => '\1es', // alias |
|
| 120 | + '/(octop)us$/' => '\1i', // octopus |
|
| 121 | + '/(ax|cris|test)is$/' => '\1es', // axis, crisis |
|
| 122 | + '/s$/' => 's', // no change (compatibility) |
|
| 123 | 123 | '/$/' => 's', |
| 124 | 124 | ]; |
| 125 | 125 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -if (! function_exists('pluralize')) { |
|
| 137 | +if (!function_exists('pluralize')) { |
|
| 138 | 138 | /** |
| 139 | 139 | * Return $word in plural form. |
| 140 | 140 | * |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | -if (! function_exists('singular')) { |
|
| 151 | +if (!function_exists('singular')) { |
|
| 152 | 152 | /** |
| 153 | 153 | * Singular |
| 154 | 154 | * |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $result = $string; |
| 160 | 160 | |
| 161 | - if (! is_pluralizable($result)) { |
|
| 161 | + if (!is_pluralizable($result)) { |
|
| 162 | 162 | return $result; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | -if (! function_exists('singularize')) { |
|
| 207 | +if (!function_exists('singularize')) { |
|
| 208 | 208 | /** |
| 209 | 209 | * Return $word in singular form. |
| 210 | 210 | * |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | -if (! function_exists('tableize')) { |
|
| 221 | +if (!function_exists('tableize')) { |
|
| 222 | 222 | /** |
| 223 | 223 | * Returns corresponding table name for given model $className. ("people" for the model class "Person"). |
| 224 | 224 | * |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | -if (! function_exists('underscore')) { |
|
| 235 | +if (!function_exists('underscore')) { |
|
| 236 | 236 | /** |
| 237 | 237 | * Underscore |
| 238 | 238 | * |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | -if (! function_exists('variable')) { |
|
| 249 | +if (!function_exists('variable')) { |
|
| 250 | 250 | /** |
| 251 | 251 | * Returns camelBacked version of an underscored string. |
| 252 | 252 | * |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | -if (! function_exists('counted')) { |
|
| 263 | +if (!function_exists('counted')) { |
|
| 264 | 264 | /** |
| 265 | 265 | * Counted |
| 266 | 266 | * |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | -if (! function_exists('pascalize')) { |
|
| 281 | +if (!function_exists('pascalize')) { |
|
| 282 | 282 | /** |
| 283 | 283 | * Pascalize |
| 284 | 284 | * |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | -if (! function_exists('is_pluralizable')) { |
|
| 297 | +if (!function_exists('is_pluralizable')) { |
|
| 298 | 298 | /** |
| 299 | 299 | * Checks if the given word has a plural version. |
| 300 | 300 | * |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | function is_pluralizable(string $word): bool |
| 304 | 304 | { |
| 305 | - return ! in_array( |
|
| 305 | + return !in_array( |
|
| 306 | 306 | strtolower($word), |
| 307 | 307 | [ |
| 308 | 308 | 'advice', |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | -if (! function_exists('ordinal')) { |
|
| 380 | +if (!function_exists('ordinal')) { |
|
| 381 | 381 | /** |
| 382 | 382 | * Returns the suffix that should be added to a |
| 383 | 383 | * number to denote the position in an ordered |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | -if (! function_exists('ordinalize')) { |
|
| 407 | +if (!function_exists('ordinalize')) { |
|
| 408 | 408 | /** |
| 409 | 409 | * Turns a number into an ordinal string used |
| 410 | 410 | * to denote the position in an ordered sequence |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $response = $handler->handle($request); |
| 28 | 28 | |
| 29 | - if (! empty($body = $response->getBody()->getContents())) { |
|
| 29 | + if (!empty($body = $response->getBody()->getContents())) { |
|
| 30 | 30 | $benchmark = Services::timer(); |
| 31 | 31 | |
| 32 | 32 | $output = str_replace( |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $response = $handler->handle($request); |
| 38 | 38 | $content = $response->getBody()->getContents(); |
| 39 | 39 | |
| 40 | - if (! $response instanceof Redirection) { |
|
| 40 | + if (!$response instanceof Redirection) { |
|
| 41 | 41 | // Mettez-le en cache sans remplacer les mesures de performances afin que nous puissions avoir des mises à jour de vitesse en direct en cours de route. |
| 42 | 42 | // Doit être exécuté après les filtres pour conserver les en-têtes de réponse. |
| 43 | 43 | $this->pageCache->make($request, $response->withBody(to_stream($content))); |
@@ -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 | |
@@ -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 | |