consistence / coding-standard
Consistence - Coding Standard - PHP Code Sniffer rules
Installs: 798 126
Dependents: 106
Suggesters: 0
Security: 0
Stars: 73
Watchers: 7
Forks: 20
Open Issues: 9
Requires
- php: ~7.1
- slevomat/coding-standard: ~6.0
- squizlabs/php_codesniffer: ~3.5.5
Requires (Dev)
- jakub-onderka/php-console-highlighter: 0.4
- jakub-onderka/php-parallel-lint: 1.0
- phing/phing: 2.16.1
- phpunit/phpunit: 7.5.1
- dev-master
- 3.10.1
- 3.10
- 3.9
- 3.8
- 3.7
- 3.6
- 3.5
- 3.4
- 3.3.1
- 3.3
- 3.2
- 3.1
- 3.0.1
- 3.0
- 2.4
- 2.3.1
- 2.3
- 2.2.1
- 2.2
- 2.1
- 2.0
- 1.1
- 1.0
- 0.13
- 0.12
- 0.11.1
- 0.11
- 0.10.1
- 0.10
- 0.9
- 0.8
- 0.7
- 0.6
- 0.5
- dev-dependabot/github_actions/coverallsapp/github-action-2.2.0
- dev-dependabot/github_actions/actions/checkout-3.5.3
- dev-dependabot/github_actions/shivammathur/setup-php-2.25.3
- dev-mutli-definitions
- dev-dev-3.x
This package is auto-updated.
Last update: 2024-10-12 16:57:07 UTC
README
Complete standard is described in a separate document.
This is a custom coding standard, which is used by all Consistence projects. It is also suitable to be used with any other project or as a foundation for your own standard.
The main objectives of this standard are:
- Strict (and predictable) code.
- Prevent common mistakes.
- Readability over writability (character count).
- Be friendly to diffs - minimize impact of changes.
- Do not write unnecessary/unreliable information.
Automatic checks
Automatic checks of this standard are implemented as sniffs for PHP_CodeSniffer (phpcs
), but not all the rules are checked yet. PHP_CodeSniffer contains also tool for automatic correction of certain errors phpcbf
, but this tool is also not 100% reliable - results produced by this may not conform to this standard.
These checks also include some code analysis tools, such as detecting unreachable code etc. These are not part of the standard, but should be helpful.
Stability
This package uses SemVer with following rules.
Coding Standard document should be considered the source of truth and main object of SemVer.
MAJOR
version will be incremented if new rules are added to the document.MINOR
version will be incremented if new sniffs are implemented to check for existing described rules.PATCH
version will be incremented for bug fixing - fixing a bug is considered everything which does not conform to the document - this may even lead to (temporarily) disabling an existing sniff - or part of it, until a better check is available or it is properly fixed.
The implementation of the automatic checks (both custom sniffs and the ruleset.xml file) are not subject to the SemVer and may change over time to accommodate changes in PHP_CodeSniffer and provided default sniffs, which are used also by this standard.
Recommended dependency on this package is on MINOR
version (e.g. ~1.0.0
), which means effectively:
- No new rules will be added.
- New automatic checks may be added.
- You get fixes for existing automatic checks, or some of them may be disabled, if regressions are found.
Installation & usage
Install package consistence/coding-standard
with Composer:
composer require --dev consistence/coding-standard
Then run phpcs
with this standard:
vendor/bin/phpcs --standard=vendor/consistence/coding-standard/Consistence/ruleset.xml --extensions=php --encoding=utf-8 -sp src
For further usage options see the PHP_CodeSniffer documentation.