Enforcing final in traits
| From: | Scott MacVicar | Date: | Fri, 04 May 2012 18:30:06 +0000 |
| Subject: | Enforcing final in traits | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-60446@lists.php.net to get a copy of this message | ||
This caused a few bugs for us / confusion. The final keyword is accepted inside a trait but it the
class also defines a method without the final keyword this takes precedence.
Two solutions:
Enforce final when a trait defines - https://whisky.macvicar.net/patches/0001-If-a-trait-declares-a-method-as-final-enforce-that.patch
Prohibit final form being used in a trait - https://whisky.macvicar.net/patches/002-traits-Disable-use-of-final-keyword.patch
I'm for the first solution here
- S