TypeNameResolverTest
class TypeNameResolverTest extends TestCase (View source)
Boundary tests for stub-source name resolution (imports + current namespace).
Shared by TypeNodeConverter (type hints) and StubClassParser (parent class / interfaces) so that class references and type hints resolve identically — which makes a regression here able to change both at once. It had no direct test.
The resolution order is: built-in → already-qualified → import alias → contains a separator → relative to the current namespace. Each branch is pinned below, along with the two subtleties worth knowing: built-ins are matched case-insensitively but returned with their original case, and a qualified-but-unimported name is treated as global rather than namespace-relative.
Methods
No description
No description
No description
Built-ins are recognised case-insensitively, but the original spelling is preserved rather
than normalised — the method returns $name, not the lowercased form it matched on.
No description
No description
An import target recorded without its leading backslash still resolves fully qualified.
No description
A name containing a separator but matching no import is treated as global-qualified, not as relative to the current namespace. This is the branch most likely to be "corrected" into namespace-relative resolution, which would silently repoint every such reference.
No description
In the global namespace, '\' must not produce a doubled separator.
No description
Import lookup is case-sensitive: PHP class names are case-insensitive, but the import map is keyed by the alias exactly as written, so a differently-cased name falls through to namespace-relative resolution. Pinned as observed behaviour rather than endorsed.
Details
protected void
setUp()
No description
testBuiltInTypesAreReturnedUnchanged(string $name)
No description
static array
builtInTypes()
No description
testBuiltInMatchingIsCaseInsensitiveButPreservesTheOriginalSpelling()
Built-ins are recognised case-insensitively, but the original spelling is preserved rather
than normalised — the method returns $name, not the lowercased form it matched on.
testAlreadyQualifiedNamesAreLeftAlone()
No description
testImportAliasWins()
No description
testImportTargetIsNormalisedToALeadingBackslash()
An import target recorded without its leading backslash still resolves fully qualified.
testImportTakesPrecedenceOverTheCurrentNamespace()
No description
testQualifiedButUnimportedNameIsTreatedAsGlobal()
A name containing a separator but matching no import is treated as global-qualified, not as relative to the current namespace. This is the branch most likely to be "corrected" into namespace-relative resolution, which would silently repoint every such reference.
testUnqualifiedNameResolvesRelativeToTheCurrentNamespace()
No description
testUnqualifiedNameInTheGlobalNamespaceGetsASingleBackslash()
In the global namespace, '\' must not produce a doubled separator.
testNestedNamespaceIsPreserved()
No description
testImportLookupIsCaseSensitive()
Import lookup is case-sensitive: PHP class names are case-insensitive, but the import map is keyed by the alias exactly as written, so a differently-cased name falls through to namespace-relative resolution. Pinned as observed behaviour rather than endorsed.