Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Commit 84cd5d5

Browse files
committed
Improve is_countable() checks and add test case for \ResourceBunlde class
1 parent d8c20ca commit 84cd5d5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/is_countable.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@
99
* @return bool Returns TRUE if var is countable, FALSE otherwise.
1010
*/
1111
function is_countable($var) {
12-
return (
13-
is_array($var)
14-
|| (
15-
is_object($var)
16-
&& (
17-
$var instanceof \Countable
18-
|| $var instanceof \SimpleXMLElement
19-
|| $var instanceof \ResourceBundle
20-
)));
12+
return is_array($var)
13+
|| $var instanceof \Countable
14+
|| $var instanceof \SimpleXMLElement
15+
|| $var instanceof \ResourceBundle;
2116
}
2217
endif;

tests/IsCountableTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public function getIsCountableData() {
2828
array(array(1, 2, 3), true),
2929
array((array) 1, true),
3030
array((object) array('foo', 'bar', 'baz'), false),
31-
array(new \SimpleXMLElement("<xml><tag>1</tag><tag>2</tag></xml>"), true),
31+
array(new \SimpleXMLElement('<xml><tag>1</tag><tag>2</tag></xml>'), true),
32+
array(new \ResourceBundle('en', null), true),
3233
);
3334
}
3435
}

0 commit comments

Comments
 (0)