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.
 
 

41 lines
786 B

--TEST--
Symfony Config pattern: cache Traversable as array with iterator_to_array
--FILE--
<?php
final class ResourceCheckerCache
{
public function __construct(private iterable $resourceCheckers)
{
}
public function all(): array
{
if (!$this->resourceCheckers instanceof Traversable) {
return $this->resourceCheckers;
}
return $this->resourceCheckers = iterator_to_array($this->resourceCheckers);
}
}
function main(): void
{
$cache = new ResourceCheckerCache(new ArrayIterator(['php' => true, 'yaml' => false]));
var_dump($cache->all());
var_dump($cache->all());
}
?>
--EXPECT--
array(2) {
["php"]=>
bool(true)
["yaml"]=>
bool(false)
}
array(2) {
["php"]=>
bool(true)
["yaml"]=>
bool(false)
}