{"record":{"id":"efd9c5eb7227a341","repo":"abhigyanpatwari/GitNexus","slug":"cfg-php-buildfunctioncfg-skipped-a-function-in","errorCode":null,"errorMessage":"[cfg] PHP buildFunctionCfg skipped a function in ${filePath}: ${String(err)}","messagePattern":"\\[cfg\\] PHP buildFunctionCfg skipped a function in (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cfg/visitors/php.ts","lineNumber":973,"sourceCode":"      builder.edge(builder.entryIndex, blk, 'seq');\n      builder.edge(blk, builder.exitIndex, 'return');\n      return builder.finish(harvest.bindingTable());\n    }\n\n    const walk = new PhpCfgWalk(builder, harvest);\n    const res = walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment'));\n    if (!res) {\n      builder.edge(builder.entryIndex, builder.exitIndex, 'seq'); // empty body\n      return builder.finish(harvest.bindingTable());\n    }\n    builder.edge(builder.entryIndex, res.entry, 'seq');\n    builder.connect(res.exits, builder.exitIndex, 'seq'); // normal fall-off → EXIT\n    return builder.finish(harvest.bindingTable());\n  } catch (err) {\n    // Never throw out of buildFunctionCfg — a malformed AST shape must skip only\n    // this one function's CFG, never drop the whole file's language group (R4).\n    // eslint-disable-next-line no-console\n    console.warn(`[cfg] PHP buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);\n    return undefined;\n  }\n}\n\n/** Whether a node is a PHP function this visitor builds a CFG for. */\nfunction isFunction(node: SyntaxNode): boolean {\n  return PHP_FUNCTION_TYPES.has(node.type);\n}\n\n/** The PHP CFG visitor. */\nexport function createPhpCfgVisitor(): CfgVisitor<SyntaxNode> {\n  return { buildFunctionCfg, isFunction };\n}\n\nexport { PHP_FUNCTION_TYPES };\n","sourceCodeStart":955,"sourceCodeEnd":989,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cfg/visitors/php.ts#L955-L989","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// prescreen: invalid PHP (mixed templates, broken tags) parses with ERROR nodes\nif (tree.rootNode.hasError) fixSourceOrExclude(file);","typeGuard":null,"tryCatchPattern":"const cfg = visitor.buildFunctionCfg(fn, ctx);\nif (cfg === undefined) continue; // warned skip for this function","preventionTips":["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'"],"tags":["cfg","tree-sitter","php","ingestion","graceful-degradation"],"backgroundTag":"tree-sitter-unknown-node-type","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}