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

Function cbm_doclink_php_qualify

internal/cbm/doclink_php.c:96–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96size_t cbm_doclink_php_qualify(char *out, size_t cap, const char *ns, size_t ns_len,
97 const cbm_doclink_php_use_t *uses, int nuses, const char *ref,
98 size_t n) {
99 size_t w = 0;
100 if (cap == 0 || n == 0) {
101 return 0;
102 }
103 out[0] = '\0';
104 if (ref[0] == '\\') {
105 return php_put(out, cap, &w, ref + SKIP_ONE, n - SKIP_ONE) ? w : 0;
106 }
107 static const char rel[] = "namespace\\";
108 size_t rl = sizeof(rel) - SKIP_ONE;
109 if (n > rl && php_eq_nocase(ref, rl, rel, rl)) {
110 ref += rl; /* namespace\Foo: the current namespace's Foo */
111 n -= rl;
112 } else {
113 const char *bs = memchr(ref, '\\', n);
114 size_t first = bs ? (size_t)(bs - ref) : n;
115 for (int i = 0; i < nuses; i++) {
116 const cbm_doclink_php_use_t *u = &uses[i];
117 if (u->kind == 'c' && php_eq_nocase(u->alias, u->alias_len, ref, first)) {
118 bool ok = php_put(out, cap, &w, u->name, u->name_len) &&
119 php_put(out, cap, &w, ref + first, n - first);
120 return ok ? w : 0;
121 }
122 }
123 }
124 bool ok =
125 !ns_len || (php_put(out, cap, &w, ns, ns_len) && php_put(out, cap, &w, "\\", SKIP_ONE));
126 return ok && php_put(out, cap, &w, ref, n) ? w : 0;
127}
128
129/* ── Tokens ──────────────────────────────────────────────────────── */
130

Callers 3

php_baseFunction · 0.85
pr_type_ofFunction · 0.85
pr_functionFunction · 0.85

Calls 2

php_putFunction · 0.85
php_eq_nocaseFunction · 0.85

Tested by

no test coverage detected