From a6437b343f6bc34c8cd8b38df9a7ebf82f2ef396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20J=C3=BCrisoo?= Date: Thu, 5 Nov 2026 21:28:15 +0000 Subject: [PATCH] Allow Pest 4 and 5 alongside 2 and 3 Dependabot (#92) proposed replacing "^2.0 || ^3.0" with "^5.3.4". Pest 5 requires PHP ^8.4 and Symfony 8 components, so as a hard pin it broke every CI job except PHP 8.4/8.5 on Laravel 13: PHP 8.1-8.3 can't install it at all (PHPStan runs on 8.3), and testbench 9/10 (Laravel 11/12) pin symfony/process ^7, which conflicts with Pest 5 even on PHP 8.4+. Archetype still supports PHP ^8.1 and Laravel 10-13, so instead of dropping those, widen the dev constraint to "^2.0 || ^3.0 || ^4.0 || ^5.3.4" and let Composer pick the newest Pest each matrix cell can install. ^4.0 is included so cells that can't reach 5 (PHP 8.3, Symfony 7 stacks) aren't stuck on 3. With that, the PHPStan job resolves Pest 4, which types $this inside test closures. The two inline "@phpstan-ignore-line" comments on $this->artisan() in ErrorsCommandTest then had nothing to ignore and PHPStan failed on ignore.unmatchedLine. They are replaced by one path-scoped ignoreErrors entry in phpstan.neon with reportUnmatched: false, so analysis passes whether Pest 2/3 (untyped $this) or 4/5 is installed. Co-Authored-By: t-1000 (Claude Code) Claude-Session: https://claude.ai/code/session_01Rae8muhQAQUSQbPZ9vRukJ --- composer.json | 2 +- phpstan.neon | 7 +++++++ tests/Feature/Commands/ErrorsCommandTest.php | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6e73891..8d179d7 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "orchestra/testbench": "^8.0 || ^9.0 || ^10.0 || ^11.0", - "pestphp/pest": "^2.0 || ^3.0", + "pestphp/pest": "^2.0 || ^3.0 || ^4.0 || ^5.3.4", "phpstan/phpstan": "^1.11 || ^2.0" }, "config": { diff --git a/phpstan.neon b/phpstan.neon index 3c5177a..bc123c6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,3 +9,10 @@ parameters: - tests/fixtures/* ignoreErrors: - '#Dummy not found#' + # Pest <= 3 leaves $this untyped inside test closures, so PHPStan flags + # $this->artisan() there; Pest 4+ types it. Ignore it without reporting + # the ignore as unmatched, so analysis passes on every Pest we allow. + - + message: '#(artisan\(\)|\$this)#' + path: tests/Feature/Commands/ErrorsCommandTest.php + reportUnmatched: false diff --git a/tests/Feature/Commands/ErrorsCommandTest.php b/tests/Feature/Commands/ErrorsCommandTest.php index 1b8782b..0fe020b 100644 --- a/tests/Feature/Commands/ErrorsCommandTest.php +++ b/tests/Feature/Commands/ErrorsCommandTest.php @@ -3,7 +3,7 @@ use Archetype\Facades\PHPFile; it('outputs no errors on a default laravel installation', function() { - $this->artisan('archetype:errors') // @phpstan-ignore-line + $this->artisan('archetype:errors') ->assertSuccessful() ->expectsOutput("No errors found!"); }); @@ -12,7 +12,7 @@ $path = PHPFile::load('app/Models/User.php')->input->absolutePath(); file_put_contents($path, 'artisan('archetype:errors') // @phpstan-ignore-line + $this->artisan('archetype:errors') ->assertSuccessful() ->expectsTable([ 'path',