@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $loader = Services::locator(); |
| 39 | 39 | |
| 40 | - if (! is_array($filenames)) { |
|
| 40 | + if (!is_array($filenames)) { |
|
| 41 | 41 | $filenames = [$filenames]; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Les helpers au niveau de l'application doivent remplacer tous les autres |
| 84 | - if (! empty($appHelper)) { |
|
| 84 | + if (!empty($appHelper)) { |
|
| 85 | 85 | $includes[] = $appHelper; |
| 86 | 86 | $loaded[] = $filename; |
| 87 | 87 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $includes = [...$includes, ...$localIncludes]; |
| 91 | 91 | |
| 92 | 92 | // Et celui par défaut du système doit être ajouté en dernier. |
| 93 | - if (! empty($systemHelper)) { |
|
| 93 | + if (!empty($systemHelper)) { |
|
| 94 | 94 | $includes[] = $systemHelper; |
| 95 | 95 | $loaded[] = $filename; |
| 96 | 96 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // Si le fichier est dans un espace de noms, nous allons simplement saisir ce fichier et ne pas en rechercher d'autres |
| 130 | 130 | if (str_contains($name, '\\')) { |
| 131 | - if (! empty($path = $loader->locateFile($name, 'schemas'))) { |
|
| 131 | + if (!empty($path = $loader->locateFile($name, 'schemas'))) { |
|
| 132 | 132 | $file = $path; |
| 133 | 133 | } |
| 134 | 134 | } else { |
@@ -146,18 +146,18 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Les schema des vendor sont prioritaire, ensuite vienne ceux de l'application |
| 149 | - if (! empty($vendorSchema)) { |
|
| 149 | + if (!empty($vendorSchema)) { |
|
| 150 | 150 | $file = $vendorSchema; |
| 151 | - } elseif (! empty($appSchema)) { |
|
| 151 | + } elseif (!empty($appSchema)) { |
|
| 152 | 152 | $file = $appSchema; |
| 153 | - } elseif (! empty($systemSchema)) { |
|
| 153 | + } elseif (!empty($systemSchema)) { |
|
| 154 | 154 | $file = $systemSchema; |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $schema = ! empty($file) ? require $file : null; |
|
| 158 | + $schema = !empty($file) ? require $file : null; |
|
| 159 | 159 | |
| 160 | - if (empty($schema) || ! ($schema instanceof Schema)) { |
|
| 160 | + if (empty($schema) || !($schema instanceof Schema)) { |
|
| 161 | 161 | $schema = Expect::mixed(); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public static function model(string $model, ?ConnectionInterface $connection = null) |
| 177 | 177 | { |
| 178 | - if (! class_exists($model) && ! Text::endsWith($model, 'Model')) { |
|
| 178 | + if (!class_exists($model) && !Text::endsWith($model, 'Model')) { |
|
| 179 | 179 | $model .= 'Model'; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if (! class_exists($model)) { |
|
| 182 | + if (!class_exists($model)) { |
|
| 183 | 183 | $model = str_replace(APP_NAMESPACE . '\\Models\\', '', $model); |
| 184 | 184 | $model = APP_NAMESPACE . '\\Models\\' . $model; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (! class_exists($model)) { |
|
| 187 | + if (!class_exists($model)) { |
|
| 188 | 188 | throw LoadException::modelNotFound($model); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | protected static function verifyPreferApp(array $options, string $name): bool |
| 214 | 214 | { |
| 215 | 215 | // Tout element sans restriction passe |
| 216 | - if (! $options['preferApp']) { |
|
| 216 | + if (!$options['preferApp']) { |
|
| 217 | 217 | return true; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $options = (array) $options; |
| 46 | 46 | |
| 47 | 47 | // N'est-il pas namespaced ? on cherche le dossier en fonction du controleur |
| 48 | - if (! str_contains($view, '\\')) { |
|
| 48 | + if (!str_contains($view, '\\')) { |
|
| 49 | 49 | $reflection = new ReflectionClass(static::class); |
| 50 | 50 | ['dirname' => $dirname, 'filename' => $filename] = pathinfo($reflection->getFileName()); |
| 51 | 51 | $dirname = str_ireplace('Controllers', 'Views', $dirname); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $dirname = implode('Views', $parts); |
| 60 | 60 | $path = implode(DS, [$dirname, $filename]) . DS; |
| 61 | 61 | |
| 62 | - if (! is_dir($path)) { |
|
| 62 | + if (!is_dir($path)) { |
|
| 63 | 63 | $path = implode(DS, [$dirname]) . DS; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | if (empty($data['title'])) { |
| 80 | - if (! is_string($controllerName = Dispatcher::getController(false))) { |
|
| 80 | + if (!is_string($controllerName = Dispatcher::getController(false))) { |
|
| 81 | 81 | $controllerName = static::class; |
| 82 | 82 | } |
| 83 | 83 | $controllerName = str_ireplace(['App\Controllers', 'Controller'], '', $controllerName); |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | $this->modelName = is_object($which) ? null : $which; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if (empty($this->model) && ! empty($this->modelName) && class_exists($this->modelName)) { |
|
| 165 | + if (empty($this->model) && !empty($this->modelName) && class_exists($this->modelName)) { |
|
| 166 | 166 | $this->model = model($this->modelName); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if (! empty($this->model) && empty($this->modelName)) { |
|
| 169 | + if (!empty($this->model) && empty($this->modelName)) { |
|
| 170 | 170 | $this->modelName = $this->model::class; |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | private function getModel() |
| 206 | 206 | { |
| 207 | - $model = ! empty($this->modelName) ? $this->modelName : str_replace('Controller', 'Model', static::class); |
|
| 207 | + $model = !empty($this->modelName) ? $this->modelName : str_replace('Controller', 'Model', static::class); |
|
| 208 | 208 | |
| 209 | 209 | if (class_exists($model)) { |
| 210 | 210 | $this->setModel($model); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function exists(string $key): bool |
| 63 | 63 | { |
| 64 | - if (! $this->configurator->exists($key)) { |
|
| 64 | + if (!$this->configurator->exists($key)) { |
|
| 65 | 65 | $config = explode('.', $key); |
| 66 | 66 | $this->load($config[0]); |
| 67 | 67 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function missing(string $key): bool |
| 86 | 86 | { |
| 87 | - return ! $this->exists($key); |
|
| 87 | + return !$this->exists($key); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | $this->load($conf, $file, null, $allow_empty); |
| 167 | 167 | } |
| 168 | - } elseif (! isset(self::$loaded[$config])) { |
|
| 168 | + } elseif (!isset(self::$loaded[$config])) { |
|
| 169 | 169 | $file ??= self::path($config); |
| 170 | 170 | $schema ??= self::schema($config); |
| 171 | 171 | |
| 172 | 172 | $configurations = []; |
| 173 | - if (file_exists($file) && ! in_array($file, get_included_files(), true)) { |
|
| 173 | + if (file_exists($file) && !in_array($file, get_included_files(), true)) { |
|
| 174 | 174 | $configurations = (array) require $file; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $configurations = Arr::merge(self::$registrars[$config] ?? [], $configurations); |
| 178 | 178 | |
| 179 | - if (empty($configurations) && ! $allow_empty && ! is_a($schema, Schema::class, true)) { |
|
| 179 | + if (empty($configurations) && !$allow_empty && !is_a($schema, Schema::class, true)) { |
|
| 180 | 180 | return; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $class = new ReflectionClass($classname); |
| 286 | - $methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC); |
|
| 286 | + $methods = $class->getMethods(ReflectionMethod::IS_STATIC|ReflectionMethod::IS_PUBLIC); |
|
| 287 | 287 | |
| 288 | 288 | foreach ($methods as $method) { |
| 289 | - if (! ($method->isPublic() && $method->isStatic())) { |
|
| 289 | + if (!($method->isPublic() && $method->isStatic())) { |
|
| 290 | 290 | continue; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if (! is_array($result = $method->invoke(null))) { |
|
| 293 | + if (!is_array($result = $method->invoke(null))) { |
|
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -359,12 +359,12 @@ discard block |
||
| 359 | 359 | { |
| 360 | 360 | $config = $this->get('app.show_debugbar', 'auto'); |
| 361 | 361 | |
| 362 | - if (! in_array($config, ['auto', true, false], true)) { |
|
| 362 | + if (!in_array($config, ['auto', true, false], true)) { |
|
| 363 | 363 | self::exceptBadConfigValue('show_debugbar', ['auto', true, false], 'app'); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | if ($config === 'auto') { |
| 367 | - $this->set('app.show_debugbar', ! is_online()); |
|
| 367 | + $this->set('app.show_debugbar', !is_online()); |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $controller = $routes->getDefaultController(); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (! $fullName && is_string($controller)) { |
|
| 181 | + if (!$fullName && is_string($controller)) { |
|
| 182 | 182 | $controller = str_replace($routes->getDefaultNamespace(), '', $controller); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -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()); |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | // Essayez de charger automatiquement la classe |
| 414 | - if (! class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
| 414 | + if (!class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
| 415 | 415 | throw PageNotFoundException::controllerNotFound($this->controller, $this->method); |
| 416 | 416 | } |
| 417 | 417 | |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | |
| 503 | 503 | $this->outputBufferingEnd(); |
| 504 | 504 | |
| 505 | - throw PageNotFoundException::pageNotFound(! on_prod() || is_cli() ? $e->getMessage() : ''); |
|
| 505 | + throw PageNotFoundException::pageNotFound(!on_prod() || is_cli() ? $e->getMessage() : ''); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | public function storePreviousURL($uri) |
| 545 | 545 | { |
| 546 | 546 | // Ignorer les requêtes CLI |
| 547 | - if (is_cli() && ! on_test()) { |
|
| 547 | + if (is_cli() && !on_test()) { |
|
| 548 | 548 | return; // @codeCoverageIgnore |
| 549 | 549 | } |
| 550 | 550 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | // Ignorer les reponses non-HTML |
| 557 | - if (! str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) { |
|
| 557 | + if (!str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) { |
|
| 558 | 558 | return; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | */ |
| 579 | 579 | protected function sendResponse() |
| 580 | 580 | { |
| 581 | - if (! $this->isAjaxRequest()) { |
|
| 581 | + if (!$this->isAjaxRequest()) { |
|
| 582 | 582 | $this->response = Services::toolbar()->prepare( |
| 583 | 583 | $this->getPerformanceStats(), |
| 584 | 584 | $this->request, |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | private function spoofRequestMethod(): callable |
| 677 | 677 | { |
| 678 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
| 678 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
| 679 | 679 | $post = $request->getParsedBody(); |
| 680 | 680 | |
| 681 | 681 | // Ne fonctionne qu'avec les formulaires POST |
| 682 | 682 | // Accepte seulement PUT, PATCH, DELETE |
| 683 | - if ($request->getMethod() === Method::POST && ! empty($post['_method']) && in_array($post['_method'], [Method::PUT, Method::PATCH, Method::DELETE], true)) { |
|
| 683 | + if ($request->getMethod() === Method::POST && !empty($post['_method']) && in_array($post['_method'], [Method::PUT, Method::PATCH, Method::DELETE], true)) { |
|
| 684 | 684 | $request = $request->withMethod($post['_method']); |
| 685 | 685 | } |
| 686 | 686 | |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | |
| 691 | 691 | private function bootApp(): callable |
| 692 | 692 | { |
| 693 | - return function (ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
|
| 693 | + return function(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
|
| 694 | 694 | Services::set(Request::class, $request); |
| 695 | 695 | Services::set(Response::class, $response); |
| 696 | 696 | |
@@ -698,10 +698,10 @@ discard block |
||
| 698 | 698 | $returned = $this->startController(); |
| 699 | 699 | |
| 700 | 700 | // Les controleur sous forme de Closure sont executes dans startController(). |
| 701 | - if (! is_callable($this->controller)) { |
|
| 701 | + if (!is_callable($this->controller)) { |
|
| 702 | 702 | $controller = $this->createController($request, $response); |
| 703 | 703 | |
| 704 | - if (! method_exists($controller, '_remap') && ! is_callable([$controller, $this->method], false)) { |
|
| 704 | + if (!method_exists($controller, '_remap') && !is_callable([$controller, $this->method], false)) { |
|
| 705 | 705 | throw PageNotFoundException::methodNotFound($this->method); |
| 706 | 706 | } |
| 707 | 707 | |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | defined('DS') || define('DS', DIRECTORY_SEPARATOR); |
| 17 | 17 | |
| 18 | 18 | // Se rassurer que le dossier courant pointe sur le dossier du front controller |
| 19 | -if (! defined('TEST_PATH')) { |
|
| 19 | +if (!defined('TEST_PATH')) { |
|
| 20 | 20 | // On doit aussi verifier qu'on n'est pas en phase de test, sinon khalan ne trouvera pas le dossier des specs |
| 21 | 21 | chdir(WEBROOT); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -return function (array $paths, string $paths_config_file, bool $is_cli): void { |
|
| 24 | +return function(array $paths, string $paths_config_file, bool $is_cli): void { |
|
| 25 | 25 | // Le chemin d'accès vers le dossier de l'application |
| 26 | 26 | if (is_dir($paths['app'])) { |
| 27 | 27 | if (($_temp = realpath($paths['app'])) !== false) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $app = new Application(); |
| 105 | 105 | $app->init(); |
| 106 | 106 | |
| 107 | - if (! $is_cli) { |
|
| 107 | + if (!$is_cli) { |
|
| 108 | 108 | $app->run(); |
| 109 | 109 | } |
| 110 | 110 | }; |
@@ -434,8 +434,8 @@ |
||
| 434 | 434 | static::PROTOCOL_SMTP => "smtp://{$this->username}:{$this->password}@{$this->host}:{$this->port}", |
| 435 | 435 | static::PROTOCOL_SENDMAIL => 'sendmail://default', |
| 436 | 436 | static::PROTOCOL_MAIL => 'sendmail://default', |
| 437 | - static::PROTOCOL_POSTMARK => "postmark+smtp://{$this->username}@default", // username joue le role de ID |
|
| 438 | - static::PROTOCOL_SENDGRID => "sendgrid+smtp://apikey:{$this->username}@default", // username joue le role de API_KEY |
|
| 437 | + static::PROTOCOL_POSTMARK => "postmark+smtp://{$this->username}@default", // username joue le role de ID |
|
| 438 | + static::PROTOCOL_SENDGRID => "sendgrid+smtp://apikey:{$this->username}@default", // username joue le role de API_KEY |
|
| 439 | 439 | default => "{$this->protocol}+smtp://{$this->username}:{$this->password}@default", |
| 440 | 440 | }; |
| 441 | 441 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function __construct(bool $debug = false) |
| 33 | 33 | { |
| 34 | 34 | $this->mailer = new Mailer(); |
| 35 | - $this->mailer->Debugoutput = static function ($str, $level): void { |
|
| 35 | + $this->mailer->Debugoutput = static function($str, $level): void { |
|
| 36 | 36 | Services::logger()->info('[Mail][' . $level . ']: ' . $str); |
| 37 | 37 | }; |
| 38 | 38 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function init(array $config): static |
| 46 | 46 | { |
| 47 | - if (! empty($config['username']) && ! empty($config['password'])) { |
|
| 47 | + if (!empty($config['username']) && !empty($config['password'])) { |
|
| 48 | 48 | $this->mailer->SMTPAuth = true; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $handler = static::$validHandlers[$handler]; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if (! class_exists($handler)) { |
|
| 129 | + if (!class_exists($handler)) { |
|
| 130 | 130 | throw new InvalidArgumentException(lang('Mail.invalidHandler', [$handler])); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $debug = on_dev(); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if (! is_subclass_of($handler, AbstractAdapter::class)) { |
|
| 138 | + if (!is_subclass_of($handler, AbstractAdapter::class)) { |
|
| 139 | 139 | throw new InvalidArgumentException(lang('Mail.handlerMustExtendClass', [$handler, AbstractAdapter::class])); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -341,15 +341,15 @@ discard block |
||
| 341 | 341 | $path = ''; |
| 342 | 342 | |
| 343 | 343 | // N'est-il pas namespaced ? on cherche le dossier en fonction du parametre "view_base" |
| 344 | - if (! str_contains($view, '\\')) { |
|
| 344 | + if (!str_contains($view, '\\')) { |
|
| 345 | 345 | $path = $this->config['view_dir'] ?? ''; |
| 346 | - if (! empty($path)) { |
|
| 346 | + if (!empty($path)) { |
|
| 347 | 347 | $path .= '/'; |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | $view = view($path . $view, $data); |
| 352 | - if (! empty($this->config['template'])) { |
|
| 352 | + if (!empty($this->config['template'])) { |
|
| 353 | 353 | $view->layout($this->config['template']); |
| 354 | 354 | } |
| 355 | 355 | |