Re: Re: [RFC] Traits with interfaces

From: Date: Sun, 06 Mar 2016 17:43:14 +0000
Subject: Re: Re: [RFC] Traits with interfaces
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-91520@lists.php.net to get a copy of this message
On 05/03/2016 23:15, Davey Shafik wrote:
You are mid-reading, none of the classes in my examples extend the others, they are all just using the same trait in different ways. - Class a: use the trait with no aliases. Result: as expected - Class b: use the trait with a simple alias, no visibility change. Result: both methods
Right, the reason I was looking at inheritance was this line:
... and_will_ override inherited methods of the same name.
I misunderstood that the rest of the examples were also about how inheritance behaved.
For the one you can't re-produce, it's class 'c', which is stand-alone here: https://3v4l.org/K9o6Y
Right, so this is actually consistent, because the resulting "stitched together" class looks like this: class C { public function bar() {} private function bat() {} } Whereas when the alias wasn't private, it looked liked this: class B { public function bar() {} public function bat() {} } You can actually change its visibility on one line and alias it on another: class e {
    use foo {
        bar as private;
        bar as bat;
    }
} https://3v4l.org/80gKF Stitched togorther, that gives you: class e { private function bar() {} public function bat() {} } So the main confusion is that "bar as private bat" != "bar as private" + "bar as bat". :) Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#91520) next »