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 | * Execute a callable if the collection isn't empty, then return the collection. |
||
7 | * |
||
8 | * @param callable callback |
||
9 | * |
||
10 | * @return \Illuminate\Support\Collection |
||
11 | */ |
||
12 | Collection::macro('ifAny', function (callable $callback): Collection { |
||
13 | if (! $this->isEmpty()) { |
||
14 | $callback($this); |
||
0 ignored issues
–
show
|
|||
15 | } |
||
16 | |||
17 | return $this; |
||
18 | }); |
||
19 |
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.