From 96895a5f7d5f38a54354dce046523e9df9cf0dae Mon Sep 17 00:00:00 2001 From: Adam Campbell Date: Fri, 27 Mar 2026 10:09:36 -0500 Subject: [PATCH 1/4] wip --- .github/workflows/tests.yml | 8 +++++++- composer.json | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd92346..bda4d7a 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,10 @@ jobs: php: 8.1 - laravel: 12.* phpunit: 10.* + - laravel: 13.* + php: 8.1 + - laravel: 13.* + phpunit: 10.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - PU${{ matrix.phpunit }} 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": { From cf9c97f9c862589067fd9b88a2ba1ed2c3722ec8 Mon Sep 17 00:00:00 2001 From: Adam Campbell Date: Fri, 27 Mar 2026 10:14:37 -0500 Subject: [PATCH 2/4] Fix CI: exclude PHP 8.2 for Laravel 13, add contents:write for tidy workflow Laravel 13 requires PHP ^8.3, so PHP 8.2 must be excluded from the matrix. The tidy workflow's git-auto-commit-action@v5 requires explicit contents:write permission to push formatting commits back to PR branches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/tests.yml | 2 ++ .github/workflows/tidy.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bda4d7a..bcbebb1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,6 +40,8 @@ jobs: phpunit: 10.* - laravel: 13.* php: 8.1 + - laravel: 13.* + php: 8.2 - laravel: 13.* phpunit: 10.* diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml index ba70704..2c01df3 100644 --- a/.github/workflows/tidy.yml +++ b/.github/workflows/tidy.yml @@ -5,6 +5,9 @@ on: pull_request: branches: [ master ] +permissions: + contents: write + jobs: lint: runs-on: ubuntu-latest From 1944c9bf10ca8d03e5aaa02335f5619cbc2ca361 Mon Sep 17 00:00:00 2001 From: Adam Campbell Date: Fri, 27 Mar 2026 10:15:58 -0500 Subject: [PATCH 3/4] Fix tidy workflow: checkout PR head ref so auto-commit can push back git-auto-commit-action fails with 'invalid reference' on PR events because actions/checkout defaults to a detached HEAD (merge commit). Checking out github.head_ref ensures the branch exists locally for the push. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/tidy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml index 2c01df3..c687806 100644 --- a/.github/workflows/tidy.yml +++ b/.github/workflows/tidy.yml @@ -14,6 +14,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: "laravel-pint" uses: aglipanci/laravel-pint-action@2.3.1 @@ -24,4 +26,4 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: PHP Linting (Pint) - skip_fetch: true + skip_fetch: false From a6c9599664bf8294c6c8e45f0bcf75a3b5d84fad Mon Sep 17 00:00:00 2001 From: hotmeteor <378585+hotmeteor@users.noreply.github.com> Date: Fri, 27 Mar 2026 15:16:21 +0000 Subject: [PATCH 4/4] PHP Linting (Pint) --- _ide_helpers.php | 4 +++- src/Assertions.php | 3 ++- src/Middleware.php | 2 +- src/RequestFactory.php | 11 +++++++---- src/Spectator.php | 2 +- src/Validation/RequestValidator.php | 7 ++++--- tests/ResponseValidatorTest.php | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) 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/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('/')