php-pp / core

PHP++ core
MIT License
1 stars 1 forks source link

PHP Deprecation warning when using PHP 8.1.22 #7

Open DJCrispyRice opened 4 months ago

DJCrispyRice commented 4 months ago

When running unit tests in a PHP 8.1.22/Symfony 6.4 project with php-pp/core installed, I always get a deprecation warning :

PHPUnit 10.5.20 by Sebastian Bergmann and contributors.

Runtime: PHP 8.1.22 with Xdebug 3.1.6 PHP Deprecated: Return type of PhpPp\Core\Component\Collection\AbstractCollection::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in {projectPath}/symfony/vendor/php-pp/core/src/Collection/AbstractCollection.php on line 298

Easy fix is to add the expected return for the key() function as stated in the deprecation.

steevanb commented 4 months ago

Hi,

Thanks for the ticket. If you want to use Collection, you should use https://github.com/steevanb/php-collection (code copied from here, with some fixes and new features).

I don't have the time for php++ anymore :(

DJCrispyRice commented 4 months ago

Tbh I already have a fix working on my part, I would happily do a PR if you're interested. If not, I'll fork your project for internal purposes if that's ok with you.

steevanb commented 4 months ago

You can send a PR if you have the fix ;)

DJCrispyRice commented 4 months ago

Hi,

I was going to submit the PR but unfortunately I saw the project should be compatible with PHP ^7.4 which means I can't use union types nor mixed as a return for the incriminated function.

As a result, unless support for this legacy PHP version is dropped, I cannot find a way to suppress this deprecation warning which is a shame. I guess I'll have to use a fork for our projects or migrate to collection.