From c5fbff50a02f38e16ee74794b46e9820cd4c11fa Mon Sep 17 00:00:00 2001 From: Petr Heinz Date: Thu, 24 Feb 2022 16:57:39 +0100 Subject: [PATCH 1/3] Update coding-standard to 8.6 and mockery-tools to 3.8 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f6b69a8..4befd07 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "slim/slim": "^3.12" }, "require-dev": { - "brandembassy/coding-standard": "^8.1", - "brandembassy/mockery-tools": "^2.14", + "brandembassy/coding-standard": "^8.6", + "brandembassy/mockery-tools": "^3.8", "mockery/mockery": "^1.2", "phpunit/phpunit": "^8.5", "roave/security-advisories": "dev-master" From cac076f7bc3321d0bb7374e30cfd2aa957ed6e6b Mon Sep 17 00:00:00 2001 From: Petr Heinz Date: Thu, 24 Feb 2022 16:58:57 +0100 Subject: [PATCH 2/3] Set PHP 7.2 for code sniffer when running on this repo --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4befd07..9edceaf 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,8 @@ "roave/security-advisories": "dev-master" }, "scripts": { - "phpcs": "vendor/bin/phpcs --standard=BrandEmbassyCodingStandard src tests --ignore=tests/temp", - "phpcbf": "./vendor/bin/phpcbf --standard=BrandEmbassyCodingStandard src tests --ignore=tests/temp", + "phpcs": "vendor/bin/phpcs --standard=BrandEmbassyCodingStandard src tests --ignore=tests/temp --runtime-set php_version 70200", + "phpcbf": "./vendor/bin/phpcbf --standard=BrandEmbassyCodingStandard src tests --ignore=tests/temp --runtime-set php_version 70200", "phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon src", "phpunit": "./vendor/bin/phpunit tests --no-coverage" }, From c5ebbb7d253242c35ae1e5ac18d49426ed12e5ad Mon Sep 17 00:00:00 2001 From: Petr Heinz Date: Thu, 24 Feb 2022 17:00:35 +0100 Subject: [PATCH 3/3] composer phpcbf - mark final classes via annotations --- src/DI/ServiceProvider.php | 5 ++++- src/DI/SlimApiExtension.php | 5 ++++- src/Middleware/BeforeRouteMiddlewares.php | 5 ++++- src/Middleware/MiddlewareFactory.php | 5 ++++- src/Middleware/MiddlewareGroups.php | 5 ++++- src/Request/DefaultRequestFactory.php | 5 ++++- src/Request/QueryParamMissingException.php | 5 ++++- src/Request/Request.php | 4 +++- src/Request/RequestAttributeMissingException.php | 5 ++++- src/Request/RequestFieldMissingException.php | 5 ++++- src/Request/RouteArgumentMissingException.php | 5 ++++- src/Response/DefaultResponseFactory.php | 5 ++++- src/Response/Response.php | 5 ++++- src/Route/InvalidRouteDefinitionException.php | 5 ++++- src/Route/RouteDefinition.php | 5 ++++- src/Route/RouteDefinitionFactory.php | 5 ++++- src/Route/RouteRegister.php | 5 ++++- src/Route/UrlPatternResolver.php | 5 ++++- src/SlimApplicationFactory.php | 5 ++++- src/SlimContainerFactory.php | 5 ++++- tests/MiddlewareInvocationCounter.php | 5 ++++- tests/Request/RequestTest.php | 5 ++++- tests/Response/ResponseTest.php | 5 ++++- tests/Sample/ApiErrorHandler.php | 5 ++++- tests/Sample/CreateChannelRoute.php | 5 ++++- tests/Sample/CreateChannelUserRoute.php | 5 ++++- tests/Sample/ErrorThrowingRoute.php | 5 ++++- tests/Sample/GoldenKeyAuthMiddleware.php | 5 ++++- tests/Sample/GroupMiddleware.php | 5 ++++- tests/Sample/HelloWorldRoute.php | 5 ++++- tests/Sample/InvokeCounterMiddleware.php | 5 ++++- tests/Sample/ListChannelsRoute.php | 5 ++++- tests/Sample/NotAllowedHandler.php | 4 +++- tests/Sample/NotFoundHandler.php | 5 ++++- tests/Sample/OnlyApiGroupMiddleware.php | 5 ++++- tests/SlimAppTester.php | 5 ++++- tests/SlimApplicationFactoryTest.php | 5 ++++- 37 files changed, 146 insertions(+), 37 deletions(-) diff --git a/src/DI/ServiceProvider.php b/src/DI/ServiceProvider.php index 0d3385e..b05f6e9 100644 --- a/src/DI/ServiceProvider.php +++ b/src/DI/ServiceProvider.php @@ -7,7 +7,10 @@ use function assert; use function class_exists; -final class ServiceProvider +/** + * @final + */ +class ServiceProvider { /** * @return object diff --git a/src/DI/SlimApiExtension.php b/src/DI/SlimApiExtension.php index 4925c9c..dd67d05 100644 --- a/src/DI/SlimApiExtension.php +++ b/src/DI/SlimApiExtension.php @@ -22,7 +22,10 @@ use Slim\Container; use Slim\Router; -final class SlimApiExtension extends CompilerExtension +/** + * @final + */ +class SlimApiExtension extends CompilerExtension { public function getConfigSchema(): Schema { diff --git a/src/Middleware/BeforeRouteMiddlewares.php b/src/Middleware/BeforeRouteMiddlewares.php index 8839641..5e805b9 100644 --- a/src/Middleware/BeforeRouteMiddlewares.php +++ b/src/Middleware/BeforeRouteMiddlewares.php @@ -2,7 +2,10 @@ namespace BrandEmbassy\Slim\Middleware; -final class BeforeRouteMiddlewares +/** + * @final + */ +class BeforeRouteMiddlewares { /** * @var callable[] diff --git a/src/Middleware/MiddlewareFactory.php b/src/Middleware/MiddlewareFactory.php index 0568196..19c81ca 100644 --- a/src/Middleware/MiddlewareFactory.php +++ b/src/Middleware/MiddlewareFactory.php @@ -8,7 +8,10 @@ use function assert; use function is_callable; -final class MiddlewareFactory +/** + * @final + */ +class MiddlewareFactory { /** * @var Container diff --git a/src/Middleware/MiddlewareGroups.php b/src/Middleware/MiddlewareGroups.php index 5377a6e..1dbcd27 100644 --- a/src/Middleware/MiddlewareGroups.php +++ b/src/Middleware/MiddlewareGroups.php @@ -5,7 +5,10 @@ use function array_map; use function array_merge_recursive; -final class MiddlewareGroups +/** + * @final + */ +class MiddlewareGroups { /** * @var array diff --git a/src/Request/DefaultRequestFactory.php b/src/Request/DefaultRequestFactory.php index f4a7483..8a98306 100644 --- a/src/Request/DefaultRequestFactory.php +++ b/src/Request/DefaultRequestFactory.php @@ -4,7 +4,10 @@ use Slim\Http\Environment; -final class DefaultRequestFactory implements RequestFactory +/** + * @final + */ +class DefaultRequestFactory implements RequestFactory { public function create(): RequestInterface { diff --git a/src/Request/QueryParamMissingException.php b/src/Request/QueryParamMissingException.php index 69078fc..4354eda 100644 --- a/src/Request/QueryParamMissingException.php +++ b/src/Request/QueryParamMissingException.php @@ -4,7 +4,10 @@ use function sprintf; -final class QueryParamMissingException extends RequestException +/** + * @final + */ +class QueryParamMissingException extends RequestException { public static function create(string $key): self { diff --git a/src/Request/Request.php b/src/Request/Request.php index 970fd75..f942951 100644 --- a/src/Request/Request.php +++ b/src/Request/Request.php @@ -18,8 +18,10 @@ /** * @method string[]|string[][] getQueryParams() * @method string|string[]|null getQueryParam(string $key, ?string $default = null) + * + * @final */ -final class Request extends SlimRequest implements RequestInterface +class Request extends SlimRequest implements RequestInterface { private const ROUTE_INFO_ATTRIBUTE = 'routeInfo'; private const ROUTE_ATTRIBUTE = 'route'; diff --git a/src/Request/RequestAttributeMissingException.php b/src/Request/RequestAttributeMissingException.php index 669cd60..e4e68fb 100644 --- a/src/Request/RequestAttributeMissingException.php +++ b/src/Request/RequestAttributeMissingException.php @@ -4,7 +4,10 @@ use function sprintf; -final class RequestAttributeMissingException extends RequestException +/** + * @final + */ +class RequestAttributeMissingException extends RequestException { public static function create(string $requestAttributeName): self { diff --git a/src/Request/RequestFieldMissingException.php b/src/Request/RequestFieldMissingException.php index 910e1bd..d7e8d84 100644 --- a/src/Request/RequestFieldMissingException.php +++ b/src/Request/RequestFieldMissingException.php @@ -4,7 +4,10 @@ use function sprintf; -final class RequestFieldMissingException extends RequestException +/** + * @final + */ +class RequestFieldMissingException extends RequestException { public static function create(string $fieldName): self { diff --git a/src/Request/RouteArgumentMissingException.php b/src/Request/RouteArgumentMissingException.php index dc7459a..4dc1818 100644 --- a/src/Request/RouteArgumentMissingException.php +++ b/src/Request/RouteArgumentMissingException.php @@ -4,7 +4,10 @@ use function sprintf; -final class RouteArgumentMissingException extends RequestException +/** + * @final + */ +class RouteArgumentMissingException extends RequestException { public static function create(string $argument): self { diff --git a/src/Response/DefaultResponseFactory.php b/src/Response/DefaultResponseFactory.php index aba73ac..35fe749 100644 --- a/src/Response/DefaultResponseFactory.php +++ b/src/Response/DefaultResponseFactory.php @@ -2,7 +2,10 @@ namespace BrandEmbassy\Slim\Response; -final class DefaultResponseFactory implements ResponseFactory +/** + * @final + */ +class DefaultResponseFactory implements ResponseFactory { public function create(): ResponseInterface { diff --git a/src/Response/Response.php b/src/Response/Response.php index 90b7745..7a9cf2f 100644 --- a/src/Response/Response.php +++ b/src/Response/Response.php @@ -8,7 +8,10 @@ use function assert; use function is_array; -final class Response extends SlimResponse implements ResponseInterface +/** + * @final + */ +class Response extends SlimResponse implements ResponseInterface { /** * @return mixed[] diff --git a/src/Route/InvalidRouteDefinitionException.php b/src/Route/InvalidRouteDefinitionException.php index 60df4f9..871cdbe 100644 --- a/src/Route/InvalidRouteDefinitionException.php +++ b/src/Route/InvalidRouteDefinitionException.php @@ -6,7 +6,10 @@ use function implode; use function sprintf; -final class InvalidRouteDefinitionException extends RuntimeException +/** + * @final + */ +class InvalidRouteDefinitionException extends RuntimeException { /** * @param string[] $path diff --git a/src/Route/RouteDefinition.php b/src/Route/RouteDefinition.php index 2591b96..4a4df83 100644 --- a/src/Route/RouteDefinition.php +++ b/src/Route/RouteDefinition.php @@ -2,7 +2,10 @@ namespace BrandEmbassy\Slim\Route; -final class RouteDefinition +/** + * @final + */ +class RouteDefinition { public const SERVICE = 'service'; public const MIDDLEWARES = 'middlewares'; diff --git a/src/Route/RouteDefinitionFactory.php b/src/Route/RouteDefinitionFactory.php index b7c50ca..b0d28cd 100644 --- a/src/Route/RouteDefinitionFactory.php +++ b/src/Route/RouteDefinitionFactory.php @@ -7,7 +7,10 @@ use LogicException; use Nette\DI\Container; -final class RouteDefinitionFactory +/** + * @final + */ +class RouteDefinitionFactory { /** * @var Container diff --git a/src/Route/RouteRegister.php b/src/Route/RouteRegister.php index b30071d..285c12a 100644 --- a/src/Route/RouteRegister.php +++ b/src/Route/RouteRegister.php @@ -9,7 +9,10 @@ use function array_merge_recursive; use function levenshtein; -final class RouteRegister +/** + * @final + */ +class RouteRegister { /** * @var RouterInterface diff --git a/src/Route/UrlPatternResolver.php b/src/Route/UrlPatternResolver.php index 255101e..3508bc7 100644 --- a/src/Route/UrlPatternResolver.php +++ b/src/Route/UrlPatternResolver.php @@ -4,7 +4,10 @@ use function trim; -final class UrlPatternResolver +/** + * @final + */ +class UrlPatternResolver { /** * @var string diff --git a/src/SlimApplicationFactory.php b/src/SlimApplicationFactory.php index a7b374a..e3de57e 100644 --- a/src/SlimApplicationFactory.php +++ b/src/SlimApplicationFactory.php @@ -14,7 +14,10 @@ use function is_callable; use function sprintf; -final class SlimApplicationFactory +/** + * @final + */ +class SlimApplicationFactory { public const SLIM_CONFIGURATION = 'slimConfiguration'; public const BEFORE_ROUTE_MIDDLEWARES = 'beforeRouteMiddlewares'; diff --git a/src/SlimContainerFactory.php b/src/SlimContainerFactory.php index e2eed7e..b10d337 100644 --- a/src/SlimContainerFactory.php +++ b/src/SlimContainerFactory.php @@ -7,7 +7,10 @@ use Slim\Container; use Slim\Interfaces\RouterInterface; -final class SlimContainerFactory +/** + * @final + */ +class SlimContainerFactory { /** * @var ResponseFactory diff --git a/tests/MiddlewareInvocationCounter.php b/tests/MiddlewareInvocationCounter.php index 51469c9..6d7cf79 100644 --- a/tests/MiddlewareInvocationCounter.php +++ b/tests/MiddlewareInvocationCounter.php @@ -4,7 +4,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; -final class MiddlewareInvocationCounter +/** + * @final + */ +class MiddlewareInvocationCounter { /** * @var int diff --git a/tests/Request/RequestTest.php b/tests/Request/RequestTest.php index 6b18b96..f63a3fe 100644 --- a/tests/Request/RequestTest.php +++ b/tests/Request/RequestTest.php @@ -13,7 +13,10 @@ use PHPUnit\Framework\TestCase; use function urlencode; -final class RequestTest extends TestCase +/** + * @final + */ +class RequestTest extends TestCase { private const PARAM_NAME = 'dateFrom'; private const DATE_TIME_STRING = '2017-06-10T01:00:00+01:00'; diff --git a/tests/Response/ResponseTest.php b/tests/Response/ResponseTest.php index 36ffad9..cff9450 100644 --- a/tests/Response/ResponseTest.php +++ b/tests/Response/ResponseTest.php @@ -6,7 +6,10 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; -final class ResponseTest extends TestCase +/** + * @final + */ +class ResponseTest extends TestCase { public function testGetParsedBodyAsArray(): void { diff --git a/tests/Sample/ApiErrorHandler.php b/tests/Sample/ApiErrorHandler.php index ddea37f..a9aa566 100644 --- a/tests/Sample/ApiErrorHandler.php +++ b/tests/Sample/ApiErrorHandler.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use Throwable; -final class ApiErrorHandler implements ErrorHandler +/** + * @final + */ +class ApiErrorHandler implements ErrorHandler { public function __invoke( RequestInterface $request, diff --git a/tests/Sample/CreateChannelRoute.php b/tests/Sample/CreateChannelRoute.php index d29920e..284bab3 100644 --- a/tests/Sample/CreateChannelRoute.php +++ b/tests/Sample/CreateChannelRoute.php @@ -6,7 +6,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use BrandEmbassy\Slim\Route\Route; -final class CreateChannelRoute implements Route +/** + * @final + */ +class CreateChannelRoute implements Route { /** * @param string[] $arguments diff --git a/tests/Sample/CreateChannelUserRoute.php b/tests/Sample/CreateChannelUserRoute.php index deeaf67..824a9b6 100644 --- a/tests/Sample/CreateChannelUserRoute.php +++ b/tests/Sample/CreateChannelUserRoute.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Route\Route; use function assert; -final class CreateChannelUserRoute implements Route +/** + * @final + */ +class CreateChannelUserRoute implements Route { /** * @var RequestInterface diff --git a/tests/Sample/ErrorThrowingRoute.php b/tests/Sample/ErrorThrowingRoute.php index a821526..9a41126 100644 --- a/tests/Sample/ErrorThrowingRoute.php +++ b/tests/Sample/ErrorThrowingRoute.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Route\Route; use LogicException; -final class ErrorThrowingRoute implements Route +/** + * @final + */ +class ErrorThrowingRoute implements Route { public function __invoke(RequestInterface $request, ResponseInterface $response): ResponseInterface { diff --git a/tests/Sample/GoldenKeyAuthMiddleware.php b/tests/Sample/GoldenKeyAuthMiddleware.php index 15197d6..970b208 100644 --- a/tests/Sample/GoldenKeyAuthMiddleware.php +++ b/tests/Sample/GoldenKeyAuthMiddleware.php @@ -6,7 +6,10 @@ use BrandEmbassy\Slim\Request\RequestInterface; use BrandEmbassy\Slim\Response\ResponseInterface; -final class GoldenKeyAuthMiddleware implements Middleware +/** + * @final + */ +class GoldenKeyAuthMiddleware implements Middleware { public const ACCESS_TOKEN = 'uber-secret-token-made-of-pure-gold'; diff --git a/tests/Sample/GroupMiddleware.php b/tests/Sample/GroupMiddleware.php index ed1bbcf..ad1a54b 100644 --- a/tests/Sample/GroupMiddleware.php +++ b/tests/Sample/GroupMiddleware.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use BrandEmbassyTest\Slim\MiddlewareInvocationCounter; -final class GroupMiddleware implements Middleware +/** + * @final + */ +class GroupMiddleware implements Middleware { public const HEADER_NAME = 'group-middleware'; diff --git a/tests/Sample/HelloWorldRoute.php b/tests/Sample/HelloWorldRoute.php index b0af873..20acf93 100644 --- a/tests/Sample/HelloWorldRoute.php +++ b/tests/Sample/HelloWorldRoute.php @@ -6,7 +6,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use BrandEmbassy\Slim\Route\Route; -final class HelloWorldRoute implements Route +/** + * @final + */ +class HelloWorldRoute implements Route { public function __invoke(RequestInterface $request, ResponseInterface $response): ResponseInterface { diff --git a/tests/Sample/InvokeCounterMiddleware.php b/tests/Sample/InvokeCounterMiddleware.php index 55b58f1..2988a6b 100644 --- a/tests/Sample/InvokeCounterMiddleware.php +++ b/tests/Sample/InvokeCounterMiddleware.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use BrandEmbassyTest\Slim\MiddlewareInvocationCounter; -final class InvokeCounterMiddleware implements Middleware +/** + * @final + */ +class InvokeCounterMiddleware implements Middleware { public const HEADER_NAME_PREFIX = 'invoke-counter-'; diff --git a/tests/Sample/ListChannelsRoute.php b/tests/Sample/ListChannelsRoute.php index 57ab0c0..f72f2b1 100644 --- a/tests/Sample/ListChannelsRoute.php +++ b/tests/Sample/ListChannelsRoute.php @@ -6,7 +6,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use BrandEmbassy\Slim\Route\Route; -final class ListChannelsRoute implements Route +/** + * @final + */ +class ListChannelsRoute implements Route { /** * @param string[] $arguments diff --git a/tests/Sample/NotAllowedHandler.php b/tests/Sample/NotAllowedHandler.php index 309a556..138e026 100644 --- a/tests/Sample/NotAllowedHandler.php +++ b/tests/Sample/NotAllowedHandler.php @@ -7,8 +7,10 @@ /** * Intentionally not extending ErrorHandler. Slim does not call this with 3rd param at __invoke method. + * + * @final */ -final class NotAllowedHandler +class NotAllowedHandler { public function __invoke(RequestInterface $request, ResponseInterface $response): ResponseInterface { diff --git a/tests/Sample/NotFoundHandler.php b/tests/Sample/NotFoundHandler.php index a774bf0..1bfbbba 100644 --- a/tests/Sample/NotFoundHandler.php +++ b/tests/Sample/NotFoundHandler.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use Throwable; -final class NotFoundHandler implements ErrorHandler +/** + * @final + */ +class NotFoundHandler implements ErrorHandler { public function __invoke( RequestInterface $request, diff --git a/tests/Sample/OnlyApiGroupMiddleware.php b/tests/Sample/OnlyApiGroupMiddleware.php index 40530ee..5b8e5fc 100644 --- a/tests/Sample/OnlyApiGroupMiddleware.php +++ b/tests/Sample/OnlyApiGroupMiddleware.php @@ -7,7 +7,10 @@ use BrandEmbassy\Slim\Response\ResponseInterface; use BrandEmbassyTest\Slim\MiddlewareInvocationCounter; -final class OnlyApiGroupMiddleware implements Middleware +/** + * @final + */ +class OnlyApiGroupMiddleware implements Middleware { public const HEADER_NAME = 'only-api-group-middleware'; diff --git a/tests/SlimAppTester.php b/tests/SlimAppTester.php index 83e1d11..b81e2a9 100644 --- a/tests/SlimAppTester.php +++ b/tests/SlimAppTester.php @@ -12,7 +12,10 @@ use function assert; use function md5; -final class SlimAppTester +/** + * @final + */ +class SlimAppTester { public static function createSlimApp(string $configPath = __DIR__ . '/config.neon'): SlimApp { diff --git a/tests/SlimApplicationFactoryTest.php b/tests/SlimApplicationFactoryTest.php index 66a5de8..08695f0 100644 --- a/tests/SlimApplicationFactoryTest.php +++ b/tests/SlimApplicationFactoryTest.php @@ -15,7 +15,10 @@ use function assert; use function count; -final class SlimApplicationFactoryTest extends TestCase +/** + * @final + */ +class SlimApplicationFactoryTest extends TestCase { public function testShouldPassSettingsToSlimContainer(): void {