Skip to content

Commit 59ed2c1

Browse files
committed
Verify setting protected(set) from inherited scope
1 parent bd19d6b commit 59ed2c1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test/php/lang/ast/unittest/emit/AsymmetricVisibilityTest.class.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ public function rename($name) {
2828
return $this;
2929
}
3030
}');
31+
32+
Assert::throws(Error::class, fn() => $t->newInstance()->fixture= 'Changed');
33+
Assert::equals('Changed', $t->newInstance()->rename('Changed')->fixture);
34+
}
35+
36+
#[Test]
37+
public function writing_from_inherited_scope() {
38+
$parent= $this->declare('class %T { public protected(set) $fixture= "Test"; }');
39+
$t= $this->declare('class %T extends '.$parent->literal().' {
40+
public function rename($name) {
41+
$this->fixture= $name;
42+
return $this;
43+
}
44+
}');
45+
46+
Assert::throws(Error::class, fn() => $t->newInstance()->fixture= 'Changed');
3147
Assert::equals('Changed', $t->newInstance()->rename('Changed')->fixture);
3248
}
3349

0 commit comments

Comments
 (0)