Now that PHP 7+ sorted out a whole bunch of problems with type-hinting of parameters, return values, variables and properties, we turn our attention to somewhat deeper issues.
Array is a native citizen in PHP. Arrays are very convenient and are widely used. However, if you stop and think about the times where you had to figure out somebody else’s code, I’m pretty sure complex arrays will come to mind at some point.
I’ve recently came across two completely independent blog posts which talk exactly about this particular area of problems:
Both are explaining the issues very well and make valid points. As far as solutions and better ways go, apart from the approaches mentioned in these blog posts, I also remembered a recent blog post from which I linked to the data transfer object library, that solves exactly that.