From aa3bfe28a364d97ac57c4b57667d26030470e8d5 Mon Sep 17 00:00:00 2001 From: Punyapal Shah Date: Fri, 21 Aug 2026 16:31:11 +0530 Subject: [PATCH 1/2] fix: teach PHPStan about describe() chain methods via BeforeEachCall mixin stub --- extension.neon | 2 ++ stubs/DescribeCall.stub | 12 +++++++++ tests/Rules/DescribeCallMethodTest.php | 21 ++++++++++++++++ tests/Rules/data/describe-call-methods.php | 29 ++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 stubs/DescribeCall.stub create mode 100644 tests/Rules/DescribeCallMethodTest.php create mode 100644 tests/Rules/data/describe-call-methods.php diff --git a/extension.neon b/extension.neon index f0f672d..7da6c15 100644 --- a/extension.neon +++ b/extension.neon @@ -3,6 +3,8 @@ parameters: - PHPUnit\Framework\TestCase scanDirectories: - src + stubFiles: + - stubs/DescribeCall.stub services: - diff --git a/stubs/DescribeCall.stub b/stubs/DescribeCall.stub new file mode 100644 index 0000000..4a079bb --- /dev/null +++ b/stubs/DescribeCall.stub @@ -0,0 +1,12 @@ +analyse([ + __DIR__.'/data/describe-call-methods.php', + ], []); +}); diff --git a/tests/Rules/data/describe-call-methods.php b/tests/Rules/data/describe-call-methods.php new file mode 100644 index 0000000..976dffd --- /dev/null +++ b/tests/Rules/data/describe-call-methods.php @@ -0,0 +1,29 @@ +toBeTrue(); + }); +})->skip(); + +describe('user settings', function (): void { + test('receives the dataset value', function (int $value): void { + expect($value)->toBeGreaterThan(0); + }); +})->with([10, 20]); + +describe('auth', function (): void { + beforeEach(fn () => null); + + test('can logout', function (): void { + expect(true)->toBeTrue(); + }); +})->skip(fn (): bool => true, 'only runs on sqlite')->with([10, 20])->group('slow'); + +describe('teardown', function (): void { + test('example', function (): void { + expect(true)->toBeTrue(); + }); +})->after(function (): void {}); From ac43ee4200b79ee0471364c5337b98b89df2fd07 Mon Sep 17 00:00:00 2001 From: Punyapal Shah Date: Fri, 21 Aug 2026 16:31:11 +0530 Subject: [PATCH 2/2] fix: ignore method.internalInterface reports on Pest arch expectations --- ...PestInternalClassAccessIgnoreExtension.php | 1 + ...InternalClassAccessIgnoreExtensionTest.php | 21 +++++++++++++++++++ .../arch-expectation-internal-methods.php | 17 +++++++++++++++ tests/Rules/internal-tag.neon | 5 +++++ 4 files changed, 44 insertions(+) create mode 100644 tests/Rules/PestInternalClassAccessIgnoreExtensionTest.php create mode 100644 tests/Rules/data/arch-expectation-internal-methods.php create mode 100644 tests/Rules/internal-tag.neon diff --git a/src/Type/Pest/PestInternalClassAccessIgnoreExtension.php b/src/Type/Pest/PestInternalClassAccessIgnoreExtension.php index c51fc2a..339179d 100644 --- a/src/Type/Pest/PestInternalClassAccessIgnoreExtension.php +++ b/src/Type/Pest/PestInternalClassAccessIgnoreExtension.php @@ -17,6 +17,7 @@ final class PestInternalClassAccessIgnoreExtension implements IgnoreErrorExtensi 'property.internalClass', 'method.internalClass', 'method.internalTrait', + 'method.internalInterface', ]; public function shouldIgnore(Error $error, Node $node, Scope $scope): bool diff --git a/tests/Rules/PestInternalClassAccessIgnoreExtensionTest.php b/tests/Rules/PestInternalClassAccessIgnoreExtensionTest.php new file mode 100644 index 0000000..35f6a12 --- /dev/null +++ b/tests/Rules/PestInternalClassAccessIgnoreExtensionTest.php @@ -0,0 +1,21 @@ +analyse([ + __DIR__.'/data/arch-expectation-internal-methods.php', + ], []); +}); diff --git a/tests/Rules/data/arch-expectation-internal-methods.php b/tests/Rules/data/arch-expectation-internal-methods.php new file mode 100644 index 0000000..2503521 --- /dev/null +++ b/tests/Rules/data/arch-expectation-internal-methods.php @@ -0,0 +1,17 @@ +expect('App\Models') + ->toBeClasses() + ->toExtend('Illuminate\Database\Eloquent\Model') + ->toOnlyBeUsedIn('App\Repositories') + ->ignoring('App\Models\User'); +}); + +test('arch expectation ignoring global functions is allowed', function (): void { + arch()->expect('App\Services') + ->toUseNothing() + ->ignoringGlobalFunctions(); +}); diff --git a/tests/Rules/internal-tag.neon b/tests/Rules/internal-tag.neon new file mode 100644 index 0000000..c40ef19 --- /dev/null +++ b/tests/Rules/internal-tag.neon @@ -0,0 +1,5 @@ +includes: + - ../extension.neon +parameters: + featureToggles: + internalTag: true