rector/rules/Renaming/ValueObject/RenameProperty.php
Tomas Votruba 4b2bd56de7 Updated Rector to commit 6577da612c2824c2add06721b903de4cd438631e
6577da612c [DX] Add input validation for method, property and function name to avoid invalid output ast (#2668)
2022-07-16 09:41:53 +00:00

47 lines
1.0 KiB
PHP

<?php
declare (strict_types=1);
namespace Rector\Renaming\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class RenameProperty
{
/**
* @readonly
* @var string
*/
private $type;
/**
* @readonly
* @var string
*/
private $oldProperty;
/**
* @readonly
* @var string
*/
private $newProperty;
public function __construct(string $type, string $oldProperty, string $newProperty)
{
$this->type = $type;
$this->oldProperty = $oldProperty;
$this->newProperty = $newProperty;
RectorAssert::className($type);
RectorAssert::propertyName($oldProperty);
RectorAssert::propertyName($newProperty);
}
public function getObjectType() : ObjectType
{
return new ObjectType($this->type);
}
public function getOldProperty() : string
{
return $this->oldProperty;
}
public function getNewProperty() : string
{
return $this->newProperty;
}
}