Skip to content

Commit

Permalink
Added handling for Assert::implementsInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
boesing authored and ondrejmirtes committed Oct 1, 2019
1 parent 5c9024f commit 24c4c76
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ private static function getExpressionResolvers(): array
)
);
},
'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())
);
},
'true' => function (Scope $scope, Arg $expr): \PhpParser\Node\Expr {
return new \PhpParser\Node\Expr\BinaryOp\Identical(
$expr->value,
Expand Down

0 comments on commit 24c4c76

Please sign in to comment.