@@ -52,14 +52,14 @@ |
||
| 52 | 52 | |
| 53 | 53 | $directory = dirname($path); |
| 54 | 54 | |
| 55 | - if (! is_dir($directory)) { |
|
| 55 | + if (!is_dir($directory)) { |
|
| 56 | 56 | mkdir($directory, 0777, true); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | if (file_exists($path)) { |
| 60 | 60 | $overwrite = (bool) $this->option('f'); |
| 61 | 61 | |
| 62 | - if (! $overwrite && ! $this->confirm("File '{$cleanPath}' already exists in destination. Overwrite?")) { |
|
| 62 | + if (!$overwrite && !$this->confirm("File '{$cleanPath}' already exists in destination. Overwrite?")) { |
|
| 63 | 63 | $this->error("Skipped {$cleanPath}. If you wish to overwrite, please use the '-f' option or reply 'y' to the prompt."); |
| 64 | 64 | |
| 65 | 65 | return; |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | $group = on_test() ? 'test' : (on_prod() ? 'production' : 'development'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if (! isset($config[$group]) && strpos($group, 'custom-') === false) { |
|
| 60 | + if (!isset($config[$group]) && strpos($group, 'custom-') === false) { |
|
| 61 | 61 | $group = 'default'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if (is_string($group) && ! isset($config[$group]) && strpos($group, 'custom-') !== 0) { |
|
| 64 | + if (is_string($group) && !isset($config[$group]) && strpos($group, 'custom-') !== 0) { |
|
| 65 | 65 | throw new InvalidArgumentException($group . ' is not a valid database connection group.'); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $config = $config[$group]; |
| 73 | 73 | |
| 74 | - if (str_contains($config['driver'], 'sqlite') && $config['database'] !== ':memory:' && ! str_contains($config['database'], DS)) { |
|
| 74 | + if (str_contains($config['driver'], 'sqlite') && $config['database'] !== ':memory:' && !str_contains($config['database'], DS)) { |
|
| 75 | 75 | $config['database'] = APP_STORAGE_PATH . $config['database']; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | // Si le package "blitz-php/database" n'existe pas on renvoi une fake connection |
| 95 | 95 | // Ceci est utile juste pour eviter le bug avec le service provider |
| 96 | - if (! class_exists(Db::class)) { |
|
| 96 | + if (!class_exists(Db::class)) { |
|
| 97 | 97 | return static::createMockConnection(); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | throw LoadException::libraryNotFound($lib); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if (true !== $file_syst && ! class_exists($lib)) { |
|
| 83 | + if (true !== $file_syst && !class_exists($lib)) { |
|
| 84 | 84 | throw LoadException::libraryDontExist($lib); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -98,16 +98,16 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public static function model(string $model, ?ConnectionInterface $connection = null) |
| 100 | 100 | { |
| 101 | - if (! class_exists($model) && ! Text::endsWith($model, 'Model')) { |
|
| 101 | + if (!class_exists($model) && !Text::endsWith($model, 'Model')) { |
|
| 102 | 102 | $model .= 'Model'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if (! class_exists($model)) { |
|
| 105 | + if (!class_exists($model)) { |
|
| 106 | 106 | $model = str_replace(APP_NAMESPACE . '\\Models\\', '', $model); |
| 107 | 107 | $model = APP_NAMESPACE . '\\Models\\' . $model; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if (! class_exists($model)) { |
|
| 110 | + if (!class_exists($model)) { |
|
| 111 | 111 | throw LoadException::modelNotFound($model); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $controller = explode('/', $controller); |
| 126 | 126 | |
| 127 | 127 | $con = ucfirst(end($controller)); |
| 128 | - $con = (! preg_match('#Controller$#', $con)) ? $con . 'Controller' : $con; |
|
| 128 | + $con = (!preg_match('#Controller$#', $con)) ? $con . 'Controller' : $con; |
|
| 129 | 129 | $controller[count($controller) - 1] = $con; |
| 130 | 130 | |
| 131 | 131 | foreach ($controller as $key => &$value) { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | $path = CONTROLLER_PATH . Helpers::ensureExt(implode(DS, $controller), 'php'); |
| 138 | 138 | |
| 139 | - if (! file_exists($path)) { |
|
| 139 | + if (!file_exists($path)) { |
|
| 140 | 140 | throw LoadException::controllerNotFound(str_replace('Controller', '', $con), $path); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | if (class_exists($class_namespaced, false)) { |
| 148 | 148 | return Injector::make($class_namespaced); |
| 149 | 149 | } |
| 150 | - if (! class_exists($con, false)) { |
|
| 150 | + if (!class_exists($con, false)) { |
|
| 151 | 151 | throw LoadException::controllerDontExist(str_replace('Controller', '', $con), $path); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | protected static function verifyPreferApp(array $options, string $name): bool |
| 177 | 177 | { |
| 178 | 178 | // Tout element sans restriction passe |
| 179 | - if (! $options['preferApp']) { |
|
| 179 | + if (!$options['preferApp']) { |
|
| 180 | 180 | return true; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function expectsJson(): bool |
| 33 | 33 | { |
| 34 | - return ($this->ajax() && ! $this->pjax() && $this->acceptsAnyContentType()) || $this->wantsJson(); |
|
| 34 | + return ($this->ajax() && !$this->pjax() && $this->acceptsAnyContentType()) || $this->wantsJson(); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | return $this->withFile($filepath, ['download' => true, 'name' => $filename]); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if (! empty($data)) { |
|
| 101 | + if (!empty($data)) { |
|
| 102 | 102 | return $this->withStringBody($data) |
| 103 | 103 | ->withType(pathinfo($filename, PATHINFO_EXTENSION)) |
| 104 | 104 | ->withDownload($filename); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $input = $this->all(); |
| 88 | 88 | |
| 89 | 89 | foreach ($keys as $value) { |
| 90 | - if (! Arr::has($input, $value)) { |
|
| 90 | + if (!Arr::has($input, $value)) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $keys = is_array($key) ? $key : func_get_args(); |
| 150 | 150 | |
| 151 | 151 | foreach ($keys as $value) { |
| 152 | - if (! $this->isEmptyString($value)) { |
|
| 152 | + if (!$this->isEmptyString($value)) { |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | $keys = is_array($key) ? $key : func_get_args(); |
| 200 | 200 | |
| 201 | - return ! $this->has($keys); |
|
| 201 | + return !$this->has($keys); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | $value = $this->input($key); |
| 228 | 228 | |
| 229 | - return ! is_bool($value) && ! is_array($value) && trim((string) $value) === ''; |
|
| 229 | + return !is_bool($value) && !is_array($value) && trim((string) $value) === ''; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | $input = array_replace_recursive($this->data(), $this->allFiles()); |
| 248 | 248 | |
| 249 | - if (! $keys) { |
|
| 249 | + if (!$keys) { |
|
| 250 | 250 | return $input; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | public function enum(string $key, $enumClass) |
| 342 | 342 | { |
| 343 | 343 | if ($this->isNotFilled($key) |
| 344 | - || ! function_exists('enum_exists') |
|
| 345 | - || ! enum_exists($enumClass) |
|
| 346 | - || ! method_exists($enumClass, 'tryFrom')) { |
|
| 344 | + || !function_exists('enum_exists') |
|
| 345 | + || !enum_exists($enumClass) |
|
| 346 | + || !method_exists($enumClass, 'tryFrom')) { |
|
| 347 | 347 | return null; |
| 348 | 348 | } |
| 349 | 349 | |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | public function hasFile(string $key): bool |
| 459 | 459 | { |
| 460 | - if (! is_array($files = $this->file($key))) { |
|
| 460 | + if (!is_array($files = $this->file($key))) { |
|
| 461 | 461 | $files = [$files]; |
| 462 | 462 | } |
| 463 | 463 | |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | */ |
| 97 | 97 | public function fullUrl(): string |
| 98 | 98 | { |
| 99 | - if (! empty($query = $this->getEnv('QUERY_STRING'))) { |
|
| 99 | + if (!empty($query = $this->getEnv('QUERY_STRING'))) { |
|
| 100 | 100 | return $this->url() . '?' . $query; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $route = Services::routes()->reverseRoute($route, ...$params); |
| 52 | 52 | |
| 53 | - if (! $route) { |
|
| 53 | + if (!$route) { |
|
| 54 | 54 | throw HttpException::invalidRedirectRoute($route); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $errors = [$errors]; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (! empty($errors)) { |
|
| 84 | + if (!empty($errors)) { |
|
| 85 | 85 | $session = Services::session(); |
| 86 | 86 | $_errors = $session->getFlashdata('errors') ?? []; |
| 87 | 87 | $session->setFlashdata( |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $controller = $routes->getDefaultController(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if (! $fullName && is_string($controller)) { |
|
| 180 | + if (!$fullName && is_string($controller)) { |
|
| 181 | 181 | $controller = str_replace($routes->getDefaultNamespace(), '', $controller); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | require_once $routes_file; |
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | - if (empty($routes) || ! ($routes instanceof RouteCollection)) { |
|
| 281 | + if (empty($routes) || !($routes instanceof RouteCollection)) { |
|
| 282 | 282 | $routes = Services::routes(); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | */ |
| 307 | 307 | $this->gatherOutput($this->middleware->handle($this->request)); |
| 308 | 308 | |
| 309 | - if (! $returnResponse) { |
|
| 309 | + if (!$returnResponse) { |
|
| 310 | 310 | $this->sendResponse(); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -354,14 +354,14 @@ discard block |
||
| 354 | 354 | return; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if (is_cli() && ! on_test()) { |
|
| 357 | + if (is_cli() && !on_test()) { |
|
| 358 | 358 | // @codeCoverageIgnoreStart |
| 359 | 359 | // $this->request = Services::clirequest($this->config); |
| 360 | 360 | // @codeCoverageIgnoreEnd |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $version = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1'; |
| 364 | - if (! is_numeric($version)) { |
|
| 364 | + if (!is_numeric($version)) { |
|
| 365 | 365 | $version = substr($version, strpos($version, '/') + 1); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | // Supposons le succès jusqu'à preuve du contraire. |
| 381 | 381 | $this->response = Services::response()->withStatus(200); |
| 382 | 382 | |
| 383 | - if (! is_cli() || on_test()) { |
|
| 383 | + if (!is_cli() || on_test()) { |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $this->response = $this->response->withProtocolVersion($this->request->getProtocolVersion()); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | { |
| 417 | 417 | if ($cachedResponse = Services::cache()->read($this->generateCacheName())) { |
| 418 | 418 | $cachedResponse = unserialize($cachedResponse); |
| 419 | - if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers'])) { |
|
| 419 | + if (!is_array($cachedResponse) || !isset($cachedResponse['output']) || !isset($cachedResponse['headers'])) { |
|
| 420 | 420 | throw new FrameworkException('Error unserializing page cache'); |
| 421 | 421 | } |
| 422 | 422 | |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | protected function determinePath(): string |
| 547 | 547 | { |
| 548 | - if (! empty($this->path)) { |
|
| 548 | + if (!empty($this->path)) { |
|
| 549 | 549 | return $this->path; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | // Essayez de charger automatiquement la classe |
| 602 | - if (! class_exists($this->controller, true) || $this->method[0] === '_') { |
|
| 602 | + if (!class_exists($this->controller, true) || $this->method[0] === '_') { |
|
| 603 | 603 | throw PageNotFoundException::controllerNotFound($this->controller, $this->method); |
| 604 | 604 | } |
| 605 | 605 | |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | // Affiche l'erreur 404 |
| 688 | 688 | $this->response = $this->response->withStatus($e->getCode()); |
| 689 | 689 | |
| 690 | - if (! on_test()) { |
|
| 690 | + if (!on_test()) { |
|
| 691 | 691 | // @codeCoverageIgnoreStart |
| 692 | 692 | if (ob_get_level() > 0) { |
| 693 | 693 | ob_end_flush(); |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | ob_end_flush(); // @codeCoverageIgnore |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - throw PageNotFoundException::pageNotFound(! on_prod() || is_cli() ? $e->getMessage() : ''); |
|
| 702 | + throw PageNotFoundException::pageNotFound(!on_prod() || is_cli() ? $e->getMessage() : ''); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | public function storePreviousURL($uri) |
| 755 | 755 | { |
| 756 | 756 | // Ignorer les requêtes CLI |
| 757 | - if (is_cli() && ! on_test()) { |
|
| 757 | + if (is_cli() && !on_test()) { |
|
| 758 | 758 | return; // @codeCoverageIgnore |
| 759 | 759 | } |
| 760 | 760 | |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | ]); |
| 860 | 860 | |
| 861 | 861 | $middlewaresFile = CONFIG_PATH . 'middlewares.php'; |
| 862 | - if (file_exists($middlewaresFile) && ! in_array($middlewaresFile, get_included_files(), true)) { |
|
| 862 | + if (file_exists($middlewaresFile) && !in_array($middlewaresFile, get_included_files(), true)) { |
|
| 863 | 863 | $middleware = require $middlewaresFile; |
| 864 | 864 | if (is_callable($middleware)) { |
| 865 | 865 | $middleware($this->middleware, $this->request); |
@@ -875,11 +875,11 @@ discard block |
||
| 875 | 875 | */ |
| 876 | 876 | private function spoofRequestMethod(): callable |
| 877 | 877 | { |
| 878 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
| 878 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
| 879 | 879 | $post = $request->getParsedBody(); |
| 880 | 880 | |
| 881 | 881 | // Ne fonctionne qu'avec les formulaires POST |
| 882 | - if (strtoupper($request->getMethod()) === 'POST' && ! empty($post['_method'])) { |
|
| 882 | + if (strtoupper($request->getMethod()) === 'POST' && !empty($post['_method'])) { |
|
| 883 | 883 | // Accepte seulement PUT, PATCH, DELETE |
| 884 | 884 | if (in_array(strtoupper($post['_method']), ['PUT', 'PATCH', 'DELETE'], true)) { |
| 885 | 885 | $request = $request->withMethod($post['_method']); |
@@ -894,15 +894,15 @@ discard block |
||
| 894 | 894 | { |
| 895 | 895 | $_this = $this; |
| 896 | 896 | |
| 897 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) use ($_this): ResponseInterface { |
|
| 897 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) use ($_this): ResponseInterface { |
|
| 898 | 898 | try { |
| 899 | 899 | $returned = $_this->startController($request, $response); |
| 900 | 900 | |
| 901 | 901 | // Closure controller has run in startController(). |
| 902 | - if (! is_callable($_this->controller)) { |
|
| 902 | + if (!is_callable($_this->controller)) { |
|
| 903 | 903 | $controller = $_this->createController($request, $response); |
| 904 | 904 | |
| 905 | - if (! method_exists($controller, '_remap') && ! is_callable([$controller, $_this->method], false)) { |
|
| 905 | + if (!method_exists($controller, '_remap') && !is_callable([$controller, $_this->method], false)) { |
|
| 906 | 906 | throw PageNotFoundException::methodNotFound($_this->method); |
| 907 | 907 | } |
| 908 | 908 | |