From dfd947d4f29ee38540e703aeb61981dd7ecd6858 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 26 Feb 2026 11:56:48 +0100 Subject: [PATCH 1/3] Fix Ci after PR Phpstan#4472 --- .../WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php | 2 ++ tests/Type/WebMozartAssert/data/impossible-check.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php b/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php index 3033b04..c6f575c 100644 --- a/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php +++ b/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php @@ -91,6 +91,7 @@ public function testExtension(): void 'Call to static method Webmozart\Assert\Assert::allContains() with array and \'foo\' will always evaluate to true.', 98, ], + /* [ 'Call to static method Webmozart\Assert\Assert::implementsInterface() with class-string|WebmozartAssertImpossibleCheck\Bar and \'WebmozartAssertImpossibleCheck\\\Bar\' will always evaluate to true.', 105, @@ -101,6 +102,7 @@ public function testExtension(): void 108, $tipText, ], + */ [ 'Call to static method Webmozart\Assert\Assert::implementsInterface() with mixed and \'WebmozartAssertImpossibleCheck\\\Foo\' will always evaluate to false.', 111, diff --git a/tests/Type/WebMozartAssert/data/impossible-check.php b/tests/Type/WebMozartAssert/data/impossible-check.php index 0e00dcc..0d83d02 100644 --- a/tests/Type/WebMozartAssert/data/impossible-check.php +++ b/tests/Type/WebMozartAssert/data/impossible-check.php @@ -102,10 +102,10 @@ public function nonEmptyStringAndSomethingUnknownNarrow($a, string $b, array $c, public function implementsInterface($a, string $b, $c): void { Assert::implementsInterface($a, Bar::class); - Assert::implementsInterface($a, Bar::class); + Assert::implementsInterface($a, Bar::class); // Could be reported as always true Assert::implementsInterface($b, Bar::class); - Assert::implementsInterface($b, Bar::class); + Assert::implementsInterface($b, Bar::class); // Could be reported as always true Assert::implementsInterface($c, Unknown::class); Assert::implementsInterface($c, self::class); From 1e117b4882b5bd96dcaece321972a28c28b5d023 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 26 Feb 2026 12:03:13 +0100 Subject: [PATCH 2/3] Try latest version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3191678..2e48680 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "keywords": ["static analysis"], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.7" + "phpstan/phpstan": "^2.1.41" }, "require-dev": { "nikic/php-parser": "^5.1", From e5d7a366698010718be13461319c386111e4b435 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 26 Feb 2026 12:08:46 +0100 Subject: [PATCH 3/3] Add tests --- .../ImpossibleCheckTypeMethodCallRuleTest.php | 5 +++++ tests/Type/WebMozartAssert/data/impossible-check.php | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php b/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php index c6f575c..4be70b0 100644 --- a/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php +++ b/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php @@ -116,6 +116,11 @@ public function testExtension(): void 'Call to static method Webmozart\Assert\Assert::startsWith() with \'value\' and string will always evaluate to true.', 126, ], + [ + 'Call to static method Webmozart\Assert\Assert::implementsInterface() with \'WebmozartAssertImpossibleCheck\\\\Bar\' and \'WebmozartAssertImpossibleCheck\\\\Bar\' will always evaluate to false.', + 134, + $tipText, + ], ]); } diff --git a/tests/Type/WebMozartAssert/data/impossible-check.php b/tests/Type/WebMozartAssert/data/impossible-check.php index 0d83d02..912d175 100644 --- a/tests/Type/WebMozartAssert/data/impossible-check.php +++ b/tests/Type/WebMozartAssert/data/impossible-check.php @@ -127,6 +127,13 @@ public function testStartsWith(string $a): void Assert::startsWith("value", "bix"); } + /** @param class-string $a */ + public function implementsInterface2(string $a): void + { + Assert::implementsInterface($a, Bar::class); + Assert::implementsInterface(Bar::class, Bar::class); + } + } interface Bar {};