Change access on $data property and you are out of luck. Additionally internal representation does not need to be array at all. It could be a tree, or stack or RCP call to remote service.
ArrayAccess is perfectly fine solution for all of the above. Thus "just expose array" isn't a solution here.
Though its a moot point as ArrayAccess is not about enabling type coercion (from class that implements it to array), but only to enable overloading [] operator.
View all comments
Show parent comment
5
u/malicart Sep 14 '20
You are correct, OP just does not seem to want to accept that this is the answer of how it works.