rector/rules/Transform/ValueObject/NewToMethodCall.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.1 KiB
PHP

<?php
declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class NewToMethodCall
{
/**
* @readonly
* @var string
*/
private $newType;
/**
* @readonly
* @var string
*/
private $serviceType;
/**
* @readonly
* @var string
*/
private $serviceMethod;
public function __construct(string $newType, string $serviceType, string $serviceMethod)
{
$this->newType = $newType;
$this->serviceType = $serviceType;
$this->serviceMethod = $serviceMethod;
RectorAssert::className($newType);
RectorAssert::className($serviceType);
RectorAssert::methodName($serviceMethod);
}
public function getNewObjectType() : ObjectType
{
return new ObjectType($this->newType);
}
public function getServiceObjectType() : ObjectType
{
return new ObjectType($this->serviceType);
}
public function getServiceMethod() : string
{
return $this->serviceMethod;
}
}