From 513b76794bfa210edfdc5b478dffbcbb19747ad0 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 5 Feb 2019 10:07:07 +0100 Subject: Make zpp failures always throw, independent of strict_types Previously zend_parse_parameters (and FastZPP) would handle invalid arguments depending on strict_types: With strict_types=1, a TypeError is thrown, with strict_types=0 a warning is thrown and (usually) NULL is returned. Additionally, some functions (constructors always and other methods sometimes) opt-it to throwing regardless of strict_types. This commit changes zpp to always generate a TypeError exception in PHP 8. --- Zend/zend.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'Zend/zend.c') diff --git a/Zend/zend.c b/Zend/zend.c index 22c9db203a..1ad1e8cfc6 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1528,35 +1528,14 @@ ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) /* {{{ */ va_end(va); } /* }}} */ -ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, const char *format, ...) /* {{{ */ +ZEND_API ZEND_COLD void zend_argument_count_error(const char *format, ...) /* {{{ */ { va_list va; char *message = NULL; va_start(va, format); zend_vspprintf(&message, 0, format, va); - if (throw_exception) { - zend_throw_exception(zend_ce_type_error, message, 0); - } else { - zend_error(E_WARNING, "%s", message); - } - efree(message); - - va_end(va); -} /* }}} */ - -ZEND_API ZEND_COLD void zend_internal_argument_count_error(zend_bool throw_exception, const char *format, ...) /* {{{ */ -{ - va_list va; - char *message = NULL; - - va_start(va, format); - zend_vspprintf(&message, 0, format, va); - if (throw_exception) { - zend_throw_exception(zend_ce_argument_count_error, message, 0); - } else { - zend_error(E_WARNING, "%s", message); - } + zend_throw_exception(zend_ce_argument_count_error, message, 0); efree(message); va_end(va); -- cgit v1.2.1