File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
test/php/lang/ast/unittest/emit Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ trait RewriteCallables {
1313
1414 protected function emitCallable ($ result , $ callable ) {
1515 if ($ callable ->expression instanceof Literal && 'clone ' === $ callable ->expression ->expression ) {
16- $ result ->out ->write ('fn($o) => clone $o ' );
16+ $ result ->out ->write ('( fn($o) => clone $o) ' );
1717 } else {
1818 $ this ->emitPartial ($ result , $ callable );
1919 }
Original file line number Diff line number Diff line change @@ -228,6 +228,18 @@ public function run() {
228228 Assert::equals ('cba ' , $ f ('abc ' ));
229229 }
230230
231+ #[Test]
232+ public function clone () {
233+ $ handles = $ this ->run ('use lang\ast\unittest\emit\Handle; class %T {
234+ public function run() {
235+ $a= new Handle(0);
236+ return [$a, $a |> clone(...)];
237+ }
238+ } ' );
239+ $ handles [1 ]->redirect (4 );
240+ Assert::notEquals ($ handles [0 ], $ handles [1 ]);
241+ }
242+
231243 #[Test]
232244 public function partial_function_application () {
233245 $ f = $ this ->run ('class %T {
You can’t perform that action at this time.
0 commit comments