function ChildDefinition::replaceArgument
You should always use this method when overwriting existing arguments of the parent definition.
If you directly call setArguments() keep in mind that you must follow certain conventions when you want to overwrite the arguments of the parent definition, otherwise your arguments will only be appended.
Return value
$this
Throws
InvalidArgumentException when $index isn't an integer
Overrides Definition::replaceArgument
File
-
vendor/
symfony/ dependency-injection/ ChildDefinition.php, line 81
Class
- ChildDefinition
- This definition extends another definition.
Namespace
Symfony\Component\DependencyInjectionCode
public function replaceArgument(int|string $index, mixed $value) : static {
if (\is_int($index)) {
$this->arguments['index_' . $index] = $value;
}
elseif (str_starts_with($index, '$')) {
$this->arguments[$index] = $value;
}
else {
throw new InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.');
}
return $this;
}