* The path that string literals (and `DIRECTORY_SEPARATOR`, read as `/`) * append to a directory: it starts with `/`, names a file rather than a * directory (no trailing `/`), and has no empty segment. Null when anything * else is appended.
(tail: SyntaxNode[], source: string)
| 144 | * else is appended. |
| 145 | */ |
| 146 | function phpAppendedPath(tail: SyntaxNode[], source: string): string | null { |
| 147 | let rest = ''; |
| 148 | for (const part of tail) { |
| 149 | const literal = phpLiteralText(part, source); |
| 150 | if (literal !== null) rest += literal; |
| 151 | else if (getNodeText(part, source).replace(/^\\/, '') === 'DIRECTORY_SEPARATOR') rest += '/'; |
| 152 | else return null; |
| 153 | } |
| 154 | if (!rest.startsWith('/') || rest.endsWith('/')) return null; |
| 155 | return rest.split('/').slice(1).every((seg) => seg !== '') ? rest : null; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * `__DIR__ . '/inc/a.php'`, `dirname(__FILE__) . DIRECTORY_SEPARATOR . 'a.php'`: |
no test coverage detected