Skip to content

4.2 Traits need empty lines between blocks #60

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

Closed
Nex-Otaku opened this issue Feb 14, 2023 · 3 comments
Closed

4.2 Traits need empty lines between blocks #60

Nex-Otaku opened this issue Feb 14, 2023 · 3 comments

Comments

@Nex-Otaku
Copy link

image

See Steven Mcconnell "Code Complete", page 729, chapter 31 "Layout and Style".

Blocks (multiline statements) must be delimited with a blank line.

So instead of

<?php

class Talker
{
    use A;
    use B {
        A::smallTalk insteadof B;
    }
    use C {
        B::bigTalk insteadof C;
        C::mediumTalk as FooBar;
    }
}

you get

<?php

class Talker
{
    use A;

    use B {
        A::smallTalk insteadof B;
    }

    use C {
        B::bigTalk insteadof C;
        C::mediumTalk as FooBar;
    }
}

It's more readable and keeps consistent rythm throughout all text.

@KorvinSzanto
Copy link
Contributor

Are you saying we should have blank lines between all multiline statements in general? We currently allow that:

Blank lines MAY be added to improve readability and to indicate related blocks of code except where explicitly forbidden.

I don't think it makes sense to add blank lines between multiline statements as a requirement at this point because it would require changes to a ton of code in the wild with limited improvements to readability.

@Nex-Otaku
Copy link
Author

@KorvinSzanto yes but it's exactly for changes in existing code and impovements to readability this project does exist, doesn't it?

Anyway we can insert blank lines in trait example even without adding a rule about blank lines.

When people will start adjusting their style guides to match PER then they will look not only at explicit rules but for sure they will look at the code examples.

So it will encourage to use blank lines around multiline blocks not forbidding to do otherwise.

@KorvinSzanto
Copy link
Contributor

I'd accept a pull request that adds blank lines to the given example if that's all you're after but I don't think we want to require blank lines today.

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