From: Nikita Popov Date: Tue, 8 Oct 2019 13:52:18 +0000 (+0200) Subject: Merge branch 'PHP-7.4' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cffa81e438a5639d50683c8b49b1cf38bfef2143;p=php Merge branch 'PHP-7.4' --- cffa81e438a5639d50683c8b49b1cf38bfef2143 diff --cc Zend/zend_compile.c index 906b544a15,255b89d95f..b169093de5 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@@ -5352,29 -5308,6 +5352,31 @@@ static zend_type zend_compile_typename( } /* }}} */ ++/* May convert value from int to float. */ +static zend_bool zend_is_valid_default_value(zend_type type, zval *value) +{ + ZEND_ASSERT(ZEND_TYPE_IS_SET(type)); + if (Z_TYPE_P(value) == IS_NULL && ZEND_TYPE_ALLOW_NULL(type)) { + return 1; + } + + if (ZEND_TYPE_IS_CLASS(type)) { + return 0; + } + if (ZEND_TYPE_CONTAINS_CODE(type, Z_TYPE_P(value))) { + return 1; + } + if ((ZEND_TYPE_MASK(type) & MAY_BE_DOUBLE) && Z_TYPE_P(value) == IS_LONG) { + /* Integers are allowed as initializers for floating-point values. */ ++ convert_to_double(value); + return 1; + } + if ((ZEND_TYPE_MASK(type) & MAY_BE_ITERABLE) && Z_TYPE_P(value) == IS_ARRAY) { + return 1; + } + return 0; +} + void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ { zend_ast_list *list = zend_ast_get_list(ast);