1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/traits/abstract_method_9.phpt
Nikita Popov cf7c68283d Fix treatment of "self" when validating against trait method
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.
2020-04-23 11:41:34 +02:00

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===