diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 5a7bd4c159ad..74e5f9d5053e 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -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); } /** diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 37e3fd082956..d2db2820fd7e 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -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; } } diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index 700163f165d6..fd9e53a85f8c 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -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); } /**