abhigyanpatwari/GitNexus · warning
[cfg] PHP buildFunctionCfg skipped a function in ${filePath}
Error message
[cfg] PHP buildFunctionCfg skipped a function in ${filePath}: ${String(err)} What it means
During indexing GitNexus builds a per-function control-flow graph (CFG) with a PHP tree-sitter visitor. buildFunctionCfg wraps the body walk (visitSeq over namedChildren minus comments) in a catch-all: any throw from an unexpected AST shape is logged with console.warn and only that function's CFG is skipped (returns undefined), protecting the file's language group ('R4' isolation).
Source
Thrown at gitnexus/src/core/ingestion/cfg/visitors/php.ts:973
builder.edge(builder.entryIndex, blk, 'seq');
builder.edge(blk, builder.exitIndex, 'return');
return builder.finish(harvest.bindingTable());
}
const walk = new PhpCfgWalk(builder, harvest);
const res = walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment'));
if (!res) {
builder.edge(builder.entryIndex, builder.exitIndex, 'seq'); // empty body
return builder.finish(harvest.bindingTable());
}
builder.edge(builder.entryIndex, res.entry, 'seq');
builder.connect(res.exits, builder.exitIndex, 'seq'); // normal fall-off → EXIT
return builder.finish(harvest.bindingTable());
} catch (err) {
// Never throw out of buildFunctionCfg — a malformed AST shape must skip only
// this one function's CFG, never drop the whole file's language group (R4).
// eslint-disable-next-line no-console
console.warn(`[cfg] PHP buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
return undefined;
}
}
/** Whether a node is a PHP function this visitor builds a CFG for. */
function isFunction(node: SyntaxNode): boolean {
return PHP_FUNCTION_TYPES.has(node.type);
}
/** The PHP CFG visitor. */
export function createPhpCfgVisitor(): CfgVisitor<SyntaxNode> {
return { buildFunctionCfg, isFunction };
}
export { PHP_FUNCTION_TYPES };
View on GitHub (pinned to aac7515d2a)
Solutions
- Read the ${String(err)} portion of the warning to identify the exception
- Reproduce on the single file and inspect the parse tree of the failing function
- Resync grammar/visitor via reinstall or patch the PHP visitor for the node type
- Re-run analyze --index-only to rebuild the CFG
- Accept the degradation — only that function loses its CFG
Defensive patterns
Strategy: fallback
Validate before calling
// prescreen: invalid PHP (mixed templates, broken tags) parses with ERROR nodes if (tree.rootNode.hasError) fixSourceOrExclude(file);
Try / catch
const cfg = visitor.buildFunctionCfg(fn, ctx); if (cfg === undefined) continue; // warned skip for this function
Prevention
- Keep grammar and visitor in sync via clean reinstalls
- Avoid indexing template fragments that are not valid standalone PHP
- Report match-expression/attribute shapes that trip the walker
- Do not read a missing CFG as 'function unused'
When it happens
Trigger: A PHP construct the walker does not model: match-expression arms, attribute declarations, arrow functions or heredoc bodies with unexpected node shapes, or ERROR/MISSING nodes from syntactically invalid PHP, causing a throw during the walk.
Common situations: Grammar drift in the PHP grammar versus the visitor's covered node types; indexing legacy PHP with mixed HTML/template fragments; files with syntax errors; very new PHP syntax the visitor predates.
Related errors
- [cfg] C# buildFunctionCfg skipped a function in ${filePath}:
- [cfg] Dart buildFunctionCfg skipped a function in ${filePath
- [cfg] Go buildFunctionCfg skipped a function in ${filePath}:
- [cfg] Java buildFunctionCfg skipped a function in ${filePath
- [cfg] Kotlin buildFunctionCfg skipped a function in ${filePa
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/efd9c5eb7227a341.
Report an issue: GitHub.