<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 18 May 2013 12:18:02 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Anthony Ferrara: What Generators Can Do For You]]></title>
      <guid>http://www.phpdeveloper.org/news/18263</guid>
      <link>http://www.phpdeveloper.org/news/18263</link>
      <description><![CDATA[<p>
<i>Anthony Ferarra</i> has a new post looking at <a href="http://blog.ircmaxell.com/2012/07/what-generators-can-do-for-you.html">using generators in your code</a> (as <a href="https://wiki.php.net/rfc/generators>proposed here</a>). He introduces the idea behind them and shows both a simple and more complex example of their use.
</p>
<blockquote>
The concept of generators was <a href="https://wiki.php.net/rfc/generators">recently proposed</a> for addition in PHP's core (Possibly for 5.5.0). While I believe that this is a great tool, it appears that many PHP developers aren't familiar with the concept of generators. So I thought I would take a little time and explain some of how it works, and how it can be used to greatly simplify code.
</blockquote>
<p>
He explains the concept of "generators" as an easier way to implement iterators. In his example he shows how to refactor is file handling iterator to replace it with generator functionality. It uses a new keyword, "yield", to return a Generator instance that can then can be used much like the file iterator without the need for all of the code to create the iterator itself. His more complex example shows how to replace an ArrayObject instance by a little trick inside its "getIterator" method.
</p>]]></description>
      <pubDate>Tue, 24 Jul 2012 08:43:58 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: ArrayAccess vs ArrayObject]]></title>
      <guid>http://www.phpdeveloper.org/news/16867</guid>
      <link>http://www.phpdeveloper.org/news/16867</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a new post to her blog <a href="http://www.lornajane.net/posts/2011/arrayaccess-vs-arrayobject">explaining ArrayObject and ArrayAccess</a> and how each is used.
