use 方法 {
    方法 as 属性 重命名
    }

    1. <?php
    2. trait A{
    3. private function show(){
    4. echo '我是私密的方法';
    5. }
    6. }
    7. class student {
    8. use A {
    9. show as public show2;
    10. }
    11. }
    12. $stu=new student;
    13. $stu->show2();
    14. ?>

    image.png