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

PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 #1512

Closed
jrfnl opened this issue Jun 17, 2017 · 2 comments
Milestone

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Jun 17, 2017

The PEAR.Functions.FunctionCallSignature allows to configure how many spaces are required after the open parenthesis and before the close parenthesis through the $requiredSpacesAfterOpen and $requiredSpacesBeforeClose properties.

For a single line function call without parameters, the behaviour is inconsistent however when these properties are set to something other than 0.

	<rule ref="PEAR.Functions.FunctionCallSignature">
		<properties>
			<property name="requiredSpacesAfterOpen" value="1"/>
			<property name="requiredSpacesBeforeClose" value="1"/>
		</properties>
	</rule>

Current behaviour:

  • If there are no tokens between the parenthesis, it bows out of the processSingleLineCall() method.
  • If there is only a whitespace token between the parenthesis, but this contains more than one space, it will report this and the auto-fixer will correct it to the expected 1 space.
  • If there is a whitespace token between the parenthesis with only one space, it will stay silent.

Expected behaviour:

  • Either always remove the whitespace between the parenthesis if there are no parameters
  • Or always correct it to the expected nr of spaces

Example code:

ms_cookie_constants(); // Is ignored.
ms_cookie_constants( ); // Is ignored as has one space.
ms_cookie_constants(      ); // Gets corrected to one space.

I'd be happy to send in a PR to make the behaviour consistent, but would want to know which of the expected behaviours is desired.

Related: WordPress/WordPress-Coding-Standards#970

@gsherwood gsherwood added this to the 3.1.1 milestone Oct 12, 2017
@gsherwood gsherwood changed the title Inconsistency in the PEAR.Functions.FunctionCallSignature sniff icm no params PEAR.Functions.FunctionCallSignature enforces spaces when no arguments if required spaces is not 0 Oct 12, 2017
gsherwood added a commit that referenced this issue Oct 12, 2017
…s when no arguments if required spaces is not 0
@gsherwood
Copy link
Member

This was obviously something I didn't consider when adding that option for setting the required spaces. Now, if the function contains no args and no comments, the required spaces is reset back to zero. Thanks for reporting this.

@jrfnl
Copy link
Contributor Author

jrfnl commented Oct 12, 2017

@gsherwood Thanks for making this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants