$message =
sprintf('the existing "%s" service',
$this->types
[$type]);
} else { return '';
} return sprintf(' You should maybe alias this %s to %s.',
class_exists($type, false
) ? 'class' : 'interface',
$message);
} private function getAliasesSuggestionForType(ContainerBuilder
$container, string
$type): ?string
{ $aliases =
[];
foreach (class_parents($type) +
class_implements($type) as $parent) { if ($container->
has($parent) && !
$container->
findDefinition($parent)->
isAbstract()) { $aliases[] =
$parent;
} } if (1 <
$len = \
count($aliases)) { $message = 'Try changing the type-hint to one of its parents: ';
for ($i = 0, --
$len;
$i <
$len; ++
$i) { $message .=
sprintf('%s "%s", ',
class_exists($aliases[$i], false
) ? 'class' : 'interface',
$aliases[$i]);
} $message .=
sprintf('or %s "%s".',
class_exists($aliases[$i], false
) ? 'class' : 'interface',
$aliases[$i]);