Skip to content

ContextFactory overwrites when multiple imports with same alias #11

Open
@asgrim

Description

@asgrim

After some discussion with @nikic on https://github.com/phpDocumentor/TypeResolver/pull/9/files#r34962566 it looks like ContextFactory::getNamespaceAliases() doesn't cope with multiple imports with the same aliased name. For example:

namespace Foo;
use Foo\X;
class A extends X {
    use Zap;
}
use Bar\X;
class B extends X {
    use Baz;
}

If you call ::getNamespaceAliases() on this perfectly valid code, you'll see:

[
    'X' => 'Bar\X'
]

This is not correct, but because it is keyed by the alias name, it is too much of a simple representation to allow multiple named aliases. It's maybe quite an edge case, but it does indeed appear to be a bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions