rector/rules/Arguments/ValueObject/ArgumentAdder.php

91 lines
2.0 KiB
PHP
Raw Normal View History

2020-08-25 21:25:00 +00:00
<?php
declare (strict_types=1);
namespace Rector\Arguments\ValueObject;
2020-08-25 21:25:00 +00:00
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\Validation\RectorAssert;
final class ArgumentAdder
2020-08-25 21:25:00 +00:00
{
/**
* @readonly
* @var string
2020-08-25 21:25:00 +00:00
*/
private $class;
/**
* @readonly
2020-08-25 21:25:00 +00:00
* @var string
*/
private $method;
/**
* @readonly
2020-08-25 21:25:00 +00:00
* @var int
*/
private $position;
/**
* @readonly
2020-08-25 21:25:00 +00:00
* @var string|null
*/
private $argumentName;
/**
* @var mixed|null
*/
private $argumentDefaultValue = null;
2020-08-25 21:25:00 +00:00
/**
* @readonly
* @var \PHPStan\Type\Type|null
2020-08-25 21:25:00 +00:00
*/
private $argumentType = null;
2020-08-25 21:25:00 +00:00
/**
* @readonly
2020-08-25 21:25:00 +00:00
* @var string|null
*/
private $scope;
2020-08-25 21:25:00 +00:00
/**
* @param mixed|null $argumentDefaultValue
*/
public function __construct(string $class, string $method, int $position, ?string $argumentName = null, $argumentDefaultValue = null, ?\PHPStan\Type\Type $argumentType = null, ?string $scope = null)
{
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;
RectorAssert::className($class);
2020-08-25 21:25:00 +00:00
}
public function getObjectType() : ObjectType
2020-08-25 21:25:00 +00:00
{
return new ObjectType($this->class);
2020-08-25 21:25:00 +00:00
}
public function getMethod() : string
2020-08-25 21:25:00 +00:00
{
return $this->method;
}
public function getPosition() : int
2020-08-25 21:25:00 +00:00
{
return $this->position;
}
public function getArgumentName() : ?string
2020-08-25 21:25:00 +00:00
{
return $this->argumentName;
}
/**
* @return mixed|null
*/
public function getArgumentDefaultValue()
{
return $this->argumentDefaultValue;
}
public function getArgumentType() : ?Type
2020-08-25 21:25:00 +00:00
{
return $this->argumentType;
}
public function getScope() : ?string
2020-08-25 21:25:00 +00:00
{
return $this->scope;
}
}