/**
* Replaces a specific argument.
*
* @return $this
*
* @throws OutOfBoundsException When the replaced argument does not exist
*/
public function replaceArgument(int|string
$index, mixed
$argument):
static { if (0 === \
count($this->arguments
)) { throw new OutOfBoundsException(sprintf('Cannot replace arguments for class "%s" if none have been configured yet.',
$this->class
));
} if (\
is_int($index) && ($index < 0 ||
$index > \
count($this->arguments
) - 1
)) { throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d] of the arguments of class "%s".',
$index, \
count($this->arguments
) - 1,
$this->class
));
} if (!\
array_key_exists($index,
$this->arguments
)) { throw new OutOfBoundsException(sprintf('The argument "%s" doesn\'t exist in class "%s".',
$index,
$this->class
));
} $this->arguments
[$index] =
$argument;