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

Comments

Projects
None yet
2 participants
@jrfnl
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-Coding-Standards/WordPress-Coding-Standards#970

@gsherwood gsherwood added this to the 3.1.1 milestone Oct 12, 2017

@gsherwood gsherwood added the Bug label Oct 12, 2017

@gsherwood gsherwood changed the title from Inconsistency in the PEAR.Functions.FunctionCallSignature sniff icm no params to 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

Fixed bug #1512 : PEAR.Functions.FunctionCallSignature enforces space…
…s when no arguments if required spaces is not 0
@gsherwood

This comment has been minimized.

Show comment
Hide comment
@gsherwood

gsherwood Oct 12, 2017

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.

Member

gsherwood commented Oct 12, 2017

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.

@gsherwood gsherwood closed this Oct 12, 2017

@jrfnl jrfnl referenced this issue Oct 12, 2017

Open

Drop PHPCS 2.x support by August 31, 2018 #1048

0 of 23 tasks complete
@jrfnl

This comment has been minimized.

Show comment
Hide comment
@jrfnl

jrfnl Oct 12, 2017

Contributor

@gsherwood Thanks for making this fix!

Contributor

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