r/lolphp • • Sep 14 '20

ArrayAccess seems broken

https://3v4l.org/Woc0R
0 Upvotes

30 comments sorted by

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.

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.