diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd92346..bcbebb1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: true matrix: - laravel: ['10.*', '11.*', '12.*'] + laravel: ['10.*', '11.*', '12.*', '13.*'] php: [8.1, 8.2, 8.3, 8.4] phpunit: [ '10.*', '11.*'] include: @@ -25,6 +25,8 @@ jobs: testbench: 9.* - laravel: 12.* testbench: 10.* + - laravel: 13.* + testbench: 11.* exclude: - laravel: 10.* phpunit: 11.* @@ -36,6 +38,12 @@ jobs: php: 8.1 - laravel: 12.* phpunit: 10.* + - laravel: 13.* + php: 8.1 + - laravel: 13.* + php: 8.2 + - laravel: 13.* + phpunit: 10.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - PU${{ matrix.phpunit }} diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml index ba70704..c687806 100644 --- a/.github/workflows/tidy.yml +++ b/.github/workflows/tidy.yml @@ -5,12 +5,17 @@ on: pull_request: branches: [ master ] +permissions: + contents: write + jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: "laravel-pint" uses: aglipanci/laravel-pint-action@2.3.1 @@ -21,4 +26,4 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: PHP Linting (Pint) - skip_fetch: true + skip_fetch: false diff --git a/_ide_helpers.php b/_ide_helpers.php index 1d10fd3..4852425 100644 --- a/_ide_helpers.php +++ b/_ide_helpers.php @@ -5,8 +5,10 @@ /** @noinspection PhpUnusedAliasInspection */ namespace Illuminate\Testing { + use Spectator\Assertions; + /** - * @see \Spectator\Assertions + * @see Assertions * * @method $this assertValidRequest() * @method $this assertInvalidRequest() diff --git a/composer.json b/composer.json index 7cc1cd0..4205481 100644 --- a/composer.json +++ b/composer.json @@ -19,15 +19,15 @@ "php": "^8.1", "ext-json": "*", "devizzent/cebe-php-openapi": "^1.0", - "laravel/framework": "^10.0 | ^11.0 | ^12.0", + "laravel/framework": ">=10.0", "opis/json-schema": "^2.3" }, "require-dev": { - "larastan/larastan": "^2.8|^3.0", + "larastan/larastan": ">=2.8", "laravel/pint": "^1.13", - "nunomaduro/collision": "^7.0|^8.0", - "orchestra/testbench": "^8.0|^9.0 | ^10.0", - "phpunit/phpunit": "^10.0|^11.0" + "nunomaduro/collision": ">=7.0", + "orchestra/testbench": ">=8.0", + "phpunit/phpunit": ">=10.0" }, "autoload": { "psr-4": { diff --git a/src/Assertions.php b/src/Assertions.php index bbd2788..be8ed75 100644 --- a/src/Assertions.php +++ b/src/Assertions.php @@ -6,6 +6,7 @@ use cebe\openapi\exceptions\UnresolvableReferenceException; use Closure; use Illuminate\Support\Str; +use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Assert as PHPUnit; use PHPUnit\Framework\ExpectationFailedException; use Spectator\Concerns\HasExpectations; @@ -16,7 +17,7 @@ use Spectator\Exceptions\ResponseValidationException; /** - * @mixin \Illuminate\Testing\TestResponse + * @mixin TestResponse */ class Assertions { diff --git a/src/Middleware.php b/src/Middleware.php index 36334eb..9b013bb 100644 --- a/src/Middleware.php +++ b/src/Middleware.php @@ -44,7 +44,7 @@ public function handle(Request $request, Closure $next): mixed } try { - /** @var \Illuminate\Routing\Route $route */ + /** @var Route $route */ $route = $request->route(); [$specPath, $pathItem] = $this->pathItem($route, $request->method(), $request->path()); } catch (InvalidPathException|MalformedSpecException|MissingSpecException|TypeErrorException|UnresolvableReferenceException $exception) { diff --git a/src/RequestFactory.php b/src/RequestFactory.php index ad42ba7..6281589 100644 --- a/src/RequestFactory.php +++ b/src/RequestFactory.php @@ -2,7 +2,10 @@ namespace Spectator; +use cebe\openapi\exceptions\IOException; use cebe\openapi\exceptions\TypeErrorException; +use cebe\openapi\exceptions\UnresolvableReferenceException; +use cebe\openapi\json\InvalidJsonPointerSyntaxException; use cebe\openapi\Reader; use cebe\openapi\spec\OpenApi; use Illuminate\Support\Arr; @@ -24,7 +27,7 @@ class RequestFactory protected ?string $pathPrefix = null; - /** @var array */ + /** @var array */ private static array $cachedSpecs = []; /** @@ -78,9 +81,9 @@ public function reset(): void * Resolve and parse the spec. * * - * @throws \cebe\openapi\exceptions\IOException - * @throws \cebe\openapi\exceptions\UnresolvableReferenceException - * @throws \cebe\openapi\json\InvalidJsonPointerSyntaxException + * @throws IOException + * @throws UnresolvableReferenceException + * @throws InvalidJsonPointerSyntaxException * @throws MalformedSpecException * @throws MissingSpecException */ diff --git a/src/Spectator.php b/src/Spectator.php index abcf3eb..de2b155 100644 --- a/src/Spectator.php +++ b/src/Spectator.php @@ -13,7 +13,7 @@ * @method static \stdClass resolve() Resolve the spec into an object. * @method bool shouldValidateRequest() Indicate if request should be validated. * - * @see \Spectator\RequestFactory + * @see RequestFactory */ class Spectator extends Facade { diff --git a/src/Validation/RequestValidator.php b/src/Validation/RequestValidator.php index d09fcf6..17c92f3 100644 --- a/src/Validation/RequestValidator.php +++ b/src/Validation/RequestValidator.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Http\UploadedFile; +use Illuminate\Routing\Route; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Opis\JsonSchema\Validator; @@ -55,7 +56,7 @@ protected function handle(): void */ protected function validateParameters(): void { - /** @var \Illuminate\Routing\Route $route */ + /** @var Route $route */ $route = $this->request->route(); $parameters = array_merge( @@ -125,7 +126,7 @@ protected function validateParameters(): void protected function translateParameterName(string $parameter): string { - /** @var \Illuminate\Routing\Route $route */ + /** @var Route $route */ $route = $this->request->route(); $route->wheres = []; @@ -234,7 +235,7 @@ private function castParameterValue(mixed $parameterValue, ?stdClass $expectedSc } /** - * @return ($data is array ? \stdClass : ($data is array ? array : mixed)) + * @return ($data is array ? stdClass : ($data is array ? array : mixed)) */ private function toObject(mixed $data): mixed { diff --git a/tests/ResponseValidatorTest.php b/tests/ResponseValidatorTest.php index 97bf1cd..25e88f0 100644 --- a/tests/ResponseValidatorTest.php +++ b/tests/ResponseValidatorTest.php @@ -881,7 +881,7 @@ public function test_handles_invalid_spec(): void Route::get('/', fn () => 'ok')->middleware(Middleware::class); - $this->expectException(\ErrorException::class); + $this->expectException(ErrorException::class); $this->expectExceptionMessage('The spec file is invalid. Please lint it using spectral (https://github.com/stoplightio/spectral) before trying again.'); $this->getJson('/')