Skip to content

Repository files navigation

EasyCodingStandard configurations for Contao

This package includes the EasyCodingStandard configuration for Contao.

Installation

Add the package to your Contao installation via Composer:

composer require contao/easy-coding-standard --dev

Usage

Create a file named ecs.php in the root directory of your project.

<?phpdeclare(strict_types=1);
useContao\EasyCodingStandard\Set\SetList;
useSymplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure()
->withSets([SetList::CONTAO])
// Adjust the configuration according to your needs.
;

Then run the script like this:

vendor/bin/ecs check

What's inside?

The package contains the following custom fixers:

ClassDescription
AssertEqualsFixerReplaces asserEquals() with assertSame() in unit tests unless the method is used to compare two objects.
CaseCommentIndentationFixerFixes the comment indentation before a case statement.
ChainedMethodBlockFixerAdds an empty line after a block of chained method calls.
CommentLengthFixerAdjusts the length of comments regardless of their indentation so that each line is about 80 characters long.
ExpectsWithCallbackFixerAdjusts the indentation of $this->callback() calls inside the with() method of a unit test.
FindByPkFixerReplaces findByPk() calls with findById().
FunctionCallWithMultilineArrayFixerFixes the indentation of function calls with multi-line array arguments.
InlinePhpdocCommentFixerEnsures that inline phpDoc comments are not converted to regular comments.
IsArrayNotEmptyFixerFixes the order of isset() and empty() calls in conjunction with is_array() checks.
MockMethodChainingIndentationFixerFixes the indentation of chained mock methods.
MultiLineIfIndentationFixerFixes the indentation of multi-line if statements.
MultiLineLambdaFunctionArgumentsFixerFixes the indentation of multi-line lambda function arguments.
NoExpectsThisAnyFixerRemoves the explicit any() assertion in unit tests.
NoLineBreakBetweenMethodArgumentsFixerFixes the indentation of method declarations.
NoSemicolonAfterShortEchoTagFixerRemoves the semicolon after short echo tag instructions.
SingleLineConfigureCommandFixerFixes the indentation of Symfony command arguments and options.
TypeHintOrderFixerFixes the type hint order in method declarations.

The package contains the following custom sniffs:

ClassDescription
ContaoFrameworkClassAliasSniffPrevents using aliased Contao classes instead of their originals.
SetDefinitionCommandSniffPrevents using the setDefinition() method in Symfony commands.
UseSprintfInExceptionsSniffPrevents using string interpolation in exception messages.

License

Contao is licensed under the terms of the LGPLv3.

Getting support

Visit the support page to learn about the available support options.

About

EasyCodingStandard configurations for Contao

Resources

Contributing

Security policy

Stars

12 stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages