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
766 B
33 lines
766 B
--TEST--
|
|
Symfony pattern: dynamic method forwarding with unpacked arguments
|
|
--FILE--
|
|
<?php
|
|
|
|
class SymfonyLikeInnerSerializer
|
|
{
|
|
public function format(string $value, string $prefix = '', string $suffix = ''): string
|
|
{
|
|
return $prefix.strtoupper($value).$suffix;
|
|
}
|
|
}
|
|
|
|
class SymfonyLikeTraceableSerializer
|
|
{
|
|
public function __construct(private SymfonyLikeInnerSerializer $serializer)
|
|
{
|
|
}
|
|
|
|
public function __call(string $method, array $arguments): mixed
|
|
{
|
|
return $this->serializer->{$method}(...$arguments);
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$serializer = new SymfonyLikeTraceableSerializer(new SymfonyLikeInnerSerializer());
|
|
var_dump($serializer->format('symfony', '[', ']'));
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(9) "[SYMFONY]"
|
|
|