mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
If we're validating a class method against a trait method, we need to treat "self" in the trait method as the class where the method is used. To achieve this, we need to thread the proto scope through all methods, so it can be provided separately from proto.common->scope.
30 lines
534 B
PHP
30 lines
534 B
PHP
--TEST--
|
|
Abstract method in trait using "self" (delayed obligation)
|
|
--FILE--
|
|
<?php
|
|
|
|
spl_autoload_register(function($class) {
|
|
if ($class == T::class) {
|
|
trait T {
|
|
abstract private function method($x): self;
|
|
}
|
|
} else if ($class == C::class) {
|
|
class C {
|
|
use T;
|
|
|
|
private function method($x): D {
|
|
return new D;
|
|
}
|
|
}
|
|
} else if ($class == D::class) {
|
|
class D extends C {}
|
|
}
|
|
});
|
|
|
|
new C;
|
|
|
|
?>
|
|
===DONE===
|
|
--EXPECT--
|
|
===DONE===
|