What rule prevents empty lines after the class opening brace?
Asked Answered
F

1

6

I'm looking for a rule that prevents empty lines after the opening brace of a class.

I found the rule Squiz.WhiteSpace.FunctionOpeningBraceSpace for functions, but I can't find any for classes.

Any suggestions are appreciated.

Freewill answered 28/3, 2017 at 9:7 Comment(3)
There is no included rule that can enforce no empty lines at the start of a class definition.Mali
Thanks @Greg Sherwood. Is there a documentation on how to write a rule?Freewill
There is a basic one here: github.com/squizlabs/PHP_CodeSniffer/wiki/… , but looking at existing sniffs would also be helpful.Mali
L
0

You are looking for no_blank_lines_after_class_opening from FriendsOfPHP/PHP-CS-Fixer.

If you want to use CodeSniffer, you still can. With EasyCodingStandard you can use both.

# easy-coding-standard.neon
checkers:
    - PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer

Do you want more? Check this short post.

Lunarian answered 2/6, 2017 at 22:26 Comment(2)
Thanks for this, but I don't want to use two tools. I use PHP_CodeSniffer in both PhpStorm and as a pipeline job in Gitlab. I want to write my own rule for this but didn't have the time yet.Freewill
I feel it the same way. It's one tool, both locally and on Github (Travis). PHP_CodeSniffer support in PHPStorm i s very limited and not flexible. See Travis, with composer.json setupLunarian

© 2022 - 2024 — McMap. All rights reserved.