Closed sjokkateer closed 2 years ago
Absolute ref:
@sjokkateer from my PoV, new $class(...)
where $class
is an interface makes absolutely no sense.
Your test should be fine, we just need to drop part of the conditional then (can be done here) :)
Also, I suggest rebasing to get your build to pass.
Thanks for investigating!
Signed-off-by: Remy Bos 27890746+sjokkateer@users.noreply.github.com
Description
Injector::create#L166-171 contains the following check:
Given the added test (which passes/satisfies), a
ClassNotFoundException::class
is thrown. This is the case because the if guard short circuits (example #1) since! class_exists($class)
will always be true for any given interface. Therefor it seems that the part|| interface_exists($class)
could hence be removed (all tests would still pass equally).My main confusion with this piece of code lies in the fact that it seems as if it was meant for an interface to get up to that point, based on the given if guard and exception message. While everything following the conditional indicates it not making sense. Since after the conditional, only parameters for a class will be resolved and an attempt is made to construct a class (which would ofcourse result in an error for an interface).
This confusion would be resolved by removing the
|| interface_exists($class)
and adjusting the message of the exception that is thrown.I have made the pull request a WIP in case you have a different opinion than the suggested. Please let me know what you think.