From b53929e2041fd82d67a73efb5b66821f9f55262d Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Wed, 25 Apr 2018 20:24:25 +0200 Subject: [PATCH] Update is_countable to include countable objects that doesn't implement \Countable --- src/Php73/bootstrap.php | 5 ++++- tests/Php73/Php73Test.php | 2 ++ tests/Php73/fixtures/en.res | Bin 0 -> 316 bytes 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/Php73/fixtures/en.res diff --git a/src/Php73/bootstrap.php b/src/Php73/bootstrap.php index 9a5895051..a08c14758 100644 --- a/src/Php73/bootstrap.php +++ b/src/Php73/bootstrap.php @@ -12,7 +12,10 @@ if (PHP_VERSION_ID < 70300) { if (!function_exists('is_countable')) { function is_countable($var) { - return is_array($var) || $var instanceof Countable; + return is_array($var) + || $var instanceof Countable + || $var instanceof ResourceBundle + || $var instanceof SimpleXmlElement; } } } diff --git a/tests/Php73/Php73Test.php b/tests/Php73/Php73Test.php index c3f49811a..ce1817f1f 100644 --- a/tests/Php73/Php73Test.php +++ b/tests/Php73/Php73Test.php @@ -26,6 +26,8 @@ public function testIsCountable() $this->assertTrue(is_countable(array(1, 2, '3'))); $this->assertTrue(is_countable(new \ArrayIterator(array('foo', 'bar', 'baz')))); $this->assertTrue(is_countable(new \ArrayIterator())); + $this->assertTrue(is_countable(new \SimpleXMLElement(''))); + $this->assertTrue(is_countable(\ResourceBundle::create('en', __DIR__.'/fixtures'))); $this->assertFalse(is_countable(new \stdClass())); } diff --git a/tests/Php73/fixtures/en.res b/tests/Php73/fixtures/en.res new file mode 100644 index 0000000000000000000000000000000000000000..7c1f71eba1be16c117e695bce2cb820d1c587211 GIT binary patch literal 316 zcmX|-yG{c!5Jk@}phz?{&>^uBMJk9A8bn8cAR5FYN*5^(asraIMqY1`j_=t|qT*Ay zHV<3ZbMHJn9#?$!_erbd$u{Fstk}+ud|W}*6FU@cf01-r1L3BQVKd}11hZjko5)=q z?b?Q9XZ9ufz{I%5j=gu*)J#MB&+l93m^g3Z&pjhLSmCu{$SEVv#3F$fE4ISmXfl7! z{x@pYIg+ZDiU+BJ6TNsVGZsg%IEIJ6u?qRqoGIR;&$a3<)N9UTn(1Rt`8$Gof62Zp Rja})IidVYsTz_&P{SDiCG)Mpd literal 0 HcmV?d00001