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/FunctionCallSignature: new bug introduced via #2506 #2647

Closed
jrfnl opened this issue Oct 12, 2019 · 3 comments
Closed

PEAR/FunctionCallSignature: new bug introduced via #2506 #2647

jrfnl opened this issue Oct 12, 2019 · 3 comments
Milestone

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Oct 12, 2019

The fix for issue #2506 has introduced a new bug where code which is formatted perfectly fine, now triggers errors.

Simplest code pattern I could find to reproduce the issue:

$notices = array(
	'index' => sprintf(
		translation_function('a text string with %s placeholder'),
		'replacement'
	),
);

I think it may have something to do with function calls within array declarations as all the instances I've seen so far have involved those.

Command to reproduce:

phpcs -ps ./file.php --standard=PEAR --sniffs=PEAR.Functions.FunctionCallSignature --tab-width=4

Unexpected errors - no errors should be thrown, this code is clean:

FILE: I:\000_GitHub\PHPCS\Tests\phpcs-xxx.php
------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------
 5 | ERROR | [x] Multi-line function call not indented correctly; expected 4 spaces but
   |       |     found 8 (PEAR.Functions.FunctionCallSignature.Indent)
 6 | ERROR | [x] Multi-line function call not indented correctly; expected 4 spaces but
   |       |     found 8 (PEAR.Functions.FunctionCallSignature.Indent)
 7 | ERROR | [x] Multi-line function call not indented correctly; expected 0 spaces but
   |       |     found 4 (PEAR.Functions.FunctionCallSignature.Indent)
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------
@gsherwood gsherwood added this to the 3.5.1 milestone Oct 13, 2019
@gsherwood
Copy link
Member

Thanks a lot for finding and reporting this. Was an issue when the array index was a string - the sniff was trying to account for multi-line strings but I forgot about that case.

Any chance you can give the sniff another test?

@jrfnl
Copy link
Contributor Author

jrfnl commented Oct 14, 2019

Thanks. Tested and on the project where I found the issue all looks fine.

If I find additional issues at a later point, I will open a new issue.

@jrfnl jrfnl closed this as completed Oct 14, 2019
@gsherwood
Copy link
Member

Thanks a lot for retesting this.

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

2 participants