test(aot): add trait private property write inherited test case

- Create new test file for trait method writing injected private property on child object
- Add trait PrivatePropertyWriter with private array property and items method
- Implement PropertyOwner class using the trait
- Create ChildPropertyOwner class extending PropertyOwner
- Add main function to test the inherited private property access
- Define expected output for the array dump result
pull/17/head
韩天峰 2 months ago
parent 9d3ea98199
commit 0ad6285cfe
  1. 44
      tests/aot/basic/trait-private-property-write-inherited.phpt

@ -0,0 +1,44 @@
--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)
}
Loading…
Cancel
Save