MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extractPHPImports

Function extractPHPImports

src/resolution/import-resolver.ts:1043–1063  ·  view source on GitHub ↗

* Extract PHP import mappings (use statements)

(content: string)

Source from the content-addressed store, hash-verified

1041 * Extract PHP import mappings (use statements)
1042 */
1043function extractPHPImports(content: string): ImportMapping[] {
1044 const mappings: ImportMapping[] = [];
1045
1046 // use Namespace\Class; or use Namespace\Class as Alias;
1047 const useRegex = /use\s+([\w\\]+)(?:\s+as\s+(\w+))?;/g;
1048 let match;
1049
1050 while ((match = useRegex.exec(content)) !== null) {
1051 const [, fullPath, alias] = match;
1052 const className = fullPath!.split('\\').pop()!;
1053 mappings.push({
1054 localName: alias || className,
1055 exportedName: className,
1056 source: fullPath!,
1057 isDefault: false,
1058 isNamespace: false,
1059 });
1060 }
1061
1062 return mappings;
1063}
1064
1065/**
1066 * Extract C/C++ import mappings from #include directives.

Callers 1

extractImportMappingsFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected