mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-21 01:41:00 +01:00
35 lines
868 B
PHP
35 lines
868 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\Defluent\NodeAnalyzer;
|
|
|
|
use PhpParser\Node\Expr\MethodCall;
|
|
use Rector\NodeTypeResolver\NodeTypeResolver;
|
|
|
|
final class GetterMethodCallAnalyzer
|
|
{
|
|
/**
|
|
* @var NodeTypeResolver
|
|
*/
|
|
private $nodeTypeResolver;
|
|
|
|
public function __construct(NodeTypeResolver $nodeTypeResolver)
|
|
{
|
|
$this->nodeTypeResolver = $nodeTypeResolver;
|
|
}
|
|
|
|
public function isGetterMethodCall(MethodCall $methodCall): bool
|
|
{
|
|
if ($methodCall->var instanceof MethodCall) {
|
|
return false;
|
|
}
|
|
|
|
$methodCallStaticType = $this->nodeTypeResolver->getStaticType($methodCall);
|
|
$methodCallVarStaticType = $this->nodeTypeResolver->getStaticType($methodCall->var);
|
|
|
|
// getter short call type
|
|
return ! $methodCallStaticType->equals($methodCallVarStaticType);
|
|
}
|
|
}
|