-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make zpp failures always throw, independent of strict_types #3794
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
Conversation
|
||
/* Parameter parsing API -- andrei */ | ||
|
||
#define ZEND_PARSE_PARAMS_THROW 0 /* No longer used, zpp always uses exceptions */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.