[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] com php-src: Allow ReflectionClass::isIterable() to return true for Traversables: =?UTF-8?
From: Sara Golemon <pollita () php ! net>
Date: 2017-05-31 21:23:57
Message-ID: php-mail-7d787c5973ce14983311f3d255e21c49391063071 () git ! php ! net
[Download RAW message or body]
Commit: d1cfd87fbe9e34bf909abedb61cfa4b2d7022b4d
Author: Sara Golemon <pollita@php.net> Wed, 31 May 2017 14:18:19 -0700
Parents: c1500f8519aded29c3632de4240fbc0a4e485a81
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d1cfd87fbe9e34bf909abedb61cfa4b2d7022b4d
Log:
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.
Changed paths:
M ext/reflection/php_reflection.c
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 84f4d66..19975d2 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));
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic