Skip to content

feat(php): PHP type inference and method-call/chained resolution #538

Description

@vitali87

Context

Structural PHP support is in place and covered by tests (functions incl. anonymous/arrow, classes/interfaces/traits/enums, calls, imports, inheritance edges, and oracle tests for containment/structure/span). This issue tracks the remaining gap toward full parity with Java: PHP-specific type inference and method-call resolution.

Gap

There is no parsers/php/ resolver subpackage analogous to parsers/java/ (which has type inference, method resolution, and inheritance-aware lookups). As a result, PHP method calls on typed receivers and chained accesses are not resolved to precise CALLS edges the way Java's are.

Unsupported / imprecise today:

  • Inferring $var types from new X(), typed parameters, typed properties, and method return types.
  • Resolving instance method calls $obj->method() to the declaring class.
  • Resolving chained access $obj->field->method() and fluent chains $obj->a()->b().
  • Walking the inheritance chain (extends/implements/trait use) so inherited members resolve.
  • self::, static::, parent:: and ::class resolution.

Proposed work

Add a codebase_rag/parsers/php/ resolver mirroring the Java approach:

  • Build a per-scope variable type map (locals, params, properties).
  • Resolve method/static calls against the receiver type, walking class/interface/trait inheritance.
  • Emit CALLS edges for resolved instance, static, and chained calls.
  • Add a PHP test suite for these resolution cases (RED/GREEN), following the existing test_php_* style.

Split off from #108, where the structural support was confirmed complete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphpPHP language

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions