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

Migrate to PHP 8.4 #256

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

redbeardcreator
Copy link

This is in response to my bug report, #254 . However, it technically also "competes" with:

I made these changes before I knew about the other two. But I'm tired and want to get this PR in. If desired, I'm happy to do the work of merging the other PRs together so everyone gets credit.

This removes the deprecations introduced in PHP 8.4
PHP 8.4 makes not doing so a deprecation.
PHP 8.4 deprecates the use of E_USER_ERROR. This can mangle the exception thrown. So, skip the test
in PHP 8.4. It may be possible to fix up what's being thrown, but I haven't found anything.

Since using trigger_error for user errors is now deprecated, error_to_exception() should probably be
deprecated as well. But that's a greater decision than making sure tests work correctly.
PHP 8.4 has changed the format of __FUNCTION__ for closures, at least.
PHP 8.4 deprecates the implicit conversion from doubles to ints when doing so would lose precision.
However, disallowing doubles as array keys in Functional would be a BC break.
@redbeardcreator
Copy link
Author

redbeardcreator commented Dec 9, 2024

Incidentally, I made these changes against the 1.17.0 release rather than main. I'll be maintaining my fork until PHP 8.4 support is merged, as I will be going to production with 8.3 (at least) soon.

@lstrojny
Copy link
Owner

Looks good! Care to extend the build matrix for CI as well?

@@ -32,6 +32,11 @@ function group($collection, callable $callback)

InvalidArgumentException::assertValidArrayKey($groupKey, __FUNCTION__);

// Avoid implicit precision-loss from doubles (which cannot be keys)
if (is_numeric($groupKey)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add a testcase for this so that we have the behavior explicitly pinned down?

// See https://3v4l.org/MmFA6.
self::markTestSkipped('Only works with PHP <8.4 due to deprecated E_USER_ERROR');
}

$origFn = function () {
\trigger_error('Some error', E_USER_ERROR);
Copy link
Owner

Choose a reason for hiding this comment

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

How about using E_DEPRECATED instead

@Egorskov
Copy link

If desired, I'm happy to do the work of merging the other PRs together so everyone gets credit.

Please merge with my pull request. This is the first PR, it will help me a lot

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.

3 participants