/**
* Registers an autowiring alias that only binds to a specific argument name.
*
* The argument name is derived from $name if provided (from $id otherwise)
* using camel case: "foo.bar" or "foo_bar" creates an alias bound to
* "$fooBar"-named arguments with $type as type-hint. Such arguments will
* receive the service $id when autowiring is used.
*/
public function registerAliasForArgument(string
$id, string
$type, string
$name = null
): Alias
{ $parsedName =
(new Target($name ??=
$id))->
getParsedName();
if (!
preg_match('/^[a-zA-Z_\x7f-\xff]/',
$parsedName)) { if ($id !==
$name) { $id =
sprintf(' for service "%s"',
$id);
} throw new InvalidArgumentException(sprintf('Invalid argument name "%s"'.
$id.': the first character must be a letter.',
$name));
} if ($parsedName !==
$name) { $this->
setAlias('.'.
$type.' $'.
$name,
$type.' $'.
$parsedName);
}