Backlog
Description
Problem or use case
- On PHP,
->m()binds only when the receiver's class is in the file's annotation table - Legacy PHP passes most objects around untyped, so most instance calls get no
callsedge:- a local assigned from a method's return value (
$a = $this->_factory->get_actions_instance(); $a->run();) - an untyped property set in the constructor (
$this->_factory = $factory;) - an untyped parameter whose callers all pass one class
- a call chain (
$f->get_x()->run())
- a local assigned from a method's return value (
- The class is knowable statically in each case: a native return type, an
@return/@param/@vardocblock, anewsite, or what the callers pass - Related: PHP: member/instance method calls never resolve to calls edges — only static Class::method() works #1682 (instance calls never resolve), PHP support, consolidated: member-call resolution, use-import handling, node identity, cross-language isolation, query seeding (superset of #1682) #2615 / fix(php): consolidated PHP support — member-call resolution, use-import handling, node identity, cross-language isolation, query seeding (#1682, #2615) #2617 (consolidated PHP support; overlaps on typed params,
newlocals and$this->prop->m())
Repro (4 files, no config):
// Factory.php
class Factory {
/** @return Actions */
public function get_actions_instance() { return new Actions(); }
public function make_validator() { return new Validator($this); }
}
// Validator.php
class Validator {
private $_factory;
public function __construct($factory) { $this->_factory = $factory; }
public function check() {
$actions = $this->_factory->get_actions_instance();
return $actions->is_game_over();
}
}
// Actions.php: class Actions { public function is_game_over() { return false; } }
// OtherActions.php: class OtherActions { public function is_game_over() { return true; } }calls edges from Validator::check() via extract():
| Graphify | edges |
|---|---|
v8 d249de3 (0.9.124) |
none |
| expected | .get_actions_instance() -> Factory.php, .is_game_over() -> Actions.php; never OtherActions.php |
Proposed solution
- Type a receiver from what produced it, step by step, all INFERRED (0.85):
- a function's return type (native or
@return); an undeclared return from itsreturns - a local's nearest earlier assignment; an
if/elsethat assigns related classes in its arms keeps each class @param/@vardocblocks- an untyped property from what its class stores in it
- an untyped constructor or method parameter from what its
newsites and callers pass; several classes meet at their nearest common base
- a function's return type (native or
- A call typed to a base class also reaches the subclass overrides a factory hands out (a class some non-test function returns), not every subclass
- A step that names no one class binds nothing; a chain with an unknown step falls back to today's file table, so no existing edge is lost
Alternatives considered
- Treat every named
new X()passed to an untyped parameter as a possible value of it: tried on a large legacy codebase, 9 of 25 sampled new edges reached an unrelated sibling class; dropped for the per-arm rule above - Bind an untyped
->m()by method name alone: not done; it guesses where no type evidence exists
Area
Extraction (PHP)
Are you willing to submit a PR?
Yes, PR ready.
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Dec 1, 2026
Thanks for opening this issue, @livingforelvis. 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.