Skip to content

Commit 288cb51

Browse files
committed
refactor(php): gate the declaration index by interop family, as the shared resolver does
1 parent bacdd1e commit 288cb51

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎graphify/extract.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4601,11 +4601,6 @@ def _resolve_csharp_qualified_calls(
46014601
})
46024602

46034603

4604-
# Every suffix the PHP extractor claims. The member-call resolver both activates on and
4605-
# indexes declarations by this set, so an included `.phtml` class is not left out.
4606-
_PHP_SUFFIXES = (".php", ".phtml", ".php3", ".php4", ".php5", ".php7", ".phps")
4607-
4608-
46094604
def _resolve_php_member_calls(
46104605
per_file: list[dict],
46114606
all_nodes: list[dict],
@@ -4644,14 +4639,14 @@ def _key(label: str) -> str:
46444639

46454640
# A genuine declaration is the target of a `contains` edge from its file node; a bare
46464641
# type reference mints a same-label stub that would otherwise make a real name ambiguous.
4647-
# Only PHP files count: the index is corpus-wide, so a same-named Java class would both
4648-
# answer the receiver and hide that nothing local declares its type.
4642+
# Only PHP declarations count: the index is corpus-wide, so a same-named Java class
4643+
# would both answer the receiver and hide that nothing local declares its type.
46494644
contained = {e.get("target") for e in all_edges if e.get("relation") == "contains"}
46504645
type_def_nids: dict[str, list[str]] = {}
46514646
node_by_id: dict[str, dict] = {}
46524647
for n in all_nodes:
46534648
node_by_id[n.get("id")] = n
4654-
if (str(n.get("source_file", "")).endswith(_PHP_SUFFIXES)
4649+
if (_lang_family(n.get("source_file")) == "php"
46554650
and n.get("id") in contained and _is_type_like_definition(n)):
46564651
type_def_nids.setdefault(_key(n.get("label", "")), []).append(n["id"])
46574652

@@ -4897,7 +4892,7 @@ def _resolve_kotlin_qualified_calls(
48974892
register_language_resolver(
48984893
LanguageResolver(
48994894
"php_member_calls",
4900-
frozenset(_PHP_SUFFIXES),
4895+
frozenset({".php", ".phtml", ".php3", ".php4", ".php5", ".php7", ".phps"}),
49014896
_resolve_php_member_calls,
49024897
)
49034898
)

0 commit comments

Comments
 (0)