GitNexus/gitnexus-shared
Gergo Magyar af9af4a958 fix(php): four PHP semantic defects flagged by PR #1497 production review
Fixes four PHP-semantic defects identified by the production-readiness
review. The bar is "graph edges must reflect what PHP actually does",
not "matches legacy DAG" — parity with the legacy DAG is not a
correctness criterion when the legacy DAG itself has the same defect.

U1: Variadic requiredParameterCount
  arity-metadata.ts:49 now subtracts the variadic slot from required
  count: total - optionalCount - (hasVariadic ? 1 : 0). f(int $req,
  ...$rest) requires 1 arg, not undefined. Adds overload-narrowing and
  lookup-core arity-filter changes so resolvers actually drop candidates
  that are definitively arity-incompatible (was silently rescuing
  empty filter sets even when bounds were known).

U2: True transitive trait MRO
  buildPhpMro now uses a BFS worklist (collectTransitiveTraits) to
  flatten the trait-of-trait DAG to fixpoint instead of expanding one
  level. Adds (trait_declaration body (use_declaration ...)) heritage
  query so trait-uses-trait IMPLEMENTS edges are emitted at all. Fixes
  3+ level trait chains silently dropping methods.

U3: parent:: bypasses composed traits
  ScopeResolver gains optional buildExtendsOnlyMro hook; PHP returns
  the unaugmented EXTENDS-only chain via buildPhpExtendsOnlyMro.
  MethodDispatchIndex gains optional extendsOnlyMroFor accessor wired
  through buildPopulatedMethodDispatch. Super-branch dispatch in
  receiver-bound-calls now walks extendsOnlyMroFor when present, so
  parent::method() routes to the parent class even when a composed
  trait shadows the same name. Other languages leave the hook
  undefined and fall back to mroFor unchanged.

U4: Namespace-aware free-call fallback
  ScopeResolver gains optional isCallableVisibleFromCaller predicate;
  pickUniqueGlobalCallable applies it to filter cross-namespace
  candidates the caller can't reach without a use-function import.
  PHP impl checks same-namespace OR explicit use-function presence,
  using a side-channel namespace cache populated by
  populatePhpNamespaceSiblings. Fixes the legacy DAG's namespace-
  blind false-positive emissions. Existing php-calls fixture
  updated: write_audit now correctly imports its targets via
  use-function rather than relying on the false-positive name-only
  match.

Tests:
  - 175/175 PHP both flag states (REGISTRY_PRIMARY_PHP=0 and =1)
  - 794/794 C#/Python/TypeScript/Go/C (no cross-language regression)
  - typecheck clean
  - 4 new fixtures: php-variadic-arity-minimum, php-transitive-traits,
    php-parent-vs-trait, php-namespace-fallback-isolation

Plan: docs/plans/2026-05-11-001-fix-php-resolver-semantic-defects-plan.md
2026-05-11 13:10:04 +01:00
..
src fix(php): four PHP semantic defects flagged by PR #1497 production review 2026-05-11 13:10:04 +01:00
package-lock.json chore(deps)(deps-dev): bump typescript in /gitnexus-shared (#1034) 2026-04-23 05:06:42 +01:00
package.json feat: shared resilient-fetch (retries + circuit breaker) (#1448) 2026-05-09 15:18:09 +01:00
tsconfig.json feat: unify web and cli ingestion pipeline (#536) 2026-03-28 14:07:11 +00:00