* 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[] = [])
| 64 | * is a left-nested tree of binary expressions. |
| 65 | */ |
| 66 | function 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 | |
| 80 | const PHP_DIRNAME_SHADOWED = new WeakMap<object, boolean>(); |
| 81 |
no test coverage detected