Make zpp failures always throw, independent of strict_types#3794
Closed
nikic wants to merge 53 commits intophp:masterfrom
Closed
Make zpp failures always throw, independent of strict_types#3794nikic wants to merge 53 commits intophp:masterfrom
nikic wants to merge 53 commits intophp:masterfrom
Conversation
derickr
reviewed
Feb 19, 2019
|
|
||
| /* Parameter parsing API -- andrei */ | ||
|
|
||
| #define ZEND_PARSE_PARAMS_THROW 0 /* No longer used, zpp always uses exceptions */ |
Member
There was a problem hiding this comment.
I think you should remove this define, so that it is more apparent that if this is used, the code no longer functions according to the intention.
Member
Author
There was a problem hiding this comment.
It still works as intended though -- it's just no longer necessary to specify it explicitly. I think especially in conjunction with zend_parse_parameters_throw and ZEND_PARSE_PARAMS_THROW, it would be best to preserve these functions/macros, so as to avoid unnecessary churn for extensions that already opt-in to throwing. Otherwise each extension will have to define these for compatibility.
e8de760 to
8258eee
Compare
30bf210 to
8b7f213
Compare
Previously zend_parse_parameters (and FastZPP) would handle invalid arguments depending on strict_types: With strict_types=1, a TypeError is thrown, with strict_types=0 a warning is thrown and (usually) NULL is returned. Additionally, some functions (constructors always and other methods sometimes) opt-it to throwing regardless of strict_types. This commit changes zpp to always generate an Error exception in PHP 8. Even with some of the zpp variation tests removed in php#3783, this is going to need a lot of test updates, as many tests are also testing zpp failures. I haven't really started on this yet.
zpp will be throwing for these now, don't report them in addition to that.
The exception type is going to change from UnexpectedValueException to TypeError here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC: https://wiki.php.net/rfc/consistent_type_errors
Previously zend_parse_parameters (and FastZPP) would handle invalid
arguments depending on strict_types: With strict_types=1, a TypeError
is thrown, with strict_types=0 a warning is thrown and (usually) NULL
is returned. Additionally, some functions (constructors always and
other methods sometimes) opt-it to throwing regardless of strict_types.
This patch changes zpp to always generate an Error exception in
PHP 8.
Even with some of the zpp variation tests removed in #3783, this is
going to need a lot of test updates, as many tests are also testing
zpp failures. I haven't really started on this yet.