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]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to