You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Chris (Jira)" <ji...@apache.org> on 2020/02/07 13:32:00 UTC
[jira] [Created] (NETBEANS-3812) PHP: Code completion detects wrong
type for typed Iterator in foreach
Chris created NETBEANS-3812:
-------------------------------
Summary: PHP: Code completion detects wrong type for typed Iterator in foreach
Key: NETBEANS-3812
URL: https://issues.apache.org/jira/browse/NETBEANS-3812
Project: NetBeans
Issue Type: Bug
Components: php - Code Analysis, php - Editor, php - Refactoring
Affects Versions: 11.2
Reporter: Chris
When using types on the elements of an Iterator, then the IDE detects the wrong types while iterating via foreach.
The variable "$item" in the source code is of type "Model" and the IDE should suggest the properties of "Model". But it thinks "$item" is of type \TestIterator and suggests methods and properties of the \TestIterator type.
Run code completion on $item within the foreach to reproduce this issue.
{code:php}
class Model
{
public $name = "test";
}
class TestIterator extends \ArrayIterator
{
public function __construct(\Model ...$items)
{
parent::__construct($items);
}
public function current(): \Model
{
return parent::current();
}
public function offsetGet($offset): \Model
{
return parent::offsetGet($offset);
}
}
$iterator = new \TestIterator(new Model(), new Model());
foreach ($iterator as $item)
{
# run code completion on $item to reproduce issue
echo $item;
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists