-
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_flip and array_rand #6859
Comments
I found these snippets: https://psalm.dev/r/b14406d8ed<?php
$specialChars = array_flip(['~', '!', '@', '#', ':', '$', '%', '^', '&', '*', '?']);
array_rand($specialChars, 2);
|
array_flip transform your array into For your need, you'd need |
I think it would be enough to update the stub like this: diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub
index e8b3026cf..802f7498d 100644
--- a/stubs/CoreGenericFunctions.phpstub
+++ b/stubs/CoreGenericFunctions.phpstub
@@ -123,7 +123,7 @@ function array_diff_assoc(array $array, array ...$arrays)
*
* @param array<TKey, TValue> $array
*
- * @return array<TValue, TKey>
+ * @return ($array is non-empty-array ? non-empty-array<TValue, TKey> : array<TValue, TKey>)
* @psalm-pure
*/ |
Oh, it might indeed |
https://psalm.dev/r/b14406d8ed
How to fix it?
The text was updated successfully, but these errors were encountered: