News Feed

News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way
Traits - Method Precedence and Conflict resolution
May 31, 2012 @ 10:07:25

On the 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

Community News: Packagist Latest Releases for 07.09.2013

DevShed: Creating a Blog Application with Interpreter Classes with PHP 5

Gonzalo Ayuso's Blog: Moving singleton and factory patterns to Abstract with php 5.3 Building a Flickr Slideshow with NetBeans IDE 6.5

Community News: Packagist Latest Releases for 06.21.2014

Community Events

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

community application conference opinion example project framework language api introduction interview yii2 part2 list series symfony composer laravel php7 podcast

All content copyright, 2015 :: - Powered by the Solar PHP Framework