| 1601 | } |
| 1602 | |
| 1603 | static void process_catch(PHPLSPContext *ctx, TSNode node) { |
| 1604 | /* Bind $e to the caught exception type. */ |
| 1605 | TSNode type_list; |
| 1606 | memset(&type_list, 0, sizeof(type_list)); |
| 1607 | TSNode var_node; |
| 1608 | memset(&var_node, 0, sizeof(var_node)); |
| 1609 | uint32_t nc = ts_node_child_count(node); |
| 1610 | for (uint32_t i = 0; i < nc; i++) { |
| 1611 | TSNode c = ts_node_child(node, i); |
| 1612 | if (ts_node_is_null(c) || !ts_node_is_named(c)) |
| 1613 | continue; |
| 1614 | const char *k = ts_node_type(c); |
| 1615 | if (strcmp(k, "type_list") == 0) |
| 1616 | type_list = c; |
| 1617 | if (strcmp(k, "variable_name") == 0) |
| 1618 | var_node = c; |
| 1619 | } |
| 1620 | if (ts_node_is_null(var_node)) |
| 1621 | return; |
| 1622 | char *vt = php_node_text(ctx, var_node); |
| 1623 | if (!vt) |
| 1624 | return; |
| 1625 | const char *vname = (vt[0] == '$') ? vt + 1 : vt; |
| 1626 | const CBMType *exc_type = cbm_type_unknown(); |
| 1627 | if (!ts_node_is_null(type_list)) { |
| 1628 | uint32_t tnc = ts_node_child_count(type_list); |
| 1629 | for (uint32_t i = 0; i < tnc; i++) { |
| 1630 | TSNode tc = ts_node_child(type_list, i); |
| 1631 | if (ts_node_is_null(tc) || !ts_node_is_named(tc)) |
| 1632 | continue; |
| 1633 | exc_type = php_parse_type_node(ctx, tc); |
| 1634 | break; |
| 1635 | } |
| 1636 | } |
| 1637 | cbm_scope_bind(ctx->current_scope, vname, exc_type); |
| 1638 | } |
| 1639 | |
| 1640 | /* ── call resolution ────────────────────────────────────────────── */ |
| 1641 |
no test coverage detected