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

@implement tag on RecursiveIterator returns an error, while Iterator does not #4718

Closed
jfcalcerrada opened this issue Mar 18, 2021 · 2 comments

Comments

@jfcalcerrada
Copy link

jfcalcerrada commented Mar 18, 2021

Bug report

@implements tag on a \RecursiveIterator doesn't work, but it does with \Iterator.

The following error is being reported:

Class Some\Foo\PeriodRecursive @implements tag contains incompatible type iterable<Some\Foo\Moment>&RecursiveIterator.

Digging into the source code, I found this commit "reverting" the change: phpstan/phpstan-src@aa92b5b

So I assume this is not a bug and it's intentional, but I'm not understanding why this was reverted.

Code snippet that reproduces the problem

Link to the playground, please ignore missing method errors:

https://phpstan.org/r/f5382215-922f-4453-a7d6-de0ae9a524d6

<?php namespace Some\Foo;

class Moment {}

/**
 * @implements \Iterator<Moment>
 */
final class Period implements \Iterator
{
}

/**
 * @implements \RecursiveIterator<Moment>
 */
final class PeriodRecursive implements \RecursiveIterator
{
}

Expected output

No error is returned, as \RecursiveIterator works the same as \Iterator

@ondrejmirtes
Copy link
Member

Hi, I don't even know what me change it, so I reverted it. RecursiveIterator is generic again! phpstan/phpstan-src@82596f5

Thank you.

@github-actions
Copy link

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 Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants