-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1732Labels
Milestone
Description
Bug report
I'm operating on an array with dynamic keys. When trying to add an item to a nested array right after initializing it, I get an error, telling me that I cannot assign a new offset to that array.
Code snippet that reproduces the problem
https://phpstan.org/r/7989deba-bb1e-4ad0-b070-c6de9bc2e4f3
The crucial part is this piece:
$config['things'] = [];
foreach ($item as $thing) {
$config['things'][] = (string) $thing;
}PHPStan complains about the assignment inside the foreach loop. But at this point, $config['things'] is guaranteed to be an array.
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
Only today? PHPStan improves my live as a developer every day!