I am using Netbeans 6.9 and writing a PHP class that implements the Iterator interface. I would like the IDE to offer Intellisense when I iterate over the elements in my object. This seems to work for the Zend Framework, as I noticed that when repeating through Zend_Db_Rowset I get intellisense for Zend_DB_Row. For example, when I write:
foreach($rowset as $row) {
$row->delete();
}
When I type "$ row->", Netbeans displays its code hints for the Zend_Db_Row_Abstract member functions. Unfortunately, I cannot get this to work for my own code. Below is the sample I was trying to find:
class Foo {
private $value;
public function setValue($value) {
$this->value = $value;
}
public function getValue() {
return $this->value;
}
}
class It implements Iterator {
private $data;
public function __construct($data) {
$this->data = $data;
}
public function current() {
return current($this->data);
}
public function key() {
return key($this->data);
}
public function next() {
return next($this->data);
}
public function rewind() {
return reset($this->data);
}
public function valid() {
return key($this->data) !== null;
}
}
$a = new Foo();
$b = new Foo();
$a->setValue('Hello');
$b->setValue('Bye');
$testData = array($a, $b);
$myIt = new It($testData);
foreach ($myIt as $obj) {
echo $obj->getValue();
}
It is strange that intellisense seems to be that $ obj is an object of type It when I want it to think (and actually it is) an object of type Foo.