/** Clears the cached PSR-4 maps. Exported for test isolation. */ export declare function clearPsr4Cache(): void; /** * Build (or retrieve from cache) the PSR-4 namespace-prefix -> source-dir[] * map for a workspace root. * * Returns an empty map when there is no `composer.json`, or it declares no * `autoload.psr-4`/`autoload-dev.psr-4` map — callers can pass the result * straight through with zero behavior change. * * `autoload` is collected before `autoload-dev`, so when a prefix is declared * in both, its candidate array always has the `autoload` (production) * directory first — see `resolvePsr4Import`'s tie-break, which relies on * this ordering. * * @param workspaceRoot - Absolute path to the project root. */ export declare function resolvePsr4Map(workspaceRoot: string): Map; /** * Resolve a raw PHP import specifier (e.g. `GuzzleHttp\Cookie\SetCookie`) to * a workspace-relative path (e.g. `src/Cookie/SetCookie`), using a PSR-4 map * built by `resolvePsr4Map`. * * Runs on the RAW backslash-separated specifier as emitted by * `PHPImportExtractor` — this resolution step happens in * `resolveImportSpecifier` (`ast/symbols.ts`) *before* `path-matching.ts`'s * `normalizePath` converts `\` to `/`, so the prefix lookup below is * deliberately backslash-aware rather than operating on an already-slashed * form. * * Matches the LONGEST registered namespace prefix (a project can declare * several via `autoload` + `autoload-dev`, and a more specific prefix like * `Foo\Bar\` must win over a broader `Foo\` if both are registered), then * builds one candidate resolved path per directory registered for that * prefix (#1002 — a prefix can have more than one, see `resolvePsr4Map`'s doc * comment) and picks among them: * 1. If `workspaceRoot` is given, the first candidate that exists on disk as * a real `.php` file wins. PSR-4's own contract (the file's basename must * equal the class name) makes this a precise existence check, not a * heuristic — and because `resolvePsr4Map` puts `autoload`'s directory * before `autoload-dev`'s, iterating in order already prefers the * production root on a tie (both candidates happen to exist). * 2. Otherwise (no `workspaceRoot`, or no candidate exists on disk — e.g. the * specifier is genuinely unresolvable), fall back to the first-registered * candidate: `autoload`'s directory when the prefix is declared there, * same as before #1002 for the single-candidate case. * * This deliberately keeps a single best-guess `string` return (not * `string[]`) rather than pushing candidate selection onto callers: its only * caller, `resolveImportSpecifier` (`ast/symbols.ts`), folds the result into * both a flat `imports: string[]` array AND a `Record` map keyed by this return value — plumbing multiple candidates * through both shapes would ripple well past this module for a case the * existence check above already resolves correctly in the overwhelming * common case (a real file exists under exactly one of the candidate roots). * * No-op (returns `specifier` unchanged) when the map is empty or no prefix * matches — non-PSR-4 specifiers and non-Composer projects see zero behavior * change. * * @param specifier - The raw (pre-`normalizePath`) PHP import specifier. * @param psr4Map - Map of namespace prefix (trailing `\`) -> candidate source dirs (each trailing `/`). * @param workspaceRoot - Absolute project root, used to disambiguate multiple * candidates by checking which resolves to a real file. Omit (e.g. in unit * tests exercising the map directly) to always get the first-registered * candidate. */ export declare function resolvePsr4Import(specifier: string, psr4Map: ReadonlyMap, workspaceRoot?: string): string; //# sourceMappingURL=php-psr4.d.ts.map