laminas / laminas-di

Automated dependency injection for PSR-11 containers
https://docs.laminas.dev/laminas-di/
BSD 3-Clause "New" or "Revised" License
36 stars 20 forks source link

CONFIG: Refactor getClassForAlias to re-use Config::isAlias #36

Closed sjokkateer closed 2 years ago

sjokkateer commented 2 years ago

Signed-off-by: Remy Bos 27890746+sjokkateer@users.noreply.github.com

Q A
Documentation no
Bugfix no
BC Break no
New Feature no
RFC no
QA no

Description

Small refactor, reducing code duplication.

sjokkateer commented 2 years ago

@Ocramius I see, thank you for your reply. There is one more thing, albeit a bit offtopic for this pull request.

It is with regards to Injector::class#L166-L171, the string message would suggest there might be a logic bug in the conditional where ! class_exists($class) || interface_exists($class) should be either: ! (class_exists($class) || interface_exists($class)) or its logical equivalent: ! class_exists($class) && ! interface_exists($class) or the string (exception message) might be in need of an update, is this correct and if so which would it be? Also, it seems that if an interface would get to that point, ! class_exists($class) would short circuit the conditional.

If there is something I am completely overlooking that makes my comment invalid then please inform me and forgive me for my lack of knowledge!

Ocramius commented 2 years ago

is this correct and if so which would it be?

I would not really know myself: a test case would highlight that 😁