diff --git a/Zend/tests/required_param_after_optional.phpt b/Zend/tests/required_param_after_optional.phpt index 93b98acfd9f..c3a925efe88 100644 --- a/Zend/tests/required_param_after_optional.phpt +++ b/Zend/tests/required_param_after_optional.phpt @@ -5,7 +5,7 @@ Required parameter after optional is deprecated function test($testA = null, $testB = null, $testC) {} function test2(Type $test2A = null, $test2B = null, $test2C) {} -function test3(Type $test3A = null, Type2 $test3B = null, $test3C) {} +function test3(Type $test3A = null, ?Type2 $test3B = null, $test3C) {} ?> --EXPECTF-- @@ -14,3 +14,5 @@ Deprecated: Optional parameter $testA declared before required parameter $testC Deprecated: Optional parameter $testB declared before required parameter $testC is implicitly treated as a required parameter in %s on line %d Deprecated: Optional parameter $test2B declared before required parameter $test2C is implicitly treated as a required parameter in %s on line %d + +Deprecated: Optional parameter $test3B declared before required parameter $test3C is implicitly treated as a required parameter in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 81c7009bda0..07e86798851 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6558,7 +6558,8 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fall /* Ignore parameters of the form "Type $param = null". * This is the PHP 5 style way of writing "?Type $param", so allow it for now. */ bool is_implicit_nullable = - type_ast && Z_TYPE(default_node.u.constant) == IS_NULL; + type_ast && !(type_ast->attr & ZEND_TYPE_NULLABLE) + && Z_TYPE(default_node.u.constant) == IS_NULL; if (!is_implicit_nullable) { zend_ast *required_param_ast = list->child[last_required_param]; zend_error(E_DEPRECATED,