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

Function phpConcatParts

src/extraction/languages/php.ts:66–78  ·  view source on GitHub ↗

* The parts of a `.` concatenation, left to right: `__DIR__ . '/inc/' . 'a.php'` * is a left-nested tree of binary expressions.

(expr: SyntaxNode, source: string, out: SyntaxNode[] = [])

Source from the content-addressed store, hash-verified

64 * is a left-nested tree of binary expressions.
65 */
66function phpConcatParts(expr: SyntaxNode, source: string, out: SyntaxNode[] = []): SyntaxNode[] {
67 const left = getChildByField(expr, 'left');
68 const right = getChildByField(expr, 'right');
69 const operator = getChildByField(expr, 'operator');
70 if (!left || !right || (operator && getNodeText(operator, source) !== '.')) return [];
71 if (left.type === 'binary_expression') {
72 if (phpConcatParts(left, source, out).length === 0) return [];
73 } else {
74 out.push(left);
75 }
76 out.push(right);
77 return out;
78}
79
80const PHP_DIRNAME_SHADOWED = new WeakMap<object, boolean>();
81

Callers 1

phpDirectoryIncludePathFunction · 0.85

Calls 3

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected