Lets say I have a typical factory pattern in PHP code:
abstract class Model
{
function m()
{
}
}
class model_A
{
function a()
{
}
}
class model_B
{
function b()
{
}
}
function modelFactory($name)
{
$className = 'model_' . $name;
$object = new $className();
// ... do some magic stuff ...
return $object;
}
I know about the @var and @return phpdoc tags, but is there any magic way so after typing this:
$x = modelFactory('A');
Eclipse will know $x is an instance of model_A?
Can I define somewhere a fixed vector of strings like this:
"modelFactory('A')" => "new model_A()"
"modelFactory('B')" => "new model_B()"
For Eclipse to replace in memory before processing with code completion.
Short answer, this is not possible in the way you want it.
As you've already rightfully pointed out in another comment you should use @var
manually to achieve code completion goodness, because it's impossible for the editor to understand the concept of programming patterns by itself
Although theoretically possible, manually authoring rules for type inference just seems backwards imho (let alone the required changes to the Docblock notation itself).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With