@param Type $name — rebind matching parameter. Tolerates generic * `<...>` in the type token. */
| 702 | /* @param Type $name — rebind matching parameter. Tolerates generic |
| 703 | * `<...>` in the type token. */ |
| 704 | static void parse_phpdoc_for_params(PHPLSPContext *ctx, const char *docstring, TSNode params) { |
| 705 | (void)params; |
| 706 | if (!docstring || !ctx->current_scope) |
| 707 | return; |
| 708 | const char *p = docstring; |
| 709 | while ((p = strstr(p, "@param")) != NULL) { |
| 710 | p += 6; |
| 711 | while (*p == ' ' || *p == '\t') |
| 712 | p++; |
| 713 | const char *type_start = p; |
| 714 | int depth = 0; |
| 715 | while (*p && *p != '\n') { |
| 716 | if (*p == '<') |
| 717 | depth++; |
| 718 | else if (*p == '>') |
| 719 | depth--; |
| 720 | else if (depth == 0 && (*p == ' ' || *p == '\t' || *p == '$')) |
| 721 | break; |
| 722 | p++; |
| 723 | } |
| 724 | if (p == type_start) |
| 725 | continue; |
| 726 | char *type_text = cbm_arena_strndup(ctx->arena, type_start, (size_t)(p - type_start)); |
| 727 | while (*p == ' ' || *p == '\t') |
| 728 | p++; |
| 729 | if (*p != '$') |
| 730 | continue; |
| 731 | p++; |
| 732 | const char *name_start = p; |
| 733 | while (*p && (isalnum((unsigned char)*p) || *p == '_')) |
| 734 | p++; |
| 735 | if (p == name_start) |
| 736 | continue; |
| 737 | char *vname = cbm_arena_strndup(ctx->arena, name_start, (size_t)(p - name_start)); |
| 738 | const CBMType *t = resolve_phpdoc_type(ctx, type_text); |
| 739 | if (vname && t && t->kind != CBM_TYPE_UNKNOWN) { |
| 740 | cbm_scope_bind(ctx->current_scope, vname, t); |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | /* @var Type $name — bind a variable in current scope. |
| 746 | * Generic types like `array<User>` may contain whitespace-free `<>` — we |
no test coverage detected