`$route['pattern'] = 'controller/method'`, verb-scoped or not, and the default controller at `/`.
(filePath: string, safe: string)
| 159 | |
| 160 | /** `$route['pattern'] = 'controller/method'`, verb-scoped or not, and the default controller at `/`. */ |
| 161 | function explicitRoutes(filePath: string, safe: string): { nodes: Node[]; references: UnresolvedRef[] } { |
| 162 | const nodes: Node[] = []; |
| 163 | const references: UnresolvedRef[] = []; |
| 164 | const now = Date.now(); |
| 165 | const root = filePath.slice(0, filePath.indexOf('application/')); |
| 166 | ROUTE_RE.lastIndex = 0; |
| 167 | let m: RegExpExecArray | null; |
| 168 | while ((m = ROUTE_RE.exec(safe)) !== null) { |
| 169 | const [, pattern, verb, handler] = m; |
| 170 | if (pattern === '404_override' || pattern === 'translate_uri_dashes' || !handler) continue; |
| 171 | const line = safe.slice(0, m.index).split('\n').length; |
| 172 | const routePath = pattern === 'default_controller' ? '/' : `/${pattern!.replace(/^\/+/, '')}`; |
| 173 | const route = routeNode(filePath, line, (verb ?? 'ANY').toUpperCase(), routePath, now); |
| 174 | nodes.push(route); |
| 175 | references.push({ |
| 176 | fromNodeId: route.id, |
| 177 | referenceName: `${ROUTE_REF}${root}|${handler}:${awaitedName(handler!)}`, |
| 178 | referenceKind: 'references', |
| 179 | line, |
| 180 | column: 0, |
| 181 | filePath, |
| 182 | language: 'php', |
| 183 | }); |
| 184 | } |
| 185 | return { nodes, references }; |
| 186 | } |
| 187 | |
| 188 | /** A method by name on a class, its own or one it inherits. PHP doesn't mind the case. */ |
| 189 | function methodOf(cls: Node, name: string, context: ResolutionContext): Node | null { |
no test coverage detected