1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00
psalm/docs/running_psalm/issues/DuplicateArrayKey.md
2020-03-21 10:13:11 -04:00

492 B

DuplicateArrayKey

Emitted when an array has a key more than once

<?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

$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 prevvious ones).