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
750 B
37 lines
750 B
--TEST--
|
|
Symfony Cache style negated static coalesce assignment condition
|
|
--FILE--
|
|
<?php
|
|
class SymfonyApcuSupportedCase
|
|
{
|
|
private static ?bool $supported = null;
|
|
public static int $checks = 0;
|
|
|
|
public static function probe(): bool
|
|
{
|
|
self::$checks++;
|
|
|
|
return false;
|
|
}
|
|
|
|
public static function createSystemCache(): string
|
|
{
|
|
if (!self::$supported ??= self::probe()) {
|
|
return 'fallback';
|
|
}
|
|
|
|
return 'apcu';
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
var_dump(SymfonyApcuSupportedCase::createSystemCache());
|
|
var_dump(SymfonyApcuSupportedCase::createSystemCache());
|
|
var_dump(SymfonyApcuSupportedCase::$checks);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(8) "fallback"
|
|
string(8) "fallback"
|
|
int(1)
|
|
|