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

Detect Traversable / Iterator + IteratorAggregate type declaration mismatch #5222

Closed
Steveb-p opened this issue Jun 28, 2021 · 2 comments
Closed

Comments

@Steveb-p
Copy link

https://phpstan.org/r/42818384-3047-4e86-9676-07f98ff0e5e7

<?php declare(strict_types = 1);

final class Item
{
}

/**
 * @extends Traversable<Item>
 */
interface ItemListInterface extends Traversable
{
}

/**
 * @implements IteratorAggregate<string>
 */
final class ItemList implements IteratorAggregate, ItemListInterface
{
	public function getIterator()
	{
		return new ArrayIterator([]);
	}
}

I understand that it's a rather specific case, and that phpstan does not "see" the connection between one interface being Traversable, and implementation class being an IteratorAggregate.

Ideally, we'd see that iterator types mismatch, but I'm pretty certain it's not simple.

Originally posted by @Steveb-p in #5221 (reply in thread)

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Jul 8, 2021

Implemented: phpstan/phpstan-src@284af50

@github-actions
Copy link

github-actions bot commented Aug 9, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants