<?php
class A {
public function example() {
return new self;
}
}
class B extends A {
}
$b = new B();
$obj = $b->example();
// SaĆda:
// A
PD9waHAKCmNsYXNzIEEgewogICAgcHVibGljIGZ1bmN0aW9uIGV4YW1wbGUoKSB7CiAgICAgICAgcmV0dXJuIG5ldyBzZWxmOwogICAgfQp9CgpjbGFzcyBCIGV4dGVuZHMgQSB7Cgp9CgokYiA9IG5ldyBCKCk7CiRvYmogPSAkYi0+ZXhhbXBsZSgpOwoKZWNobyBnZXRfY2xhc3MoJG9iaiksIFBIUF9FT0w7CgovLyBTYcOtZGE6Ci8vIEE=