Skip to content

Commit 48cea29

Browse files
committed
Verify parameter and property type restrictions work
1 parent f7c5e3f commit 48cea29

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,26 @@ public function run($h= self::$h) {
8181
}');
8282
Assert::equals(new Handle(0), $r);
8383
}
84+
85+
#[Test]
86+
public function typed_proprety() {
87+
$r= $this->run('use lang\ast\unittest\emit\Handle; class <T> {
88+
private Handle $h= new Handle(0);
89+
90+
public function run() {
91+
return $this->h;
92+
}
93+
}');
94+
Assert::equals(new Handle(0), $r);
95+
}
96+
97+
#[Test]
98+
public function typed_parameter() {
99+
$r= $this->run('use lang\ast\unittest\emit\Handle; class <T> {
100+
public function run(Handle $h= new Handle(0)) {
101+
return $h;
102+
}
103+
}');
104+
Assert::equals(new Handle(0), $r);
105+
}
84106
}

0 commit comments

Comments
 (0)