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

Switch and case indenting #20

Closed
MadCoder253 opened this issue Sep 23, 2016 · 3 comments
Closed

Switch and case indenting #20

MadCoder253 opened this issue Sep 23, 2016 · 3 comments

Comments

@MadCoder253
Copy link

Hi,

PHPCS is working great for me, very handy to update code as I work on it or making sure new code is formatted correctly.

It appears that the indenting check for the case may be off. If I have a switch statement inside a function, it is indented and then the case statement has an additional indent. However, the PHPCS shows the indentation is wrong, that it was expecting 4 spaces, but found 8. I think the check may not be taking into account the indent for being inside a function.

I double checked the standard.
http://www.php-fig.org/psr/psr-2/#5-2-switch-case

Here's my truncated sample code. There is an error message for each case line and the default line.

function createWebsiteImage($orig_name, $new_name, $path, $w, $h, $img) { switch($img) { **case 1:** $nw = 150; $nh = 205; break; **case 2:** $nw = 205; $nh = 150; break; **default:** $nw = 220; $nh = 220; break; } }

@bsgrd
Copy link

bsgrd commented Jan 30, 2017

I have the same problem.

@ikappas
Copy link
Owner

ikappas commented Jan 31, 2017

This plugin does not affect the sniffs in any way. This means that if you have false positives this means that something changed in phpcs. I think this kind of problem should be reported to https://github.com/squizlabs/PHP_CodeSniffer/issues directly

@ikappas ikappas closed this as completed Jan 31, 2017
@MadCoder253
Copy link
Author

Cool, thanks ikappas!

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

3 participants