As it states that it's ok to answer my own question and having found some trick to achieve code completion in Eclipse IDE (for PHP) I would like to share this with other users.
I found some solution here but somehow I can't make doxygen work properly with such declared properties, I found some workaround.
The problem
If you use magic methods, especially for property overloading __get()
, __set()
, (probably it concerns also __call()
and __invoke()
), there is a problem, that property names defined in somehow dynamic (as variable variables) and not visible in any scope. It is possible because their names are passed as strings and can be manipulated in any way.
So it is not possible to have those magically accessed properties (or methods) in code completion, and in my case (don't know why, but it doesn't matter), in the generated documentation of the class.
(The code-completion is when the editor helps the programmer by showing all possible properties and methods, thus letting avoid some errors.)
Consider we have the following class:
/**
* Test class
*/
class myClass {
private $field_someValue1;
private $field_someValue2;
/**
* Magic method getter for hidden properties.
* @param string $name
* @return mixed
*/
public function __get($name){
switch($name){
case 'foo': return $this->$field_someValue1; break;
case 'bar': return $this->$field_someValue2; break;
default:
// handle non-existing property error here
}
}
/**
* Simply do nothing, but be some public part of the class.
* @return void
*/
public function doNothing(){
}
}
$a = new myClass();
So in my code when I type $a->
the editor should help me by hinting that there are two properties for my object: foo
and bar
. Of course it can't show $field_someValue1
and $field_someValue2
as they are private.
How to make Eclipse help me?