Skip to content

Promote warnings to exceptions in ext/gettext, ext/sysvmsg and ext/xml #5926

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

Closed
wants to merge 1 commit into from

Conversation

kocsismate
Copy link
Member

@kocsismate kocsismate commented Aug 2, 2020

These warning promotions remove quite a few false return values.

@kocsismate kocsismate changed the title Promote warnings to exceptions in ext/sysvmsg and ext/xml Promote warnings to exceptions in ext/gettext, ext/sysvmsg and ext/xml Aug 2, 2020
@kocsismate kocsismate force-pushed the warning-promo branch 4 times, most recently from f8817aa to 26137e2 Compare August 3, 2020 08:09
@kocsismate
Copy link
Member Author

CI failure is not related to these changes (apparently, 05c5c93#r41138411 caused it)

@kocsismate
Copy link
Member Author

@nikic I believe these errors promotions should be safe to do. Can I merge this PR?

@@ -78,7 +78,7 @@ PHP_FUNCTION(textdomain)
RETURN_THROWS();
}

PHP_GETTEXT_DOMAIN_LENGTH_CHECK(domain_len)
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(2, domain_len)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(2, domain_len)
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)

@@ -1029,8 +1029,8 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
} else if (strcasecmp(encoding_param, "US-ASCII") == 0) {
encoding = (XML_Char*)"US-ASCII";
} else {
php_error_docref(NULL, E_WARNING, "Unsupported source encoding \"%s\"", encoding_param);
RETURN_FALSE;
zend_argument_value_error(1, "is an unsupported source encoding");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_argument_value_error(1, "is an unsupported source encoding");
zend_argument_value_error(1, "is not a supported source encoding");

...maybe? This reads nicer to me, but your version is also ok.

}
parser->target_encoding = enc->name;
break;
}
default:
php_error_docref(NULL, E_WARNING, "Unknown option");
RETURN_FALSE;
zend_argument_value_error(2, "must be one of PHP_XML_OPTION_CASE_FOLDING, PHP_XML_OPTION_SKIP_TAGSTART, PHP_XML_OPTION_SKIP_WHITE, PHP_XML_OPTION_TARGET_ENCODING");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_argument_value_error(2, "must be one of PHP_XML_OPTION_CASE_FOLDING, PHP_XML_OPTION_SKIP_TAGSTART, PHP_XML_OPTION_SKIP_WHITE, PHP_XML_OPTION_TARGET_ENCODING");
zend_argument_value_error(2, "must be a PHP_XML_OPTION_* constant");

or similar. I think we should not list out all possible values in cases such as these.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these suggestion so went with them!

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.

2 participants