-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ContextFactory incorrect namespace aliases #76
Comments
Hm, I need to check if this was intended by design or that this is a bug. It is hard to believe that a library that is so widely used has a major issue like this one. It would be helpful if you can provide a link to your project that currently uses this library. |
I wanted to use it in one of my private projects and immediately stumbled upon this issue. I use it with the Actually, I think I found when the bug exactly came. When you go back to the commit Referring even to php docs you can find such examples: use My\Full\Classname as Another;
// this is the same as use My\Full\NSname as NSname
use My\Full\NSname; That's why I believe the array('NSname' => 'My\Full\NSname') instead of array('My\Full\NSname' => 'My\Full\NSname') The only workaround for now is to use: use My\Full\NSname as NSname; But as you can tell it shouldn't work like that. Regarding the tests of
$expected = [
'm' => m::class,
'DocBlock' => DocBlock::class,
'Tag' => Tag::class,
'phpDocumentor' => 'phpDocumentor',
'TestCase' => TestCase::class,
'Assert' => Assert::class,
'e' => e::class,
ReflectionClass::class => ReflectionClass::class,
'stdClass',
];
sort($expected);
sort($actual);
$this->assertSame($expected, $actual); The $this->assertSame(sort($expected), sort($actual)); The result of |
Thanks for this awesome description and search work. This helped a lot in understanding where things went wrong. |
You're welcome, good to hear it helped. :) |
Released v 0.7.2 and 1.0.1 including the fix suggested in #77. |
Following the example below:
Unfortunately, instead of the type
Common\Domain\DayOfWeek
on thedayOfWeek
property, its type isApp\DayOfWeek
.After a longer digging, I stumbled upon
ContextFactory::extractUseStatements
method. The problem here is how this method uses aliasing.For the example above the
Context::getNamespaceAliases
call will end up withinstead of
Also, I noticed the tests
testReadsAliasesFromClassReflection
,testReadsAliasesFromProvidedNamespaceAndContent
are incorrect forContextFactory
, that's why it looks like no one has been able to notice it all this time.The text was updated successfully, but these errors were encountered: