Skip to content

MIR0303

DuplicateArrayKey

An array literal contains duplicate keys. In PHP, when duplicate keys exist, later values overwrite earlier ones, which may indicate a logic error.

<?php
$config = [
'host' => 'localhost',
'port' => 3306,
'host' => '127.0.0.1', // Duplicate key - overwrites 'localhost'
];

Remove duplicate keys or use different keys:

<?php
$config = [
'host' => '127.0.0.1',
'port' => 3306,
];