Infinate loop in resolving non-existant class
carnage opened this issue · comments
carnage commented
I had made an error with putting a class in a directory which didn't match it's PSR-4 namespace. I had added this class to the container using ClassName::class
Upon attempting to resolve it, the definition class went into an infinite loop and seg faulted PHP as class_exists() returns false for the class name string as it's unable to resolve it.
The offending code is on line 191 of Definition.php comments above it state:
// if we still have a string, try to pull it from the container
// this allows for `alias -> alias -> ... -> concrete
Unfortunately, if the string is not an alias this will cause this issue.
Recommendation for a fix is to put the following code above that line
if (is_string($concrete) && $concrete === $this->concrete) {
throw new NotFoundException(
sprintf('Alias (%s) cannot be resolved to a concrete instance, perhaps this is a missing class or you meant to specify this as a literal not a service', $id)
);
}