<?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>Tue, 21 May 2013 14:59:11 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Benjamin Eberlei: Traits are Static Access]]></title>
      <guid>http://www.phpdeveloper.org/news/19453</guid>
      <link>http://www.phpdeveloper.org/news/19453</link>
      <description><![CDATA[<p>
In a new post to his site <i>Benjamin Eberlei</i> shares an opinion about traits, noting that they're <a href="http://www.whitewashing.de/2013/04/12/traits_are_static_access.html">basically the same as static functionality</a> when it comes to several things like coupling, not being testable and being a "global state" container.
</p>
<blockquote>
I used to look forward to traits as a feature in PHP 5.4, but after discussions with Kore I came to the conclusion that traits are nothing else than static access in disguise. They actually lead to the exact same code smells. Familiar with the outcome of too much static use, we should reject traits as just another way of statically coupling your code to other classes.
</blockquote>
<p>
He includes some code examples showing traits in use in an example controller to handle a simple redirect. He points out at least six different issues with just this simple implementation. He rewrites it as "static" code to help prove his point. He comes to the conclusion that, much like static methods, traits should be avoided and instead aggregation should be favored.
</p>
Link: http://www.whitewashing.de/2013/04/12/traits_are_static_access.html]]></description>
      <pubDate>Fri, 12 Apr 2013 11:16:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[The Coders Lexicon: My Love / Hate Relationship With PHP Traits]]></title>
      <guid>http://www.phpdeveloper.org/news/19165</guid>
      <link>http://www.phpdeveloper.org/news/19165</link>
      <description><![CDATA[<p>
On the Coder's Lexicon site, there's a recent post talking about the author's <a href="http://www.coderslexicon.com/my-love-hate-relationship-with-php-traits/">love/hate relationship with PHP traits</a>, a relatively new feature of the language that apps for more "drop-in" functionality similar to mixins in other languages.
</p>
<blockquote>
When I saw the introduction of PHP traits in 5.4.0 I was eager to learn all about them and how they worked. [...] PHP traits, in my opinion, are handy and very flexible. I guess that is the "love" part of my relationship with them. [...] However, I feel that traits also meddle with a bit of the inheritance rules that have been proven time and time again. Is it possible to love as well as hate something at the same time?
</blockquote>
<p>
He talks first about "the love" he feels for using traits in his code. He talks about their usefulness for geting around PHP's single inheritance structure and being able to "bolt on" functionality as needed. Then comes "the hate" of them, noting that in the wrong hands, they could lead to very messy and lazy coding practices (including the <a href="http://en.wikipedia.org/wiki/Deadly_Diamond_of_Death#The_diamond_problem">deadly diamond of death</a> problem).
</p>]]></description>
      <pubDate>Mon, 11 Feb 2013 12:50:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: PHP Traits: Good or Bad?]]></title>
      <guid>http://www.phpdeveloper.org/news/19066</guid>
      <link>http://www.phpdeveloper.org/news/19066</link>
      <description><![CDATA[<p>
In <a href="http://phpmaster.com/php-traits-good-or-bad/">this new post</a> to PHPMaster.com, <i>Callum Hopkins</i> takes a look at one of the more recently added features of the PHP language, <a href="http://php.net/traits">traits</a> an tries to determine if they're a good or bad thing for PHP development.
</p>
<blockquote>
In early March 2012, the PHP Group announced the release of PHP 5.4. Developer eagerly anticipated the release because of the many new features 5.4 would bring, the most sought after being traits. [...] Traits have have been generally accepted by the PHP development community, mainly because it's a feature that exists within other programming languages like Java, C++, and Python. [...] Are they a feature which will help raise the level of PHP development, or are they just a fad?
</blockquote>
<p>
The starts with a few reasons why he thinks traits are bad like their potential for abuse and the difficulties that could be caused by using them instead of something like an interface. On the good side, though, he mentions things like allowing for "multiple inheritance" and their addition showing growth in the language.
</p>]]></description>
      <pubDate>Mon, 21 Jan 2013 09:19:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso: Multiple inheritance with PHP and Traits]]></title>
      <guid>http://www.phpdeveloper.org/news/18919</guid>
      <link>http://www.phpdeveloper.org/news/18919</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a new post today showing how you can use <a href="http://php.net/traits">traits</a> in PHP to simulate <a href="http://gonzalo123.com/2012/12/17/multiple-inheritance-with-php-and-traits/">a kind of multiple inheritance</a>.
