Skip to content

Deprecate passing null to non-nullable arg of internal function #6475

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 14 commits into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Dec 1, 2020

Implementation for https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg.

TODO:

  • Update the remaining tests.

@nikic nikic added the RFC label Dec 1, 2020
@nikic nikic added this to the PHP 8.1 milestone Dec 1, 2020
Zend/zend_API.c Outdated
@@ -426,9 +426,20 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **p
}
/* }}} */

static ZEND_COLD bool zend_null_arg_deprecated(const char *type) {
zend_string *func_name = get_active_function_or_method_name();
zend_error(E_DEPRECATED, "%s(): Passing null to argument of type %s is deprecated",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it say "Passing null as argument" or "Passing null to parameter"?

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've changed it to say "Passing null to parameter".

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 decided to thread through the argument number after all, and provide a more detailed error message:

Deprecated: date_interval_create_from_date_string(): Passing null to parameter #1 ($datetime) of type string is deprecated

@nikic
Copy link
Member Author

nikic commented Feb 11, 2021

Yay, all tests passing.

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

Successfully merging this pull request may close these issues.

4 participants