1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
psalm/docs/running_psalm/issues/DuplicateArrayKey.md
Tom Klingenberg ea52b9d23a
Fix minor typos in docs (#3956)
While I was searching for some code, ran across these.
2020-08-08 08:09:41 -04:00

31 lines
491 B
Markdown

# DuplicateArrayKey
Emitted when an array has a key more than once
```php
<?php
$arr = [
'a' => 'one',
'b' => 'two',
'c' => 'this text will be overwritten by the next line',
'c' => 'three',
];
```
## How to fix
Remove the offending duplicates:
```php
<?php
$arr = [
'a' => 'one',
'b' => 'two',
'c' => 'three',
];
```
The first matching `'c'` key was removed to prevent a change in behaviour (any new duplicate keys overwrite the values of previous ones).