With PHPStan, how does one annotate a type as being a non-empty Collection?

4 days ago 7
ARTICLE AD BOX

PHPStan provides the non-empty-array and non-empty-list types. It also seems to have some special handling for types named Collection, when those types are not declared generic, if I'm interpreting the docs correctly, there. However, I can't find any way to declare that a value should be a Collection, but only a non-empty one.

I'm specifically working with the Doctrine Collection interface, which is generic, so that's my main interest, but I feel a really complete answer, for the sake of prosperity, should discuss both generic and non-generic Collection types.

Read Entire Article