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

[PHP] Formatting multiline function arguments is incorrect #6714

Closed
terax6669 opened this issue Nov 17, 2023 · 5 comments · Fixed by #6877
Closed

[PHP] Formatting multiline function arguments is incorrect #6714

terax6669 opened this issue Nov 17, 2023 · 5 comments · Fixed by #6877
Assignees
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Milestone

Comments

@terax6669
Copy link

terax6669 commented Nov 17, 2023

Apache NetBeans version

Apache NetBeans 20 release candidate

What happened

NetBeans formats multiline function arguments incorrectly:

Actual

<?php

class F
{
	public array $x = [];
	public array $y = [];

	public function a()
	{
		return array_merge(
			$this->x,
   $this->y,
		);
	}

	public function b()
	{
		return array_merge(
			$this->nonExistant($anyArgument),
					  $this->y,
		);
	}
}

array_merge(
	$x,
 $y,
);

Expected

<?php

class F
{
	public array $x = [];
	public array $y = [];

	public function a()
	{
		return array_merge(
			$this->x,
			$this->y,
		);
	}

	public function b()
	{
		return array_merge(
			$this->nonExistant($anyArgument),
			$this->y,
		);
	}
}

array_merge(
	$x,
	$y,
);

How to reproduce

Use the code attached above and use Source->Format (alt+shift+F)

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

21.0.1

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

I use tabs for indent.
Turning off Formatting -> Alignment -> Multiline Alignment -> Method Call Arguments resolves the issue.

image

It doesn't work in NetBeans 18 as well, so it's not caused by any recent changes.

Are you willing to submit a pull request?

No

@terax6669 terax6669 added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Nov 17, 2023
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Nov 18, 2023
@junichi11
Copy link
Member

Please also write an expected result and an actual result.

@terax6669
Copy link
Author

Updated description

@MartynasJanu
Copy link

Don't You mean this is the expected? Or am I understanding this incorrectly..

class F {

    public array $x = [];
    public array $y = [];

    public function a() {
        return array_merge(
            $this->x,
            $this->y,
        );
    }

    public function b() {
        return array_merge(
            $this->nonExistant($anyArgument),
            $this->y,
        );
    }
}

array_merge(
    $x,
    $y,
);

@terax6669
Copy link
Author

@MartynasJanu

I don't see any difference between my expected section and your code block.

If it's not clear the issue is in indentation.

IMG_20231204_115829

@junichi11
Copy link
Member

Reproducible. Thanks.

@junichi11 junichi11 removed the needs:triage Requires attention from one of the committers label Dec 23, 2023
@junichi11 junichi11 self-assigned this Dec 23, 2023
@junichi11 junichi11 added this to the NB21 milestone Dec 24, 2023
junichi11 added a commit to junichi11/netbeans that referenced this issue Dec 24, 2023
…che#6714

- apache#6714
- Consider the TAB size when a column size is got

Example:
```php
array_merge(
	$x,
	$y,
);
```

Before:

```php
array_merge(
	$x,
 $y,
);
```

After:

```php
array_merge(
        $x,
        $y,
);
```

- Keep the last anchor to a stack when a method calls are nested

Example:

```php
nestedCall(
	something(
				$arg1,
			$arg2,
		C::something(
					$x,
					$y,
				$z,
		)
	),
			$y,
		$z,
);
```

Before:

```php
nestedCall(
	something(
		$arg1,
  $arg2,
  C::something(
			$x,
   $y,
   $z,
		)
	),
   $y,
   $z,
);
```

After:

```php
nestedCall(
	something(
		$arg1,
		$arg2,
		C::something(
			$x,
			$y,
			$z,
		)
	),
	$y,
	$z,
);
```

- Add unit tests
junichi11 added a commit that referenced this issue Dec 24, 2023
…ignment

Fix the formatting for the method call arguments alignment option #6714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants