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
569 B
33 lines
569 B
--TEST--
|
|
Symfony AssetMapper pattern: new expression as constructor default
|
|
--FILE--
|
|
<?php
|
|
|
|
class Compressor
|
|
{
|
|
public function compress(string $value): string
|
|
{
|
|
return 'gz:'.$value;
|
|
}
|
|
}
|
|
|
|
class GzipAsset
|
|
{
|
|
public function __construct(
|
|
private readonly Compressor $compressor = new Compressor(),
|
|
) {
|
|
}
|
|
|
|
public function encode(string $value): string
|
|
{
|
|
return $this->compressor->compress($value);
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
var_dump((new GzipAsset())->encode('asset'));
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(8) "gz:asset"
|
|
|