Remove need for unstable feature attribute in HHVM
[hiphop-php.git] / hphp / test / slow / readonly / readonly_overview_with_attr.php
blob79dc2b0e2d3211c17dd355e7dad3fd8d7ab8f0a1
1 <?hh
2 <<file:__EnableUnstableFeatures("readonly")>>
3 class Foo {
4 public int $prop = 2;
6 function foo(readonly Foo $x): readonly Foo {
7 $y = HH\Readonly\as_mut(readonly $x->prop);
8 var_dump($y);
9 return $x;
12 class Test {
13 public function __construct(
14 public readonly Foo $prop
15 ) {}
17 public readonly function get(): readonly Foo {
18 return readonly $this->prop;
23 class ReadonlyBox<T> {
24 public function __construct(
25 private readonly T $contents
26 ) {}
28 public readonly function get(): readonly T {
29 return readonly $this->contents;
32 public function set(readonly T $x): void {
33 $this->contents = $x;
37 <<__EntryPoint>>
38 function main(): void {
39 $y = new Test(new Foo());
40 $a = readonly $y->prop;
41 $y = new ReadonlyBox($a);
42 $z = readonly $y->get();
43 readonly foo($z);
44 echo "Done\n";