rector/rules/Defluent/NodeAnalyzer/GetterMethodCallAnalyzer.php
Tomas Votruba cdc3b7adef Updated Rector to commit f451b0b8e1e6761ec7f50809745d44d01caba66d
f451b0b8e1 [PHP 8.0] Bump to promoted properties (#4)
2021-05-10 23:39:21 +00:00

29 lines
956 B
PHP

<?php
declare (strict_types=1);
namespace Rector\Defluent\NodeAnalyzer;
use PhpParser\Node\Expr\MethodCall;
use Rector\NodeTypeResolver\NodeTypeResolver;
final class GetterMethodCallAnalyzer
{
/**
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver)
{
$this->nodeTypeResolver = $nodeTypeResolver;
}
public function isGetterMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool
{
if ($methodCall->var instanceof \PhpParser\Node\Expr\MethodCall) {
return \false;
}
$methodCallStaticType = $this->nodeTypeResolver->getStaticType($methodCall);
$methodCallVarStaticType = $this->nodeTypeResolver->getStaticType($methodCall->var);
// getter short call type
return !$methodCallStaticType->equals($methodCallVarStaticType);
}
}