Athari / YaLinqo

Yet Another LINQ to Objects for PHP [Simplified BSD]
https://athari.github.io/YaLinqo
BSD 2-Clause "Simplified" License
441 stars 39 forks source link

Return type of YaLinqo\Enumerable::getIterator() should either be compatible #62

Open GarciaSiego opened 9 months ago

GarciaSiego commented 9 months ago

Getting following error on php 8.2 Package: "athari/yalinqo": "^2.5",

[message] => Return type of YaLinqo\Enumerable::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [file] => /var/www/html/custom/vendor/athari/yalinqo/YaLinqo/Enumerable.php

Athari commented 9 months ago

Wait, is PHP actually making specifying types mandatory? In a minor version? With a hacky commented out attribute to avoid the warning?

Will argument types become mandatory too?

GarciaSiego commented 9 months ago

Simple tag seems to fix it https://github.com/Athari/YaLinqo/pull/63

Clonkex commented 9 months ago

This SO post explains the reasoning quite well. Because they now specify the return type of IteratorAggregate::getIterator(), you now also need to specify the return type on your Enumerable::getIterator(). Rather than instantly break tonnes of older code by specifying return types on built-in classes, they added the #[TentativeType] attribute to give people time to update by causing the deprecation message rather than a straight error.