mirror of
https://github.com/php/php-src.git
synced 2024-10-01 23:06:11 +00:00
05a9649043
#That was suggested several times already, but am still not sure whether that really reads better. #Especially since only the trait is mentioned, since the method name would be duplicated anyway.
31 lines
483 B
PHP
31 lines
483 B
PHP
--TEST--
|
|
Use instead to solve a conflict and as to access the method.
|
|
--FILE--
|
|
<?php
|
|
error_reporting(E_ALL);
|
|
|
|
trait Hello {
|
|
public function saySomething() {
|
|
echo 'Hello';
|
|
}
|
|
}
|
|
|
|
trait World {
|
|
public function saySomething() {
|
|
echo ' World';
|
|
}
|
|
}
|
|
|
|
class MyHelloWorld {
|
|
use Hello, World {
|
|
Hello::saySomething insteadof World;
|
|
World::saySomething as sayWorld;
|
|
}
|
|
}
|
|
|
|
$o = new MyHelloWorld();
|
|
$o->saySomething();
|
|
$o->sayWorld();
|
|
?>
|
|
--EXPECTF--
|
|
Hello World
|