Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Created January 24, 2012 22:16
Show Gist options
  • Save Majkl578/1673061 to your computer and use it in GitHub Desktop.
Save Majkl578/1673061 to your computer and use it in GitHub Desktop.
PHP 5.4 traits
<?php
trait T {
public function xyz()
{
echo __TRAIT__, PHP_EOL;
}
}
class A {
use T;
}
(new A)->xyz(); // T - OK
class B {
use T {
T::xyz as abc;
}
}
(new B)->xyz(); // T - should not work?
class C {
use T {
T::xyz as abc;
}
public function xyz()
{
echo __CLASS__, PHP_EOL;
}
}
(new C)->xyz(); // C - magic?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment