mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
cdc3b7adef
f451b0b8e1
[PHP 8.0] Bump to promoted properties (#4)
29 lines
956 B
PHP
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);
|
|
}
|
|
}
|