import { getCurrentParsingFile, log, logCore, ParserExtraMensagens, wrapMinimal } from '../utils.js';
export function parseComPhp(codigo) {
    try {
        const classes = Array.from(codigo.matchAll(/\bclass\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
        const functions = Array.from(codigo.matchAll(/\bfunction\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
        const namespaces = Array.from(codigo.matchAll(/\bnamespace\s+([A-Za-z0-9_\\]+)/g)).map(m => m[1]);
        const interfaces = Array.from(codigo.matchAll(/\binterface\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
        const traits = Array.from(codigo.matchAll(/\btrait\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
        const enums = Array.from(codigo.matchAll(/\benum\s+([A-Za-z0-9_]+)/g)).map(m => m[1]);
        const constants = Array.from(codigo.matchAll(/\bconst\s+([A-Za-z0-9_]+)\s*=/g)).map(m => m[1]);
        const defines = Array.from(codigo.matchAll(/\bdefine\s*\(\s*['"]([A-Za-z0-9_]+)['"]/g)).map(m => m[1]);
        const methodSignatures = Array.from(codigo.matchAll(/(public|private|protected)\s+(static\s+)?function\s+([A-Za-z0-9_]+)/g)).map(m => ({
            visibility: m[1],
            isStatic: !!m[2],
            name: m[3]
        }));
        const arrowFunctions = Array.from(codigo.matchAll(/\$([A-Za-z0-9_]+)\s*=\s*fn\s*\(/g)).map(m => m[1]);
        log.debug(ParserExtraMensagens.phpParse
            .replace('{classes}', String(classes.length))
            .replace('{functions}', String(functions.length))
            .replace('{interfaces}', String(interfaces.length))
            .replace('{traits}', String(traits.length)));
        return wrapMinimal('php', {
            classes,
            functions,
            namespaces,
            interfaces,
            traits,
            enums,
            constants,
            defines,
            methodSignatures,
            arrowFunctions
        });
    }
    catch (erro) {
        logCore.erroBabel(erro.message, getCurrentParsingFile());
        return null;
    }
}
//# sourceMappingURL=php.js.map