summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorLevi Morrison <levim@php.net>2016-04-28 15:26:57 -0600
committerLevi Morrison <levim@php.net>2016-05-05 11:53:32 -0600
commit9662259cb93ff04be80766bdade39d2e827e0e16 (patch)
tree6dbc991b00567eb964f4b11db90b34bc03705ee9 /Zend/zend_compile.c
parent49fe737e585d2bf3cea4df14ef7a1965dc632655 (diff)
downloadphp-git-9662259cb93ff04be80766bdade39d2e827e0e16.tar.gz
Add nullable parameter types
This works off of Dmitry's commit for nullable return types
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index fe81aadcf8..b5f91c4495 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4866,7 +4866,7 @@ static void zend_compile_typename(zend_ast *ast, zend_arg_info *arg_info) /* {{{
zend_uchar type = zend_lookup_builtin_type_by_name(class_name);
if (type != 0) {
- if (ast->attr != ZEND_NAME_NOT_FQ) {
+ if ((ast->attr & ZEND_NAME_NOT_FQ) != ZEND_NAME_NOT_FQ) {
zend_error_noreturn(E_COMPILE_ERROR,
"Scalar type declaration '%s' must be unqualified",
ZSTR_VAL(zend_string_tolower(class_name)));
@@ -4999,9 +4999,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;
op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
- arg_info->allow_null = has_null_default;
+ arg_info->allow_null = has_null_default || is_explicitly_nullable;
zend_compile_typename(type_ast, arg_info);