Skip to content

Commit

Permalink
wip fix nulls and other linebreak edge cases for android, and legacy …
Browse files Browse the repository at this point in the history
…systems
  • Loading branch information
nikuscs committed Nov 6, 2024
1 parent 8d17b12 commit 081426d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Macros/StrMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,16 @@ public static function normalizeCharacters(): void
public static function linesToCollection(): void
{
Str::macro('lines_to_collection', function (
string|array $value,
string $delimiter = ',',
string|array|null $value,
bool $unique = true
): Collection {
if (is_null($value)) {
return collect();
}
// Handle array input
$items = is_array($value)
? $value
: explode($delimiter, $value);
: preg_split('/\r\n|\r|\n|\\\\n|\\\\r\\\\n|\\\\r|\x{2028}|\x{2029}|\x{0085}|\v|\f/u', $value);

// Create collection and process items
return Collection::make($items)

Check failure on line 397 in src/Macros/StrMacros.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $items of static method Illuminate\Support\Collection<(int|string),mixed>::make() expects Illuminate\Contracts\Support\Arrayable<(int|string), mixed>|iterable<(int|string), mixed>|null, array|false given.
Expand Down

0 comments on commit 081426d

Please sign in to comment.