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

Fix formatting for method chaining [GH-7172] #7487

Conversation

junichi11
Copy link
Member

Example:

    $test1 = $example
            ->method(
        test: $param,
    );

    $test2 = $example
            ->method(
            test: $param,
        )
        ->field;

    $test3 = $example
            ->method(
            test: $param,
        )
        ->method2();

Before:

$test1 = $example
    ->method(
    test: $param,
);

$test2 = $example
        ->method(
            test: $param,
        )
    ->field;

$test3 = $example
    ->method(
        test: $param,
    )
    ->method2();

After:

$test1 = $example
    ->method(
        test: $param,
    );

$test2 = $example
    ->method(
        test: $param,
    )
    ->field;

$test3 = $example
    ->method(
        test: $param,
    )
    ->method2();

- apache#7172
- Check whether there is a new line between an object operator(or nullsafe operator) and a dispatcher
- Check whether a parent node is `FieldAccess`
- Add unit tests

Example:
```php
    $test1 = $example
            ->method(
        test: $param,
    );

    $test2 = $example
            ->method(
            test: $param,
        )
        ->field;

    $test3 = $example
            ->method(
            test: $param,
        )
        ->method2();
```

Before:
```php
$test1 = $example
    ->method(
    test: $param,
);

$test2 = $example
        ->method(
            test: $param,
        )
    ->field;

$test3 = $example
    ->method(
        test: $param,
    )
    ->method2();
```

After:
```php
$test1 = $example
    ->method(
        test: $param,
    );

$test2 = $example
    ->method(
        test: $param,
    )
    ->field;

$test3 = $example
    ->method(
        test: $param,
    )
    ->method2();
```
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Jun 16, 2024
@junichi11 junichi11 added this to the NB23 milestone Jun 16, 2024
@junichi11 junichi11 linked an issue Jun 16, 2024 that may be closed by this pull request
@junichi11 junichi11 requested a review from tmysik June 16, 2024 22:33
@tmysik
Copy link
Member

tmysik commented Jun 17, 2024

@junichi11 Great to have all those tests 👍

@junichi11
Copy link
Member Author

@tmysik Sure :) Thank you for your time!

@junichi11 junichi11 merged commit b4f3d08 into apache:master Jun 17, 2024
33 checks passed
@junichi11 junichi11 deleted the php-gh-7172-incorrect-formatting-for-method-chaining branch June 17, 2024 20:44
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.

Formatting problems in chaining functions in PHP
2 participants