Skip to content

Commit

Permalink
fix PHP 8.1 deprecation warnings (laravel#37087)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor authored and bert-w committed Apr 29, 2021
1 parent 05ec613 commit d65fd28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Collection.php
Expand Up @@ -515,10 +515,10 @@ public function implode($value, $glue = null)
$first = $this->first();

if (is_array($first) || (is_object($first) && ! $first instanceof Stringable)) {
return implode($glue, $this->pluck($value)->all());
return implode($glue ?? '', $this->pluck($value)->all());
}

return implode($value, $this->items);
return implode($value ?? '', $this->items);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Illuminate/Support/Str.php
Expand Up @@ -217,7 +217,10 @@ public static function containsAll($haystack, array $needles)
public static function endsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle !== '' && substr($haystack, -strlen($needle)) === (string) $needle) {
if (
$needle !== '' && $needle !== null
&& substr($haystack, -strlen($needle)) === (string) $needle
) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Stringable.php
Expand Up @@ -662,7 +662,7 @@ public function substr($start, $length = null)
*/
public function substrCount($needle, $offset = null, $length = null)
{
return Str::substrCount($this->value, $needle, $offset, $length);
return Str::substrCount($this->value, $needle, $offset ?? 0, $length);
}

/**
Expand Down

0 comments on commit d65fd28

Please sign in to comment.