Skip to content

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

@ondrejmirtes

Description

@ondrejmirtes

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions