| 1743 | enum { PHP_GROUP_WALK_MAX = 64, PHP_PREFIX_PARTS_MAX = 8 }; |
| 1744 | |
| 1745 | static const char *php_chain_prefix_arg(CBMArena *a, TSNode call_node, const char *source) { |
| 1746 | /* call_node is a member_call_expression / scoped_call_expression whose |
| 1747 | * name is `prefix`; return its first string argument (unquoted). */ |
| 1748 | TSNode args = ts_node_child_by_field_name(call_node, TS_FIELD("arguments")); |
| 1749 | if (ts_node_is_null(args)) { |
| 1750 | return NULL; |
| 1751 | } |
| 1752 | uint32_t nc = ts_node_named_child_count(args); |
| 1753 | for (uint32_t i = 0; i < nc; i++) { |
| 1754 | TSNode arg = ts_node_named_child(args, i); |
| 1755 | TSNode inner = arg; |
| 1756 | if (strcmp(ts_node_type(arg), "argument") == 0 && ts_node_named_child_count(arg) > 0) { |
| 1757 | inner = ts_node_named_child(arg, 0); |
| 1758 | } |
| 1759 | if (strcmp(ts_node_type(inner), "string") == 0 || |
| 1760 | strcmp(ts_node_type(inner), "encapsed_string") == 0) { |
| 1761 | char *txt = cbm_node_text(a, inner, source); |
| 1762 | if (txt && txt[0]) { |
| 1763 | size_t len = strlen(txt); |
| 1764 | if (len >= 2 && (txt[0] == '\'' || txt[0] == '"')) { |
| 1765 | txt[len - 1] = '\0'; |
| 1766 | txt++; |
| 1767 | } |
| 1768 | return txt[0] ? txt : NULL; |
| 1769 | } |
| 1770 | } |
| 1771 | } |
| 1772 | return NULL; |
| 1773 | } |
| 1774 | |
| 1775 | /* Compose route-group prefix segments into one path. parts[] is inner-first; |
| 1776 | * the result is outer-first with exactly one '/' between segments and a |
no test coverage detected