If a library I use, have a class that extends 2 other classes by the use of __call()
, only the main extended class gets it's methods listed in the objects suggestions.
I noticed that if I make another php file in the project, where I put a class with the same name and namespace, and let it extend the other class, the IDE don't know witch one of them I'm referring to and gives me the suggestions for both of them, that way it suggests the methods from both of the extended classes.
This works sometimes, but in some case the IDE is to smart, and somehow know that my class isn't the real one, and only shows methods from the main extendsion.
Is there a better way to tell the IDE that a class in the library have more functions that it seams? Or a way that at least works every time?
Example:
<?php // index.php
include(__DIR__ . "/lib.php");
$c = new c();
echo $c->s_a();
echo $c->s_b(); // Accepted by the IDE
$d = new d();
echo $d->s_a();
echo $d->s_b(); // Not acceted by the IDE
<?php // lib.php
class a {
function s_a() { return "a";}
}
class b {
function s_b() { return "b";}
}
class c extends a {
public $b;
function __construct() {
$this->b = new b();
}
function __call($name, $arguments) {
return call_user_func_array(array($this->b, $name), $arguments);
}
}
class d extends c {}
<?php // fake.php
class c extends b {};
For $c
the IDE don't know if it should use class c from lib.php or from fake.php, so it gives be a list with the methods of both.
For $d
the that is of class d that extends c, it somehow know that its class c in file lib.php, so $d->s_b()
are not sugested.