com php-src: Add is_iterable() function: ext/standa rd/basic_functions.c ext/standard/php_type.h ext/st andard/type.c

From: Date: Fri, 03 Jun 2016 22:42:12 +0000
Subject: com php-src: Add is_iterable() function: ext/standa rd/basic_functions.c ext/standard/php_type.h ext/st andard/type.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92302@lists.php.net to get a copy of this message
Commit: 0e221cb3ebea3ebe4e3ec6cd824b22748efc36b8 Author: Aaron Piotrowski <aaron@trowski.com> Fri, 3 Jun 2016 17:42:12 -0500 Parents: 72692e9a9c3439be3083135eec3b174410ef08e4 Branches: iterable Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0e221cb3ebea3ebe4e3ec6cd824b22748efc36b8 Log: Add is_iterable() function Changed paths: M ext/standard/basic_functions.c M ext/standard/php_type.h M ext/standard/type.c Diff: diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 5fb5246..1ac3120 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2563,6 +2563,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_is_callable, 0, 0, 1) ZEND_ARG_INFO(0, syntax_only) ZEND_ARG_INFO(1, callable_name) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_is_iterable, 0, 0, 1) + ZEND_ARG_INFO(0, var) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ uniqid.c */ #ifdef HAVE_GETTIMEOFDAY @@ -3060,6 +3064,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(is_object, arginfo_is_object) PHP_FE(is_scalar, arginfo_is_scalar) PHP_FE(is_callable, arginfo_is_callable) + PHP_FE(is_iterable, arginfo_is_iterable) /* functions from file.c */ PHP_FE(pclose, arginfo_pclose) diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index e9a3155..c58718d 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -38,5 +38,6 @@ PHP_FUNCTION(is_array); PHP_FUNCTION(is_object); PHP_FUNCTION(is_scalar); PHP_FUNCTION(is_callable); +PHP_FUNCTION(is_iterable); #endif diff --git a/ext/standard/type.c b/ext/standard/type.c index 529d666..3cd234d 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -434,6 +434,20 @@ PHP_FUNCTION(is_callable) } /* }}} */ +/* {{{ proto bool is_iterable(mixed var) + Returns true if var is iterable (array or instance of Traversable). */ +PHP_FUNCTION(is_iterable) +{ + zval *var; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &var) == FAILURE) { + return; + } + + RETURN_BOOL(zend_is_iterable(var)); +} +/* }}} */ + /* * Local variables: * tab-width: 4

« previous php.cvs (#92302) next »