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.
43 lines
952 B
43 lines
952 B
--TEST--
|
|
Symfony pattern: Closure::bind returns reference to private property
|
|
--SKIPIF--
|
|
<?php
|
|
exit("skip: returning by reference from a closure is not supported in AOT");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
final class ReferenceConfigurator
|
|
{
|
|
private array $instanceof = [
|
|
'base' => 'service',
|
|
];
|
|
|
|
public function getReferenceAccessor(): Closure
|
|
{
|
|
return Closure::bind(fn &() => $this->instanceof, $this, self::class);
|
|
}
|
|
|
|
public function dump(): void
|
|
{
|
|
foreach ($this->instanceof as $key => $value) {
|
|
var_dump($key.':'.$value);
|
|
}
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$configurator = new ReferenceConfigurator();
|
|
$accessor = $configurator->getReferenceAccessor();
|
|
$instanceof = &$accessor();
|
|
|
|
$instanceof['extra'] = 'listener';
|
|
$instanceof['base'] = strtoupper($instanceof['base']);
|
|
|
|
$configurator->dump();
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(12) "base:SERVICE"
|
|
string(14) "extra:listener"
|
|
|