2020-08-25 21:25:00 +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\Arguments\ValueObject;
|
2020-08-25 21:25:00 +00:00
|
|
|
|
2022-06-06 17:12:56 +00:00
|
|
|
use PHPStan\Type\ObjectType;
|
|
|
|
use PHPStan\Type\Type;
|
|
|
|
use Rector\Core\Validation\RectorAssert;
|
2020-09-12 21:19:08 +00:00
|
|
|
final class ArgumentAdder
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2022-08-06 15:23:35 +00:00
|
|
|
* @var string
|
2020-08-25 21:25:00 +00:00
|
|
|
*/
|
|
|
|
private $class;
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2020-08-25 21:25:00 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $method;
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2020-08-25 21:25:00 +00:00
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
private $position;
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2020-08-25 21:25:00 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
2021-05-12 13:15:45 +00:00
|
|
|
private $argumentName;
|
2021-08-22 21:22:18 +00:00
|
|
|
/**
|
|
|
|
* @var mixed|null
|
|
|
|
*/
|
2021-05-11 10:40:34 +00:00
|
|
|
private $argumentDefaultValue = null;
|
2020-08-25 21:25:00 +00:00
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2021-09-19 11:08:13 +00:00
|
|
|
* @var \PHPStan\Type\Type|null
|
2020-08-25 21:25:00 +00:00
|
|
|
*/
|
2023-06-11 23:01:39 +00:00
|
|
|
private $argumentType = null;
|
2020-08-25 21:25:00 +00:00
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2020-08-25 21:25:00 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
2021-05-12 13:15:45 +00:00
|
|
|
private $scope;
|
2020-08-25 21:25:00 +00:00
|
|
|
/**
|
|
|
|
* @param mixed|null $argumentDefaultValue
|
|
|
|
*/
|
2022-08-11 14:29:35 +00:00
|
|
|
public function __construct(string $class, string $method, int $position, ?string $argumentName = null, $argumentDefaultValue = null, ?\PHPStan\Type\Type $argumentType = null, ?string $scope = null)
|
2021-05-09 20:15:43 +00:00
|
|
|
{
|
2020-08-25 21:25:00 +00:00
|
|
|
$this->class = $class;
|
|
|
|
$this->method = $method;
|
|
|
|
$this->position = $position;
|
|
|
|
$this->argumentName = $argumentName;
|
|
|
|
$this->argumentDefaultValue = $argumentDefaultValue;
|
|
|
|
$this->argumentType = $argumentType;
|
|
|
|
$this->scope = $scope;
|
2022-06-07 08:22:29 +00:00
|
|
|
RectorAssert::className($class);
|
2020-08-25 21:25:00 +00:00
|
|
|
}
|
2022-06-07 08:22:29 +00:00
|
|
|
public function getObjectType() : ObjectType
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
2022-06-07 08:22:29 +00:00
|
|
|
return new ObjectType($this->class);
|
2020-08-25 21:25:00 +00:00
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getMethod() : string
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
|
|
|
return $this->method;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getPosition() : int
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
|
|
|
return $this->position;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getArgumentName() : ?string
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
|
|
|
return $this->argumentName;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return mixed|null
|
|
|
|
*/
|
|
|
|
public function getArgumentDefaultValue()
|
|
|
|
{
|
|
|
|
return $this->argumentDefaultValue;
|
|
|
|
}
|
2022-06-07 08:22:29 +00:00
|
|
|
public function getArgumentType() : ?Type
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
|
|
|
return $this->argumentType;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getScope() : ?string
|
2020-08-25 21:25:00 +00:00
|
|
|
{
|
|
|
|
return $this->scope;
|
|
|
|
}
|
|
|
|
}
|