-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Some miscellaneous ext/standard cleanup #15953
base: master
Are you sure you want to change the base?
Conversation
DanielEScherzer
commented
Sep 19, 2024
- Should overall have no real changes
- Each commit/file can be reviewed independently
- If a `case` block always returns something, a `break` is unneeded - If every `case` block returns something, and there is a `default` block, then any code after the `switch` is unreachable, and can be replaced with `ZEND_UNREACHABLE()`
- Instead of manually wrapping `assert()` statements with a `ZEND_DEBUG` condition, use `ZEND_ASSERT()`, so that for non-debug builds the compiler is told to assume that the assertion is correct. - Update some return types for methods that return `zend_result`.
- `php_mail_build_headers_check_field_name()` returns `zend_result`, not bool - use `EMPTY_SWITCH_DEFAULT_CASE()` and `ZEND_UNREACHABLE()` for impossible conditions
17 different functions are implemented in essentially the same way - the single parameter (a `double`) is parser, a math function written in C (named the same as the PHP function being implemented) is called, and the result is returned with `RETURN_DOUBLE()`. Add a helper macro to deduplicate the implementations.
Single-use one-line method that is not exported, no need to exist separately
I don't like the changes done with the switches on the enums: having an exception thrown instead of causing UB seems more defensive to me. |
Which file is this about? The |
@DanielEScherzer Thank you for your PR! It would be easier if you created a PR for each unrelated change, as then they can be merged individually. It'll also be easier to keep the history clean, as you can simply commit to the branch (even via GUI) and we can just squash when merging.
Each path must return a value. Whether there's a switch (sort_type & ~PHP_SORT_FLAG_CASE) {
case PHP_SORT_NUMERIC:
if (reverse) {
return php_array_reverse_data_compare_numeric;
} else {
// Oops
// return php_array_data_compare_numeric;
}
case PHP_SORT_STRING:
|
@DanielEScherzer I was specifically referring to changes like in |
Other than the So probably drop that commit and we can proceed with the merge. Also for your information, I added some tasks on our "meta" issue tracker: https://github.com/php/php-tasks/issues |