Skip to content

PHP: pre-scan short-name conflict drop degrades toward a possible wrong edge, and #53 widened its trigger set #55

Closed

Description

@filipechagas

Surfaced in the adversarial re-review of #53 (cycle branch fix/resolution-gaps-52-53-54), reported at mechanism level — no end-to-end repro built.

Mechanism (measured against the pre-scan directly): _php_pre_scan_class_namespaces (graphify/extractors/engine.py:200-270) keys its declared-FQN map by SHORT name and drops any short name declared twice under different namespaces in one file. The drop predates #53, but #53 grew its input set from class_declaration to all four declaration kinds (_PHP_FQN_DECLARATIONS):

"<?php namespace A; class Foo {} namespace B; interface Foo {}"
  pre-#53 -> {'foo': 'A\\Foo'}   (the class kept its declared FQN)
  now     -> {}                  (both dropped)

Why it matters: the drop is not purely fail-closed. A class that loses its declared FQN gets judged by the PSR-4 path branch of _php_fqn_names_another_class (graphify/extractors/php.py:110-117), which can bail out to "no evidence" and KEEP an edge — the same degradation shape as the incremental vendor-import hole #53's amendment fixed (see review notes on #53).

Preconditions: one file declaring two namespaces (a PSR-1 violation) AND reusing a short name across them for two different declaration kinds — rare, which is why the reviewer rated it minor.

Candidate fix (reviewer's): key the pre-scan map by (namespace, short name) so the collision never arises, instead of dropping on short-name conflict.

Activity

  1. added
    needs-triage
    wontfix
    and removed
    needs-triage
    on Aug 7, 2026
  2. filipechagas commented on Aug 7, 2026

    @filipechagas
    CollaboratorAuthor

    Triage (2026-08-07): closing as wontfix — the mechanism is real, the defect is not reachable

    Measured, not inferred (probes run on the integrated fix/resolution-gaps-52-53-54 branch, PR #57):

    1. The precondition does not occur on the target corpus. Scanned every non-vendor PHP file in the pinned api.lawnstarter.com clone for multiple namespace declarations in one file: zero files. The shape requires a PSR-1 violation that this corpus simply doesn't contain.

    2. The wrong-edge scenario does not materialize end-to-end. Fixture namespace A; class Foo {} namespace B; interface Foo {} (both FQNs conflict-dropped, reproduced: pre-scan returns {}), plus:

      • a caller with use Vendor\Sdk\Foo and a Foo-typed receiver → no calls edge — the two same-short-name declarations sit in the type census, so the single-definition guard refuses before the FQN map's absence can matter;
      • a caller with the legitimate use A\Foo → no edge either (fail-closed recall loss confined to the PSR-1-violating shape — and pre-PHP: _php_non_class_types receiver refusal is now redundant conservatism — recoverable member-call fan-in left unrealized #53 this bound nothing as well, since the blanket short-name refusal covered Foo);
      • inline (new \A\Foo())->bar() → the edge still binds the class the source names, demoted EXTRACTED → INFERRED (control without the conflict: EXTRACTED). Confidence downgrade, not a fabricated edge.

      So the issue's "degrades toward a possible wrong edge" is not reachable: every consumer of the dropped FQN either refuses (census) or keeps the correctly-named target at lower confidence.

    3. The sketched fix wouldn't help its consumers. class_fqn_by_file is looked up by (defining file, short name) — declared_fqn() has only the node's label and source file. With two same-short-name types in one file, that lookup is inherently ambiguous no matter how the map is keyed; dropping is the correct fail-closed answer for the contract as it exists. Re-keying by (namespace, short) would require threading namespace identity onto the type nodes themselves — a larger change with no measured defect to justify it.

    The docstring at _php_pre_scan_class_namespaces already states the drop rule and its rationale ("a wrong answer is worse than no answer"), which the probes confirm is what actually happens. If a corpus ever surfaces a real wrong edge through this path, reopen with the repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions