Skip to content

Commit ccc8820

Browse files
committed
Add more tests for private(set) properties implicit final
1 parent 0b7c768 commit ccc8820

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

src/main/php/lang/ast/emit/AsymmetricVisibility.class.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ protected function emitProperty($result, $property) {
4949
$modifiers & MODIFIER_PROTECTED && $modifiers&= ~0x0000800;
5050
} else if ($modifiers & 0x0001000) {
5151
$checks= [$this->private($property->name, 'modify private(set)')];
52-
$modifiers & MODIFIER_PRIVATE && $modifiers&= ~0x0001000;
53-
$modifiers|= MODIFIER_FINAL;
52+
$modifiers & MODIFIER_PRIVATE ? $modifiers&= ~0x0001000 : $modifiers|= MODIFIER_FINAL;
5453
}
5554

5655
// Emit XP meta information for the reflection API

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

+5-17
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ public function protected_set_reflection() {
112112
);
113113
}
114114

115-
#[Test]
116-
public function private_set_implicitely_final_in_reflection() {
115+
#[Test, Values(['protected', 'public'])]
116+
public function private_set_implicitely_final_in_reflection($modifier) {
117117
$t= $this->declare('class %T {
118-
public private(set) string $fixture= "Test";
118+
'.$modifier.' private(set) string $fixture= "Test";
119119
}');
120120

121121
Assert::equals(
122-
'public final private(set) string $fixture',
122+
$modifier.' final private(set) string $fixture',
123123
$t->property('fixture')->toString()
124124
);
125125
}
126126

127-
#[Test, Values(['protected', 'public'])]
127+
#[Test, Values(['private', 'protected', 'public'])]
128128
public function same_modifier_for_get_and_set($modifier) {
129129
$t= $this->declare('class %T {
130130
'.$modifier.' '.$modifier.'(set) string $fixture= "Test";
@@ -136,18 +136,6 @@ public function same_modifier_for_get_and_set($modifier) {
136136
);
137137
}
138138

139-
#[Test]
140-
public function private_modifier_for_get_and_set() {
141-
$t= $this->declare('class %T {
142-
private private(set) string $fixture= "Test";
143-
}');
144-
145-
Assert::equals(
146-
'private final string $fixture',
147-
$t->property('fixture')->toString()
148-
);
149-
}
150-
151139
#[Test]
152140
public function interaction_with_hooks() {
153141
$t= $this->declare('class %T {

0 commit comments

Comments
 (0)