Re: Enforcing final in traits

From: Date: Sat, 05 May 2012 09:26:47 +0000
Subject: Re: Enforcing final in traits
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-60456@lists.php.net to get a copy of this message
On Sat, May 5, 2012 at 1:38 AM, Stefan Marr <php@stefan-marr.de> wrote: > > On 04 May 2012, at 21:46, Hannes Magnusson wrote: > >> On Fri, May 4, 2012 at 8:30 PM, Scott MacVicar <scott@macvicar.net> wrote: >>> 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. > > The methods in the class always take precedency. > > However, the final keyword might just be something I overlooked. > It sounds sensible that if the final is not explicitly removed during composition to treat it > as what final was meant for and check it against the methods defined in the class body as well. > > Scott, could you elaborate a bit of the use case of final in a trait? Here is an example: http://stackoverflow.com/questions/7104957/building-a-singleton-trait-with-php-5-4 Not the best things to use traits for, but probably something people *will* try to do. Nikita

« previous php.internals (#60456) next »