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
list does not contain iterable #3605
Labels
Comments
I found these snippets: https://psalm.dev/r/d1a18e0d8d<?php
/**
* @psalm-pure
* @psalm-assert iterable<string> $value
*
* @param mixed $value
* @param string $message
*
* @throws InvalidArgumentException
*/
function allString($value, $message = ''): void {}
function takesAnArray(array $a): void {
$keys = array_keys($a);
allString($keys);
}
|
Another example: https://psalm.dev/r/15c5758fe5 If you change order of asserts then you'll get reversed error which is fine as standalone check but in this case I make two checks and resulting assert must take this into account
|
I found these snippets: https://psalm.dev/r/15c5758fe5<?php
/**
* @param mixed $a
* @psalm-assert list<string> $a
*/
function listOfStrings($a): void {}
/**
* @param mixed $a
* @psalm-assert iterable<non-empty-string> $a
*/
function allStringNotEmpty($a): void {}
/**
* @param mixed $a
* @psalm-assert list<non-empty-string> $a
*/
function listOfNotEmptyStrings($a): void {
listOfStrings($a);
allStringNotEmpty($a);
}
listOfNotEmptyStrings(['asd', '']);
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/d1a18e0d8d
This is a valid and logical php: you get keys and you check all of them are strings.
I believe after the line 16 the
$keys
should be narrowed to eitherlist<string>
oriterable<string>
.Yet it does not.
The text was updated successfully, but these errors were encountered: