From 303688c1a7fb4713fc2031759b75000a038a4d65 Mon Sep 17 00:00:00 2001 From: sspat Date: Thu, 21 Jul 2022 16:18:59 +0300 Subject: [PATCH] get rid of forks (#174) * get rid of forks * Fix static analysis complaints * Fix mutation testing error * fix phpstan error Co-authored-by: Patrik Foldes --- README.md | 13 ------------- composer.json | 14 ++------------ phpstan.neon | 12 ++++++++++++ src/Router/RouteLoader.php | 5 +++-- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 9272e90..c551c32 100644 --- a/README.md +++ b/README.md @@ -24,19 +24,6 @@ All you have to do is to implement the API call handler interfaces and return th The preferred way to install this extension is through [composer](http://getcomposer.org/download/). -The following workaround with a forked version of `cebe/php-openapi` will be used until a version of it -compatible with php 8.1 will be released: - -Add to your composer.json -``` -"repositories": [ - { - "type": "vcs", - "url": "https://github.com/onmoon/php-openapi" - } -], -``` - Run ``` diff --git a/composer.json b/composer.json index 46d595e..72adfc1 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ "require": { "php": "^8.0", "ext-json": "*", - "cebe/php-openapi": "dev-php-81-compat", - "league/openapi-psr7-validator": "dev-use-forked-php-openapi", + "cebe/php-openapi": "^1.7", + "league/openapi-psr7-validator": "^0.18.0", "lukasoppermann/http-status": "^3.2", "nikic/php-parser": "^4.13", "nyholm/psr7": "^1.5", @@ -60,16 +60,6 @@ "thecodingmachine/phpstan-safe-rule": "^1.2", "vimeo/psalm": "^4.22" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/onmoon/php-openapi" - }, - { - "type": "vcs", - "url": "https://github.com/onmoon/openapi-psr7-validator" - } - ], "minimum-stability": "dev", "prefer-stable": true, "config": { diff --git a/phpstan.neon b/phpstan.neon index e2cde8f..ae5e870 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,6 +29,18 @@ parameters: message: '#Instanceof between cebe\\openapi\\spec\\MediaType and cebe\\openapi\\spec\\MediaType will always evaluate to true\.#' paths: - %currentWorkingDirectory%/src/Specification/SpecificationParser.php + - + message: '#SpecificationLoaderTest\.php:55\)\) of method#' + paths: + - %currentWorkingDirectory%/test/functional/Specification/SpecificationLoaderTest.php + - + message: '#TestApiServerCodeGeneratorFactory\.php:55\)\) of method#' + paths: + - %currentWorkingDirectory%/test/generation/TestApiServerCodeGeneratorFactory.php + - + message: '#OnMoon\\OpenApiServerBundle\\Router\\RouteLoader::__construct\(\) does not call parent constructor from Symfony\\Component\\Config\\Loader\\Loader\.#' + paths: + - %currentWorkingDirectory%/src/Router/RouteLoader.php includes: - vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon - vendor/phpstan/phpstan-phpunit/extension.neon diff --git a/src/Router/RouteLoader.php b/src/Router/RouteLoader.php index b345bf9..c482c3a 100644 --- a/src/Router/RouteLoader.php +++ b/src/Router/RouteLoader.php @@ -7,6 +7,7 @@ use OnMoon\OpenApiServerBundle\Controller\ApiController; use OnMoon\OpenApiServerBundle\Specification\SpecificationLoader; use OnMoon\OpenApiServerBundle\Types\ArgumentResolver; +use Stringable; use Symfony\Component\Config\Loader\Loader; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; @@ -25,8 +26,6 @@ public function __construct(SpecificationLoader $loader, ArgumentResolver $argum { $this->loader = $loader; $this->argumentResolver = $argumentResolver; - - parent::__construct(); } public function load(mixed $resource, ?string $type = null): RouteCollection @@ -37,10 +36,12 @@ public function load(mixed $resource, ?string $type = null): RouteCollection $routes = new RouteCollection(); foreach ($specification->getOperations() as $operationId => $operation) { + /** @psalm-var array<(string|Stringable)> $requirements */ $requirements = []; $parameters = $operation->getRequestParameters(); if (array_key_exists('path', $parameters)) { + /** @psalm-var array<(string|Stringable)> $requirements */ $requirements = $this->argumentResolver->resolveArgumentPatterns($parameters['path']); }