Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

ArrayUtils::inArray always call strict version of in_array #42

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions test/ArrayUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}