Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public function testExtension(): void
'Call to static method Webmozart\Assert\Assert::allContains() with array<non-empty-string> and \'foo\' will always evaluate to true.',
98,
],
/*
[
'Call to static method Webmozart\Assert\Assert::implementsInterface() with class-string<WebmozartAssertImpossibleCheck\Bar>|WebmozartAssertImpossibleCheck\Bar and \'WebmozartAssertImpossibleCheck\\\Bar\' will always evaluate to true.',
105,
Expand All @@ -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,
Expand All @@ -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,
],
]);
}

Expand Down
11 changes: 9 additions & 2 deletions tests/Type/WebMozartAssert/data/impossible-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -127,6 +127,13 @@ public function testStartsWith(string $a): void
Assert::startsWith("value", "bix");
}

/** @param class-string<Bar> $a */
public function implementsInterface2(string $a): void
{
Assert::implementsInterface($a, Bar::class);
Assert::implementsInterface(Bar::class, Bar::class);
}

}

interface Bar {};
Expand Down
Loading