Skip to content

Commit

Permalink
[5.3] Restore support for non-string needle in Str::startsWith() (#15…
Browse files Browse the repository at this point in the history
…397)

* Add test to prevent a potential regression

* Restore support for non-string needle

* Code unification
  • Loading branch information
vlakoff authored and taylorotwell committed Sep 12, 2016
1 parent 95d9dd5 commit 026dcaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function contains($haystack, $needles)
public static function endsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ((string) $needle === substr($haystack, -strlen($needle))) {
if (substr($haystack, -strlen($needle)) === (string) $needle) {
return true;
}
}
Expand Down Expand Up @@ -403,7 +403,7 @@ public static function snake($value, $delimiter = '_')
public static function startsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && substr($haystack, 0, strlen($needle)) === $needle) {
if ($needle != '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
return true;
}
}
Expand Down

0 comments on commit 026dcaa

Please sign in to comment.