bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.61k stars 94 forks source link

Enhance type recognition for values in SplDoublyLinkedList #2870

Closed Dmcz closed 3 months ago

Dmcz commented 5 months ago

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);