Inheritance: extends A
Exemplo n.º 1
0
<?php

class A
{
    protected static function f()
    {
        return 'A::f()';
    }
}
class B1 extends A
{
    protected static function f()
    {
        return 'B1::f()';
    }
}
class B2 extends A
{
    public static function test()
    {
        var_dump(is_callable('B1::f'));
        B1::f();
    }
}
B2::test();
Exemplo n.º 2
0
class B2 extends A2
{
    public static function doTest(A2 $obj)
    {
        echo __METHOD__ . "\n";
        $obj->test();
    }
}
class C2 extends A2
{
    protected static function test()
    {
        echo __METHOD__ . "\n";
    }
}
B2::doTest(new C2());
/* Right now Ctor's cannot be made protected when defined in a ctor. That is
 * we cannot decrease visibility.
 *

interface Ctor
{
	function __construct($x);
}

class A3 implements Ctor
{
	protected function __construct()
	{
		echo __METHOD__ . "\n";
	}