forked from apache/netbeans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix formatting for an indent of a return statement of a closure [apac…
…heGH-7140] - apache#7140 - Add an indent token to a return statement of a closure if a function invocation has the closure - Add unit tests Example: ```php class GH7140 { public function test1(): void { $this->test->test(Test::class, function (): Test { return new Test( test: 0, ); }); } } ``` Before: ```php class GH7140 { public function test1(): void { $this->test->test(Test::class, function (): Test { return new Test( test: 0, ); }); } } ``` After: ```php class GH7140 { public function test1(): void { $this->test->test(Test::class, function (): Test { return new Test( test: 0, ); }); } } ```
- Loading branch information
Showing
5 changed files
with
351 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
php/php.editor/test/unit/data/testfiles/formatting/issueGH7140.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class GH7140 { | ||
|
||
public function test1(): void { | ||
$this->test->test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
}); | ||
} | ||
|
||
public function test2(): void { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test3(): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
} | ||
|
||
function test(): Test { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
|
||
// formatted | ||
class GH7140_2 { | ||
|
||
public function test1(): void { | ||
$this->test->test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
}); | ||
} | ||
|
||
public function test2(): void { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test3(): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
} | ||
|
||
function test(): Test { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); |
113 changes: 113 additions & 0 deletions
113
php/php.editor/test/unit/data/testfiles/formatting/issueGH7140.php.testGH7140_01.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class GH7140 { | ||
|
||
public function test1(): void { | ||
$this->test->test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
}); | ||
} | ||
|
||
public function test2(): void { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test3(): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
} | ||
|
||
function test(): Test { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
|
||
// formatted | ||
class GH7140_2 { | ||
|
||
public function test1(): void { | ||
$this->test->test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
}); | ||
} | ||
|
||
public function test2(): void { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test3(): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
} | ||
|
||
function test(): Test { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); |
113 changes: 113 additions & 0 deletions
113
php/php.editor/test/unit/data/testfiles/formatting/issueGH7140.php.testGH7140_02.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class GH7140 { | ||
|
||
public function test1(): void { | ||
$this->test->test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
}); | ||
} | ||
|
||
public function test2(): void { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test3(): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
} | ||
|
||
function test(): Test { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
|
||
// formatted | ||
class GH7140_2 { | ||
|
||
public function test1(): void { | ||
$this->test->test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
}); | ||
} | ||
|
||
public function test2(): void { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
public function test3(): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
} | ||
|
||
function test(): Test { | ||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); | ||
} | ||
|
||
test(Test::class, | ||
function (): Test { | ||
return new Test( | ||
test: 0, | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters