From 5bcfd985feb24b084422161d07bc05a6a23938a3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 19 Mar 2021 17:14:23 +0700 Subject: [PATCH] Change is_a to UnionType()->isSuperTypeOf()->yes in NetteControlFactoryInterfaceAnalyzer --- .../NetteControlFactoryInterfaceAnalyzer.php | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/rules/NetteToSymfony/NodeAnalyzer/NetteControlFactoryInterfaceAnalyzer.php b/rules/NetteToSymfony/NodeAnalyzer/NetteControlFactoryInterfaceAnalyzer.php index 27956cb9ba91..3950cb34e023 100644 --- a/rules/NetteToSymfony/NodeAnalyzer/NetteControlFactoryInterfaceAnalyzer.php +++ b/rules/NetteToSymfony/NodeAnalyzer/NetteControlFactoryInterfaceAnalyzer.php @@ -5,8 +5,9 @@ namespace Rector\NetteToSymfony\NodeAnalyzer; use PhpParser\Node\Stmt\Interface_; +use PHPStan\Type\ObjectType; use PHPStan\Type\TypeWithClassName; -use Rector\NodeTypeResolver\NodeTypeResolver; +use PHPStan\Type\UnionType; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; final class NetteControlFactoryInterfaceAnalyzer @@ -16,15 +17,9 @@ final class NetteControlFactoryInterfaceAnalyzer */ private $returnTypeInferer; - /** - * @var NodeTypeResolver - */ - private $nodeTypeResolver; - - public function __construct(ReturnTypeInferer $returnTypeInferer, NodeTypeResolver $nodeTypeResolver) + public function __construct(ReturnTypeInferer $returnTypeInferer) { $this->returnTypeInferer = $returnTypeInferer; - $this->nodeTypeResolver = $nodeTypeResolver; } /** @@ -38,14 +33,12 @@ public function isComponentFactoryInterface(Interface_ $interface): bool return false; } - $className = $this->nodeTypeResolver->getFullyQualifiedClassName($returnType); - if (is_a($className, 'Nette\Application\UI\Control', true)) { - return true; - } + $controlOrForm = new UnionType([ + new ObjectType('Nette\Application\UI\Control'), + new ObjectType('Nette\Application\UI\Form'), + ]); - if (is_a($className, 'Nette\Application\UI\Form', true)) { - return true; - } + return $controlOrForm->isSuperTypeOf($returnType)->yes(); } return false;