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

[2.x] PHP 8.4 support #90

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
Draft

[2.x] PHP 8.4 support #90

wants to merge 14 commits into from

Conversation

Jubeki
Copy link
Contributor

@Jubeki Jubeki commented Sep 6, 2024

PestPHP doesn't support PHP 8.4 yet, and can therefor not be installed without the platform-req=php+

Copy link

github-actions bot commented Sep 6, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@driesvints
Copy link
Member

I'd honestly like to wait until it does support php 8.4 so we don't have to use platform-req=php

@Jubeki
Copy link
Contributor Author

Jubeki commented Sep 6, 2024

Yeah that's why I left it in Draft for now. Just wanted to see if something else's needed to be fixed.

@crynobone
Copy link
Member

@Jubeki I made a draft PR #91 just to experiment around. I closed it once I'm done with testing and applies the changes here.

@crynobone
Copy link
Member

CleanShot 2024-09-25 at 12 55 04

I'm curious what would cause this error on PHP 8.4 tests https://github.com/laravel/framework/actions/runs/11024490854/job/30617746097

@Jubeki
Copy link
Contributor Author

Jubeki commented Sep 25, 2024

@crynobone maybe this is a little helpful (I don't know much about serialising closures yet)

Following Code snippet causes the error in the test ImplicitRouteBindingTest::test_it_can_resolve_the_implicit_backed_enum_route_bindings_for_the_given_route (first one in your image):
https://github.com/laravel/framework/blob/b17b2bd8ebcb850a909fd046c380d075fd2f118b/src/Illuminate/Routing/RouteSignatureParameters.php#L19-L23

This is the value of $action['uses'] for

PHP 8.3:

O:55:"Laravel\SerializableClosure\UnsignedSerializableClosure":1:{s:12:"serializable";O:46:"Laravel\SerializableClosure\Serializers\Native":5:{s:3:"use";a:0:{}s:8:"function";s:114:"function (\Illuminate\Tests\Routing\CategoryBackedEnum $category) {\n
            return $category->value;\n
        }";s:5:"scope";s:49:"Illuminate\Tests\Routing\ImplicitRouteBindingTest";s:4:"this";N;s:4:"self";s:32:"00000000000001060000000000000000";}}

PHP 8.4:

O:55:"Laravel\SerializableClosure\UnsignedSerializableClosure":1:{s:12:"serializable";O:46:"Laravel\SerializableClosure\Serializers\Native":5:{s:3:"use";a:0:{}s:8:"function";s:123:"function (\{closure:Illuminate\Tests\Routing\CategoryBackedEnum $category) {\n
            return $category->value;\n
        }";s:5:"scope";s:49:"Illuminate\Tests\Routing\ImplicitRouteBindingTest";s:4:"this";N;s:4:"self";s:32:"00000000000001060000000000000000";}}

See the small difference s:114 -> s:123? and function (\Illuminate\Tests\Routing\CategoryBackedEnum $category) -> function (\{closure:Illuminate\Tests\Routing\CategoryBackedEnum $category)

Not sure if this helpful, but maybe a starting point for further debugging.

@Jubeki
Copy link
Contributor Author

Jubeki commented Sep 25, 2024

@crynobone I think this PR is related:

How to fix this:

$code = $reflector->getCode();

Instead use the following:

$code = $reflector->getCode();
$code = str_replace('\{closure:', '', $code);

In the end, I think this is a bug with PHP and should probably be reported.

src/Serializers/Native.php Outdated Show resolved Hide resolved
@crynobone crynobone changed the title [1.x] PHP 8.4 support [2.x] PHP 8.4 support Oct 1, 2024
@crynobone crynobone changed the base branch from master to develop October 1, 2024 09:28
@takaram
Copy link

takaram commented Oct 1, 2024

I submitted an issue to php-src and they changed the return value of ReflectionFunction::getNamespaceName().
php/php-src#16122

Here's a sample code of how the reflection methods related to closure namespace work in PHP8.4.
https://3v4l.org/srIno/rfc

Now ReflectionFunction::getNamespaceName() returns "" for anonymous functions.
$reflection->getClosureScopeClass()->getNamespaceName() will still work only if the closure is created in a method. Otherwise the namespace seems unable to be retrieved in a simple way.

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.

4 participants