com php-src: Forbid ?void: Zend/tests/type_declarations /nullable_void.phpt Zend/zend_compile.c

From: Date: Sat, 04 Jun 2016 12:53:50 +0000
Subject: com php-src: Forbid ?void: Zend/tests/type_declarations /nullable_void.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92296@lists.php.net to get a copy of this message
Commit: 9ba243b6f385a1f38f6f180d0dbf82928f15341c Author: Nikita Popov <nikic@php.net> Sat, 4 Jun 2016 14:53:50 +0200 Parents: 73b2f791997a254788b1939ca8cef373694f8461 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9ba243b6f385a1f38f6f180d0dbf82928f15341c Log: Forbid ?void Changed paths: A Zend/tests/type_declarations/nullable_void.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/type_declarations/nullable_void.phpt b/Zend/tests/type_declarations/nullable_void.phpt new file mode 100644 index 0000000..4ff0edb --- /dev/null +++ b/Zend/tests/type_declarations/nullable_void.phpt @@ -0,0 +1,11 @@ +--TEST-- +Void cannot be nullable +--FILE-- +<?php + +function test() : ?void { +} + +?> +--EXPECTF-- +Fatal error: Void type cannot be nullable in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2a575cf..ce82246 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4964,6 +4964,10 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ zend_compile_typename(return_type_ast, arg_infos); + if (arg_infos->type_hint == IS_VOID && arg_infos->allow_null) { + zend_error_noreturn(E_COMPILE_ERROR, "Void type cannot be nullable"); + } + arg_infos++; op_array->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE; } else {

« previous php.cvs (#92296) next »