Skip to content

Commit

Permalink
add php config for ecs version >9 (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgen <[email protected]>
  • Loading branch information
gitHomesPhp and Evgen authored Feb 5, 2021
1 parent 8360392 commit ddad9a5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ imports:
- { resource: vendor/umbrellio/code-style-php/umbrellio-cs.yml }
```
If major version of [EasyCodingStandard](https://github.com/Symplify/EasyCodingStandard) 9 or higher
create config `ecs.php`:

```php
<?php
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
return static function(ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SETS, [
'vendor/umbrellio/code-style-php/umbrellio-cs.php'
]);
};
```

---

### Usage
Expand All @@ -29,6 +49,12 @@ Run in CLI:
vendor/bin/ecs check src --fix --config=ecs.yml
```

or:

```
vendor/bin/ecs check src --fix --config=ecs.php
```

### Dependencies (and Links)

- [EasyCodingStandard](https://github.com/Symplify/EasyCodingStandard) - used library.
Expand Down
47 changes: 47 additions & 0 deletions umbrellio-cs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function(ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$services = $containerConfigurator->services();

$parameters->set(Option::SETS, [
SetList::CLEAN_CODE,
SetList::PSR_12,
SetList::COMMON,
SetList::SYMPLIFY,
]);

$services->set(DeclareStrictTypesFixer::class);
$services->set('SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff')
->property('allowPartialUses', true);

$parameters->set('skip', [
NotOperatorWithSuccessorSpaceFixer::class => null,
'Symplify\CodingStandard\Sniffs\Naming\TraitNameSniff' => null,
'Symplify\CodingStandard\Sniffs\Naming\InterfaceNameSniff' => null,
'Symplify\CodingStandard\Sniffs\Naming\ClassNameSuffixByParentSniff' => null,
'Symplify\CodingStandard\Sniffs\Naming\AbstractClassNameSniff' => null,
'Symplify\CodingStandard\Sniffs\Commenting\VarConstantCommentSniff' => null,
'Symplify\CodingStandard\Fixer\Commenting\BlockPropertyCommentFixer' => null,
'Symplify\CodingStandard\Fixer\Naming\PropertyNameMatchingTypeFixer' => null,
'Symplify\CodingStandard\Fixer\Import\ImportNamespacedNameFixer' => null,
'SlamCsFixer\FinalInternalClassFixer' => null,
'Symplify\CodingStandard\Sniffs\CleanCode\ForbiddenStaticFunctionSniff' => null,
'Symplify\CodingStandard\Sniffs\DependencyInjection\NoClassInstantiationSniff' => null,
'Symplify\CodingStandard\Sniffs\Architecture\ExplicitExceptionSniff' => null,
'SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff' => null,
AssignmentInConditionSniff::class => null,
'SlevomatCodingStandard\Sniffs\Classes\TraitUseDeclarationSniff' => null,
ClassAttributesSeparationFixer::class => null
]);
};

0 comments on commit ddad9a5

Please sign in to comment.