-
Couldn't load subscription status.
- Fork 27
Closed
Description
Assert::implementsInterface() works on object|string, not just object, so it should be translated to something like assert($foo instanceof $type || in_array($interface, \class_implements($value))) (see https://3v4l.org/VdIbR).
Not sure what the correct translation (understood by PHPStan) would be.
For reference, this is the current implementation:
phpstan-webmozart-assert/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php
Lines 303 to 313 in 97cde39
| 'implementsInterface' => function (Scope $scope, Arg $expr, Arg $class): ?\PhpParser\Node\Expr { | |
| $classType = $scope->getType($class->value); | |
| if (!$classType instanceof ConstantStringType) { | |
| return null; | |
| } | |
| return new \PhpParser\Node\Expr\Instanceof_( | |
| $expr->value, | |
| new \PhpParser\Node\Name($classType->getValue()) | |
| ); | |
| }, |
Metadata
Metadata
Assignees
Labels
No labels