[nycphp-talk] SPL - Do you use?
Rob Marscher
rmarscher at beaffinitive.com
Fri Sep 28 11:17:41 EDT 2007
On Sep 27, 2007, at 8:14 AM, Jon Baer wrote:
> Do many here use the SPL library?
I know zend framework uses a bunch of it. Zend_Registry, for
example, extends from ArrayObject. The DirectoryIterator seems kinda
convenient. I haven't gotten that into it yet though.
> I could never really understand this "library", on one side part of
> the Java programming that I really felt to be a burden of added /
> bloated code was the idea of the "Iterator" (you always had to grab
> one) and that is pretty much what the SPL is (for PHP5), and part
> of the joy to PHP was the ease + use of a foreach loop and then
> Java took a step back and implemented the same foreach idea in
> current JVMs but I barely see it used in many projects. I would
> guess that Java people coming to PHP would understand it's uses /
> design pattern better but the part of the Zend article I don't
> understand is ...
> "This library of interfaces creates a standard API for certain
> kinds of built-in functionality, allowing your classes to interact
> with the PHP engine in a much more seamless manner."
> Im just wondering if this means the use of saying "foreach($objects
> as $object)" or does refactoring w/ PHP5 Iterators also get you
> something else as well?
I think there are more built-in php functions that your objects can
take advantage of... found this in the unit test code, for example:
<?php
$ar = array(0=>0, 1=>1);
$ar = new ArrayObject($ar);
var_dump($ar);
$ar[2] = 2;
var_dump($ar[2]);
var_dump($ar["3"] = 3);
var_dump(array_merge((array)$ar, array(4=>4, 5=>5)));
?>
On a side note, the initial reaction of a of mine friend to the zend
framework was that it felt too much like java. He's a former java
developer, who switched to php, and now works in ruby as well).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070928/1b30145d/attachment.html>
More information about the talk
mailing list