talk() публичный Метод

public talk ( )
Пример #1
0
    public function smallTalk()
    {
        echo 'b';
    }
    public function bigTalk()
    {
        echo 'B';
    }
}
class Talker
{
    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
    }
}
class Aliased_Talker
{
    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
        B::bigTalk as talk;
    }
}
$t = new Talker();
$t->smallTalk();
$t->bigTalk();
echo "<br>";
$al = new Aliased_Talker();
$al->talk();
$al->bigTalk();
Пример #2
0
        A::bigTalk insteadof B;
        B::bigTalk as talk;
    }
}
$a = new Talker();
$a->smallTalk();
// expecting 'b'
$a->bigTalk();
//expecting 'A'
echo PHP_EOL;
$a = new Aliased_Talker();
$a->smallTalk();
// expecting 'b'
$a->bigTalk();
// expecting 'A'
$a->talk();
// expecting 'B'
echo PHP_EOL;
trait HelloWorld
{
    public function sayHello()
    {
        echo 'Hello World!';
    }
}
// Change visibility of sayHello
class MyClass1
{
    use HelloWorld {
        sayHello as protected;
    }