Skip to content

Conversation

@marcing
Copy link
Contributor

@marcing marcing commented Apr 17, 2025

PHP 8.4: Implicitly nullable parameter declarations deprecated

https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated

Fixes error:
Implicitly marking parameter ? as nullable is deprecated, the explicit nullable type must be used instead

Fix using Zf1s\Compat\Types

@marcing marcing force-pushed the php84-nullable-deprecated branch from bb2943d to 4afbcd2 Compare April 18, 2025 15:36
@dmnc
Copy link
Contributor

dmnc commented Aug 1, 2025

This is a tricky one. If I understand correctly, we can not make 8.4 happy whilst supporting less than 7.1.

This seems to prevent a conflict between keeping ZF1 usable on new PHP versions with this package and fixing vulnerabilities with it.

The approach taken here makes me a little nervous but it does seem to perform what we want:

  • Compatible with all PHP versions
  • Doesn't break child classes that have types on these methods
  • Has thorough docblocks so editors remain able to understand the expected type.

It does introduce a surprising pattern though. Is that preferable to making future version >=7.1?

@marcing
Copy link
Contributor Author

marcing commented Aug 1, 2025

@dmnc No actually in the end I managed to make it work on all versions 5.6-8.4. I had to introduce a helper function though, because there is no syntax that would work in both 5.6 and 8.4.

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