Keep same return for class names without alias#20
Conversation
|
Indeed, good catch. |
|
Of course, it tooked me some time to figure out what exactly was going on but following is the explanation. I need to notice before that we are relying on https://github.com/Roave/BetterReflection for better reflection performances. This library is the reason why we found this behaviour during code test execution. Imagine the following code exaple: <?php
include 'vendor/autoload.php';
(new \Roave\BetterReflection\BetterReflection)->classReflector()->reflect(\Vendor\Package\MyClass::class);
new \Vendor\Package\MyClass(); which results into:
The reason behind this is inside BetterReflection library at https://github.com/Roave/BetterReflection/blob/4.13.x/src/SourceLocator/Type/AutoloadSourceLocator/FileReadTrapStreamWrapper.php :) Cheers 🍻 |
|
This looks good, thanks and sorry for the large delay! |
Current intention of
ClassAliasLoader::getOriginalClassNameisto returnNULL if no alias mapping is found or the original class name as string`But the behaviour actually sets a NULL value in case a alias mapping is not found. This would lead on a second call to catch into the first condition which then returns the input parameter class name. This in case leads to the error that
ClassAliasLoader::loadClassWithAliaswill callloadOriginalClassAndSetAliaseson a second try cause the return value is no more NULL but then the class name that was given as parameter. In some cases like for testing this results into PHP Warnings :)The fix will now check if the value has already been set to NULL and returns the same result like in the first call.