com php-src: Fix default values for booleans, thanks to virtual types: Zend/tests/typehints/default_boolean_hint_values.phpt Zend/zend_compile.c

From: Date: Wed, 18 Feb 2015 21:34:43 +0000
Subject: com php-src: Fix default values for booleans, thanks to virtual types: Zend/tests/typehints/default_boolean_hint_values.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85697@lists.php.net to get a copy of this message
Commit: c6996a2988a6a59772efaff29b91175b04aae965 Author: Anthony Ferrara <ircmaxell@gmail.com> Wed, 18 Feb 2015 16:34:43 -0500 Parents: d5aaebc355f9865a818cb43c93afc3975dbb3213 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c6996a2988a6a59772efaff29b91175b04aae965 Log: Fix default values for booleans, thanks to virtual types Changed paths: A Zend/tests/typehints/default_boolean_hint_values.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/typehints/default_boolean_hint_values.phpt b/Zend/tests/typehints/default_boolean_hint_values.phpt new file mode 100644 index 0000000..6ba2628 --- /dev/null +++ b/Zend/tests/typehints/default_boolean_hint_values.phpt @@ -0,0 +1,16 @@ +--TEST-- +Default values for boolean hints should work +--FILE-- +<?php + +function foo(bool $x = true, bool $y = false) { + var_dump($x, $y); +} + + + +foo(); +?> +--EXPECTF-- +bool(true) +bool(false) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2c9c02d..263af0a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4103,7 +4103,7 @@ done: if (arg_info->class_name) { zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " "with a class type hint can only be NULL"); - } else if (Z_TYPE(default_node.u.constant) != arg_info->type_hint) { + } else if (!ZEND_SAME_FAKE_TYPE(arg_info->type_hint, Z_TYPE(default_node.u.constant))) { zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " "with a %s type hint can only be %s or NULL", class_name->val, class_name->val); }

« previous php.cvs (#85697) next »