com php-src: Fixed nullable handling (phpunit failure): Zend/tests/type_declarations/nullable_null.phpt Zend/ze nd_execute.c
| From: | Dmitry Stogov | Date: | Fri, 13 Jan 2017 16:51:12 +0000 |
| Subject: | com php-src: Fixed nullable handling (phpunit failure): Zend/tests/type_declarations/nullable_null.phpt Zend/ze nd_execute.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96720@lists.php.net to get a copy of this message | ||
Commit: 501ff45283157bc69b0a73adc916d8ec2bf7003e
Author: Dmitry Stogov <dmitry@zend.com> Fri, 13 Jan 2017 19:51:12 +0300
Parents: 6eaa55db793a44af991f1e48ae0e97854634ca1a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=501ff45283157bc69b0a73adc916d8ec2bf7003e
Log:
Fixed nullable handling (phpunit failure)
Changed paths:
A Zend/tests/type_declarations/nullable_null.phpt
M Zend/zend_execute.c
Diff:
diff --git a/Zend/tests/type_declarations/nullable_null.phpt
b/Zend/tests/type_declarations/nullable_null.phpt
new file mode 100644
index 0000000..61b05e9
--- /dev/null
+++ b/Zend/tests/type_declarations/nullable_null.phpt
@@ -0,0 +1,11 @@
+--TEST--
+nullable class
+--FILE--
+<?php
+function test(Foo $a = null) {
+ echo "ok\n";
+}
+test(null);
+?>
+--EXPECT--
+ok
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 313593b..417f3a0 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -801,7 +801,7 @@ static zend_always_inline zend_bool zend_check_type(
} else {
*ce = zend_fetch_class(ZEND_TYPE_NAME(type), (ZEND_FETCH_CLASS_AUTO |
ZEND_FETCH_CLASS_NO_AUTOLOAD));
if (UNEXPECTED(!*ce)) {
- return 0;
+ return Z_TYPE_P(arg) == IS_NULL && (ZEND_TYPE_ALLOW_NULL(type) || (default_value
&& is_null_constant(scope, default_value)));
}
*cache_slot = (void *) *ce;
}