Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance type recognition for values in SplDoublyLinkedList #2870

Open
Dmcz opened this issue Apr 30, 2024 · 0 comments
Open

Enhance type recognition for values in SplDoublyLinkedList #2870

Dmcz opened this issue Apr 30, 2024 · 0 comments
Labels
Milestone

Comments

@Dmcz
Copy link

Dmcz commented Apr 30, 2024

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);
@bmewburn bmewburn added the stubs label May 11, 2024
@bmewburn bmewburn added this to the 1.11.0 milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants