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

PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket false positive for heredoc/nowdoc #3706

Open
mabar opened this issue Nov 3, 2022 · 0 comments

Comments

@mabar
Copy link

mabar commented Nov 3, 2022

Describe the bug

PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket forbids space before close bracket, but it should not be reported if last value in call is heredoc/nowdoc

Code sample

This is okay

function test()
{
	foo(
		'bar',
		'baz',
	);

	foo(
		<<<'MSG'
Long
Message
MSG,
	);
}

This is reported by rule

function test(): void
{
	foo(<<<'MSG'
Long
Message
MSG,
	);
}

Custom ruleset

<?xml version="1.0"?>
<ruleset>
  <rule ref="PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket"/>
</ruleset>

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
Expected 0 spaces before closing parenthesis; newline found (PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket)

Expected behavior
No error.

Interesting is that similar code without heredoc/nowdoc does not report problematic check, but instead reports PSR2.Methods.FunctionCallSignature.ContentAfterOpenBracket

function test(): void
{
	foo('bar',
		'baz',
	);
}

Reporting fixable ContentAfterOpenBracket would also work (and should be probably fixed too), because in case ContentAfterOpenBracket is fixed, then SpaceBeforeCloseBracket is no longer reported

Versions:

  • OS: Windows 10
  • PHP: 8.1.9
  • PHPCS: 3.7.1
  • Standard: orisai/coding-standard-php (but mostly irrelevant for the issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant