Skip to content

Commit b53929e

Browse files
committed
Update is_countable to include countable objects that doesn't implement \Countable
1 parent 8d09841 commit b53929e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/Php73/bootstrap.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
if (PHP_VERSION_ID < 70300) {
1313
if (!function_exists('is_countable')) {
1414
function is_countable($var) {
15-
return is_array($var) || $var instanceof Countable;
15+
return is_array($var)
16+
|| $var instanceof Countable
17+
|| $var instanceof ResourceBundle
18+
|| $var instanceof SimpleXmlElement;
1619
}
1720
}
1821
}

tests/Php73/Php73Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public function testIsCountable()
2626
$this->assertTrue(is_countable(array(1, 2, '3')));
2727
$this->assertTrue(is_countable(new \ArrayIterator(array('foo', 'bar', 'baz'))));
2828
$this->assertTrue(is_countable(new \ArrayIterator()));
29+
$this->assertTrue(is_countable(new \SimpleXMLElement('<foo><bar/><bar/><bar/></foo>')));
30+
$this->assertTrue(is_countable(\ResourceBundle::create('en', __DIR__.'/fixtures')));
2931
$this->assertFalse(is_countable(new \stdClass()));
3032
}
3133

tests/Php73/fixtures/en.res

316 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)