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

Prepare for php 8.4's deprecation of implicit nullable types #3411

Open
mhsdesign opened this issue Nov 2, 2024 · 5 comments
Open

Prepare for php 8.4's deprecation of implicit nullable types #3411

mhsdesign opened this issue Nov 2, 2024 · 5 comments

Comments

@mhsdesign
Copy link
Member

with php 8.4 implicit nullable types are deprecated: https://stitcher.io/blog/new-in-php-84#implicit-nullable-types-deprecation

These are a few usages that i found just in the interfaces:

... and also in neos - https://github.com/neos/neos-development-collection/blob/ee36cc29460aa2005a22b577080a85ba505a6d1f/Neos.Neos/Classes/Service/DataSource/DataSourceInterface.php#L44

As i tested it should be non breaking to adjust PropertyMappingConfigurationInterface $configuration = null to be PropertyMappingConfigurationInterface|null $configuration = null event if someone implemented it and doesnt use |null yet. That seems to be possible because the implementation narrows the type which seams legal in php. Meaning we can actually adjust that at any time so Flow 9.0 would be php8.4 compatible in that aspect at some point.

@Benjamin-K
Copy link
Contributor

I've done that for Flow right now on the 8.4 branch. As this might be breaking (classes using the interfaces might have to be changed), I didn't use 8.3 yet. Or do we only want to target Neos 9.0, as it is only a deprecation warning and Flow/Neos 8.x will only support php until 8.4?

See my commit for the 142 affected files in flow:
die-wegmeister@f1bcb50

@mhsdesign
Copy link
Member Author

Wow thanks for your help!!! I think 8.4 is perfect. Neos 8.4 will also contain the updated proxy-building which works better for newer php version https://discuss.neos.io/t/funding-request-proxy-class-building-and-php-8-2-support-for-flow-9-0/6287

I think its acceptable that Neos & Flow 8.3 will not run with deprecations on php 8.4?

But contradicting to what we thought, changing interfaces is NOT breaking because extended classes are allowed to narrow types in interfaces:

https://3v4l.org/EHQvv

Meaning we can make $lifetime of FrontendInterface nullable but in a custom implementation (CustomFrontend) have it still set to int $lifetime = null which of course yields a deprecation there but does not crash php which is good :D

Deprecated: CustomFrontend::set(): Implicitly marking parameter $lifetime as nullable is deprecated, the explicit nullable type must be used instead

So Flow 8.4 could technically be considered as well as target if we like. It would be great if you can open a pr we still can change the base later!

@dlubitz
Copy link
Contributor

dlubitz commented Jan 6, 2025

+1 for PHP 8.4 support in Neos/Flow 8.4

@mhsdesign
Copy link
Member Author

christian wrote on slack

definitely 8.3 too

so lets try that as well?

@Benjamin-K
Copy link
Contributor

I created a PR against 8.3 here: #3427
As this is non-breaking, I think it's safe to also update Flow 8.3 and not only 8.4, as 8.3 is still in the regular update period.

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

3 participants