| 2706 | } |
| 2707 | |
| 2708 | static void process_class_decl(PHPLSPContext *ctx, TSNode node) { |
| 2709 | TSNode name_node = ts_node_child_by_field_name(node, "name", 4); |
| 2710 | if (ts_node_is_null(name_node)) |
| 2711 | return; |
| 2712 | char *cname = php_node_text(ctx, name_node); |
| 2713 | if (!cname) |
| 2714 | return; |
| 2715 | |
| 2716 | const char *saved_class = ctx->enclosing_class_qn; |
| 2717 | const char *saved_parent = ctx->enclosing_parent_qn; |
| 2718 | |
| 2719 | /* enclosing_class_qn must match what the unified extractor records, |
| 2720 | * which uses module_qn (file-path-based), NOT the PHP `namespace` |
| 2721 | * declaration. */ |
| 2722 | if (ctx->module_qn) { |
| 2723 | ctx->enclosing_class_qn = cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->module_qn, cname); |
| 2724 | } else { |
| 2725 | ctx->enclosing_class_qn = cbm_arena_strdup(ctx->arena, cname); |
| 2726 | } |
| 2727 | ctx->enclosing_parent_qn = find_extends_qn(ctx, node); |
| 2728 | |
| 2729 | /* Walk class body — pick out method_declaration nodes. */ |
| 2730 | TSNode body = ts_node_child_by_field_name(node, "body", 4); |
| 2731 | if (ts_node_is_null(body)) |
| 2732 | body = child_named(node, "declaration_list"); |
| 2733 | if (!ts_node_is_null(body)) { |
| 2734 | uint32_t nc = ts_node_child_count(body); |
| 2735 | for (uint32_t i = 0; i < nc; i++) { |
| 2736 | TSNode c = ts_node_child(body, i); |
| 2737 | if (ts_node_is_null(c)) |
| 2738 | continue; |
| 2739 | const char *k = ts_node_type(c); |
| 2740 | if (strcmp(k, "method_declaration") == 0) { |
| 2741 | process_function_like(ctx, c); |
| 2742 | } |
| 2743 | } |
| 2744 | } |
| 2745 | |
| 2746 | ctx->enclosing_class_qn = saved_class; |
| 2747 | ctx->enclosing_parent_qn = saved_parent; |
| 2748 | } |
| 2749 | |
| 2750 | /* ── top-level pass ─────────────────────────────────────────────── */ |
| 2751 |
no test coverage detected