-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add config option for number of spaces around conditions in PEAR.ControlStructures.MultiLineCondition #454
Comments
None of the included standards are conflicting That check was specifically added because it was missing from the PEAR standard and so wasn't fixing code correctly. Are you using 2 sniffs in a custom standard that conflict? If so, which 2 sniffs and what settings? What code are you running the standard over? |
Yes. It's This way |
I guess |
You can't use the PEAR sniff if you want to enforce a single space after the braces. PEAR disallows this, so sniffs in there are going to enforce 0 spaces. I think what you really need is an option in the PEAR sniff like the PSR sniff has. Does this sound right? |
Yes, option for specifying how much spaces needs to be after
If PEAR has a rule, that no space should be after |
The other issue is that valid PSR-2 code like this is now falsely reported: if (
(count($this->_values) && $data instanceof Query) ||
($this->_query && is_array($data))
) {
...
} Please revert this.
That means a real "space", not a newline-whitespace: // invalid PSR-2
if ( $foo ) {
} Note that you do NOT check on closing parentheses and whitespace before that one either (which would currently be ok, and would be inconsistent to the breaking chance introduced in 2.2.0). To sum things up: // multiline phpcs 2.2.0 (fixed)
if ($foo &&
$bar) { or continue to allow (IMO PSR-2 conform) // multiline without 2.2.0 regression
if (
$foo &&
$bar
) { And also note that the first is not good because the indentation level is not clear from that: // multiline phpcs 2.2.0 (fixed)
if ($foo &&
$bar) {
$foo = $bar; // This line has now the same indentation
} That proofs for me that this is indeed the wrong interpretation of what FIG implicitly meant here. if ($foo &&
$bar)
{
$foo = $bar; // This line has now has correct indentation
} |
@dereuromark The change you are talking about is here: ccf1f70 It is completely unrelated to the change @aik099 is talking about, which is only in the PEAR standard. You may want to submit a different report for the issue you are having. Then we can have a discussion about if newlines are the same thing as spaces or not. |
I am sorry if I confused the issues. If you want to can port the relevant information to a different issue. |
Got same issue in 2.2.0 with negation in front:
(PEAR.ControlStructures.MultiLineCondition.SpacingAfterOpenBrace) Temp solution: <rule ref="PEAR.ControlStructures.MultiLineCondition.SpacingAfterOpenBrace"><severity>0</severity></rule> |
In my |
The "SpacingAfterOpenBrace" error in "PEAR.ControlStructures.MultiLineCondition", that was introduced only in 2.2.0 release now checks that there must be no space between opening parenthesis of IF statement and 1st condition.
This conflicts with another sniff that allows for any X number of spaces (0 by default) that should be after opening parenthesis.
Error message:
First condition of a multi-line IF statement must directly follow the opening parenthesis
.The text was updated successfully, but these errors were encountered: