diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c94f66e..6975fa433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 3.3.0 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + ## 3.2.2 - TBD ### Added diff --git a/benchmark/ArrayUtilsBench.php b/benchmark/ArrayUtilsBench.php new file mode 100644 index 000000000..aeff33ad1 --- /dev/null +++ b/benchmark/ArrayUtilsBench.php @@ -0,0 +1,44 @@ + 'value', + ]); + } + + public function benchHasIntegerKeys() + { + ArrayUtils::hasIntegerKeys([ + 1 => 'value', + ]); + } + + public function benchHasNumericKeys() + { + ArrayUtils::hasNumericKeys([ + '1' => 'value', + ]); + } +} diff --git a/src/ArrayUtils.php b/src/ArrayUtils.php index 4edcacf11..69eeb4168 100644 --- a/src/ArrayUtils.php +++ b/src/ArrayUtils.php @@ -47,7 +47,7 @@ public static function hasStringKeys($value, $allowEmpty = false) return $allowEmpty; } - return count(array_filter(array_keys($value), 'is_string')) > 0; + return [] !== array_filter(array_keys($value), 'is_string'); } /** @@ -67,7 +67,7 @@ public static function hasIntegerKeys($value, $allowEmpty = false) return $allowEmpty; } - return count(array_filter(array_keys($value), 'is_int')) > 0; + return [] !== array_filter(array_keys($value), 'is_int'); } /** @@ -94,7 +94,7 @@ public static function hasNumericKeys($value, $allowEmpty = false) return $allowEmpty; } - return count(array_filter(array_keys($value), 'is_numeric')) > 0; + return [] !== array_filter(array_keys($value), 'is_numeric'); } /**