</p>
<blockquote>
Multiple inheritance isn't allowed in PHP. [It's not] possible with PHP (in Java is not possible either), but today we can do something similar (is not the exactly the same) with Traits. Let me explain that: Instead of classes we can create Traits.
</blockquote>
<p>
He includes a code example showing the creation of two traits, "Base1" and "Base2", that are implemented (via "use") and the calls to methods on each. He also points out the error condition and message that can come up when there's a conflict in the method names between two or more traits. This is relatively easy to solve with the mapping ability of the "use" statement (code example included for that too).
</p>]]></description>
      <pubDate>Wed, 19 Dec 2012 13:17:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Refulz.com: Traits - Method Precedence and Conflict resolution]]></title>
      <guid>http://www.phpdeveloper.org/news/18029</guid>
      <link>http://www.phpdeveloper.org/news/18029</link>
      <description><![CDATA[<p>
On the Refulz.com site today they've posted a new tutorial looking at the use of traits and <a href="http://php.refulz.com/traits-method-precedence-and-conflict-resolution/">how to resolve conflicts</a> and work with method precedence.
</p>
<blockquote>
In our previous post about the <a href="http://php.refulz.com/traits-in-php-multiple-and-nested-traits/">multiple and nested traits</a>, we read how nested and multiple traits can be used in a class. In such cases, there is a possibility of the same method name existing in the trait, and the class using the trait. Furthermore, the same method name might also be present in the parent class of the class using traits. It is important to understand how the precedence order works for such cases.
</blockquote>
<p>
First they look at the precedence between classes and traits with the class always winning...unless the method is inherited from a parent class. They also mention the order when it comes to using the "insteadof" and "as" operators as a way to get around conflicts between traits.
</p>]]></description>
      <pubDate>Thu, 31 May 2012 10:07:25 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Refulz.com: Traits in PHP - Multiple and Nested Traits]]></title>
      <guid>http://www.phpdeveloper.org/news/18009</guid>
      <link>http://www.phpdeveloper.org/news/18009</link>
      <description><![CDATA[<p>
On the Refulz.com blog there's a new tutorial posted looking at <a href="http://php.refulz.com/traits-in-php-multiple-and-nested-traits/">traits (and nested traits) in PHP</a> including examples of them in use and how to create your own.
</p>
<blockquote>
Traits is a good new addition to PHP language. In our series about the <a href="http://php.refulz.com/series/new-in-php-5-4/">new features of PHP 5.4</a>, we reviewed the concept of Traits in PHP. The <a href="http://php.refulz.com/traits-in-php-5-4-introduction/">introductory article</a> talks about what the traits are and what is the general syntax of Traits in PHP. The second article attempts to explain <a href="http://php.refulz.com/traits-in-php-5-4-why-we-need-traits/">why we need traits</a>.
</blockquote>
<p>
The tutorial shows you how to define a custom trait use things like abstract methods, nesting them by making them "users" and how to use multiples at the same time (comma-separating).
</p>]]></description>
      <pubDate>Mon, 28 May 2012 15:16:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Inject dependencies via PhpDoc]]></title>
      <guid>http://www.phpdeveloper.org/news/17796</guid>
      <link>http://www.phpdeveloper.org/news/17796</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a new post to his blog looking at <a href="http://gonzalo123.wordpress.com/2012/04/09/inject-dependencies-via-phpdoc/">a method for injecting dependencies</a> into your application's code based on comments in the PHPDocumentor-formatted comments of your methods.
