From 24c4c76b77b4dfc896eebc5ccd198b93b380aea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Mon, 30 Sep 2019 16:40:29 +0200 Subject: [PATCH] Added handling for `Assert::implementsInterface` --- .../WebMozartAssert/AssertTypeSpecifyingExtension.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php b/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php index 6a1338e..3cdb39a 100644 --- a/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php +++ b/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php @@ -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,