<?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>Sun, 19 May 2013 13:51:37 -0500</pubDate>
    <ttl>30</ttl>
    <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: Where Multiple Inheritance Will Kill You]]></title>
      <guid>http://www.phpdeveloper.org/news/12896</guid>
      <link>http://www.phpdeveloper.org/news/12896</link>
      <description><![CDATA[<p>
In <a href="http://www.brandonsavage.net/where-multiple-inheritance-will-kill-you/">this new post</a> to his blog <i>Brandon Savage</i> takes a look at multiple inheritance in PHP applications - specifically where it could "kill you" if you're not careful.
</p>
<blockquote>
This is a fantastic way to further encapsulate and abstract your code because it means you can define some base functionality and then later on extend that class to add new functionality and even override existing functionality to make the class specific. But this concept is a double-edged sword in PHP (and all other languages).
</blockquote>
<p>
The problem lies in methods in classes that could be overriding parents and the sort of results that instance of might return in a multiple inheritance environment. He includes code snippets both illustrating the problem and showing a suggestion for how it could be avoided.
</p>]]></description>
      <pubDate>Fri, 17 Jul 2009 11:19:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David Otton's Blog: PHP Tip: Classes Aren't Derived From stdClass]]></title>
      <guid>http://www.phpdeveloper.org/news/11415</guid>
      <link>http://www.phpdeveloper.org/news/11415</link>
      <description><![CDATA[<p>
<i>David Otton</i> has shared a <a href="http://www.otton.org/2008/11/11/php-base-class-stdclass/">discovery</a> he's come across in his development - user-defined classes are not derived from stdClass.
</p>
<blockquote>
Many OO languages have the concept of a single base class from which all other classes are explicitly or implicitly descended. For example, Ruby, Java and .NET all have Object. It's a very <a href="http://www.google.co.uk/search?hl=en&q=php%20%22base%20class%22%20stdClass&meta=">common belief</a> that PHP implements stdClass as a base class for all objects, but this is in fact not the case.
</blockquote>
<p>
He illustrates with a code example showing the results of calls to instanceof with a normal user class and one that extends the stdClass object.
</p>]]></description>
      <pubDate>Sun, 16 Nov 2008 10:54:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP 10.0 Blog: duck operator]]></title>
      <guid>http://www.phpdeveloper.org/news/10352</guid>
      <link>http://www.phpdeveloper.org/news/10352</link>
      <description><![CDATA[<p>
In <a href="http://php100.wordpress.com/2008/06/05/duck-operator/">this new post</a> to the PHP 10.0 blog today, <i>Stas</i> talks about <a href="http://en.wikipedia.org/wiki/Duck_typing">duck typing</a>, a method that lets the code decide the functionality to use rather than a direct relation to a parent.
</p>
<blockquote>
Well, if you are into <a href="http://en.wikipedia.org/wiki/Duck_typing">duck typing</a> style of programming, it may be interesting for you to have an object that implements certain set of functions, but not necessary declares it at class definition. Languages like Smalltalk do it all day along, so why PHP couldn't?
</blockquote>
<p>
His example defines an interface Cow and a class MooingGrassEater and a function, CowConsumer, that does the work. A classname is passed in and an instance of that class is checked with "implements" rather than "instanceof" to see if it uses the Cow interface. He points out a place where PHP itself uses something similar in <a href="http://php.net/manual/en/function.stream-wrapper-register.php">user defined streams</a>.
</p>]]></description>
      <pubDate>Thu, 05 Jun 2008 14:36:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Enforcing Object Types in PHP - Using the PHP5 instanceof Operator]]></title>
      <guid>http://www.phpdeveloper.org/news/4887</guid>
      <link>http://www.phpdeveloper.org/news/4887</link>
      <description><![CDATA[DevShed is continuing their "Enforcing Object Types in PHP" series with <a href="http://www.devshed.com/c/a/PHP/Enforcing-Object-Types-in-PHP-Using-the-PHP5-instanceof-Operator/">this new tutorial</a> today. This time, they're focusing mor eon the use of the instanceof operator in PHP5.
<p>
<quote>
<i>
This three-part series goes through the basic concepts of object type enforcement in PHP 4/PHP 5. It explores different approaches for checking types of objects to help you avoid possible code contamination when objects of incorrect type are inputted within PHP classes.
<p>
The end result of this article hopefully will help you to expand your grounding in how to implement object type enforcement in PHP 5, by developing some illustrative, object-oriented examples. 
</i>
</quote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Enforcing-Object-Types-in-PHP-Using-the-PHP5-instanceof-Operator/2">start</a> with a look at how not to do the object checking but provide a solution to the situation with the help of the instanceof operator. They explain its usage in the context of the widget class they've created, and show you how it can be integrated easily to simplify object validation.]]></description>
      <pubDate>Thu, 23 Feb 2006 07:01:43 -0600</pubDate>
    </item>
  </channel>
</rss>
