mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10002] Make paginator covariant #12036
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10002
State: closed
Merged: Yes
see https://phpstan.org/blog/whats-up-with-template-covariant
see https://psalm.dev/docs/annotating_code/templated_annotations/
A method which accepts
Paginator<Animal>should be able to acceptPaginator<Cat>.I received the error
It's because the template of ArrayIterator is not covariant.
But the template for Traversable is covariant.
It makes sens to use Traversable instead of ArrayIterator as return type because
ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable
the issue is the ArrayAccess.
If you preferred I can use somethink like
Any suggestion @greg0ire ?