-
Notifications
You must be signed in to change notification settings - Fork 651
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
Built-in NoRewindIterator stub does not work #6387
Labels
Comments
I found these snippets: https://psalm.dev/r/a7edd80625<?php
/**
* @return Generator<int, string>
*/
function generator(): Generator
{
yield 'test';
}
$iterator = new NoRewindIterator(generator());
/** @psalm-trace $iterator */
|
It seems to work when we push an Iterator instead of a Generator: https://psalm.dev/r/b8a3eaff57 |
I found these snippets: https://psalm.dev/r/b8a3eaff57<?php
/**
* @return Iterator<int, string>
*/
function generator()
{
}
$iterator = new NoRewindIterator(generator());
/** @psalm-trace $iterator */
|
The stub declare it accepts an |
Reproducible with user-defined classes as well: https://psalm.dev/r/36a0f142e0 |
I found these snippets: https://psalm.dev/r/36a0f142e0<?php
/**
* @template TK
* @template TV
*/
class C {
/**
* @param Iterator<TK,TV> $it
*/
public function __construct($it) {}
}
/** @return Generator<int, string> */
function generator(): Generator {
yield "a";
}
$_t = new C(generator());
/** @psalm-trace $_t */;
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/a7edd80625
The text was updated successfully, but these errors were encountered: