-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#3993Description
Bug report
After updates to 2.1.15 (from 2.1.14), php started to report that following simplified code have errors.
Example code:
function test(RootClass $object): void
{
$searchId = $object instanceof SomeClass ? 'uid' : 'aid';
$targetId = $object instanceof SomeClass ? 'aid' : 'uid';
$array = [
$searchId => $object->getId(), // Here we have an "error"
$targetId => 'info',
];
// sql()->insert('tablename', $array); - example how this will be used
}Errors are:
22 Array has 2 duplicate keys with value 'aid' ($searchId, $targetId).
🪪 array.duplicateKey
22 Array has 2 duplicate keys with value 'uid' ($searchId, $targetId).
🪪 array.duplicateKey
In reality, it has no errors.
Please follow link to reproduce error
Code snippet that reproduces the problem
https://phpstan.org/r/48c58510-01e1-495c-9fc6-6e188d148189
Expected output
There should be no errors
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels