underscore-php
underscore-php copied to clipboard
make sure needle is converted to string before calling strpos
I had (a rather edge case) where Strings::startsWith was called from an Arrays::each closure similar to this:
$string = "12345";
Arrays::each([
'1234' => "jey"
], function($value, $key) use ($string) {
if(Strings::startsWith($string, $key)) {
print_r("match");
}
});
this would never match, since the key is automagically converted into an integer and strpos($haystack, INTEGER) will never match.