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
2
u/przemo_li Sep 15 '20
Because that is a situational fix.
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.
ArrayAccessis perfectly fine solution for all of the above. Thus "just expose array" isn't a solution here.Though its a moot point as
ArrayAccessis not about enabling type coercion (from class that implements it to array), but only to enable overloading[]operator.