Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5829,7 +5829,8 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fall

if (type_ast) {
uint32_t default_type = default_ast ? Z_TYPE(default_node.u.constant) : IS_UNDEF;

zend_bool is_arg_explicitly_nullable = (type_ast->attr & ZEND_TYPE_NULLABLE) == ZEND_TYPE_NULLABLE;

op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
arg_info->type = zend_compile_typename(
type_ast, default_type == IS_NULL, /* use_arena */ 0);
Expand All @@ -5838,6 +5839,12 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fall
zend_error_noreturn(E_COMPILE_ERROR, "void cannot be used as a parameter type");
}


if (default_type == IS_NULL && !is_arg_explicitly_nullable) {
zend_error(E_DEPRECATED, "Implicit nullable types are deprecated, mark the type as explicitly nullable with the '?' sign");
}


if (default_type > IS_NULL && default_type != IS_CONSTANT_AST
&& !zend_is_valid_default_value(arg_info->type, &default_node.u.constant)) {
zend_string *type_str = zend_type_to_string(arg_info->type);
Expand Down