Skip to content

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

markrandall
Copy link

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.

@markrandall
Copy link
Author

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

@markrandall markrandall marked this pull request as draft July 3, 2022 00:43
@xPaw
Copy link
Contributor

xPaw commented Jul 3, 2022

Shouldn't the tests be fixed not to have undefined variables, otherwise they will break in 9.0?

@cmb69
Copy link
Member

cmb69 commented Jul 3, 2022

It looks like one of the files was saved incorrectly,

That is a character encoding issue (file was ISO-Latin, now is UTF-8).

@markrandall
Copy link
Author

Shouldn't the tests be fixed not to have undefined variables, otherwise they will break in 9.0?

That will need to be done, but it doesn't need to be done for 8.2

@markrandall markrandall marked this pull request as ready for review December 17, 2022 21:37
@markrandall
Copy link
Author

markrandall commented Dec 17, 2022

So far as I can see from scanning the codebase and tests, this should be ready to go to review.

Copy link
Member

@cmb69 cmb69 left a 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.

@@ -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));
Copy link
Member

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):

Suggested change
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?

Copy link
Member

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 :)

Copy link
Author

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.

@markrandall markrandall force-pushed the undefined-var-alerts branch from de6ee5d to 039885e Compare January 2, 2023 21:10
@markrandall markrandall force-pushed the undefined-var-alerts branch from d9346b5 to 8858ca7 Compare January 2, 2023 22:34
@kocsismate
Copy link
Member

Now only sapi/fpm/tests/bug77106-fcgi-missing-nl.phpt is failing :) But otherwise the PR LGTM!

@markrandall markrandall requested a review from dstogov as a code owner October 7, 2023 13:51
@Girgias
Copy link
Member

Girgias commented Oct 15, 2023

@markrandall this requires a rebase :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants