TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
926 B
53 lines
926 B
--TEST--
|
|
Private, nested and aliased trait methods retain class scope across instances
|
|
--FILE--
|
|
<?php
|
|
|
|
trait NestedPrivateMethod
|
|
{
|
|
private function nestedSecret(): string
|
|
{
|
|
return 'nested';
|
|
}
|
|
}
|
|
|
|
trait NestedPrivateComposition
|
|
{
|
|
use NestedPrivateMethod;
|
|
}
|
|
|
|
trait AliasMethodSource
|
|
{
|
|
protected function sourceSecret(): string
|
|
{
|
|
return 'alias';
|
|
}
|
|
}
|
|
|
|
class PrivateTraitConsumer
|
|
{
|
|
use NestedPrivateComposition;
|
|
use AliasMethodSource {
|
|
sourceSecret as private aliasSecret;
|
|
}
|
|
|
|
public function readOther(): string
|
|
{
|
|
$other = new static();
|
|
return $other->nestedSecret() . ':' . $other->aliasSecret();
|
|
}
|
|
}
|
|
|
|
class PrivateTraitChild extends PrivateTraitConsumer
|
|
{
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
echo (new PrivateTraitConsumer())->readOther(), "\n";
|
|
echo (new PrivateTraitChild())->readOther(), "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
nested:alias
|
|
nested:alias
|
|
|