Skip to content

ScannedType

One class-like declaration, as read out of its source file by the tokenizer.

This is what SourceScanner produces before any autoloading happens. The fully-qualified name here is the one the file actually declares, not one derived from the file’s path, which is the distinction that makes it safe to reflect.

final class ScannedType

SourceScan/ScannedType.php
PropertyTypeDescription
$absolutePathstringreadonly.
$baseDirstringreadonly.
$fqcnstringreadonly.
$importsarrayreadonly.
$kindstringreadonly.
$namespacestringreadonly.
$shortNamestringreadonly.

public function __construct(string $fqcn, string $shortName, string $namespace, 'class'|'interface'|'trait'|'enum' $kind, string $absolutePath, string $baseDir, array<string, string> $imports): mixed

Alias (lowercased) => fully-qualified name, from the file’s top-level use statements. Needed to resolve the unqualified Foo docblock references that reflection alone cannot.

ParameterTypeDescription
$fqcnstring
$shortNamestring
$namespacestring
$kind`‘class’“'interface'
$absolutePathstring
$baseDirstring
$importsarray``<``string``, ``string``>Alias (lowercased) => fully-qualified name, from the file’s top-level use statements. Needed to resolve the unqualified Foo docblock references that reflection alone cannot.

Returns mixed

MethodDescription
relativePath(): stringReturns the path of this file relative to the PSR-4 base directory it was found under.
resolveImport(string $alias): ?stringResolves an alias used in this file to its fully-qualified name, or null when unimported.

public function relativePath(): string

Returns the path of this file relative to the PSR-4 base directory it was found under.

Source links are built from this rather than from ReflectionClass::getFileName(), which resolves symlinks: the monorepo’s vendor entries are symlinks into packages/, so the same class reports a different absolute path in a checkout than in a published install.

Returns string

public function resolveImport(string $alias): ?string

Resolves an alias used in this file to its fully-qualified name, or null when unimported.

ParameterTypeDescription
$aliasstring

Returns ?``string