Skip to content

Commit 16aab10

Browse files
committed
Add test verifying private & protected accessibility from "clone with"
1 parent 2818d88 commit 16aab10

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ public function run($in) {
9999
);
100100
}
101101

102+
#[Test, Values(['protected', 'private'])]
103+
public function clone_with_can_access($modifiers) {
104+
$clone= $this->run('class %T {
105+
'.$modifiers.' $id= 1;
106+
107+
public function id() { return $this->id; }
108+
109+
public function run() {
110+
return clone($this, ["id" => 6100]);
111+
}
112+
}');
113+
114+
Assert::equals(6100, $clone->id());
115+
}
116+
102117
#[Test, Ignore('Could be done with reflection but with significant performance cost')]
103118
public function clone_with_respects_visibility() {
104119
$base= $this->type('class %T { private $id= 1; }');

0 commit comments

Comments
 (0)