</p>
<blockquote>
Last month I attended to <a href="http://www.codemotion.es/">Codemotion</a> conference. I was listening to a talk about Java and I saw the "@inject" decorator. I must admit I switched off my mind from the conference and I started to take notes in my notebook. The idea is to implement something similar in PHP. It's a pity we don't have real decorators in PHP. I really <a href="http://gonzalo123.wordpress.com/2009/12/09/things-i-miss-in-php-function-decorators/">miss</a> them. We need to use <a href="http://gonzalo123.wordpress.com/2011/02/01/function-decorators-in-php-with-phpdoc-and-annotations/">PhpDoc</a>. It's not the same than real decorators in other programming languages. That's my prototype. Let's go.
</blockquote>
<p>
All of the code you'll need to recreate his solution is included - a sample "User" class that needs a valid PDO object in a private "db" property, a "DocInject" class that parses the comments and, using a new feature of PHP 5.4 (traits), injects the needed functionality into the "User" class and creates/assigns the object.
</p>
<p>
You can see just the full code in <a href="https://gist.github.com/2343376">these</a> <a href="https://gist.github.com/2343390">two</a> gists on Github.
</p>]]></description>
      <pubDate>Tue, 10 Apr 2012 10:23:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Refulz Blog: Traits in PHP 5.4 - Why we need Traits]]></title>
      <guid>http://www.phpdeveloper.org/news/17759</guid>
      <link>http://www.phpdeveloper.org/news/17759</link>
      <description><![CDATA[<p>
On the Refulz blog today there's a new post about traits in PHP (recently introduced in PHP 5.,4) and <a href="http://php.refulz.com/traits-in-php-5-4-why-we-need-traits/">why we need them</a> in our development.
</p>
<blockquote>
Traits is one major addition to PHP. We read an introductory article about <a href="http://php.refulz.com/traits-in-php-5-4-introduction/">Traits in PHP 5.4</a>. In the post, we saw an example code which only resembles single inheritance. So, what is the actual purpose of Traits and why do we need to use Traits in our code.
</blockquote>
<p>
They give a sample use case involving two types of clients, Business and Individual, and how you can use a single Client class and trait to provide address-related functionality.
</p>]]></description>
      <pubDate>Fri, 30 Mar 2012 11:53:35 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Using Traits in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/17522</guid>
      <link>http://www.phpdeveloper.org/news/17522</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial about using a feature in the upcoming PHP release (5.4) to make it easier to work with more modular code - <a href="http://phpmaster.com/using-traits-in-php-5-4/">using traits</a>.
</p>
<blockquote>
In this article I will discuss traits, a new feature introduced in PHP 5.4 to overcome [issues where multiple inheritance is needed]. The concept of traits itself is nothing new to programming and is used in other languages like Scala and Perl. They allows us to horizontally reuse code across independent classes in different class hierarchies.
</blockquote>
<p>
Included in the post is example code showing what the use of a trait looks like and a method for creating a Singleton that can spawn instances of two classes. Also included are examples of:
</p>
<ul>
<li>using multiple traits at once, 
<li>traits made up of traits, 
<li>the importance of order, 
<li>aliasing to avoid conflicts, 
<li>reflection 
<li>and a few other features that come along with their use.
</ul>]]></description>
      <pubDate>Thu, 09 Feb 2012 08:40:50 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP.net: PHP 5.4.0 RC6 released]]></title>
      <guid>http://www.phpdeveloper.org/news/17443</guid>
      <link>http://www.phpdeveloper.org/news/17443</link>
      <description><![CDATA[<p>
The PHP.net has announced the availability of the latest Release Candidate in the PHP 5.4.0 series - <a href="http://www.php.net/index.php#id2012-01-24-1">PHP 5.4.0 RC6</a>:
</p>
<blockquote>
The PHP development team announces the 6th release candidate of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. [...] The 6th release candidate focused on improving traits. Please test them carefully and help us to identify bugs in order to ensure that the release is solid and all things behave as expected.
</blockquote>
<p>
You can download this latest release from the <a href="http://qa.php.net/">PHP QA site</a> (<a href="http://windows.php.net/qa/">Windows binaries</a>) and test it on your local instance/applications. Any and all feedback about issues should be reported to either the <a href="php-qa@lists.php.net">QA mailing list</a> or on <a href="https://bugs.php.net/">the bug tracker</a>. A complete list of updates is available in <a href="https://svn.php.net/repository/php/php-src/tags/php_5_4_0RC6/NEWS">the NEWS file</a>.
</p>]]></description>
      <pubDate>Tue, 24 Jan 2012 07:32:05 -0600</pubDate>
    </item>
  </channel>
</rss>
