diff options
author | Aaron Piotrowski <aaron@trowski.com> | 2016-06-03 17:42:04 -0500 |
---|---|---|
committer | Aaron Piotrowski <aaron@trowski.com> | 2016-06-03 17:42:04 -0500 |
commit | 72692e9a9c3439be3083135eec3b174410ef08e4 (patch) | |
tree | 7e2c0f66ba752c62838f29a727dfcb2cc86cbefc /Zend/zend_API.c | |
parent | b7bb6d04fd829bc5e854e76f669316f8147e468a (diff) | |
download | php-git-72692e9a9c3439be3083135eec3b174410ef08e4.tar.gz |
Add iterable pseudo-type
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index eb76c671fc..0ecbe0e278 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -27,6 +27,7 @@ #include "zend_modules.h" #include "zend_extensions.h" #include "zend_constants.h" +#include "zend_interfaces.h" #include "zend_exceptions.h" #include "zend_closures.h" #include "zend_inheritance.h" @@ -4201,6 +4202,19 @@ ZEND_API const char *zend_get_object_type(const zend_class_entry *ce) /* {{{ */ } /* }}} */ +ZEND_API zend_bool zend_is_iterable(zval *iterable) /* {{{ */ +{ + switch (Z_TYPE_P(iterable)) { + case IS_ARRAY: + return 1; + case IS_OBJECT: + return instanceof_function(Z_OBJCE_P(iterable), zend_ce_traversable); + default: + return 0; + } +} +/* }}} */ + /* * Local variables: * tab-width: 4 |