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

Generic.WhiteSpace.ArbitraryParenthesesSpacing false positive for return new parent() #3618

Closed
ondrejmirtes opened this issue Jun 23, 2022 · 2 comments · Fixed by #3619
Closed

Comments

@ondrejmirtes
Copy link

Describe the bug

When doing return new parent(), the code reports:

---------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 267 | WARNING | Empty set of arbitrary parentheses found.
     |         | (Generic.WhiteSpace.ArbitraryParenthesesSpacing.FoundEmpty)
---------------------------------------------------------------------------------------------------------------------

Code sample

	public function generalize(GeneralizePrecision $precision): Type
	{
		return new parent();
	}

Custom ruleset

https://github.com/phpstan/phpstan-src/blob/adf7313ac266ef217cf144fc4901a2998ead4df2/phpcs.xml

Expected behavior

No error should be reported. New with parentheses is required by SlevomatCodingStandard.ControlStructures.NewWithParentheses.MissingParentheses.

Versions (please complete the following information):

  • OS: macOS 12.4
  • PHP: 8.1.4
  • PHPCS: 3.7.1
  • Standard: see custom ruleset

Additional context
Add any other context about the problem here.

@jrfnl
Copy link
Contributor

jrfnl commented Jun 23, 2022

@ondrejmirtes Thanks for reporting this. I've reproduced the issue and will pull a fix in a moment.

@jrfnl
Copy link
Contributor

jrfnl commented Jun 23, 2022

@ondrejmirtes PR #3619 should fix this. Testing appreciated.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Jun 27, 2022
@gsherwood gsherwood changed the title return new parent() is reported by Generic.WhiteSpace.ArbitraryParenthesesSpacing.FoundEmpty Generic.WhiteSpace.ArbitraryParenthesesSpacing false positive for return new parent() Jun 27, 2022
gsherwood added a commit that referenced this issue Jun 27, 2022
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Jun 27, 2022
@gsherwood gsherwood added this to the 3.7.2 milestone Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging a pull request may close this issue.

3 participants