Skip to content

PHP Class::method() static calls without an explicit 'use' import stay INFERRED instead of EXTRACTED #3872

Closed

Description

@rikurunico

Summary

For PHP, a type-qualified static call ClassName::method() is emitted as INFERRED (confidence_score 0.85) instead of EXTRACTED (1.0) whenever the caller and callee classes share a namespace and therefore have no explicit use import statement — even though the receiver type is named explicitly in source text.

Other languages' member-call resolvers (Swift _resolve_swift_member_calls, Python _resolve_python_member_calls, C++, Java, C#, Kotlin) all promote a type-qualified call (Type.staticMethod()) to EXTRACTED regardless of import evidence — see the comment at extract.py around line 3821-3824:

# A type-qualified call (`Type.staticMethod()`) names the receiver type
# explicitly in source, so it is an exact reference — EXTRACTED, matching
# the Python qualified-class-method pass (#1533). An instance call whose
# receiver type came from local inference (`obj.method()`) stays INFERRED.

PHP has no equivalent dedicated resolver. scoped_call_expression (Class::method()) calls fall through to the generic cross-file name resolver (extract.py ~L8380-8444), which gates EXTRACTED purely on has_import_evidence (an explicit use statement or matching import edge). Same-namespace PHP classes never need a use import for each other, so every same-namespace static call gets stuck at INFERRED 0.85 even though the class name is written right there in the call.

Repro

// app/StoreClass/LogApi.php
namespace App\StoreClass;

class LogApi
{
    public static function logIncoming($flag_log, $endpoint_log, $request_log = [], $response_log = []): LogApiModel
    {
        $request_log = is_array($request_log) ? LogActivity::sanitize($request_log) : $request_log;
        ...
    }
}

LogActivity lives in the same App\StoreClass namespace, so there's no use App\StoreClass\LogActivity; line. The resulting edge:

{
  "source": "app_storeclass_logapi_logapi_logincoming",
  "target": "app_storeclass_logactivity_logactivity",
  "relation": "calls",
  "_origin": "ast",
  "confidence": "INFERRED",
  "confidence_score": 0.85,
  "context": "call",
  "source_file": "app/StoreClass/LogApi.php",
  "source_location": "L20"
}

Ran a corpus-wide sweep on a Laravel app (585 PHP INFERRED _origin:ast calls edges): 83 of them were genuine Class::method() scoped calls (confirmed by checking the source line at source_location for a \b[A-Z][A-Za-z0-9_\\]*::\s*\w+\s*\( pattern with no $obj->method( on the same line) — all should have been EXTRACTED. The remaining 500 were true $obj->method() instance calls where the receiver type is inferred, correctly left as INFERRED.

Expected

A PHP scoped_call_expression (ClassName::method(), including self::, static::, parent:: resolved to a concrete class) should be treated as type-qualified and promoted to EXTRACTED/1.0 the same way the Swift/Python/C++/Java/C#/Kotlin member-call resolvers already do, independent of whether an explicit use import exists — same-namespace classes legitimately never have one.

Suggested fix

Add a PHP-specific resolver (or extend the generic one) that inspects the raw call node type before falling back to name-only resolution: if it's scoped_call_expression with an uppercase/class-like left-hand identifier, set confidence="EXTRACTED", confidence_score=1.0 regardless of has_import_evidence, mirroring the existing type_qualified branches at extract.py:3830, 4121, 4287, 4509, 4880.

Environment

  • graphifyy 0.9.69
  • Detected via /graphify skill incremental --update on a Laravel 12 / PHP 8.5 codebase

Activity

  1. github-actions commented on Sep 27, 2026

    @github-actions

    Thanks for opening this issue, @rikurunico. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. added a commit that references this issue on Oct 12, 2026
    2d37da1
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions