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

Function resolve_static_call

internal/cbm/lsp/php_lsp.c:1782–1840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1780}
1781
1782static void resolve_static_call(PHPLSPContext *ctx, TSNode call, CBMResolvedKind kind) {
1783 TSNode scope = ts_node_child_by_field_name(call, "scope", 5);
1784 TSNode name_node = ts_node_child_by_field_name(call, "name", 4);
1785 if (ts_node_is_null(name_node))
1786 return;
1787 if (kind == CBM_RESOLVED_CALL_REFERENCE &&
1788 php_callable_reference_has_dynamic_member_name(ctx, call)) {
1789 return;
1790 }
1791 char *method_name = php_node_text(ctx, name_node);
1792 if (!method_name)
1793 return;
1794
1795 const char *class_qn = NULL;
1796 const char *strategy = "php_static_resolved";
1797 if (!ts_node_is_null(scope)) {
1798 char *cls = php_node_text(ctx, scope);
1799 if (cls) {
1800 if (strcmp(cls, "self") == 0 || strcmp(cls, "static") == 0) {
1801 class_qn = ctx->enclosing_class_qn;
1802 strategy = "php_self_static";
1803 } else if (strcmp(cls, "parent") == 0) {
1804 class_qn = ctx->enclosing_parent_qn;
1805 strategy = "php_self_static";
1806 } else {
1807 class_qn = php_resolve_class_name(ctx, cls);
1808 strategy = php_receiver_strategy(ctx, class_qn, strategy);
1809 }
1810 }
1811 }
1812 if (!class_qn)
1813 return;
1814
1815 const CBMRegisteredFunc *f = php_lookup_method(ctx, class_qn, method_name);
1816 if (f) {
1817 emit_resolved_kind(ctx, f->qualified_name, strategy, 0.95f, kind);
1818 return;
1819 }
1820 /* A first-class reference to an absent static method has an exact target
1821 * only when a materialized `__callStatic` exists. Preserve the source name
1822 * as the occurrence-join reason, but point at the real method node. Normal
1823 * facade invocations retain their existing low-confidence behavior. */
1824 const CBMRegisteredFunc *magic_static = php_lookup_method(ctx, class_qn, "__callStatic");
1825 if (magic_static && kind == CBM_RESOLVED_CALL_REFERENCE) {
1826 emit_resolved_reason_kind(ctx, magic_static->qualified_name, "php_static_magic_reference",
1827 0.95f, method_name, kind);
1828 return;
1829 }
1830 /* Facade detection: class has __callStatic in its chain. */
1831 if (magic_static) {
1832 emit_resolved_kind(ctx, cbm_arena_sprintf(ctx->arena, "%s.%s", class_qn, method_name),
1833 "php_dynamic_unresolved", 0.10f, kind);
1834 return;
1835 }
1836 /* Class resolved (e.g., from a `use` clause), method unknown — emit
1837 * synthetic resolved call so the pipeline bridge can suppress the
1838 * unified extractor's name-fallback misroute. */
1839 emit_external_or_unindexed(ctx, class_qn, method_name, "php_static_unindexed", kind);

Callers 1

Calls 9

php_node_textFunction · 0.85
php_resolve_class_nameFunction · 0.85
php_receiver_strategyFunction · 0.85
php_lookup_methodFunction · 0.85
emit_resolved_kindFunction · 0.85
cbm_arena_sprintfFunction · 0.50

Tested by

no test coverage detected