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.
34 lines
555 B
34 lines
555 B
--TEST--
|
|
Trait method calling protected parent::method() of the composing class
|
|
--FILE--
|
|
<?php
|
|
|
|
trait GreetTrait
|
|
{
|
|
public function greet(string $name): string
|
|
{
|
|
return parent::greet($name) . ' [via trait]';
|
|
}
|
|
}
|
|
|
|
class BaseGreeter
|
|
{
|
|
protected function greet(string $name): string
|
|
{
|
|
return 'Hello ' . $name;
|
|
}
|
|
}
|
|
|
|
class ChildGreeter extends BaseGreeter
|
|
{
|
|
use GreetTrait;
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$g = new ChildGreeter();
|
|
var_dump($g->greet('World'));
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(23) "Hello World [via trait]"
|
|
|