</p>
<blockquote>
I help people qualify for <a href="http://www.zend.com/services/certification/">Zend Certification</a> and in the last few months I've had questions about both <a href="http://php.net/manual/en/class.arrayaccess.php">ArrayAccess</a> and <a href="http://php.net/manual/en/class.arrayobject.php">ArrayObject</a>. This post is an attempt to illuminate both. In very simple terms, ArrayAccess is an interface, which you can implement in your own objects; ArrayObject, on the other hand, is a class, which you can either use or extend.
</blockquote>
<p>
She give an example of ArrayAccess - a simple class that implements it to make it work like an array. For ArrayObject, she describes some of the things it comes with, including automatically implementing the ArrayAccess, Countable and Traversable <a href="http://www.php.net/manual/en/reserved.interfaces.php">interfaces</a> making it a "more powerful array" type.
</p>]]></description>
      <pubDate>Fri, 16 Sep 2011 09:16:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Stuart Herbert's Blog: Should is_array() Accept ArrayObject?]]></title>
      <guid>http://www.phpdeveloper.org/news/14818</guid>
      <link>http://www.phpdeveloper.org/news/14818</link>
      <description><![CDATA[<p>
In a <a href="http://blog.stuartherbert.com/php/2010/07/19/should-is_array-accept-arrayobject/">quick blog post</a> today <i>Stuart Herbert</i> asks the community at large a question - should <a href="http://php.net/is_array">is_array</a> accept an <a href="http://us.php.net/arrayobject">ArrayObject</a>?
</p>
<blockquote>
Here's a quick question for the wider PHP programming community '¦ if you're writing code that tests for the presence of an array, should is_array() also accept objects that behave like arrays?
</blockquote>
<p>
Some quick code snippets show that, currently in PHP 5.2, an is_array test will return false. If you use an instanceof to check it, however, you can get it to return true. There's <a href="http://blog.stuartherbert.com/php/2010/07/19/should-is_array-accept-arrayobject/#comments">plenty of comments</a> on the subject with quite a few "no"s in the group.
</p>]]></description>
      <pubDate>Tue, 20 Jul 2010 10:08:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brandon Savage's Blog: A Closer Look At ArrayObject]]></title>
      <guid>http://www.phpdeveloper.org/news/14410</guid>
      <link>http://www.phpdeveloper.org/news/14410</link>
      <description><![CDATA[<p>
In a new post to his blog today <i>Brandon Savage</i> has taken a look at <A href="http://www.brandonsavage.net/a-closer-look-at-arrayobject/">the SPL ArrayObject</a> component including how it's handled in a PHP5 OOP kind of world.
</p>
<blockquote>
ArrayObject is an object that is designed to behave exactly like an array. If that seems confusing, don't worry, it's not. ArrayObject is an object. It follows all the rules of how objects work. But it's designed to implicitly behave like an array for all intents and purposes, including being used in a foreach loop, and accessing it's properties just like you would access the values in an array.
</blockquote>
<p>
He includes a code snippet showing how the ArrayObject can be used and explains that, since it's an object and not an array, the "copy, not duplicate" handling applies to it. You get the best of two worlds - the ease of an array and the power of an object (plus there's some <a href="http://blueparabola.com/blog/spl-deserves-some-reiteration">performance improvements</a> too).
</p>]]></description>
      <pubDate>Mon, 26 Apr 2010 10:50:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Havard Eide's Blog:  Countable]]></title>
      <guid>http://www.phpdeveloper.org/news/10739</guid>
      <link>http://www.phpdeveloper.org/news/10739</link>
      <description><![CDATA[<p>
In a <a href="http://eide.org/2008/07/30/countable/">new post</a> <i>Havard Eide</i> looks at the creation of a Countable interface that can be used in any application:
</p>
<blockquote>
Today I will look at the Countable interface, it has a single function that needs to be implemented: count(), by implementing this you can ensure that there is a count() function ready to use on any given class that implements it. The Countable interface is used in other places in the SPL as well: the ArrayIterator and ArrayObject classes implements this interface ( and SqliteResult if present ).
</blockquote>
<p>
In his code examples he shows simple methods for returning the count() of a property, but notes that the real power of it comes in the ability to manipulate the number returned from the call based on other parameters (or filtering).
</p>]]></description>
      <pubDate>Fri, 01 Aug 2008 10:23:28 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Allen's Blog: Simple Zend_Form File Upload Example Revisited]]></title>
      <guid>http://www.phpdeveloper.org/news/10210</guid>
      <link>http://www.phpdeveloper.org/news/10210</link>
      <description><![CDATA[<p>
<i>Rob Allen</i> has <a href="http://akrabat.com/2008/05/16/simple-zend_form-file-upload-example-revisited/">revisited</a> a Zend_Form example he had created before, updating it with a fix for a common error people were seeing when the form tries to validate.
</p>
<blockquote>
I've been thinking about the <a href="http://akrabat.com/2008/04/07/simple-zend_form-file-upload-example/">Simple Zend_Form File Upload Example</a> that I discussed last month. To recap, if you haven't read the comments, if the form fails to validate for some reason then you get a nasty error.
</blockquote>
<p>
He corrects the issue by creating an ArrayObject (thanks to the SPL) that can be used both as an array and can look like a string to htmlspecialchars and changing up the validation a little bit to work with the new object.
</p>]]></description>
      <pubDate>Mon, 19 May 2008 09:33:13 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weir O'Phinney's Blog: Overloading arrays in PHP 5.2.0]]></title>
      <guid>http://www.phpdeveloper.org/news/7129</guid>
      <link>http://www.phpdeveloper.org/news/7129</link>
      <description><![CDATA[<p>
In <a href="http://weierophinney.net/matthew/archives/131-Overloading-arrays-in-PHP-5.2.0.html">a new post</a> to his blog, <i>Matthew Weir O'Phinney</i> talks about a method for overloading arrays in a script written for the PHP 5.2 series.
</p>
<blockquote>
<p>
Several weeks back, a bug was reported against <a href="http://framework.zend.com/manual/en/zend.view.html">Zend_View</a> that had me initially stumped. [...] I'd read about this some months back on the php internals list, but at the time hadn't understood the consequences. 
</p>
<p>
Basically, __get() no longer returns a reference and returns values in read mode, which makes modifying arrays using overloading impossible using traditional methods.
</p>
</blockquote>
<p>
Unfortunately, this was exactly the functionality that was needed, so <i>Matthew</i> <a href="http://weierophinney.net/matthew/archives/131-Overloading-arrays-in-PHP-5.2.0.html">set out</a> to find a way to do just that. His initial method, extending the ArrayObject, worked but still gave errors. On <a href="http://mikenaberezny.com/">Mike Naberezny</a>'s recommendation, though, this too was resolved with a simple call to the __set method instead.
</p>]]></description>
      <pubDate>Sat, 19 Jan 2008 08:01:25 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Maarten Balliauw's Blog: Generic arrays in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/8902</guid>
      <link>http://www.phpdeveloper.org/news/8902</link>
      <description><![CDATA[<p>
On his blog, <i>Maarten Balliauw</i> has an <a href="http://blog.maartenballiauw.be/post/2007/10/Generic-arrays-in-PHP.aspx">interesting new post</a> dealing with the use of generics in PHP:
</p>
<blockquote>
Assuming everyone knows what generics are, let's get down to business right away. PHP does not support generics or something similar, though it could be very useful in PHP development.  Luckily, using some standard OO-practises, a semi-generic array can easily be created, even in multiple ways! Here's the road to PHP generics. 
</blockquote>
<p>
He <a href="http://blog.maartenballiauw.be/post/2007/10/Generic-arrays-in-PHP.aspx">shows</a> the two ways to make generics possible - the hard way (simple inheritance and type hinting) and the more flexible way (a GenericArrayObject that extends the normal ArrayObject to make appending and validating the contents of the array simple).
</p>]]></description>
      <pubDate>Thu, 25 Oct 2007 08:50:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weir O'Phinney's Blog: Overloading arrays in PHP 5.2.0]]></title>
      <guid>http://www.phpdeveloper.org/news/6993</guid>
      <link>http://www.phpdeveloper.org/news/6993</link>
      <description><![CDATA[<p>
<i>Matthew Weir O'Phinney</i> has a new post on his blog today talking about <a href="http://weierophinney.net/matthew/archives/131-Overloading-arrays-in-PHP-5.2.0.html">overloading arrays</a> in PHP 5.2.0 using the magic __get and __construct functions.
</p>
<blockquote>
Several weeks back, a bug was reported against <a href="http://framework.zend.com/manual/en/zend.view.html">Zend_View</a>  that had me initially stumped. [...] Basically, __get() no longer returns a reference and returns values in read mode, which makes modifying arrays using overloading impossible using traditional methods.
</blockquote>
<p>
He <a href="http://weierophinney.net/matthew/archives/131-Overloading-arrays-in-PHP-5.2.0.html">gives a code example</a> of the problem and two ways to get around it - one using a switch statement to get around the problem and the other ("best solution") was <i>Matthew</i>'s option to extend the ArrayObject class.
</p>]]></description>
      <pubDate>Fri, 29 Dec 2006 07:33:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Mike Wallner's Blog: __get() and array rumors]]></title>
      <guid>http://www.phpdeveloper.org/news/6090</guid>
      <link>http://www.phpdeveloper.org/news/6090</link>
      <description><![CDATA[<p>
In <a href="http://blog.iworks.at/?/archives/47-__get-and-array-rumors.html">a brief new post</a>, <i>Mike Wallner</i> talks about some of the discussion surrounding overloaded array properties lately and something he's discovered about it.
</p>
<blockquote>
As arrays are the only complex types that are passed by value (resources don't really count here) the solution to described problem is simple: use an object; either an instance of stdClass or ArrayObject will do well, depending if you want to use array index notation.
</blockquote>
<p>
He <a href="http://blog.iworks.at/?/archives/47-__get-and-array-rumors.html">includes two code examples</a>, one just trying to overload it in a class with __get (yielding an error) and the other using the constructor to pass an ArrayObject out first, allowing for error-free assignment.
</p>]]></description>
      <pubDate>Mon, 21 Aug 2006 07:49:03 -0500</pubDate>
    </item>
  </channel>
</rss>
