PHP: Never type hint on arrays
7 years ago in #php by crell (60)
$0.51
- Past Payouts $0.51
- - Author $0.41
- - Curators $0.10
17 votes
- limesoda: $0.49
- bencagri: $0.01
- asiajabeen: $0.00
- dessertplay: $0.00
- antvls88: $0.00
- kiraluchkova: $0.00
- filkreserved: $0.00
- trubadurkir: $0.00
- donortopmast: $0.00
- hexagoncanadian: $0.00
- cyandyewilson: $0.00
- kindlytwist: $0.00
- sableside: $0.00
- definitefeed: $0.00
- blueberryeither: $0.00
- amichman: $0.00
- zaporylie: $0.00
very well article. And I disagree about arrays are fine. arrays are useful.
Nope, they are not. :)
They have their uses, totally. If you have a low-cardinality list of things an array is absolutely a reasonable tool to use for it.
It's type hinting against that array that is rarely useful.
I just wanted to mention that
iterableis only available in PHP7.1.0and above. While everyone should be running a new enough version, not everyone is 😞.