mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
c726969380
fc10fce13d
[Rectify] [Php81] Enable Rectify on Readonly Property only (#1384)
84 lines
2.2 KiB
PHP
84 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Naming\ValueObject;
|
|
|
|
use PhpParser\Node\Stmt\ClassLike;
|
|
use PhpParser\Node\Stmt\Property;
|
|
use PhpParser\Node\Stmt\PropertyProperty;
|
|
use Rector\Naming\Contract\RenamePropertyValueObjectInterface;
|
|
final class PropertyRename implements \Rector\Naming\Contract\RenamePropertyValueObjectInterface
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \PhpParser\Node\Stmt\Property
|
|
*/
|
|
private $property;
|
|
/**
|
|
* @readonly
|
|
* @var string
|
|
*/
|
|
private $expectedName;
|
|
/**
|
|
* @readonly
|
|
* @var string
|
|
*/
|
|
private $currentName;
|
|
/**
|
|
* @readonly
|
|
* @var \PhpParser\Node\Stmt\ClassLike
|
|
*/
|
|
private $classLike;
|
|
/**
|
|
* @readonly
|
|
* @var string
|
|
*/
|
|
private $classLikeName;
|
|
/**
|
|
* @readonly
|
|
* @var \PhpParser\Node\Stmt\PropertyProperty
|
|
*/
|
|
private $propertyProperty;
|
|
public function __construct(\PhpParser\Node\Stmt\Property $property, string $expectedName, string $currentName, \PhpParser\Node\Stmt\ClassLike $classLike, string $classLikeName, \PhpParser\Node\Stmt\PropertyProperty $propertyProperty)
|
|
{
|
|
$this->property = $property;
|
|
$this->expectedName = $expectedName;
|
|
$this->currentName = $currentName;
|
|
$this->classLike = $classLike;
|
|
$this->classLikeName = $classLikeName;
|
|
$this->propertyProperty = $propertyProperty;
|
|
}
|
|
public function getProperty() : \PhpParser\Node\Stmt\Property
|
|
{
|
|
return $this->property;
|
|
}
|
|
public function isPrivateProperty() : bool
|
|
{
|
|
return $this->property->isPrivate();
|
|
}
|
|
public function getExpectedName() : string
|
|
{
|
|
return $this->expectedName;
|
|
}
|
|
public function getCurrentName() : string
|
|
{
|
|
return $this->currentName;
|
|
}
|
|
public function isAlreadyExpectedName() : bool
|
|
{
|
|
return $this->currentName === $this->expectedName;
|
|
}
|
|
public function getClassLike() : \PhpParser\Node\Stmt\ClassLike
|
|
{
|
|
return $this->classLike;
|
|
}
|
|
public function getClassLikeName() : string
|
|
{
|
|
return $this->classLikeName;
|
|
}
|
|
public function getPropertyProperty() : \PhpParser\Node\Stmt\PropertyProperty
|
|
{
|
|
return $this->propertyProperty;
|
|
}
|
|
}
|