-
Notifications
You must be signed in to change notification settings - Fork 653
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
UnusedMethodCall false positive with foreach #4373
Comments
I found these snippets: https://psalm.dev/r/dd77299d18<?php
/**
* @psalm-immutable
*/
class A implements IteratorAggregate
{
/**
* @return Iterator<string>
*/
public function getIterator() {
yield from [];
}
}
$a = new A;
foreach ($a as $v) {
echo $v;
}
|
Seems similar to: #3625 EDIT: except it didn't have an immutable annotation |
Yeah it's the same problem. My snippet is just a bit cleaner since it doesn't have other issues. Immutable annotation is not completely necessary. For instance |
I found these snippets: https://psalm.dev/r/ab4bb38b1e<?php
class A implements IteratorAggregate
{
/**
* @return Iterator<string>
* @psalm-mutation-free
*/
public function getIterator() {
yield from [];
}
}
$a = new A;
foreach ($a as $v) {
echo $v;
}
|
Closing as duplicate of #3625 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/dd77299d18
The text was updated successfully, but these errors were encountered: