Skip to content

Commit 2f904da

Browse files
committed
Ignore unknown class to avoid annoyance
1 parent 5575013 commit 2f904da

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,10 @@ private static function getExpressionResolvers(): array
449449
$classType = $scope->getType($class->value);
450450
if ($classType instanceof ConstantStringType) {
451451
$classReflection = (new ObjectType($classType->getValue()))->getClassReflection();
452-
if ($classReflection === null || !$classReflection->isInterface()) {
452+
if ($classReflection === null) {
453+
return null;
454+
}
455+
if (!$classReflection->isInterface()) {
453456
return new ConstFetch(new Name('false'));
454457
}
455458
}

tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ public function testExtension(): void
9292
'Call to static method Webmozart\Assert\Assert::implementsInterface() with class-string<WebmozartAssertImpossibleCheck\Bar> and \'WebmozartAssertImpossibleCheck\\\Bar\' will always evaluate to true.',
9393
108,
9494
],
95-
[
96-
'Call to static method Webmozart\Assert\Assert::implementsInterface() with mixed and \'WebmozartAssertImpossibleCheck\\\Unknown\' will always evaluate to false.',
97-
110,
98-
],
9995
[
10096
'Call to static method Webmozart\Assert\Assert::implementsInterface() with mixed and \'WebmozartAssertImpossibleCheck\\\Foo\' will always evaluate to false.',
10197
111,

tests/Type/WebMozartAssert/data/impossible-check.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public function nonEmptyStringAndSomethingUnknownNarrow($a, string $b, array $c,
102102
public function implementsInterface($a, string $b, $c): void
103103
{
104104
Assert::implementsInterface($a, Bar::class);
105-
Assert::implementsInterface($a, Bar::class); // only this should report
105+
Assert::implementsInterface($a, Bar::class);
106106

107107
Assert::implementsInterface($b, Bar::class);
108-
Assert::implementsInterface($b, Bar::class); // only this should report
108+
Assert::implementsInterface($b, Bar::class);
109109

110110
Assert::implementsInterface($c, Unknown::class);
111111
Assert::implementsInterface($c, self::class);

0 commit comments

Comments
 (0)