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.
33 lines
620 B
33 lines
620 B
--TEST--
|
|
Trait methods take precedence over __call magic fallback
|
|
--FILE--
|
|
<?php
|
|
|
|
trait AttributeLookup
|
|
{
|
|
public function getAttribute(string $class): string
|
|
{
|
|
return 'attribute:' . $class;
|
|
}
|
|
}
|
|
|
|
class TraitMethodConsumer
|
|
{
|
|
use AttributeLookup;
|
|
|
|
public function __call(string $name, array $arguments): mixed
|
|
{
|
|
return 'magic:' . $name;
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$object = new TraitMethodConsumer();
|
|
var_dump($object->getAttribute('SomeClass'));
|
|
var_dump($object->missingMethod());
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(19) "attribute:SomeClass"
|
|
string(19) "magic:missingMethod"
|
|
|