phpstan / phpstan-webmozart-assert

PHPStan extension for webmozart/assert
160 stars 27 forks source link

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

Closed herndlm closed 3 months ago

herndlm commented 3 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 3 months ago

Thank you.

VincentLanglet commented 3 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.