wrong Design or Problem of PHP resp. PDT [message #560092] |
Tue, 21 September 2010 03:52  |
Eclipse User |
|
|
|
hi,
i have a question about auto-complete methods from return Objects.
to explain a little code.
class node {
public $age = 10;
public function __construct(/*int*/ $age){
$this->age = $this->age + $age;
}
public function getAge(){
return $this->age;
}
}
class tree {
public static function getNodes(/*int*/ $number){
$nodes = array();
for($i=0; $i<=$number; $i++){
$nodes[] = new node($i);
}
return $nodes;
}
}
$Tree = tree::getNodes(9);
foreach($Tree as $Node){
echo 'Node age:'.$Node->getAge();
}
the auto-complete function does not work on the
$Node in the last for-each loop.
I think, it is because PDT don't know the elements in the Array.
If i return the object directly (also only one) the auto-complete function works correctly.
In Java there are Return Types and and everything is a Object.
There are no Problems with this.
Is the code above only a design error?
Is there a other method to code something like this?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05895 seconds