function AutowirePass::getCombinedAlias
1 call to AutowirePass::getCombinedAlias()
- AutowirePass::getAutowiredReference in vendor/
symfony/ dependency-injection/ Compiler/ AutowirePass.php - Returns a reference to the service matching the given type, if any.
File
-
vendor/
symfony/ dependency-injection/ Compiler/ AutowirePass.php, line 723
Class
- AutowirePass
- Inspects existing service definitions and wires the autowired ones using the type hints of their classes.
Namespace
Symfony\Component\DependencyInjection\CompilerCode
private function getCombinedAlias(string $type, ?string $name = null) : ?string {
if (str_contains($type, '&')) {
$types = explode('&', $type);
}
elseif (str_contains($type, '|')) {
$types = explode('|', $type);
}
else {
return null;
}
$alias = null;
$suffix = $name ? ' $' . $name : '';
foreach ($types as $type) {
if (!$this->container
->hasAlias($type . $suffix)) {
return null;
}
if (null === $alias) {
$alias = (string) $this->container
->getAlias($type . $suffix);
}
elseif ((string) $this->container
->getAlias($type . $suffix) !== $alias) {
return null;
}
}
return $alias;
}