cakephp / cakephp-codesniffer
CakePHP CodeSniffer Standards
Installs: 8 225 149
Dependents: 637
Suggesters: 48
Security: 0
Stars: 238
Watchers: 34
Forks: 84
Open Issues: 6
Type:phpcodesniffer-standard
Requires
- php: >=8.1.0
- phpstan/phpdoc-parser: ^1.4.5
- slevomat/coding-standard: ^8.15
- squizlabs/php_codesniffer: ^3.9
Requires (Dev)
- phpunit/phpunit: ^9.3.4
- 5.x-dev
- 5.1.3
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.1
- 5.0.0
- 4.x-dev
- 4.7.0
- 4.6.0
- 4.5.1
- 4.5.0
- 4.4.2
- 4.4.1
- 4.4.0
- 4.3.0
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.1
- 4.0.0
- 4.0.0-beta5
- 4.0.0-beta4
- 4.0.0-beta3
- 4.0.0-beta2
- 4.0.0-beta1
- 3.x-dev
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.5
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.1.31
- 0.1.30
- 0.1.29
- 0.1.28
- 0.1.27
- 0.1.26
- 0.1.25
- 0.1.24
- dev-new-sniffs
- dev-5.next
- dev-5.x-updates
- dev-unused-closure-vars
This package is auto-updated.
Last update: 2024-11-23 07:52:16 UTC
README
This code works with squizlabs/php_codesniffer and checks code against the coding standards used in CakePHP.
This sniffer package follows PSR-12 completely and ships with a lot of additional fixers on top.
Which version should I use?
See version map.
Installation
You should install this codesniffer with composer:
composer require --dev cakephp/cakephp-codesniffer
vendor/bin/phpcs --config-set installed_paths /path/to/your/app/vendor/cakephp/cakephp-codesniffer
The second command lets phpcs
know where to find your new sniffs. Ensure that
you do not overwrite any existing installed_paths
value. Alternatively, install
the dealerdirect/phpcodesniffer-composer-installer
composer package which will handle configuring the phpcs
installed_paths
for you.
Usage
⚠️ Warning when these sniffs are installed with composer, ensure that
you have configured the CodeSniffer installed_paths
setting.
Depending on how you installed the code sniffer changes how you run it. If you have installed phpcs, and this package with PEAR, you can do the following:
vendor/bin/phpcs --colors -p -s --standard=CakePHP /path/to/code/
You can also copy the phpcs.xml.dist
file to your project's root folder as phpcs.xml
.
This file will import the CakePHP Coding Standard. From there you can edit it to
include/exclude as needed. With this file in place, you can run:
vendor/bin/phpcs --colors -p -s /path/to/code/
If you are using Composer to manage your CakePHP project, you can also add the below to your composer.json file:
{ "scripts": { "cs-check": "vendor/bin/phpcs --colors -p -s --extensions=php src/ tests/" } }
Running Tests
You can run tests with composer. Because of how PHPCS test suites work, there is
additional configuration state in phpcs
that is required.
composer test
Once this has been done once, you can use composer phpunit
to run the
tests for the rules in this repository.
Contributing
If you'd like to contribute to the Code Sniffer, you can fork the project add features and send pull requests.
Releasing CakePHP Code Sniffer
- Create a signed tag
- Write the changelog in the tag commit