naitsirch opened a new issue, #5663: URL: https://github.com/apache/netbeans/issues/5663
### Apache NetBeans version Apache NetBeans 17 ### What happened If I am iterating with `foreach` over an iterator object Netbeans offers auto completion for the members of the object that provides the iterator. But this is wrong. Here's a screenshot:  It would be great if Netbeans would offer auto completion for the `foreach` items (as far as I remember this already worked some years ago). But at least the wrong suggestions should be removed. You will find an example code to reproduce the issue below. ### How to reproduce ```php <?php class CollectionItem {} class Collection implements IteratorAggregate { public function __construct( private array $items ) {} public function getIterator(): \Traversable { return new ArrayIterator($this->items); } public function customCollectionMethod() {} } class Example { private Collection $collection; public function __construct() { $this->collection = new Collection([ new CollectionItem(), new CollectionItem(), ]); } /** * @return CollectionItem[] */ public function getCollection(): Collection { return $this->collection; } } $example = new Example(); foreach ($example->getCollection() as $item) { $item-> // put your cursor here and press Ctrl + Space } ``` Netbeans offers `getCollection()` and `customCollectionMethod()` for auto completion. This would be correct if I press Ctrl + Space after `$example->getCollection()->`. But when iterating over `$example->getCollection()` the items usually have other properties. ### Did this work correctly in an earlier version? No / Don't know ### Operating System Debian Linux ### JDK OpenJDK Runtime Environment 11.0.18+10-post-Debian-1deb11u1 ### Apache NetBeans packaging Apache NetBeans binary zip ### Anything else _No response_ ### Are you willing to submit a pull request? No -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
