diff --git a/src/ArrayUtils.php b/src/ArrayUtils.php index 17e3ae3cd..69b97219a 100644 --- a/src/ArrayUtils.php +++ b/src/ArrayUtils.php @@ -199,7 +199,7 @@ public static function inArray($needle, array $haystack, $strict = false) } } } - return in_array($needle, $haystack, $strict); + return in_array($needle, $haystack, true); } /** diff --git a/test/ArrayUtilsTest.php b/test/ArrayUtilsTest.php index 8127276fe..1d21cb694 100644 --- a/test/ArrayUtilsTest.php +++ b/test/ArrayUtilsTest.php @@ -542,4 +542,15 @@ public function testInvalidCallableRaiseInvalidArgumentException() { ArrayUtils::filter([], "INVALID"); } + + /** + * @see https://github.com/zendframework/zend-stdlib/issues/41 + */ + public function testInArrayFunctionCallShouldAlwaysBeStrictToPreventStringMatchingIssues() + { + $needle = '1.10'; + $haystack = ['1.1']; + + $this->assertFalse(ArrayUtils::inArray($needle, $haystack)); + } }