Skip to content

Commit cad16ee

Browse files
committed
Add tests for typed properties and constants
See https://wiki.php.net/rfc/typed_class_constants
1 parent dc0da5d commit cad16ee

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ public function run() {
1818
Assert::equals('Test', $r);
1919
}
2020

21+
#[Test]
22+
public function typed_class_property() {
23+
$r= $this->run('class <T> {
24+
private static string $MEMBER= "Test";
25+
26+
public function run() {
27+
return self::$MEMBER;
28+
}
29+
}');
30+
31+
Assert::equals('Test', $r);
32+
}
33+
2134
#[Test]
2235
public function class_method() {
2336
$r= $this->run('class <T> {
@@ -44,6 +57,19 @@ public function run() {
4457
Assert::equals('Test', $r);
4558
}
4659

60+
#[Test]
61+
public function typed_class_constant() {
62+
$r= $this->run('class <T> {
63+
private const string MEMBER = "Test";
64+
65+
public function run() {
66+
return self::MEMBER;
67+
}
68+
}');
69+
70+
Assert::equals('Test', $r);
71+
}
72+
4773
#[Test]
4874
public function dynamic_class_property() {
4975
$r= $this->run('class <T> {
@@ -154,6 +180,19 @@ public function run() {
154180
Assert::equals('Test', $r);
155181
}
156182

183+
#[Test]
184+
public function typed_instance_property() {
185+
$r= $this->run('class <T> {
186+
private string $member= "Test";
187+
188+
public function run() {
189+
return $this->member;
190+
}
191+
}');
192+
193+
Assert::equals('Test', $r);
194+
}
195+
157196
#[Test]
158197
public function instance_method() {
159198
$r= $this->run('class <T> {

0 commit comments

Comments
 (0)