vscode-intelephense
vscode-intelephense copied to clipboard
Enhance type recognition for values in SplDoublyLinkedList
Feature description or problem with existing feature The type of values within SplDoublyLinkedList is not recognized despite type annotations like SplDoublyLinkedList<string> or SplDoublyLinkedList<int>
Describe the solution you'd like Improve type inference to recognize and infer the types of values in SplDoublyLinkedList based on their declared types in the annotations.
Additional context some sample
/** @var SplDoublyLinkedList<string> */
$list = new SplDoublyLinkedList;
// the $val should be recognized as string
foreach($list as $val){
}
$list->push("Abc");
$list->pop();
/**
*
* @return SplDoublyLinkedList<int>
*/
function getList(): SplDoublyLinkedList
{
$list = new SplDoublyLinkedList;
$list->push(1);
$list->push(2);
$list->push(3);
return $list;
}
// the $val should be recognized as int
foreach(getList() as $val){
}
getList()->pop();
getList()->push(1);