phpstan / phpstan-webmozart-assert

PHPStan extension for webmozart/assert
MIT License
165 stars 28 forks source link

Specify non-empty-array for Assert::uniqueValues #177

Closed herndlm closed 7 months ago

herndlm commented 7 months ago

This was basically the only simple thing still missing. Implemented the same way as the non-empty-string + something (e.g. Assert::email) were implemented.

See https://github.com/webmozarts/assert?tab=readme-ov-file#type-assertions

Check that the given array contains unique values

ondrejmirtes commented 7 months ago

Thank you.

VincentLanglet commented 7 months ago

Looking at the implementation, https://github.com/webmozarts/assert/blob/11cb2199493b2f8a3b53e7f19068fc6aac760991/src/Assert.php#L751

$a = [];
Assert::uniqueValues($a);

Seems valid, so I don't think we can assert the array is not empty after this assertion.