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

strange multiline if alignment #72

Open
trylika opened this issue Feb 26, 2015 · 1 comment
Open

strange multiline if alignment #72

trylika opened this issue Feb 26, 2015 · 1 comment
Labels

Comments

@trylika
Copy link
Contributor

trylika commented Feb 26, 2015

according to strictstandart, it suggests to aling multiline if like that:

            if (!isset($suggestion)
                || (isset($suggestion)
                && ($suggestion->status == SuggestionDocument::STATUS_NEW
                || $suggestion->status == SuggestionDocument::STATUS_NO_MATCHES))
            ) 

it doesn't look natural because of complexity of if structure. Maybe it should be aligned differently?

@tautrimas
Copy link
Contributor

You are right. Proper formatting should look like this:

        if (!isset($suggestion)
            || (isset($suggestion)
                && ($suggestion->status == SuggestionDocument::STATUS_NEW
                    || $suggestion->status == SuggestionDocument::STATUS_NO_MATCHES))
        ) {

Or even better like this:

        if (!isset($suggestion)
            || (
                isset($suggestion)
                && (
                    $suggestion->status == SuggestionDocument::STATUS_NEW
                    || $suggestion->status == SuggestionDocument::STATUS_NO_MATCHES
                )
            )
        ) {

In the latter variant, ONGR Strict Standard (Squiz standard) disallows hierarchical indentation and expects every line to begin with boolean operator.

  1. These rules should be either disabled, or programmed to only disallow boolean operator at the end of line.
  2. Incorrect forcing of hierarchical indentation should be fixed or disabled.

@tautrimas tautrimas added the bug label Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants