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

PHP Deprecation warning when using PHP 8.1.22 #7

Open
DJCrispyRice opened this issue May 7, 2024 · 4 comments
Open

PHP Deprecation warning when using PHP 8.1.22 #7

DJCrispyRice opened this issue May 7, 2024 · 4 comments

Comments

@DJCrispyRice
Copy link

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.

@DJCrispyRice DJCrispyRice changed the title PHP Deprecation warning when using PHP 8.1 PHP Deprecation warning when using PHP 8.1.22 May 7, 2024
@steevanb
Copy link
Member

steevanb commented May 7, 2024

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
Copy link
Author

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
Copy link
Member

steevanb commented May 7, 2024

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

@DJCrispyRice
Copy link
Author

DJCrispyRice commented May 13, 2024

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.

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

No branches or pull requests

2 participants