Skip to content

Commit a9be6f5

Browse files
authored
fix PHP 8.1 deprecation warnings (#37087)
1 parent a69479a commit a9be6f5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ public function implode($value, $glue = null)
515515
$first = $this->first();
516516

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

521-
return implode($value, $this->items);
521+
return implode($value ?? '', $this->items);
522522
}
523523

524524
/**

src/Illuminate/Support/Str.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ public static function containsAll($haystack, array $needles)
217217
public static function endsWith($haystack, $needles)
218218
{
219219
foreach ((array) $needles as $needle) {
220-
if ($needle !== '' && substr($haystack, -strlen($needle)) === (string) $needle) {
220+
if (
221+
$needle !== '' && $needle !== null
222+
&& substr($haystack, -strlen($needle)) === (string) $needle
223+
) {
221224
return true;
222225
}
223226
}

src/Illuminate/Support/Stringable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ public function substr($start, $length = null)
662662
*/
663663
public function substrCount($needle, $offset = null, $length = null)
664664
{
665-
return Str::substrCount($this->value, $needle, $offset, $length);
665+
return Str::substrCount($this->value, $needle, $offset ?? 0, $length);
666666
}
667667

668668
/**

0 commit comments

Comments
 (0)