News Feed
Jobs Feed
Sections




News Archive
Refulz.com:
Traits - Method Precedence and Conflict resolution
May 31, 2012 @ 10:07:25

On the Refulz.com site today they've posted a new tutorial looking at the use of traits and how to resolve conflicts and work with method precedence.

In our previous post about the multiple and nested traits, 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.

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.

0 comments voice your opinion now!
traits conflict resolution inheritance precedence insteadof as tutorial


blog comments powered by Disqus

Similar Posts

Version Control Blog: Upgrading Drupal with Git

PHPMaster.com: Using Traits in PHP 5.4

Felix Geisendorfer's Blog: Setting up Xdebug on Mac OS X (or Win32 / Linux)

Chris Hartjes' Blog: Don’t Fear The Command Line: Using CakePHP Shells

Larry Garfield's Blog: Benchmarking magic


Community Events











Don't see your event here?
Let us know!


release language framework api phpunit testing functional database unittest opinion introduction development composer zendframework2 code podcast example series community interview

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework