From 408d8c63be94fb86307d2cdacca07c4f97a461f5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Apr 2018 03:47:24 +0000 Subject: [PATCH] General: Introduce a polyfill for `is_countable()` function added in PHP 7.3. Props jrf, ayeshrajans, desrosj. Merges [43034] to the 4.9 branch. See #43583. Built from https://develop.svn.wordpress.org/branches/4.9@43035 git-svn-id: http://core.svn.wordpress.org/branches/4.9@42864 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/compat.php | 18 ++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 7e37c30762..a0976c1ef2 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -497,3 +497,21 @@ endif; if ( ! function_exists( 'spl_autoload_register' ) ) { require_once ABSPATH . WPINC . '/spl-autoload-compat.php'; } + +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. + * + * @since 4.9.6 + * + * @param mixed $var The value to check. + * + * @return bool True if `$var` is countable, false otherwise. + */ + function is_countable( $var ) { + return ( is_array( $var ) || $var instanceof Countable ); + } +} diff --git a/wp-includes/version.php b/wp-includes/version.php index 8d0174c5de..082665c84a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9.6-alpha-43033'; +$wp_version = '4.9.6-alpha-43035'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.