Closed cziegenberg closed 9 years ago
Thank you for the report.
Lazy me : v2 or v3 ? PR on tests would also be helpful in case you love. Thank you.
Tested with v3. If I have some time, I'll try to add tests (currently working on bugs of my own projects :)).
I'd suggest to explicitly define in the docs, that you MUST NOT leading namespace separators
Added a note in the docs as part of c8a6957.
I also suggest to remove them automatically from given class name arguments
Easier to do in the methods than in the arrays. PR welcome on that one, if you like.
Class name resolution via ::class is perfect to be used here, but just if you run >=5.5.
http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class
I did a simple test and found a problem with the handling of namespaces. The optional leading namespace separator "\" can result in
Aura\Di\Resolver\UnresolvedParam
exceptions when used, because the (parent) class parameters cannot be found.As you always have to use full class names, I'd suggest to explicitly define in the docs, that you MUST NOT leading namespace separators, and I also suggest to remove them automatically from given class name arguments (e.g. in
newInstance
).TEST 1: Result: Works
TEST 2: Result: Fails (Aura\Di\Resolver\UnresolvedParam)
TEST 3: Result: Works
TEST 4: // Result: Fails (Aura\Di\Resolver\UnresolvedParam), because get_parent_class() return class names without leading "\"
TEST 5: Result: Works
TEST 6: // Result: Fails (Aura\Di\Resolver\UnresolvedParam), because get_parent_class() return class names without leading "\"
TEST 7: Result: Works
TEST 8: Result: Fails (Aura\Di\Resolver\UnresolvedParam)