Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETBEANS-3391] Support PSR-12 valid formatting rules #3254

Merged
merged 2 commits into from Oct 20, 2021

Conversation

junichi11
Copy link
Member

@junichi11 junichi11 commented Oct 19, 2021

https://issues.apache.org/jira/browse/NETBEANS-3391

  • Add new wrapping options for parentheses of "for/foreach" and Method Call Args, and Method Params
  • Wrap After '(' and Wrap ')': Wrap when there is a newline within ()
  • Keep ')' and '{' on the same line: Keep them when the Braces option
    for Method Declaration is "New Line" and wrap ()

e.g.

//for ($index = 0;
//$index < count($array);
//$index++) {
//    echo $index;
//}
for (
        $index = 0;
        $index < count($array);
        $index++
) {
    echo $index;
}

//test($param1,
//        $param2,
// $param3);
test(
        $param1,
        $param2,
        $param3
);

//function test(
//$param1,
//$param2,
//$param3,): void {
//
//}
function test(
        $param1,
        $param2,
        $param3,
): void {

}

// Keep ')' and '{' on the same line
// the Braces option for Method Declaration is "New Line"
//function test($param1, int $param2): void{
//}
function test($param1, int $param2): void
{

}

// Keep ')' and '{' on the same line
// the Braces option for Method Declaration is "New Line"
//function test(int $param1,
//        Test &$param2,
//): void{
//}
function test(
        int $param1,
        Test &$param2,
): void {

}
  • Note: It doesn't work correctly with new options yet when the wrapping
    option of Method Parameters/Method Call Arguments/For is "If Long"

Screenshot

netbeans-3391-formatting-wrapping-options

- Add new wrapping options for parentheses of "for/foreach" and Method Call Args, and Method Params
- Wrap After '(' and Wrap ')': Wrap when there is a newline within ()
- Keep ')' and '{' on the same line: Keep them when the Braces option
for Method Declaration is "New Line" and wrap ()

e.g.
```php
//for ($index = 0;
//$index < count($array);
//$index++) {
//    echo $index;
//}
for (
        $index = 0;
        $index < count($array);
        $index++
) {
    echo $index;
}

//test($param1,
//        $param2,
// $param3);
test(
        $param1,
        $param2,
        $param3
);

//function test(
//$param1,
//$param2,
//$param3,): void {
//
//}
function test(
        $param1,
        $param2,
        $param3,
): void {

}

// Keep ')' and '{' on the same line
// the Braces option for Method Declaration is "New Line"
//function test($param1, int $param2): void{
//}
function test($param1, int $param2): void
{

}

// Keep ')' and '{' on the same line
// the Braces option for Method Declaration is "New Line"
//function test(int $param1,
//        Test &$param2,
//): void{
//}
function test(
        int $param1,
        Test &$param2,
): void {

}

```
- Note: It doesn't work correctly with new options yet when the wrapping
option of Method Parameters/Method Call Arguments/For is "If Long"
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Oct 19, 2021
@junichi11 junichi11 added this to the 12.6 milestone Oct 19, 2021
@junichi11 junichi11 requested a review from tmysik October 19, 2021 05:52
@junichi11
Copy link
Member Author

@tmysik Could you please have a look at this although I think it's impossible to review all? Sorry for the huge changes.

Feature freeze: https://lists.apache.org/thread.html/r3201513afcc326391b344a33a32475e7e61b661f4342281cbe93acfe%40%3Cdev.netbeans.apache.org%3E
cc: @neilcsmith-net

@junichi11
Copy link
Member Author

Will add a screenshot of the option later.

Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible to review such a huge PR, at least for me :)

However, I just looked into a couple of tests and everything seems to me to be OK.

@tmysik
Copy link
Member

tmysik commented Oct 20, 2021

@junichi11

Let me know if I can merge it (when? now?).

Since we have many tests here, I would expect that it should be fine.

Thanks a lot for your great work!

@junichi11
Copy link
Member Author

@tmysik

It is not possible to review such a huge PR, at least for me :)

Yes :)

Let me know if I can merge it (when? now?).

Since we have many tests here, I would expect that it should be fine.

Yes. Let's merge it.

Thanks a lot for your review!

@tmysik tmysik merged commit 0b2ad13 into apache:master Oct 20, 2021
@junichi11 junichi11 deleted the netbeans-3391-psr12 branch October 20, 2021 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants