symplify / easy-coding-standard-prefixed
Prefixed scoped version of ECS package
Installs: 227 749
Dependents: 7
Suggesters: 2
Security: 0
Stars: 4
Watchers: 1
Forks: 3
pkg:composer/symplify/easy-coding-standard-prefixed
- dev-main
- v9.3.1
- v9.3.0
- v9.2.23
- v9.2.22
- v9.2.21
- v9.2.19
- v9.2.18
- v9.2.17
- v9.2.15
- v9.2.14
- v9.2.13
- v9.2.12
- v9.2.11
- v9.2.10
- v9.2.9
- v9.2.8
- v9.2.7
- v9.2.6
- v9.2.5
- v9.2.4
- v9.2.3
- v9.2.2
- 9.2.1
- 9.2.0
- 9.1.9
- 9.1.8
- 9.1.7
- 9.1.6
- 9.1.5
- 9.1.4
- 9.1.3
- 9.0.19
- 9.0.18
- 9.0.17
- 9.0.16
- 9.0.15
- 9.0.14
- 9.0.13
- 9.0.12
- 9.0.11
- 9.0.10
- 9.0.9
- 9.0.8
- 9.0.7
- 9.0.6
- 9.0.5
- 9.0.4
- 9.0.3
- 9.0.2
- 9.0.1
- 9.0.0
- 9.0.0-rc1
- 9.0.0-BETA9
- 9.0.0-BETA8
- 9.0.0-BETA7
- 9.0.0-BETA6
- 9.0.0-BETA5
- 9.0.0-BETA4
- 9.0.0-BETA3
- 9.0.0-BETA2
- 9.0.0-BETA1
- 8.3.48
- 8.3.47
- 8.3.46
- 8.3.45
- 8.3.44
- 8.3.43
- 8.3.42
- 8.3.41
- 8.3.40
- 8.3.39
- 8.3.38
- 8.3.37
- 8.3.36
- 8.3.35
- 8.3.34
- 8.3.33
- 8.3.32
- 8.3.31
- 8.3.30
- 8.3.29
- 8.3.28
- 8.3.27
- 8.3.26
- 8.3.25
- 8.3.24
- 8.3.23
- 8.3.22
- 8.3.21
- 8.3.20
- 8.3.19
- 8.3.18
- 8.3.17
- 8.3.16
- 8.3.15
- 8.3.14
- 8.3.13
- 8.3.12
- 8.3.11
- 8.3.10
- 8.3.9
- 8.3.8
- 8.3.7
- 8.3.6
- 8.3.5
- 8.3.4
- 8.3.3
- 8.3.2
- 8.3.1
- 8.3.0
- 8.2.27
- 8.2.26
- 8.2.25
- 8.2.24
- 8.2.23
- 8.2.22
- 8.2.21
- 8.2.20
- 8.2.19
- 8.2.18
- 8.2.17
- v8.2.16
- v8.2.15
- v8.2.14
- v8.2.13
- v8.2.12
- v8.2.11
- v8.2.10
- v8.2.9
- v8.2.8
- v8.2.7
- v8.2.6
- v8.2.5
- v8.2.4
- v8.2.3
- v8.2.2
- v8.2.1
- v8.2.0
- v8.1.21
- v8.1.20
- v8.1.19
- v8.1.18
- v8.1.17
- v8.1.16
- v8.1.15
- v8.1.14
- v8.1.13
- v8.1.12
- v8.1.11
- v8.1.10
- v8.1.9
- v8.1.8
- v8.1.7
- v8.1.6
- v8.1.5
- v8.1.4
- v8.1.3
- v8.1.2
- v8.1.1
- v8.1.0
- v8.0.1
- v8.0.0
- v8.0.0-beta4
- v8.0.0-beta3
- v8.0.0-beta2
- v8.0.0-beta1
- v7.3.18
- v7.3.17
- v7.3.16
- v7.3.15
- v7.3.14
- v7.3.13
- v7.3.12
- v7.3.11
- v7.3.10
- v7.3.9
- v7.3.8
- v7.3.7
- v7.3.6
- v7.3.5
- v7.3.4
- v7.3.3
- v7.3.2
- v7.3.1
- v7.3.0
- v7.2.20
- v7.2.19
- v7.2.18
- v7.2.17
- v7.2.16
- v7.2.15
- v7.2.14
- v7.2.13
- v7.2.12
- v7.2.11
- v7.2.10
- v7.2.9
- v7.2.8
- v7.2.7
- v7.2.6
- v7.2.5
- v7.2.4
- v7.2.3
- v7.2.2
This package is auto-updated.
Last update: 2021-05-07 09:45:30 UTC
README
Features
- Use PHP_CodeSniffer || PHP-CS-Fixer - anything you like
- 2nd run under few seconds with un-changed file cache
- Skipping files for specific checkers
- Prepared sets - PSR12, Symfony, Common, Array, Symplify and more...
- Prefixed version in case of conflicts on install
Are you already using another tool?
- How to Migrate From PHP_CodeSniffer to EasyCodingStandard in 7 Steps
- How to Migrate From PHP CS Fixer to EasyCodingStandard in 6 Steps
Install
composer require symplify/easy-coding-standard --dev
Prefixed Version
The prefix verion can be used when there are dependancy clashes. Head over to the "Easy Coding Standard Prefixed" repository for more information.
composer require symplify/easy-coding-standard-prefixed --dev
Usage
1. Create Configuration and Setup Checkers
// ecs.php use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\EasyCodingStandard\ValueObject\Set\SetList; return static function (ContainerConfigurator $containerConfigurator): void { // A. standalone rule $services = $containerConfigurator->services(); $services->set(ArraySyntaxFixer::class) ->call('configure', [[ 'syntax' => 'short', ]]); // B. full sets $containerConfigurator->import(SetList::PSR_12); };
2. Run in CLI
# dry vendor/bin/ecs check src # fix vendor/bin/ecs check src --fix
Features
How to load own config?
vendor/bin/ecs check src --config another-config.php
Configuration
Configuration can be extended with many options. Here is list of them with example values and little description what are they for:
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symplify\EasyCodingStandard\ValueObject\Option; return static function (ContainerConfigurator $containerConfigurator): void { $parameters = $containerConfigurator->parameters(); // alternative to CLI arguments, easier to maintain and extend $parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']); // run single rule only on specific path $parameters->set(Option::ONLY, [ ArraySyntaxFixer::class => [__DIR__ . '/src/NewCode'], ]); $parameters->set(Option::SKIP, [ // skip paths with legacy code __DIR__ . '/packages/*/src/Legacy', ArraySyntaxFixer::class => [ // path to file (you can copy this from error report) __DIR__ . '/packages/EasyCodingStandard/packages/SniffRunner/src/File/File.php', // or multiple files by path to match against "fnmatch()" __DIR__ . '/packages/*/src/Command', ], // skip rule completely ArraySyntaxFixer::class, // just single one part of the rule? ArraySyntaxFixer::class . '.SomeSingleOption', // ignore specific error message 'Cognitive complexity for method "addAction" is 13 but has to be less than or equal to 8.', ]); // scan other file extendsions; [default: [php]] $parameters->set(Option::FILE_EXTENSIONS, ['php', 'phpt']); // configure cache paths & namespace - useful for Gitlab CI caching, where getcwd() produces always different path // [default: sys_get_temp_dir() . '/_changed_files_detector_tests'] $parameters->set(Option::CACHE_DIRECTORY, '.ecs_cache'); // [default: \Nette\Utils\Strings::webalize(getcwd())'] $parameters->set(Option::CACHE_NAMESPACE, 'my_project_namespace'); // indent and tabs/spaces // [default: spaces] $parameters->set(Option::INDENTATION, 'tab'); // [default: PHP_EOL]; other options: "\n" $parameters->set(Option::LINE_ENDING, "\r\n"); };
Codings Standards in Markdown
How to correct PHP snippets in Markdown files?
vendor/bin/ecs check-markdown README.md
vendor/bin/ecs check-markdown README.md docs/rules.md
# to fix them, add --fix
vendor/bin/ecs check-markdown README.md docs/rules.md --fix
Do you have already paths defined in ecs.php config? Drop them from CLI and let ECS use those:
vendor/bin/ecs check-markdown --fix
FAQ
How can I see all loaded checkers?
vendor/bin/ecs show vendor/bin/ecs show --config ...
How do I clear cache?
vendor/bin/ecs check src --clear-cache
Run on Git Diff Changed Files Only
Execution can be limited to changed files using the process option --match-git-diff:
vendor/bin/ecs check src --match-git-diff
This option will filter the files included by the configuration, creating an intersection with the files listed in git diff.
Your IDE Integration
PHPStorm
ECS can be used as an External Tool
Go to Preferences > Tools > External Tools and click + to add a new tool.
- Name:
ecs(Can be any value) - Description:
easyCodingStandard(Can be any value) - Program:
$ProjectFileDir$/vendor/bin/ecs(Path toecsexecutable; On Windows path separators must be a\) - Parameters:
check $FilePathRelativeToProjectRoot$(append--fixto auto-fix) - Working directory:
$ProjectFileDir$
Press Cmd/Ctrl + Shift + A (Find Action), search for ecs, and then hit Enter. It will run ecs for the current file.
To run ecs on a directory, right click on a folder in the project browser go to external tools and select ecs.
You can also create a keyboard shortcut in Preferences > Keymap to run ecs.
Visual Studio Code
EasyCodingStandard for Visual Studio Code extension adds support for running EasyCodingStandard inside the editor.
Tool Integration
| Tool | Extension | Description |
|---|---|---|
| GrumPHP | ECS Task | Provides a new task for GrumPHP which runs ECS |
Report Issues
In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker
Contribute
The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.


