Closed enumag closed 7 years ago
Not sure if it's possible to fix it otherwise than ignoring it with
private function checkCase($class)
{
if (class_exists($class) || interface_exists($class)) {
$name = (new ReflectionClass($class))->getName();
if ($class !== $name && strtolower($class) === strtolower($name)) {
throw new ServiceCreationException("Case mismatch on class name '$class', correct name is '$name'.");
}
}
}
EDIT: It seems there is no way to get the defined class alias so I guess there is no better fix.
@dg Any estimate 2.4.9 with this fix could be available? This bug is blocking some of my open-source projects.
@enumag done
Thank you!
Description
Nette/DI seems to be incompatible with class aliases. My tests are failing with this error:
Obviously there is no case mismatch. It's just that
Twig\NodeVisitor\NodeVisitorInterface
is an alias ofTwig_NodeVisitorInterface
which confuses ContainerBuilder::checkCase().Steps To Reproduce
Create a class and an alias to that class. Add it to DIC as service. Try to autowire it into another service using the alias instead of the base class. EDIT: See the test case in my PR.