News for hackers. Stuff that matters.
Re:New to PHP 5.4: Traits by viraptor on Saturday November 20, 2010 @10:20AM (#1924603)
Agreed. Also the conflict resolution is done in an interesting way. If you have 2 traits that have N conflicting methods, you have to rename all N methods in every single class using the traits (even if it doesn't use the methods in question).

Another interesting side effect is that even if you don't use a particular trait, but a conflict appears upstream - boom - "Warning: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d"

If I understand it correctly: You will be warned that a collision appeared, NONE of them will be applied and it's only a warning, so it won't stop the execution until you step on the "missing method" trap. Now that's a creative way to shoot yourself in the foot.

Re:New to PHP 5.4: Traits by encoderer on Saturday November 20, 2010 @02:18PM (#1925082)
For the sake of readership (assuming that you understand why) this is because traits are compile-time but method calls can be done dynamically at run-time.

So when you say "even if it doesn't use the methods in question" -- well, the compiler has no way to know that.