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.
 
 

37 lines
768 B

--TEST--
Symfony Doctrine pattern: match true with assignment condition and dynamic method call
--FILE--
<?php
final class ResetContainer
{
private array $methodMap = [
'cache' => 'resetCache',
];
public function reset(string $name): string
{
$method = null;
return match (true) {
!$method = $this->methodMap[$name] ?? null => 'missing',
default => $this->{$method}($name),
};
}
private function resetCache(string $name): string
{
return 'reset:'.$name;
}
}
function main(): void
{
$container = new ResetContainer();
var_dump($container->reset('cache'));
var_dump($container->reset('logger'));
}
?>
--EXPECT--
string(11) "reset:cache"
string(7) "missing"