-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update warning messages about undefined variables #8912
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
base: master
Are you sure you want to change the base?
Conversation
It looks like one of the files was saved incorrectly, I'll dig into why, probably an editor issue. https://github.com/php/php-src/pull/8912/files#diff-a639e5dd9c3864e9767fadfc556a754d955da151cbc5d9a2902cb4122b4027f4 |
Shouldn't the tests be fixed not to have undefined variables, otherwise they will break in 9.0? |
That is a character encoding issue (file was ISO-Latin, now is UTF-8). |
That will need to be done, but it doesn't need to be done for 8.2 |
So far as I can see from scanning the codebase and tests, this should be ready to go to review. |
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.
Thank you for the PR! Besides the nit about the error message, this looks good to me.
Zend/zend_execute.c
Outdated
@@ -269,7 +269,7 @@ static zend_never_inline ZEND_COLD zval* zval_undefined_cv(uint32_t var EXECUTE_ | |||
{ | |||
if (EXPECTED(EG(exception) == NULL)) { | |||
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); | |||
zend_error(E_WARNING, "Undefined variable $%s", ZSTR_VAL(cv)); | |||
zend_error(E_WARNING, "Undefined variable $%s (This will become an error in PHP 9.0)", ZSTR_VAL(cv)); |
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 don't think we should start a new sentence here (and for the other messages):
zend_error(E_WARNING, "Undefined variable $%s (This will become an error in PHP 9.0)", ZSTR_VAL(cv)); | |
zend_error(E_WARNING, "Undefined variable $%s (this will become an error in PHP 9.0)", ZSTR_VAL(cv)); |
@kocsismate, what do you think?
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.
Hm, yes, lowercasing looks slightly better to me :)
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'll change this later this week.
de6ee5d
to
039885e
Compare
…errors in PHP 9.0
The proper test expectation is a CR instead of a LF.
d9346b5
to
8858ca7
Compare
Now only sapi/fpm/tests/bug77106-fcgi-missing-nl.phpt is failing :) But otherwise the PR LGTM! |
@markrandall this requires a rebase :) |
As per RFC https://wiki.php.net/rfc/undefined_variable_error_promotion the next version will include a modified warning message when accessing undefined variables to indicate that they will become errors in PHP 9.0.