NYCPHP Meetup

NYPHP.org

[nycphp-talk] SPL - Do you use?

Scott Mattocks scott at crisscott.com
Thu Sep 27 08:58:18 EDT 2007


Jon Baer wrote:
> Do many here use the SPL library?
> 

I use the ArrayAccess interface all the time. It allows me to get some 
OOP benefits for data structures while still having the ease of use of 
an array.

For example, we opened up a SOAP interface for our system. Internally we 
had things working as arrays but in order to provider more structure for 
the web service, we needed to have objects. Instead of rewriting the 
whole code base, I just made a few new classes which implemented 
ArrayAccess, changed $thing = array(); to $thing = new 
ArrayLikeObject(); and left the rest of the code alone. The rest of the 
code still does things like $thing[$key] = $var; but the SOAP interface 
has the objects it needs. It saved us from a lot of extra work rewriting 
tons of code.

-- 
Scott Mattocks
Author: Pro PHP-GTK
http://www.crisscott.com



More information about the talk mailing list