<?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>Wed, 19 Jun 2013 09:22:44 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Zend Developer Zone: Trait-like Functionality for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14311</guid>
      <link>http://www.phpdeveloper.org/news/14311</link>
      <description><![CDATA[<p>
In a new tutorial posted on the Zend Developer Zone today <i>Steve Hollis</i> looks at something several PHP developers have said they want to seen in the language - traits - and how, until then, you can <a href="http://devzone.zend.com/article/12014-Trait-like-Functionality-for-PHP">use traits now</a> (well, sort of).
</p>
<blockquote>
So why do we need traits, anyway? PHP is a single inheritance language, meaning that each class can only extend one other. This allows us to build logical class hierarchies which extend functionality in a "vertical" way. [...] What we need is a means of re-using code other than simple inheritance. That's where traits come in. Traits are classes containing a collection of methods, usually relating to a particular behaviour. 
</blockquote>
<p>
He shares a way that you can mimic some of the functionality that traits would give you (full code is <a href="http://www.stevehollis.com/wp-content/uploads/2010/04/traits.zip">available here</a>) with an abstract trait class, reflection and a "superclass" that's extended to pass off the requests to the correct child object.
</p>]]></description>
      <pubDate>Wed, 07 Apr 2010 10:05:52 -0500</pubDate>
    </item>
  </channel>
</rss>
