Esempio n. 1
0
    {
        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();
Esempio n. 2
0
{
    public function smallTalk()
    {
        echo 'b' . "\n";
    }
    public function bigTalk()
    {
        echo 'B' . "\n";
    }
}
class Talker
{
    use A, B {
        A::smallTalk insteadof B;
        B::bigTalk insteadof A;
    }
}
class Aliased_Talker
{
    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
        B::bigTalk as talk;
    }
}
$oAT = new Aliased_Talker();
echo $oAT->bigTalk();
echo $oAT->smallTalk();
$oT = new Talker();
echo $oT->smallTalk();
echo $oT->bigTalk();
Esempio n. 3
0
    use A, B {
        B::smallTalk insteadof A;
        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 {