<?php
class A
{
public function abc()
{
$a = '';
$a .= self::test();
$a .= static::test();
return $a;
}
public static function test()
{
return 'A';
}
public function __toString()
{
}
public static function createSelfObject()
{
return new self();
}
public static function createStaticObject()
{
return new static();
}
}
class B extends A
{
public function abc()
{
return parent::abc() . "\n";
}
public static function test()
{
return 'B';
}
}
$a = new A();
echo "Class A: ";
echo $a->abc();
echo "***\n";
$b = new B();
echo "Class B: ";
echo $b->abc();
echo "***\n";
$a1 = A::createSelfObject();
echo 'A::createSelfObject() -> ' . $a1;
$a2 = A::createStaticObject();
echo 'A::createStaticObject() -> ' . $a2;
$b1 = B::createSelfObject();
echo 'B::createSelfObject() -> ' . $b1;
$b2 = B::createStaticObject();
echo 'B::createStaticObject() -> ' . $b2;
PD9waHAKCmNsYXNzIEEKewogICAgcHVibGljIGZ1bmN0aW9uIGFiYygpCiAgICB7CiAgICAgICAgJGEgPSAnJzsKICAgICAgICAkYSAuPSBzZWxmOjp0ZXN0KCk7CiAgICAgICAgJGEgLj0gc3RhdGljOjp0ZXN0KCk7CiAgICAgICAgcmV0dXJuICRhOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgZnVuY3Rpb24gdGVzdCgpCiAgICB7CiAgICAgICAgcmV0dXJuICdBJzsKICAgIH0KCiAgICBwdWJsaWMgZnVuY3Rpb24gX190b1N0cmluZygpCiAgICB7CiAgICAgICAgcmV0dXJuIGdldF9jbGFzcygkdGhpcykgLiAiXG4iOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgZnVuY3Rpb24gY3JlYXRlU2VsZk9iamVjdCgpCiAgICB7CiAgICAgICAgcmV0dXJuIG5ldyBzZWxmKCk7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyBmdW5jdGlvbiBjcmVhdGVTdGF0aWNPYmplY3QoKQogICAgewogICAgICAgIHJldHVybiBuZXcgc3RhdGljKCk7CiAgICB9Cn0KCmNsYXNzIEIgZXh0ZW5kcyBBCnsKICAgIHB1YmxpYyBmdW5jdGlvbiB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