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:704–743  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

702/* @param Type $name — rebind matching parameter. Tolerates generic
703 * `<...>` in the type token. */
704static 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

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