rector/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue...

81 lines
1.7 KiB
PHP
Raw Normal View History

2020-08-25 22:21:41 +00:00
<?php
declare (strict_types=1);
namespace Rector\Arguments\ValueObject;
2020-08-25 22:21:41 +00:00
use PHPStan\Type\ObjectType;
use Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface;
use Rector\Validation\RectorAssert;
final class ReplaceArgumentDefaultValue implements ReplaceArgumentDefaultValueInterface
2020-08-25 22:21:41 +00:00
{
/**
* @readonly
* @var string
2020-08-25 22:21:41 +00:00
*/
private $class;
/**
* @readonly
2020-08-25 22:21:41 +00:00
* @var string
*/
private $method;
/**
* @var int<0, max>
* @readonly
2020-08-25 22:21:41 +00:00
*/
private $position;
/**
* @readonly
* @var mixed
*/
2020-08-25 22:21:41 +00:00
private $valueBefore;
/**
* @readonly
* @var mixed
*/
2020-08-25 22:21:41 +00:00
private $valueAfter;
/**
* @var string
*/
public const ANY_VALUE_BEFORE = '*ANY_VALUE_BEFORE*';
2020-08-25 22:21:41 +00:00
/**
* @param int<0, max> $position
2020-08-25 22:21:41 +00:00
* @param mixed $valueBefore
* @param mixed $valueAfter
*/
public function __construct(string $class, string $method, int $position, $valueBefore, $valueAfter)
{
$this->class = $class;
$this->method = $method;
$this->position = $position;
$this->valueBefore = $valueBefore;
$this->valueAfter = $valueAfter;
RectorAssert::className($class);
2020-08-25 22:21:41 +00:00
}
public function getObjectType() : ObjectType
2020-08-25 22:21:41 +00:00
{
return new ObjectType($this->class);
2020-08-25 22:21:41 +00:00
}
public function getMethod() : string
2020-08-25 22:21:41 +00:00
{
return $this->method;
}
public function getPosition() : int
2020-08-25 22:21:41 +00:00
{
return $this->position;
}
/**
* @return mixed
*/
public function getValueBefore()
{
return $this->valueBefore;
}
/**
* @return mixed
*/
public function getValueAfter()
{
return $this->valueAfter;
}
}