diff --git a/src/Assert.php b/src/Assert.php index ee15dff3..5997c2e9 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -17,6 +17,8 @@ use Countable; use Exception; use InvalidArgumentException; +use ResourceBundle; +use SimpleXMLElement; use Throwable; use Traversable; @@ -487,7 +489,12 @@ public static function isArrayAccessible($value, $message = '') */ public static function isCountable($value, $message = '') { - if (!\is_array($value) && !($value instanceof Countable)) { + if ( + !\is_array($value) + && !($value instanceof Countable) + && !($value instanceof ResourceBundle) + && !($value instanceof SimpleXMLElement) + ) { static::reportInvalidArgument(\sprintf( $message ?: 'Expected a countable. Got: %s', static::typeToString($value) diff --git a/tests/AssertTest.php b/tests/AssertTest.php index 890475d5..dea9893f 100644 --- a/tests/AssertTest.php +++ b/tests/AssertTest.php @@ -122,6 +122,7 @@ public function getTests() array('isCountable', array(array(1, 2)), true), array('isCountable', array(new ArrayIterator(array())), true), array('isCountable', array(new stdClass()), false), + array('isCountable', array(new \SimpleXMLElement('bar')), true), array('isCountable', array('abcd'), false), array('isCountable', array(123), false), array('isIterable', array(array()), true),