MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parse_phpdoc_for_params

Function parse_phpdoc_for_params

internal/cbm/lsp/php_lsp.c:719–758  ·  view source on GitHub ↗

@param Type $name — rebind matching parameter. Tolerates generic * `<...>` in the type token. */

Source from the content-addressed store, hash-verified

717/* @param Type $name — rebind matching parameter. Tolerates generic
718 * `<...>` in the type token. */
719static void parse_phpdoc_for_params(PHPLSPContext *ctx, const char *docstring, TSNode params) {
720 (void)params;
721 if (!docstring || !ctx->current_scope)
722 return;
723 const char *p = docstring;
724 while ((p = strstr(p, "@param")) != NULL) {
725 p += 6;
726 while (*p == ' ' || *p == '\t')
727 p++;
728 const char *type_start = p;
729 int depth = 0;
730 while (*p && *p != '\n') {
731 if (*p == '<')
732 depth++;
733 else if (*p == '>')
734 depth--;
735 else if (depth == 0 && (*p == ' ' || *p == '\t' || *p == '$'))
736 break;
737 p++;
738 }
739 if (p == type_start)
740 continue;
741 char *type_text = cbm_arena_strndup(ctx->arena, type_start, (size_t)(p - type_start));
742 while (*p == ' ' || *p == '\t')
743 p++;
744 if (*p != '$')
745 continue;
746 p++;
747 const char *name_start = p;
748 while (*p && (isalnum((unsigned char)*p) || *p == '_'))
749 p++;
750 if (p == name_start)
751 continue;
752 char *vname = cbm_arena_strndup(ctx->arena, name_start, (size_t)(p - name_start));
753 const CBMType *t = resolve_phpdoc_type(ctx, type_text);
754 if (vname && t && t->kind != CBM_TYPE_UNKNOWN) {
755 cbm_scope_bind(ctx->current_scope, vname, t);
756 }
757 }
758}
759
760/* @var Type $name — bind a variable in current scope.
761 * Generic types like `array<User>` may contain whitespace-free `<>` — we

Callers 1

process_function_likeFunction · 0.85

Calls 3

resolve_phpdoc_typeFunction · 0.85
cbm_scope_bindFunction · 0.85
cbm_arena_strndupFunction · 0.50

Tested by

no test coverage detected