public function expectreplacedBehavior()
 {
     $mock = new ClassMethodReplacementGuard();
     $mock->replace('StaticMock\\MethodReplacer\\A', 'a', function () {
         return 3;
     });
     $mock->replace('StaticMock\\MethodReplacer\\B', 'b', function () {
         return 4;
     });
     $this->assertEquals(3, A::a());
     $this->assertEquals(4, B::b());
     $this->assertEquals(3, C::bar());
 }
Esempio n. 2
0
function main()
{
    $c = new C();
    $d = new D();
    $c->foo();
    $d->foo();
    echo "**************\n";
    $c->bar();
    $d->bar();
    echo "**************\n";
    C::foo();
    D::bar();
    echo "**************\n";
    $d->yar();
    D::yar();
}
Esempio n. 3
0
    }
}
class D extends C
{
    static $cls = 'D';
    public function __construct()
    {
        var_dump(isset($this));
        var_dump(static::$cls);
    }
    public function yar()
    {
        var_dump(isset($this));
        var_dump(static::$cls);
        C::yar();
    }
}
$c = new C();
$d = new D();
echo "**************\n";
$c->foo();
$d->foo();
echo "**************\n";
$c->bar();
$d->bar();
echo "**************\n";
C::foo();
D::bar();
echo "**************\n";
$d->yar();
D::yar();
Esempio n. 4
0
<?php

interface I
{
    public function foo();
}
class C implements I
{
    protected function foo()
    {
        echo "foo\n";
    }
    public function bar()
    {
        $this->foo();
    }
}
$obj = new C();
$obj->bar();
Esempio n. 5
0
<?php

trait T1
{
    function foo()
    {
        (yield 1);
    }
}
trait T2
{
    use T1 {
        foo as bar;
    }
    function foo()
    {
        return bar();
    }
}
class C
{
    use T2;
}
foreach (C::bar() as $x) {
    var_dump($x);
}
Esempio n. 6
0
 public function doBar()
 {
     $this->bar();
     // G G
     B::bar();
     // B B
     C::bar();
     // C C
     D::bar();
     // D D
     F::bar();
     // F F
     G::bar();
     // G G
     H::bar();
     // H H
     parent::bar();
     // F G
     self::bar();
     // G G
     static::bar();
     // G G
     echo "****************\n";
 }