diff --git a/composer.json b/composer.json index 4a312ec2..1515cfeb 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,7 @@ "phpunit/phpcov": "^6.0", "phpunit/phpunit": "^8.3", "roave/security-advisories": "dev-master", - "shlinkio/php-coding-standard": "~1.2.2", + "shlinkio/php-coding-standard": "~2.0.0", "shlinkio/shlink-test-utils": "^1.0", "symfony/dotenv": "^4.3", "symfony/var-dumper": "^4.3", diff --git a/config/autoload/app_options.global.php b/config/autoload/app_options.global.php index 9b363f1f..e10f1b20 100644 --- a/config/autoload/app_options.global.php +++ b/config/autoload/app_options.global.php @@ -1,4 +1,5 @@ [ diff --git a/config/autoload/router.global.php b/config/autoload/router.global.php index 24f40e71..7ab1cc82 100644 --- a/config/autoload/router.global.php +++ b/config/autoload/router.global.php @@ -1,4 +1,5 @@ get(EntityManager::class); +return (function () { + /** @var ContainerInterface|ServiceManager $container */ + $container = include __DIR__ . '/container.php'; + $em = $container->get(EntityManager::class); -return ConsoleRunner::createHelperSet($em); + return ConsoleRunner::createHelperSet($em); +})(); diff --git a/config/config.php b/config/config.php index 3a44fb17..ed04d037 100644 --- a/config/config.php +++ b/config/config.php @@ -1,4 +1,5 @@ setTable('domains'); diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php index 47bc9d10..8dd6dc49 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php @@ -1,4 +1,5 @@ setTable('short_urls') diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php index b8a4ac33..8ecaa2c6 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php @@ -1,4 +1,5 @@ setTable('tags') diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php index f16cf147..c30b83c9 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php @@ -1,4 +1,5 @@ setTable('visits') diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php index 762e5e13..073214d3 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php @@ -1,4 +1,5 @@ setTable('visit_locations'); diff --git a/module/Core/config/entity-manager.config.php b/module/Core/config/entity-manager.config.php index 4d331494..d7af7ac5 100644 --- a/module/Core/config/entity-manager.config.php +++ b/module/Core/config/entity-manager.config.php @@ -1,4 +1,5 @@ getEntityManager()->getConnection()->getDatabasePlatform()->getName(); $ordering = $dbPlatform === 'postgresql' ? 'ASC' : 'DESC'; - $dql= <<setTable('api_keys'); diff --git a/module/Rest/config/entity-manager.config.php b/module/Rest/config/entity-manager.config.php index 4d331494..d7af7ac5 100644 --- a/module/Rest/config/entity-manager.config.php +++ b/module/Rest/config/entity-manager.config.php @@ -1,4 +1,5 @@ getAttribute(RouteResult::class); - if ($routeResult === null + if ( + $routeResult === null || $routeResult->isFailure() || $request->getMethod() === self::METHOD_OPTIONS || contains($this->routesWhitelist, $routeResult->getMatchedRouteName()) diff --git a/module/Rest/src/Middleware/BodyParserMiddleware.php b/module/Rest/src/Middleware/BodyParserMiddleware.php index 79ae52ee..5814753e 100644 --- a/module/Rest/src/Middleware/BodyParserMiddleware.php +++ b/module/Rest/src/Middleware/BodyParserMiddleware.php @@ -1,4 +1,5 @@ getParsedBody(); // In requests that do not allow body or if the body has already been parsed, continue to next middleware - if (! empty($currentParams) || contains([ - self::METHOD_GET, - self::METHOD_HEAD, - self::METHOD_OPTIONS, - ], $method)) { + if ( + ! empty($currentParams) + || contains([ + self::METHOD_GET, + self::METHOD_HEAD, + self::METHOD_OPTIONS, + ], $method) + ) { return $handler->handle($request); } diff --git a/module/Rest/src/Middleware/CrossDomainMiddleware.php b/module/Rest/src/Middleware/CrossDomainMiddleware.php index 9ebc84e7..aacda9fc 100644 --- a/module/Rest/src/Middleware/CrossDomainMiddleware.php +++ b/module/Rest/src/Middleware/CrossDomainMiddleware.php @@ -1,4 +1,5 @@ [new class extends Exception implements ContainerExceptionInterface { - }]; + $containerException = new class extends Exception implements ContainerExceptionInterface { + }; + + yield 'container exception' => [$containerException]; yield 'authentication exception' => [NoAuthenticationException::fromExpectedTypes([])]; } diff --git a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php index df1216cd..fb69c695 100644 --- a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php +++ b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php @@ -1,4 +1,5 @@ get(Application::class)->run(); +(function () { + /** @var ContainerInterface $container */ + $container = include __DIR__ . '/../config/container.php'; + $container->get(Application::class)->run(); +})();