@@ -64,7 +64,7 @@ |
||
| 64 | 64 | $method = new ReflectionFunction($controllerName); |
| 65 | 65 | } else { |
| 66 | 66 | try { |
| 67 | - $method = new ReflectionMethod($controllerName, ! empty($methodName) ? $methodName : $router->methodName()); |
|
| 67 | + $method = new ReflectionMethod($controllerName, !empty($methodName) ? $methodName : $router->methodName()); |
|
| 68 | 68 | } catch (ReflectionException $e) { |
| 69 | 69 | // Si nous sommes ici, la méthode n'existe pas |
| 70 | 70 | // et est probablement calculé dans _remap. |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | foreach (EventManager::getPerformanceLogs() as $row) { |
| 91 | 91 | $key = $row['event']; |
| 92 | 92 | |
| 93 | - if (! array_key_exists($key, $data['events'])) { |
|
| 93 | + if (!array_key_exists($key, $data['events'])) { |
|
| 94 | 94 | $data['events'][$key] = [ |
| 95 | 95 | 'event' => $key, |
| 96 | 96 | 'duration' => number_format(($row['end'] - $row['start']) * 1000, 2), |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | </span> |
| 43 | 43 | |
| 44 | 44 | <?php foreach ($collectors as $c) : ?> |
| 45 | - <?php if (! $c['isEmpty'] && ($c['hasTabContent'] || $c['hasLabel'])) : ?> |
|
| 45 | + <?php if (!$c['isEmpty'] && ($c['hasTabContent'] || $c['hasLabel'])) : ?> |
|
| 46 | 46 | <span class="ci-label"> |
| 47 | 47 | <a href="javascript: void(0)" data-tab="ci-<?= $c['titleSafe'] ?>"> |
| 48 | 48 | <img src="<?= $c['icon'] ?>"> |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | <!-- Collector-provided Tabs --> |
| 104 | 104 | <?php foreach ($collectors as $c) : ?> |
| 105 | - <?php if (! $c['isEmpty']) : ?> |
|
| 105 | + <?php if (!$c['isEmpty']) : ?> |
|
| 106 | 106 | <?php if ($c['hasTabContent']) : ?> |
| 107 | 107 | <div id="ci-<?= $c['titleSafe'] ?>" class="tab"> |
| 108 | 108 | <h2><?= $c['title'] ?> <span><?= $c['titleDetails'] ?></span></h2> |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | </a> |
| 150 | 150 | |
| 151 | 151 | <?php if (isset($vars['session'])) : ?> |
| 152 | - <?php if (! empty($vars['session'])) : ?> |
|
| 152 | + <?php if (!empty($vars['session'])) : ?> |
|
| 153 | 153 | <table id="session_table"> |
| 154 | 154 | <tbody> |
| 155 | 155 | <?php foreach ($vars['session'] as $key => $value) : ?> |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->config = $config ?? (object) config('toolbar'); |
| 66 | 66 | |
| 67 | 67 | foreach ($this->config->collectors as $collector) { |
| 68 | - if (! class_exists($collector)) { |
|
| 68 | + if (!class_exists($collector)) { |
|
| 69 | 69 | logger()->critical( |
| 70 | 70 | 'Toolbar collector does not exist (' . $collector . ').' |
| 71 | 71 | . ' Please check $collectors in the app/Config/toolbar.php file.' |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $data['vars']['varData'][esc($heading)] = $varData; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if (! empty($_SESSION)) { |
|
| 134 | + if (!empty($_SESSION)) { |
|
| 135 | 135 | foreach ($_SESSION as $key => $value) { |
| 136 | 136 | // Remplacez les données binaires par une chaîne pour éviter l'échec de json_encode. |
| 137 | 137 | if (is_string($value) && preg_match('~[^\x20-\x7E\t\r\n]~', $value)) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if (! is_array($value)) { |
|
| 158 | + if (!is_array($value)) { |
|
| 159 | 159 | $value = [$value]; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | continue; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (! is_array($value)) { |
|
| 187 | + if (!is_array($value)) { |
|
| 188 | 188 | $value = [$value]; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | $output = ''; |
| 223 | 223 | |
| 224 | 224 | foreach ($rows as $row) { |
| 225 | - $hasChildren = isset($row['children']) && ! empty($row['children']); |
|
| 226 | - $isQuery = isset($row['query']) && ! empty($row['query']); |
|
| 225 | + $hasChildren = isset($row['children']) && !empty($row['children']); |
|
| 226 | + $isQuery = isset($row['query']) && !empty($row['query']); |
|
| 227 | 227 | |
| 228 | 228 | // Ouvrir la chronologie du contrôleur par défaut |
| 229 | 229 | $open = $row['name'] === 'Controller'; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | // Le collecter |
| 290 | 290 | foreach ($collectors as $collector) { |
| 291 | - if (! $collector['hasTimelineData']) { |
|
| 291 | + if (!$collector['hasTimelineData']) { |
|
| 292 | 292 | continue; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | array_multisort(...$sortArray); |
| 306 | 306 | |
| 307 | 307 | // Ajouter une heure de fin à chaque élément |
| 308 | - array_walk($data, static function (&$row) { |
|
| 308 | + array_walk($data, static function(&$row) { |
|
| 309 | 309 | $row['end'] = $row['start'] + $row['duration']; |
| 310 | 310 | }); |
| 311 | 311 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $element = array_shift($elements); |
| 325 | 325 | |
| 326 | 326 | // Si nous avons des enfants derrière nous, récupérez-les et attachez-les-nous |
| 327 | - while (! empty($elements) && $elements[array_key_first($elements)]['end'] <= $element['end']) { |
|
| 327 | + while (!empty($elements) && $elements[array_key_first($elements)]['end'] <= $element['end']) { |
|
| 328 | 328 | $element['children'][] = array_shift($elements); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -348,14 +348,14 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | protected function collectVarData(): array |
| 350 | 350 | { |
| 351 | - if (! ($this->config->collectVarData ?? true)) { |
|
| 351 | + if (!($this->config->collectVarData ?? true)) { |
|
| 352 | 352 | return []; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $data = []; |
| 356 | 356 | |
| 357 | 357 | foreach ($this->collectors as $collector) { |
| 358 | - if (! $collector->hasVarData()) { |
|
| 358 | + if (!$collector->hasVarData()) { |
|
| 359 | 359 | continue; |
| 360 | 360 | } |
| 361 | 361 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | // Si on a desactiver le debogage ou l'affichage de la debugbar, on s'arrete |
| 392 | - if (! BLITZ_DEBUG || ! $this->config->show_debugbar) { |
|
| 392 | + if (!BLITZ_DEBUG || !$this->config->show_debugbar) { |
|
| 393 | 393 | return $response; |
| 394 | 394 | } |
| 395 | 395 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | // Mise à jour vers microtime() pour que nous puissions obtenir l'historique |
| 405 | 405 | $time = sprintf('%.6f', microtime(true)); |
| 406 | 406 | |
| 407 | - if (! is_dir($this->debugPath)) { |
|
| 407 | + if (!is_dir($this->debugPath)) { |
|
| 408 | 408 | mkdir($this->debugPath, 0777); |
| 409 | 409 | } |
| 410 | 410 | |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $authority = $this->host; |
| 174 | 174 | |
| 175 | - if (! empty($this->getUserInfo())) { |
|
| 175 | + if (!empty($this->getUserInfo())) { |
|
| 176 | 176 | $authority = $this->getUserInfo() . '@' . $authority; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if (! empty($this->port) && ! $ignorePort) { |
|
| 179 | + if (!empty($this->port) && !$ignorePort) { |
|
| 180 | 180 | // N'ajoute pas de port s'il s'agit d'un port standard pour ce schéma |
| 181 | 181 | if ($this->port !== $this->defaultPorts[$this->scheme]) { |
| 182 | 182 | $authority .= ':' . $this->port; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $userInfo = $this->user; |
| 197 | 197 | |
| 198 | - if ($this->showPassword === true && ! empty($this->password)) { |
|
| 198 | + if ($this->showPassword === true && !empty($this->password)) { |
|
| 199 | 199 | $userInfo .= ':' . $this->password; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $vars = $this->query; |
| 246 | 246 | |
| 247 | 247 | if (array_key_exists('except', $options)) { |
| 248 | - if (! is_array($options['except'])) { |
|
| 248 | + if (!is_array($options['except'])) { |
|
| 249 | 249 | $options['except'] = [$options['except']]; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | } elseif (array_key_exists('only', $options)) { |
| 256 | 256 | $temp = []; |
| 257 | 257 | |
| 258 | - if (! is_array($options['only'])) { |
|
| 258 | + if (!is_array($options['only'])) { |
|
| 259 | 259 | $options['only'] = [$options['only']]; |
| 260 | 260 | } |
| 261 | 261 | |
@@ -356,11 +356,11 @@ discard block |
||
| 356 | 356 | public static function createURIString(?string $scheme = null, ?string $authority = null, ?string $path = null, ?string $query = null, ?string $fragment = null): string |
| 357 | 357 | { |
| 358 | 358 | $uri = ''; |
| 359 | - if (! empty($scheme)) { |
|
| 359 | + if (!empty($scheme)) { |
|
| 360 | 360 | $uri .= $scheme . '://'; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if (! empty($authority)) { |
|
| 363 | + if (!empty($authority)) { |
|
| 364 | 364 | $uri .= $authority; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | { |
| 387 | 387 | $parts = parse_url($str); |
| 388 | 388 | |
| 389 | - if (empty($parts['host']) && ! empty($parts['path'])) { |
|
| 389 | + if (empty($parts['host']) && !empty($parts['path'])) { |
|
| 390 | 390 | $parts['host'] = $parts['path']; |
| 391 | 391 | unset($parts['path']); |
| 392 | 392 | } |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | // Ne peut pas avoir de début ? |
| 534 | - if (! empty($query) && strpos($query, '?') === 0) { |
|
| 534 | + if (!empty($query) && strpos($query, '?') === 0) { |
|
| 535 | 535 | $query = substr($query, 1); |
| 536 | 536 | } |
| 537 | 537 | |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | $temp = []; |
| 597 | 597 | |
| 598 | 598 | foreach ($this->query as $key => $value) { |
| 599 | - if (! in_array($key, $params, true)) { |
|
| 599 | + if (!in_array($key, $params, true)) { |
|
| 600 | 600 | continue; |
| 601 | 601 | } |
| 602 | 602 | |
@@ -667,19 +667,19 @@ discard block |
||
| 667 | 667 | */ |
| 668 | 668 | protected function applyParts(array $parts) |
| 669 | 669 | { |
| 670 | - if (! empty($parts['host'])) { |
|
| 670 | + if (!empty($parts['host'])) { |
|
| 671 | 671 | $this->host = $parts['host']; |
| 672 | 672 | } |
| 673 | - if (! empty($parts['user'])) { |
|
| 673 | + if (!empty($parts['user'])) { |
|
| 674 | 674 | $this->user = $parts['user']; |
| 675 | 675 | } |
| 676 | - if (! empty($parts['path'])) { |
|
| 676 | + if (!empty($parts['path'])) { |
|
| 677 | 677 | $this->path = $this->filterPath($parts['path']); |
| 678 | 678 | } |
| 679 | - if (! empty($parts['query'])) { |
|
| 679 | + if (!empty($parts['query'])) { |
|
| 680 | 680 | $this->setQuery($parts['query']); |
| 681 | 681 | } |
| 682 | - if (! empty($parts['fragment'])) { |
|
| 682 | + if (!empty($parts['fragment'])) { |
|
| 683 | 683 | $this->fragment = $parts['fragment']; |
| 684 | 684 | } |
| 685 | 685 | |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | $this->password = $parts['pass']; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - if (! empty($parts['path'])) { |
|
| 704 | + if (!empty($parts['path'])) { |
|
| 705 | 705 | $this->segments = explode('/', trim($parts['path'], '/')); |
| 706 | 706 | } |
| 707 | 707 | } |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | $transformed = clone $relative; |
| 729 | 729 | |
| 730 | 730 | // 5.2.2 Transformer les références dans une méthode non stricte (pas de schéma) |
| 731 | - if (! empty($relative->getAuthority())) { |
|
| 731 | + if (!empty($relative->getAuthority())) { |
|
| 732 | 732 | $transformed->setAuthority($relative->getAuthority()) |
| 733 | 733 | ->setPath($relative->getPath()) |
| 734 | 734 | ->setQuery($relative->getQuery()); |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | */ |
| 769 | 769 | protected function mergePaths(self $base, self $reference): string |
| 770 | 770 | { |
| 771 | - if (! empty($base->getAuthority()) && empty($base->getPath())) { |
|
| 771 | + if (!empty($base->getAuthority()) && empty($base->getPath())) { |
|
| 772 | 772 | return '/' . ltrim($reference->getPath(), '/ '); |
| 773 | 773 | } |
| 774 | 774 | |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | $controllerName = $this->controllerName(); |
| 103 | 103 | |
| 104 | - if (! $this->isValidSegment($controllerName)) { |
|
| 104 | + if (!$this->isValidSegment($controllerName)) { |
|
| 105 | 105 | throw new PageNotFoundException($this->controller . ' is not a valid controller name'); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Utilise le nom de la méthode s'il existe. |
| 109 | 109 | // Si ce n'est pas le cas, ce n'est pas grave - le nom de la méthode par défaut |
| 110 | 110 | // a déjà été défini. |
| 111 | - if (! empty($segments)) { |
|
| 111 | + if (!empty($segments)) { |
|
| 112 | 112 | $this->setMethod(array_shift($segments) ?: $this->method); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | /** @var array $params An array of params to the controller method. */ |
| 121 | 121 | $params = []; |
| 122 | 122 | |
| 123 | - if (! empty($segments)) { |
|
| 123 | + if (!empty($segments)) { |
|
| 124 | 124 | $params = $segments; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $controller = strtolower($controller); |
| 135 | 135 | |
| 136 | 136 | foreach ($this->protectedControllers as $controllerInRoute) { |
| 137 | - if (! is_string($controllerInRoute)) { |
|
| 137 | + if (!is_string($controllerInRoute)) { |
|
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | 140 | if (strtolower($controllerInRoute) !== $controller) { |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | $this->translateURIDashes ? str_replace('-', '_', $segments[0]) : $segments[0] |
| 197 | 197 | ); |
| 198 | 198 | // dès que nous rencontrons un segment non conforme à PSR-4, arrêtons la recherche |
| 199 | - if (! $this->isValidSegment($segmentConvert)) { |
|
| 199 | + if (!$this->isValidSegment($segmentConvert)) { |
|
| 200 | 200 | return $segments; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $test = CONTROLLER_PATH . $this->directory . $segmentConvert; |
| 204 | 204 | |
| 205 | 205 | // tant que chaque segment n'est *pas* un fichier de contrôleur mais correspond à un répertoire, ajoutez-le à $this->répertoire |
| 206 | - if (! is_file($test . '.php') && is_dir($test)) { |
|
| 206 | + if (!is_file($test . '.php') && is_dir($test)) { |
|
| 207 | 207 | $this->setDirectory($segmentConvert, true, false); |
| 208 | 208 | array_shift($segments); |
| 209 | 209 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $segments = explode('/', trim($dir, '/')); |
| 245 | 245 | |
| 246 | 246 | foreach ($segments as $segment) { |
| 247 | - if (! $this->isValidSegment($segment)) { |
|
| 247 | + if (!$this->isValidSegment($segment)) { |
|
| 248 | 248 | return; |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function directory(): string |
| 265 | 265 | { |
| 266 | - return ! empty($this->directory) ? $this->directory : ''; |
|
| 266 | + return !empty($this->directory) ? $this->directory : ''; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | private function controllerName() |
| 275 | 275 | { |
| 276 | - if (! is_string($this->controller)) { |
|
| 276 | + if (!is_string($this->controller)) { |
|
| 277 | 277 | return $this->controller; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec |
| 160 | 160 | // Contrôleurs/répertoires, mais l'application peut ne pas |
| 161 | 161 | // vouloir ceci, comme dans le cas des API. |
| 162 | - if (! $this->collection->shouldAutoRoute()) { |
|
| 162 | + if (!$this->collection->shouldAutoRoute()) { |
|
| 163 | 163 | $verb = strtolower($this->collection->getHTTPVerb()); |
| 164 | 164 | |
| 165 | 165 | throw new PageNotFoundException("Can't find a route for '{$verb}: {$uri}'."); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function controllerName() |
| 189 | 189 | { |
| 190 | - if (! is_string($this->controller)) { |
|
| 190 | + if (!is_string($this->controller)) { |
|
| 191 | 191 | return $this->controller; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | return [ |
| 223 | 223 | $routeArray[0], // Controller |
| 224 | - $routeArray[1] ?? 'index', // Method |
|
| 224 | + $routeArray[1] ?? 'index', // Method |
|
| 225 | 225 | ]; |
| 226 | 226 | } |
| 227 | 227 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | // Cette route est-elle censée rediriger vers une autre ? |
| 346 | 346 | if ($this->collection->isRedirect($routeKey)) { |
| 347 | 347 | // remplacement des groupes de routes correspondants par des références : post/([0-9]+) -> post/$1 |
| 348 | - $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () { |
|
| 348 | + $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function() { |
|
| 349 | 349 | static $i = 1; |
| 350 | 350 | |
| 351 | 351 | return '$' . $i++; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | // Utilisons-nous Closures ? Si tel est le cas, nous devons collecter les paramètres dans un tableau |
| 372 | 372 | // afin qu'ils puissent être transmis ultérieurement à la méthode du contrôleur. |
| 373 | - if (! is_string($handler) && is_callable($handler)) { |
|
| 373 | + if (!is_string($handler) && is_callable($handler)) { |
|
| 374 | 374 | $this->controller = $handler; |
| 375 | 375 | |
| 376 | 376 | // Supprime la chaîne d'origine du tableau matches |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | // $this->method contient déjà le nom de la méthode par défaut, |
| 466 | 466 | // donc ne l'écrasez pas avec le vide. |
| 467 | - if (! empty($method)) { |
|
| 467 | + if (!empty($method)) { |
|
| 468 | 468 | $this->setMethod($method); |
| 469 | 469 | } |
| 470 | 470 | |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | $this->method = $this->collection->getDefaultMethod(); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if (! is_file(CONTROLLER_PATH . $this->directory . $this->makeController($class) . '.php')) { |
|
| 490 | + if (!is_file(CONTROLLER_PATH . $this->directory . $this->makeController($class) . '.php')) { |
|
| 491 | 491 | return; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function addPlaceholder($placeholder, ?string $pattern = null): self |
| 221 | 221 | { |
| 222 | - if (! is_array($placeholder)) { |
|
| 222 | + if (!is_array($placeholder)) { |
|
| 223 | 223 | $placeholder = [$placeholder => $pattern]; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | foreach ($collection as $name => $r) { |
| 406 | 406 | $key = key($r['route']); |
| 407 | 407 | |
| 408 | - if (! $withName) { |
|
| 408 | + if (!$withName) { |
|
| 409 | 409 | $routes[$key] = $r['route'][$key]; |
| 410 | 410 | } else { |
| 411 | 411 | $routes[$key] = [ |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | * |
| 787 | 787 | * @param array|Closure|string $to |
| 788 | 788 | */ |
| 789 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
| 789 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
| 790 | 790 | { |
| 791 | 791 | if (empty($from) || empty($to)) { |
| 792 | 792 | throw new InvalidArgumentException('You must supply the parameters: from, to.'); |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | $to = $route['route'][$from]; |
| 932 | 932 | |
| 933 | 933 | // on ignore les closures |
| 934 | - if (! is_string($to)) { |
|
| 934 | + if (!is_string($to)) { |
|
| 935 | 935 | continue; |
| 936 | 936 | } |
| 937 | 937 | |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | // Construire notre chaîne résultante, en insérant les $params dans |
| 1014 | 1014 | // les endroits appropriés. |
| 1015 | 1015 | foreach ($matches[0] as $index => $pattern) { |
| 1016 | - if (! preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
| 1016 | + if (!preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
| 1017 | 1017 | throw RouterException::invalidParameterType(); |
| 1018 | 1018 | } |
| 1019 | 1019 | |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | // Limitation du nom d'hôte ? |
| 1061 | - if (! empty($options['hostname'])) { |
|
| 1061 | + if (!empty($options['hostname'])) { |
|
| 1062 | 1062 | // @todo determine if there's a way to whitelist hosts? |
| 1063 | 1063 | if (isset($_SERVER['HTTP_HOST']) && strtolower($_SERVER['HTTP_HOST']) !== strtolower($options['hostname'])) { |
| 1064 | 1064 | return; |
@@ -1068,10 +1068,10 @@ discard block |
||
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | // Limitation du nom sous-domaine ? |
| 1071 | - elseif (! empty($options['subdomain'])) { |
|
| 1071 | + elseif (!empty($options['subdomain'])) { |
|
| 1072 | 1072 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
| 1073 | 1073 | // nous n'avons pas besoin d'ajouter la route. |
| 1074 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
| 1074 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
| 1075 | 1075 | return; |
| 1076 | 1076 | } |
| 1077 | 1077 | |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | // S'il s'agit d'une redirection, aucun traitement |
| 1105 | - if (! isset($options['redirect']) && is_string($to)) { |
|
| 1105 | + if (!isset($options['redirect']) && is_string($to)) { |
|
| 1106 | 1106 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
| 1107 | 1107 | if (strpos($to, '\\') === false || strpos($to, '\\') > 0) { |
| 1108 | 1108 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | // les routes manuelement définies doivent toujours être la "source de vérité". |
| 1121 | 1121 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
| 1122 | 1122 | // pour tenter de router la requête. |
| 1123 | - if (isset($this->routes[$verb][$name]) && ! $overwrite) { |
|
| 1123 | + if (isset($this->routes[$verb][$name]) && !$overwrite) { |
|
| 1124 | 1124 | return; |
| 1125 | 1125 | } |
| 1126 | 1126 | |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | private function checkSubdomains($subdomains): bool |
| 1146 | 1146 | { |
| 1147 | 1147 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
| 1148 | - if (! isset($_SERVER['HTTP_HOST'])) { |
|
| 1148 | + if (!isset($_SERVER['HTTP_HOST'])) { |
|
| 1149 | 1149 | return false; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
@@ -1153,13 +1153,13 @@ discard block |
||
| 1153 | 1153 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | - if (! is_array($subdomains)) { |
|
| 1156 | + if (!is_array($subdomains)) { |
|
| 1157 | 1157 | $subdomains = [$subdomains]; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
| 1161 | 1161 | // il nécessite la présence d'un sous-domaine. |
| 1162 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
| 1162 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
| 1163 | 1163 | return true; |
| 1164 | 1164 | } |
| 1165 | 1165 | |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | $controllers = []; |
| 1286 | 1286 | |
| 1287 | 1287 | foreach ($routes as $handler) { |
| 1288 | - if (! is_string($handler)) { |
|
| 1288 | + if (!is_string($handler)) { |
|
| 1289 | 1289 | continue; |
| 1290 | 1290 | } |
| 1291 | 1291 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | use BlitzPHP\Loader\Filesystem; |
| 13 | 13 | |
| 14 | -if (! function_exists('directory_map')) { |
|
| 14 | +if (!function_exists('directory_map')) { |
|
| 15 | 15 | /** |
| 16 | 16 | * Créer une carte de répertoire |
| 17 | 17 | * |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -if (! function_exists('directory_mirror')) { |
|
| 32 | +if (!function_exists('directory_mirror')) { |
|
| 33 | 33 | /** |
| 34 | 34 | * Copie récursivement les fichiers et répertoires du répertoire d'origine |
| 35 | 35 | * dans le répertoire cible, c'est-à-dire "miroir" son contenu. |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -if (! function_exists('write_file')) { |
|
| 45 | +if (!function_exists('write_file')) { |
|
| 46 | 46 | /** |
| 47 | 47 | * Write File |
| 48 | 48 | * |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | -if (! function_exists('delete_files')) { |
|
| 79 | +if (!function_exists('delete_files')) { |
|
| 80 | 80 | /** |
| 81 | 81 | * Delete Files |
| 82 | 82 | * |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | RecursiveIteratorIterator::CHILD_FIRST |
| 102 | 102 | ) as $object) { |
| 103 | 103 | $filename = $object->getFilename(); |
| 104 | - if (! $hidden && $filename[0] === '.') { |
|
| 104 | + if (!$hidden && $filename[0] === '.') { |
|
| 105 | 105 | continue; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if (! $htdocs || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) { |
|
| 108 | + if (!$htdocs || !preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) { |
|
| 109 | 109 | $isDir = $object->isDir(); |
| 110 | 110 | if ($isDir && $delDir) { |
| 111 | 111 | rmdir($object->getPathname()); |
| 112 | 112 | |
| 113 | 113 | continue; |
| 114 | 114 | } |
| 115 | - if (! $isDir) { |
|
| 115 | + if (!$isDir) { |
|
| 116 | 116 | unlink($object->getPathname()); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | -if (! function_exists('get_filenames')) { |
|
| 128 | +if (!function_exists('get_filenames')) { |
|
| 129 | 129 | /** |
| 130 | 130 | * Get Filenames |
| 131 | 131 | * |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | RecursiveIteratorIterator::SELF_FIRST |
| 155 | 155 | ) as $name => $object) { |
| 156 | 156 | $basename = pathinfo($name, PATHINFO_BASENAME); |
| 157 | - if (! $hidden && $basename[0] === '.') { |
|
| 157 | + if (!$hidden && $basename[0] === '.') { |
|
| 158 | 158 | continue; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ($includeDir || ! $object->isDir()) { |
|
| 161 | + if ($includeDir || !$object->isDir()) { |
|
| 162 | 162 | if ($includePath === false) { |
| 163 | 163 | $files[] = $basename; |
| 164 | 164 | } elseif ($includePath === null) { |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | -if (! function_exists('get_dir_file_info')) { |
|
| 181 | +if (!function_exists('get_dir_file_info')) { |
|
| 182 | 182 | /** |
| 183 | 183 | * Get Directory File Information |
| 184 | 184 | * |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | -if (! function_exists('get_file_info')) { |
|
| 227 | +if (!function_exists('get_file_info')) { |
|
| 228 | 228 | /** |
| 229 | 229 | * Get File Info |
| 230 | 230 | * |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | function get_file_info(string $file, $returnedValues = ['name', 'server_path', 'size', 'date']) |
| 242 | 242 | { |
| 243 | - if (! is_file($file)) { |
|
| 243 | + if (!is_file($file)) { |
|
| 244 | 244 | return null; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | -if (! function_exists('symbolic_permissions')) { |
|
| 293 | +if (!function_exists('symbolic_permissions')) { |
|
| 294 | 294 | /** |
| 295 | 295 | * Symbolic Permissions |
| 296 | 296 | * |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | -if (! function_exists('octal_permissions')) { |
|
| 341 | +if (!function_exists('octal_permissions')) { |
|
| 342 | 342 | /** |
| 343 | 343 | * Octal Permissions |
| 344 | 344 | * |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | -if (! function_exists('same_file')) { |
|
| 356 | +if (!function_exists('same_file')) { |
|
| 357 | 357 | /** |
| 358 | 358 | * Checks if two files both exist and have identical hashes |
| 359 | 359 | * |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | -if (! function_exists('set_realpath')) { |
|
| 368 | +if (!function_exists('set_realpath')) { |
|
| 369 | 369 | /** |
| 370 | 370 | * Set Realpath |
| 371 | 371 | * |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | // Resolve the path |
| 382 | 382 | if (realpath($path) !== false) { |
| 383 | 383 | $path = realpath($path); |
| 384 | - } elseif ($checkExistence && ! is_dir($path) && ! is_file($path)) { |
|
| 384 | + } elseif ($checkExistence && !is_dir($path) && !is_file($path)) { |
|
| 385 | 385 | throw new InvalidArgumentException('Not a valid path: ' . $path); |
| 386 | 386 | } |
| 387 | 387 | |