-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Promote warnings to exceptions in the standard lib #4937
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
1709d41
to
19a2cc3
Compare
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'm not exactly sure if the ones related to files/ftp should be changed to Errors so I'll hand of the decision to somebody more knowledgable.
ext/standard/tests/general_functions/gettype_settype_error.phpt
Outdated
Show resolved
Hide resolved
Test failures are legit, mostly about fscanf which need to be updated. |
5611f2b
to
b0de09a
Compare
1ad3b16
to
2e15b92
Compare
2e15b92
to
ddd8362
Compare
Huh, finally the tests are going to be green after my latest fix... |
@@ -361,7 +361,7 @@ function is_uploaded_file(string $path): bool {} | |||
|
|||
function move_uploaded_file(string $path, string $new_path): bool {} | |||
|
|||
function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array {} | |||
function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {} |
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.
Isn't this change the wrong way around?
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 believe it's not, because as far as I saw parse_ini_file()
can also return false
:
php-src/ext/standard/basic_functions.c
Line 4236 in 2adb1bb
RETURN_FALSE; |
A lot in here that is not very clear-cut... Feel free to already commit the log and settype changes, and the htmlspecialchars capitalization fix. |
The file_get_contents change is fine as well. |
@@ -618,7 +618,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, | |||
if (numVars) { | |||
for (i = varStart;i < argCount;i++){ | |||
if ( ! Z_ISREF(args[ i ] ) ) { |
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.
Convert this into ZEND_ASSERT(Z_ISREF(args[i]))
, it should never fail.
@@ -3202,7 +3202,7 @@ static int user_shutdown_function_call(zval *zv) /* {{{ */ | |||
if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, NULL)) { | |||
zend_string *function_name | |||
= zend_get_callable_name(&shutdown_function_entry->arguments[0]); | |||
php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); | |||
zend_value_error("(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); |
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.
A potential problem here is that this warnings is triggered during shutdown, so there is actually no way to catch the exception. Maybe that's okay though, I'm not sure.
Thanks Nikita for the review! I admit, these changes only seemed "clear cut" for the first sight. I believe though that warning promotions for the |
@kocsismate chgrp is fine modulo two nits. password_* will require corresponding changes in ext/sodium, some of the code is duplicated there. |
Btw, I'm not saying the rest here can't land, I just didn't review it in detail. I can take another look after a rebase. |
OK, sorry, I misunderstood your words a little bit. I've just rebased to current master (I hope it worked :S). |
I tried to choose warnings where promotion didn't seem problematic. I committed all the promotions separately, but I can also
explode()
the PR into smaller ones.