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", diff --git a/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php b/tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php index 3033b04..4be70b0 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, @@ -114,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 0e00dcc..912d175 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); @@ -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 {};