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.
44 lines
619 B
44 lines
619 B
--TEST--
|
|
trait method writes injected private property on child object
|
|
--SKIPIF--
|
|
--FILE--
|
|
<?php
|
|
|
|
trait PrivatePropertyWriter
|
|
{
|
|
private ?array $items = null;
|
|
|
|
public function items(): array
|
|
{
|
|
if ($this->items !== null) {
|
|
return $this->items;
|
|
}
|
|
return $this->items = [1, 3, 4];
|
|
}
|
|
}
|
|
|
|
class PropertyOwner
|
|
{
|
|
use PrivatePropertyWriter;
|
|
}
|
|
|
|
class ChildPropertyOwner extends PropertyOwner
|
|
{
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$object = new ChildPropertyOwner();
|
|
var_dump($object->items());
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
array(3) {
|
|
[0]=>
|
|
int(1)
|
|
[1]=>
|
|
int(3)
|
|
[2]=>
|
|
int(4)
|
|
}
|
|
|