These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Illuminate\Support\Collection; |
||
4 | |||
5 | /* |
||
6 | * Join all items from the collection using a string. The final items can use a separate glue string. |
||
7 | * |
||
8 | */ |
||
9 | Collection::macro('join', function (string $glue, string $finalGlue = ''): string { |
||
10 | if ($finalGlue === '') { |
||
11 | return $this->implode($glue); |
||
0 ignored issues
–
show
|
|||
12 | }; |
||
13 | |||
14 | if ($this->count() === 0) { |
||
15 | return ''; |
||
16 | } |
||
17 | |||
18 | if ($this->count() === 1) { |
||
19 | return $this->last(); |
||
20 | } |
||
21 | |||
22 | $collection = new Collection($this->items); |
||
23 | |||
24 | $finalItem = $collection->pop(); |
||
25 | |||
26 | return $collection->implode($glue) . $finalGlue . $finalItem; |
||
27 | }); |
||
28 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.