Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Fixes for PHP 8.1 in Illuminate\Support #37087

Merged
merged 1 commit into from Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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