Deprecate passing null to non-nullable arg of internal function#4227
Deprecate passing null to non-nullable arg of internal function#4227nikic wants to merge 4 commits into
Conversation
It should be possible to skip any of these (and use the ini configured defaults) by passing null, independently of strict_types settings. Noticed while working on GH-4227.
A lot of test updates missing.
The ones where bless_tests.php worked right with little modification.
|
The ship has sailed here for 7.4, but might be worth considering again for PHP 8. Before we do so, we'll need to do some comprehensive review of internal function parameters that should be nullable but aren't. People who have been adding stubs (cc @kocsismate) have probably noticed that we have a lot of Ideally we'd change those to be nullable (even independently of the change proposed here). |
|
I also planned to ask you in the recent days if it is feasible to sneak this into PHP 7.4. Yes, it would be a breaking change for sure, but it could still be very useful for forward-compatibility. Unfortunately, I am not sure if PHP has precedents to do something like this before... But surely, getting rid of |
I don't think we really do deprecations in patch releases ... but as this particular one if very large and has a lot of potential impact, it definitely can't go into 7.4. |
Yes, I can't remember any... :/
Ah yes, makes sense... I have to remember myself that breaking backward compatibility (at such a big scale) isn't worth for forward compatibility... |
|
This PR is rebooted at #6475. |
For user functions, parameters only accept null if they are explicitly declared nullable -- independently of strict_types. An
intparameter will always rejectnull. It is necessary to use?intto accept it.The same is not the case for internal functions using zpp, which will silently accept null and cast it to the appropriate type (will become one of
false,0,0.0or""). If the internal function uses arginfo instead, then the behavior is the same as for user functions.As we would like to annotate internal functions with arginfo information in PHP 8, it is important to resolve this behavioral difference -- otherwise any future arginfo addition may also result in a behavior change wrt null handling. Edit: This particular issue has been resolved by special-casing arginfo handling for internal functions.
TODO: