diff options
author | Sara Golemon <pollita@php.net> | 2017-05-31 14:18:19 -0700 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2017-05-31 14:23:57 -0700 |
commit | d1cfd87fbe9e34bf909abedb61cfa4b2d7022b4d (patch) | |
tree | 62fdc98de055fb4774123a5aaa60e9e7732489d6 | |
parent | c1500f8519aded29c3632de4240fbc0a4e485a81 (diff) | |
download | php-git-d1cfd87fbe9e34bf909abedb61cfa4b2d7022b4d.tar.gz |
Allow ReflectionClass::isIterable() to return true for Traversables
Current behavior is essentially "Is an INTERNAL iterable class".
This change allows isIterable() to return true for userspace classes as well.
-rw-r--r-- | ext/reflection/php_reflection.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 84f4d66aeb..19975d29bc 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5131,7 +5131,12 @@ ZEND_METHOD(reflection_class, isIterable) METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - RETURN_BOOL(ce->get_iterator != NULL); + if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | + ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { + RETURN_FALSE; + } + + RETURN_BOOL(ce->get_iterator || instanceof_function(ce, zend_ce_traversable)); } /* }}} */ |