mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
12ed8d9e0a
7753562da2
[Naming] Remove parent lookup on PropertyRenameFactory (#4232)
28 lines
929 B
PHP
28 lines
929 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Naming\ValueObjectFactory;
|
|
|
|
use PhpParser\Node\Stmt\ClassLike;
|
|
use PhpParser\Node\Stmt\Property;
|
|
use Rector\Naming\ValueObject\PropertyRename;
|
|
use Rector\NodeNameResolver\NodeNameResolver;
|
|
final class PropertyRenameFactory
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\NodeNameResolver\NodeNameResolver
|
|
*/
|
|
private $nodeNameResolver;
|
|
public function __construct(NodeNameResolver $nodeNameResolver)
|
|
{
|
|
$this->nodeNameResolver = $nodeNameResolver;
|
|
}
|
|
public function createFromExpectedName(ClassLike $classLike, Property $property, string $expectedName) : ?PropertyRename
|
|
{
|
|
$currentName = $this->nodeNameResolver->getName($property);
|
|
$className = (string) $this->nodeNameResolver->getName($classLike);
|
|
return new PropertyRename($property, $expectedName, $currentName, $classLike, $className, $property->props[0]);
|
|
}
|
|
}
|