Skip to content

Commit 24c4c76

Browse files
boesingondrejmirtes
authored andcommitted
Added handling for Assert::implementsInterface
1 parent 5c9024f commit 24c4c76

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,17 @@ private static function getExpressionResolvers(): array
300300
)
301301
);
302302
},
303+
'implementsInterface' => function (Scope $scope, Arg $expr, Arg $class): ?\PhpParser\Node\Expr {
304+
$classType = $scope->getType($class->value);
305+
if (!$classType instanceof ConstantStringType) {
306+
return null;
307+
}
308+
309+
return new \PhpParser\Node\Expr\Instanceof_(
310+
$expr->value,
311+
new \PhpParser\Node\Name($classType->getValue())
312+
);
313+
},
303314
'true' => function (Scope $scope, Arg $expr): \PhpParser\Node\Expr {
304315
return new \PhpParser\Node\Expr\BinaryOp\Identical(
305316
$expr->value,

0 commit comments

Comments
 (0)