2020-08-26 10:54:53 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2022-06-06 17:12:56 +00:00
|
|
|
namespace Rector\Renaming\ValueObject;
|
2020-08-26 10:54:53 +00:00
|
|
|
|
2022-06-06 17:12:56 +00:00
|
|
|
use PHPStan\Type\ObjectType;
|
|
|
|
use Rector\Renaming\Contract\RenameClassConstFetchInterface;
|
2024-01-02 02:40:38 +00:00
|
|
|
use Rector\Validation\RectorAssert;
|
2022-06-07 08:22:29 +00:00
|
|
|
final class RenameClassAndConstFetch implements RenameClassConstFetchInterface
|
2020-08-26 10:54:53 +00:00
|
|
|
{
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2022-08-06 15:23:35 +00:00
|
|
|
* @var string
|
2020-08-26 10:54:53 +00:00
|
|
|
*/
|
|
|
|
private $oldClass;
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2020-08-26 10:54:53 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $oldConstant;
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2022-08-06 15:23:35 +00:00
|
|
|
* @var string
|
2020-08-26 10:54:53 +00:00
|
|
|
*/
|
2021-05-10 23:39:21 +00:00
|
|
|
private $newClass;
|
2021-01-27 14:09:08 +00:00
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2021-01-27 14:09:08 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
2021-05-10 23:39:21 +00:00
|
|
|
private $newConstant;
|
2021-01-27 14:09:08 +00:00
|
|
|
public function __construct(string $oldClass, string $oldConstant, string $newClass, string $newConstant)
|
2020-08-26 10:54:53 +00:00
|
|
|
{
|
|
|
|
$this->oldClass = $oldClass;
|
|
|
|
$this->oldConstant = $oldConstant;
|
2021-01-27 14:09:08 +00:00
|
|
|
$this->newClass = $newClass;
|
2021-05-10 23:39:21 +00:00
|
|
|
$this->newConstant = $newConstant;
|
2022-07-16 11:25:49 +00:00
|
|
|
RectorAssert::className($oldClass);
|
2022-07-16 12:31:38 +00:00
|
|
|
RectorAssert::constantName($oldConstant);
|
2022-07-16 11:25:49 +00:00
|
|
|
RectorAssert::className($newClass);
|
2022-07-16 12:31:38 +00:00
|
|
|
RectorAssert::constantName($newConstant);
|
2020-08-26 10:54:53 +00:00
|
|
|
}
|
2022-06-07 08:22:29 +00:00
|
|
|
public function getOldObjectType() : ObjectType
|
2020-08-26 10:54:53 +00:00
|
|
|
{
|
2022-06-07 08:22:29 +00:00
|
|
|
return new ObjectType($this->oldClass);
|
2020-08-26 10:54:53 +00:00
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getOldConstant() : string
|
2020-08-26 10:54:53 +00:00
|
|
|
{
|
|
|
|
return $this->oldConstant;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getNewConstant() : string
|
2020-08-26 10:54:53 +00:00
|
|
|
{
|
|
|
|
return $this->newConstant;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getNewClass() : string
|
2021-01-27 14:09:08 +00:00
|
|
|
{
|
|
|
|
return $this->newClass;
|
|
|
|
}
|
2020-08-26 10:54:53 +00:00
|
|
|
}
|