Re: Use-case for `use`ing the same trait multiple times in the same class?

From: Date: Mon, 04 Dec 2017 19:59:32 +0000
Subject: Re: Use-case for `use`ing the same trait multiple times in the same class?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-101232@lists.php.net to get a copy of this message
On 4 December 2017 17:26:12 GMT+00:00, Levi Morrison <levim@php.net> wrote: > Using T::get as get2 still conflicts because that >*aliases* even though most literature says it renames. Funnily enough, I was just recently wondering why exactly that was, and couldn't find much of an answer. The RFC rather vaguely says that it would cause problems with dynamic dispatch, but it's not obvious to me why using "insteadof" to replace an inherited or locally declared method would be any different from using it to choose between two traits. However, even if that limitation wasn't present, I can't see a use case for *directly* using the same trait twice in one class. I say directly, because even now you can *indirectly* introduce a trait twice, via inheritance of either the class or the trait. trait A { function foo() {} } trait B { use A; function bar() {} } trait C { use A; function baz() {} } class X { use B, C { B::foo insteadof C; } } class Y extends X { use A; } Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#101232) next »