Index: src/wp-includes/compat.php
===================================================================
--- src/wp-includes/compat.php	(revision 42992)
+++ src/wp-includes/compat.php	(working copy)
@@ -505,3 +505,21 @@
 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 Returns true if var is countable, false otherwise.
+	 */
+	function is_countable( $var ) {
+		return ( is_array( $var ) || $var instanceof Countable );
+	}
+}
Index: tests/phpunit/tests/compat.php
===================================================================
--- tests/phpunit/tests/compat.php	(revision 42992)
+++ tests/phpunit/tests/compat.php	(working copy)
@@ -186,6 +186,44 @@
 		$this->assertEquals( '["foo"]', $json->encodeUnsafe( array( 'foo' ) ) );
 		$this->assertEquals( array( 'foo' ), $json->decode( '["foo"]' ) );
 	}
+
+	function test_is_countable_availability() {
+		$this->assertTrue( function_exists( 'is_countable' ) );
+	}
+
+	/**
+	 * Test is_countable polyfill.
+	 *
+	 * @ticket 43583
+	 *
+	 * @dataProvider countable_variable_test_data
+	 */
+	function test_is_countable_functionality($variable, $is_countable) {
+		$this->assertEquals( is_countable( $variable ), $is_countable );
+	}
+
+	/**
+	 * Data provider for test_is_countable_functionality test. First array value
+	 * is the variable, and the second value is the expected return value of the
+	 * PHP 7.3's is_countable function.
+	 *
+	 * @ticket 43583
+	 *
+	 * @return array test data.
+	 */
+	public function countable_variable_test_data() {
+		return array(
+			array( true, false ),
+			array( new stdClass(), false ),
+			array( new ArrayIteratorFake(), true ),
+			array( new CountableFake(), true ),
+			array( 16, false ),
+			array( null, false ),
+			array( array( 1, 2, 3 ), true ),
+			array( (array) 1, true ),
+			array( (object) array( 'foo', 'bar', 'baz' ), false ),
+		);
+	}
 }
 
 /* used in test_mb_substr_phpcore */
@@ -194,3 +232,12 @@
 		return 'Class A object';
 	}
 }
+
+class ArrayIteratorFake extends ArrayIterator {
+}
+
+class CountableFake implements Countable {
+	public function count() {
+		return 16;
+	}
+}
