diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 353cef9579199..14435cdcabfa0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5102,7 +5102,7 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ arg_infos->class_name = NULL; if (return_type_ast->attr & ZEND_TYPE_NULLABLE) { - arg_infos->allow_null = 1; + arg_infos->allow_null = 2; return_type_ast->attr &= ~ZEND_TYPE_NULLABLE; } @@ -5194,10 +5194,10 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ && (Z_TYPE(default_node.u.constant) == IS_NULL || (Z_TYPE(default_node.u.constant) == IS_CONSTANT && strcasecmp(Z_STRVAL(default_node.u.constant), "NULL") == 0)); - zend_bool is_explicitly_nullable = (type_ast->attr & ZEND_TYPE_NULLABLE) == ZEND_TYPE_NULLABLE; + zend_bool is_explicitly_nullable = ((type_ast->attr & ZEND_TYPE_NULLABLE) == ZEND_TYPE_NULLABLE) << 1; op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS; - arg_info->allow_null = has_null_default || is_explicitly_nullable; + arg_info->allow_null = has_null_default | is_explicitly_nullable; type_ast->attr &= ~ZEND_TYPE_NULLABLE; zend_compile_typename(type_ast, arg_info); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 16601ee4d6ba1..09331d93e8db5 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3031,7 +3031,7 @@ ZEND_METHOD(reflection_type, __toString) str = reflection_type_name(param); - if (param->arg_info->allow_null) { + if (param->arg_info->allow_null & 2) { size_t orig_len = ZSTR_LEN(str); str = zend_string_extend(str, orig_len + 1, 0); memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1); diff --git a/ext/reflection/tests/ReflectionType_001.phpt b/ext/reflection/tests/ReflectionType_001.phpt index ee2ebb64dd63c..92c9f52b6d2dc 100644 --- a/ext/reflection/tests/ReflectionType_001.phpt +++ b/ext/reflection/tests/ReflectionType_001.phpt @@ -2,7 +2,7 @@ ReflectionParameter::get/hasType and ReflectionType tests --FILE--