nette / coding-standard
Requires
- php: ^8.0
- friendsofphp/php-cs-fixer: ^3.87
- kubawerlos/php-cs-fixer-custom-fixers: ^3.22
- slevomat/coding-standard: ^8.16
- squizlabs/php_codesniffer: ^4.0
Requires (Dev)
- nette/tester: ^2.6
- tracy/tracy: ^2.11
- dev-master / 3.x-dev
- v3.5.1
- v3.5.0
- v3.4.5
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.3.1
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.0
- v1.0.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.0
- v0.6.1
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.0
This package is auto-updated.
Last update: 2026-04-13 14:25:43 UTC
README
This is set of sniffs and fixers that checks and fixes code of Nette Framework against Coding Standard in Documentation.
Installation and Usage
Install the tool globally:
composer global require nette/coding-standard
Check coding standard in folders src and tests:
ecs check src tests
And fix it:
ecs fix src tests
The PHP version preset is automatically detected from your project's composer.json. If auto-detection is not possible, you can specify it manually:
ecs check src tests --preset php81
Custom Configuration
You can tweak rules per-project by placing ncs.php (PHP CS Fixer) and/or ncs.xml (PHP_CodeSniffer) in your project root. Both are discovered automatically and merged on top of the preset.
ncs.php returns an associative array of fixer overrides:
<?php return [ 'strict_comparison' => false, 'PhpCsFixerCustomFixers/commented_out_function' => false, // don't comment out dump(), var_dump(), ... ];
ncs.xml is a PHP_CodeSniffer ruleset. It does not need to reference the version preset – it is automatically combined with it. Use $presets/ to reference any bundled preset:
<?xml version="1.0"?> <ruleset name="MyProject"> <!-- Optional: enable use function/const imports --> <rule ref="$presets/optimize-fn.xml"/> <!-- Disable a rule --> <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/> </ruleset>
Ad-hoc Configuration via --config-file
For one-off runs (e.g. when you want to keep dump() calls intact during debugging) you can point to an additional config file without committing it to the project:
ecs fix src --config-file ./my-overrides.php
The tool is selected by extension: .php applies to PHP CS Fixer, .xml to PHP_CodeSniffer. You can pass --config-file twice to configure both tools. Project-level ncs.php/ncs.xml are still used; values from --config-file take precedence.
GitHub Actions
# .github/workflows/coding-style.yml steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: 8.1 - run: composer create-project nette/coding-standard temp/coding-standard - run: php temp/coding-standard/ecs check src tests