vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Enhance type recognition for values in SplDoublyLinkedList

Open Dmcz opened this issue 9 months ago • 0 comments

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

Dmcz avatar Apr 30 '24 03:04 Dmcz