Trait behavior when providing a new name while no conflict exists
| From: | Patrick ALLAERT | Date: | Thu, 18 Nov 2010 15:01:56 +0000 |
| Subject: | Trait behavior when providing a new name while no conflict exists | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-50347@lists.php.net to get a copy of this message | ||
Hi,
Is this intended not being able to give a new name to a method even in
case of no conflict?
In the following example, I try to provide the name "sayIt"
additionally to "saySomething" from trait "Hello":
<?php
trait Hello {
public function saySomething() {
echo 'Hello';
}
}
class MyHello{
use Hello {
Hello::saySomething as sayIt;
}
}
?>
The following error message is shown while running it:
Fatal error: Failed to add aliased trait method (sayIt) to the trait
table. There is probably already a trait method with the same name in
%s on line %d
The error message might be misleading even if it should only be
available in case of conflict.
Regards,
--
Patrick Allaert
---
http://code.google.com/p/peclapm/ - Alternative PHP
Monitor