Let's be controversial: In modern #PHP, you should never type-hint an array.

https://peakd.com/php/@crell/php-never-type-hint-on-arrays

PHP: Never type hint on arrays | PeakD

Let's be controversial: In modern PHP, you should never type-hint an array. Before you start throwing tomatoes, hear me... by crell

PeakD

@Crell I thought this seemed really familiar, and then I saw the date… I probably read this soon after you first posted this also.

Sorry, but then, as now, I'm not really interested in writing my own iterable list thingamabob when the language already gives me one. Plus, when working with someone else's code, if it returns an array, I know what it's doing; if it's some custom ThingamabobIterator I can probably guess but I'm going to have to stop what I'm doing and look up the code to be sure.

@Crell And I wouldn't want to force anyone using my code to learn how to use my own iterators either.

In short, can't we just get a tight little "List" in PHP already and let "arrays" do the dictionary stuff? Yeah, SplBlahBlah but something first class and "native" would be better and more discoverable.

@Albright I'd be supportive, but that always runs smack into the typed arrays / generics problem.
@Albright I have a bot that reposts my old blog posts at random event few days. Some are quite old, but IMO evergreen. :-)