From 912cb8b8b52f958ac6eb482466c01e99fc0c0e35 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 24 Nov 2020 10:09:28 +0100 Subject: [PATCH] Fixed bug #80391 Iterable was not considered a subtype of array|object, and thus also not a subtype of mixed. --- NEWS | 1 + Zend/tests/bug80391.phpt | 23 +++++++++++++++++++++++ Zend/zend_inheritance.c | 4 ++++ 3 files changed, 28 insertions(+) create mode 100644 Zend/tests/bug80391.phpt diff --git a/NEWS b/NEWS index a3923e6972..bd3a10adfa 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ PHP NEWS . Fixed bug #80345 (PHPIZE configuration has outdated PHP_RELEASE_VERSION). (cmb) . Fixed bug #72964 (White space not unfolded for CC/Bcc headers). (cmb) + . Fixed bug #80391 (Iterable not covariant to mixed). (Nikita) - Tidy: . Fixed bug #77594 (ob_tidyhandler is never reset). (cmb) diff --git a/Zend/tests/bug80391.phpt b/Zend/tests/bug80391.phpt new file mode 100644 index 0000000000..f483ed80fc --- /dev/null +++ b/Zend/tests/bug80391.phpt @@ -0,0 +1,23 @@ +--TEST-- +Iterable not covariant to mixed +--FILE-- + +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 7401456d8f..882738b758 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -323,6 +323,10 @@ static zend_bool unlinked_instanceof(zend_class_entry *ce1, zend_class_entry *ce static zend_bool zend_type_contains_traversable(zend_type type) { zend_type *single_type; + if (ZEND_TYPE_FULL_MASK(type) & MAY_BE_OBJECT) { + return 1; + } + ZEND_TYPE_FOREACH(type, single_type) { if (ZEND_TYPE_HAS_NAME(*single_type) && zend_string_equals_literal_ci(ZEND_TYPE_NAME(*single_type), "Traversable")) { -- 2.40.0