* Extract PHP import mappings (use statements)
(content: string)
| 1041 | * Extract PHP import mappings (use statements) |
| 1042 | */ |
| 1043 | function 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. |
no test coverage detected