From 839da617bf67c62624daa7199bb7c12529d25360 Mon Sep 17 00:00:00 2001 From: osteel Date: Thu, 15 Jun 2023 16:35:06 +0100 Subject: [PATCH] dropped support for PHP 7 --- .../CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 .../ISSUE_TEMPLATE.md | 3 ++ .../PULL_REQUEST_TEMPLATE.md | 0 .github/workflows/ci.yml | 21 ++++++------ composer.json | 7 ++-- rector.php | 14 ++++++++ src/Adapters/HttpFoundationAdapter.php | 2 +- src/Exceptions/ValidationException.php | 1 - src/Validator.php | 32 ++----------------- src/ValidatorBuilder.php | 19 ++--------- 11 files changed, 39 insertions(+), 60 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) rename ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md (73%) rename PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md (100%) create mode 100644 rector.php diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md similarity index 73% rename from ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE.md index 5b48c57..17930c1 100644 --- a/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,5 +1,8 @@ +> **Warning** +> Are you sure your issue is caused by this package? Almost all reported issues come from a misunderstanding of the [OpenAPI specification](https://swagger.io/specification/). Please make sure that your answer isn't there before posting. + ## Detailed description Provide a detailed description of the change or addition you are proposing. diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 497879a..fcacff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,27 +8,30 @@ on: jobs: - phpcs: - name: PHP_CodeSniffer + style: + name: Style runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + tools: cs2pr, phpcs - - name: Run PHP_CodeSniffer - uses: chekalsky/phpcs-action@v1 + - name: Run phpcs + run: phpcs -q --report=checkstyle | cs2pr - phpunit: - name: PHPUnit + tests: + name: Tests runs-on: ubuntu-latest strategy: fail-fast: false matrix: php-version: - - "7.3" - - "7.4" - "8.0" - "8.1" - "8.2" diff --git a/composer.json b/composer.json index b61a1de..3200039 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } ], "require": { - "php": "^7.3|^8.0", + "php": "^8.0", "ext-json": "*", "league/openapi-psr7-validator": "^0.19", "nyholm/psr7": "^1.0", @@ -33,6 +33,7 @@ }, "require-dev": { "phpunit/phpunit": "^9.0", + "rector/rector": "^0.17.1", "squizlabs/php_codesniffer": "^3.5" }, "autoload": { @@ -47,8 +48,8 @@ }, "scripts": { "test": "phpunit", - "check-style": "phpcs src tests", - "fix-style": "phpcbf src tests" + "fix": "phpcbf src tests", + "refactor": "rector process" }, "extra": { "branch-alias": { diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..eca49a8 --- /dev/null +++ b/rector.php @@ -0,0 +1,14 @@ +paths([ + __DIR__ . '/src', + ]); + + $rectorConfig->sets([LevelSetList::UP_TO_PHP_80]); +}; diff --git a/src/Adapters/HttpFoundationAdapter.php b/src/Adapters/HttpFoundationAdapter.php index 5a09366..87d01f4 100644 --- a/src/Adapters/HttpFoundationAdapter.php +++ b/src/Adapters/HttpFoundationAdapter.php @@ -39,6 +39,6 @@ public function convert(object $message): MessageInterface return $psrHttpFactory->createRequest($message); } - throw new InvalidArgumentException(sprintf('Unsupported %s object received', get_class($message))); + throw new InvalidArgumentException(sprintf('Unsupported %s object received', $message::class)); } } diff --git a/src/Exceptions/ValidationException.php b/src/Exceptions/ValidationException.php index ee786c8..7418b0a 100644 --- a/src/Exceptions/ValidationException.php +++ b/src/Exceptions/ValidationException.php @@ -13,7 +13,6 @@ class ValidationException extends Exception /** * Build a new exception from a ValidationFailed exception. * - * @param ValidationFailed $exception * @return ValidationException */ public static function fromValidationFailed(ValidationFailed $exception): ValidationException diff --git a/src/Validator.php b/src/Validator.php index d4b5a86..c410938 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -15,37 +15,11 @@ final class Validator implements ValidatorInterface { - /** - * @var RoutedServerRequestValidator - */ - private $requestValidator; - - /** - * @var ResponseValidator - */ - private $responseValidator; - - /** - * @var AdapterInterface - */ - private $adapter; - - /** - * Constructor. - * - * @param RoutedServerRequestValidator $requestValidator - * @param ResponseValidator $responseValidator - * @param AdapterInterface $adapter - * @return void - */ public function __construct( - RoutedServerRequestValidator $requestValidator, - ResponseValidator $responseValidator, - AdapterInterface $adapter + private RoutedServerRequestValidator $requestValidator, + private ResponseValidator $responseValidator, + private AdapterInterface $adapter ) { - $this->requestValidator = $requestValidator; - $this->responseValidator = $responseValidator; - $this->adapter = $adapter; } /** diff --git a/src/ValidatorBuilder.php b/src/ValidatorBuilder.php index 8622fad..9759068 100644 --- a/src/ValidatorBuilder.php +++ b/src/ValidatorBuilder.php @@ -14,25 +14,10 @@ */ final class ValidatorBuilder implements ValidatorBuilderInterface { - /** - * @var string - */ - private $adapter = HttpFoundationAdapter::class; - - /** - * @var BaseValidatorBuilder - */ - private $validatorBuilder; + private string $adapter = HttpFoundationAdapter::class; - /** - * Constructor. - * - * @param BaseValidatorBuilder $builder - * @return void - */ - public function __construct(BaseValidatorBuilder $builder) + public function __construct(private BaseValidatorBuilder $validatorBuilder) { - $this->validatorBuilder = $builder; } /**