-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array keys not retained when using splat operator to define class constant #10460
Comments
I found these snippets: https://psalm.dev/r/32157859fc<?php
class BaseClass {
public const KEYS = [
'hostname' => 'host',
'pass' => 'password',
'dbname' => 'db',
];
}
class ChildClass extends BaseClass {
public const KEYS = [
...parent::KEYS,
'ssl' => 'sslmode',
];
}
/**
* @param array<non-empty-string, non-empty-string> $keyMap
*/
function example(array $keyMap): void
{
}
example(ChildClass::KEYS);
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using the splat operator to define a class constant, Psalm seems to resolve the resulting array as having integer keys instead of retaining the key type of the source array.
https://psalm.dev/r/32157859fc
The text was updated successfully, but these errors were encountered: