Skip to content

Instantly share code, notes, and snippets.

@manuelpichler
Created January 29, 2012 20:22
Show Gist options
  • Save manuelpichler/1700470 to your computer and use it in GitHub Desktop.
Save manuelpichler/1700470 to your computer and use it in GitHub Desktop.
Trait nightmare
<?php
trait A {
function f( ) {
return __METHOD__;
}
}
class C {
use A {
f as x;
f as y;
}
}
$c = new C;
var_dump( $c->x(), $c->y() );
<?php
trait A {
function f() {
return __METHOD__;
}
}
trait B {
function f() {
return __METHOD__;
}
}
class C {
use A {
A::f insteadof B;
}
use B {
B::f insteadof A;
}
}
$c = new C;
$c->f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment