Skip to content

Add @implements to SPL iterator stubs#5672

Open
takaram wants to merge 1 commit into
phpstan:2.1.xfrom
takaram:recursive-iterator-iterator
Open

Add @implements to SPL iterator stubs#5672
takaram wants to merge 1 commit into
phpstan:2.1.xfrom
takaram:recursive-iterator-iterator

Conversation

@takaram
Copy link
Copy Markdown
Contributor

@takaram takaram commented May 16, 2026

This PR adds @implement annotations to the stub of three classes:

  • RecursiveIteratorIterator
  • DirectoryIterator
  • RecursiveDirectoryIterator

Closes phpstan/phpstan#8435

@phpstan-bot
Copy link
Copy Markdown
Collaborator

You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x.

@takaram takaram changed the base branch from 2.2.x to 2.1.x May 16, 2026 09:20
@takaram takaram closed this May 16, 2026
@takaram takaram reopened this May 16, 2026
Comment thread stubs/iterable.stub
Comment on lines +199 to +201
* @template-covariant TKey
* @template-covariant TValue
* @template TIterator of \RecursiveIterator<TKey, TValue>|\IteratorAggregate<TKey, TValue>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it means that RecursiveIteratorIterator has now three template like

RecursiveIteratorIterator<int, int, IteratorAggregate<int, int>>

if so, it will break code where people used the single-template RecursiveIteratorIterator no ?

Also, this won't be compatible with the stub from psalm
https://github.com/vimeo/psalm/blob/ca151242c84d8962b921bf59c509b49362ce0eec/stubs/CoreGenericIterators.phpstub#L902-L903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RecursiveDirectoryIterator type

3 participants