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 | * Extract keys from a collection, like `only`, except: |
||
7 | * - If a value doesn't exist, it returns null instead of omitting it |
||
8 | * - It returns a collection without keys, so `list()` can be used. |
||
9 | * |
||
10 | * @return \Illuminate\Support\Collection |
||
11 | */ |
||
12 | Collection::macro('extract', function ($keys): Collection { |
||
13 | $keys = is_array($keys) ? $keys : func_get_args(); |
||
14 | |||
15 | return array_reduce($keys, function ($extracted, $key) { |
||
16 | return $extracted->push( |
||
17 | data_get($this->items, $key) |
||
0 ignored issues
–
show
|
|||
18 | ); |
||
19 | }, new static()); |
||
20 | }); |
||
21 |
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.