Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F7077272
D1640.id4184.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D1640.id4184.diff
View Options
diff --git a/src/Collections/TraversableUtilities.php b/src/Collections/TraversableUtilities.php
--- a/src/Collections/TraversableUtilities.php
+++ b/src/Collections/TraversableUtilities.php
@@ -4,19 +4,17 @@
namespace Keruald\OmniTools\Collections;
use Countable;
+use ResourceBundle;
+use SimpleXMLElement;
use TypeError;
class TraversableUtilities {
public static function count ($countable) : int {
- if (is_array($countable)) {
+ if (self::isCountable($countable)) {
return count($countable);
}
- if ($countable instanceof Countable) {
- return $countable->count();
- }
-
if ($countable === null || $countable === false) {
return 0;
}
@@ -24,4 +22,12 @@
throw new TypeError;
}
+ public static function isCountable ($countable) : bool {
+ // https://github.com/Ayesh/is_countable-polyfill/blob/master/src/is_countable.php
+ return is_array($countable)
+ || $countable instanceof Countable
+ || $countable instanceof SimpleXMLElement
+ || $countable instanceof ResourceBundle;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 21, 07:52 (11 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587884
Default Alt Text
D1640.id4184.diff (1 KB)
Attached To
Mode
D1640: Support other countable legacy types
Attached
Detach File
Event Timeline
Log In to Comment