From 94cbb2a3f6d702b0f9ee0076872269b5c7d4a891 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Apr 2018 04:15:21 +0000 Subject: [PATCH] General: Introduce a polyfill for `is_iterable()` function added in PHP 7.1. Props jrf, schlessera, desrosj. See #43619. Built from https://develop.svn.wordpress.org/trunk@43036 git-svn-id: http://core.svn.wordpress.org/trunk@42865 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/compat.php | 20 +++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 77762cb6f6..cabe71d211 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -511,7 +511,7 @@ if ( ! function_exists( 'is_countable' ) ) { * Polyfill for is_countable() function added in PHP 7.3. * * Verify that the content of a variable is an array or an object - * implementing Countable. + * implementing the Countable interface. * * @since 4.9.6 * @@ -523,3 +523,21 @@ if ( ! function_exists( 'is_countable' ) ) { return ( is_array( $var ) || $var instanceof Countable ); } } + +if ( ! function_exists( 'is_iterable' ) ) { + /** + * Polyfill for is_iterable() function added in PHP 7.1. + * + * Verify that the content of a variable is an array or an object + * implementing the Traversable interface. + * + * @since 4.9.6 + * + * @param mixed $var The value to check. + * + * @return bool True if `$var` is iterable, false otherwise. + */ + function is_iterable( $var ) { + return ( is_array( $var ) || $var instanceof Traversable ); + } +} diff --git a/wp-includes/version.php b/wp-includes/version.php index ed2a00aacc..40bce2d998 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-43034'; +$wp_version = '5.0-alpha-43036'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.