facile-it / facile-coding-standard
Facile.it coding standard
Installs: 100 447
Dependents: 26
Suggesters: 0
Security: 0
Stars: 10
Watchers: 26
Forks: 8
Open Issues: 4
Type:composer-plugin
Requires
- php: ^7.4 || ^8.0
- composer-plugin-api: ^2.0
- ext-json: *
- friendsofphp/php-cs-fixer: ^3.4
- symfony/console: ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/polyfill-php80: ^1.0
Requires (Dev)
- composer/composer: ^2.0
- composer/semver: ^3.0
- mikey179/vfsstream: ^1.6.8
- phpspec/prophecy: ^1.10
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.5.28 || ^10.5.36
- psalm/plugin-phpunit: ^0.19.0
- vimeo/psalm: ^5.23
- dev-master
- 1.x-dev
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 1.0.0-RC1
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.0
- dev-arguments-trailing-commas
- dev-drop-trailing-commas
- dev-solve-deprecated-rules
- dev-deprecated-rules
- dev-add-new-rules
- dev-symfony6
- dev-check-upgrade-no-interactive
- dev-updated-rules-0.4
This package is auto-updated.
Last update: 2024-12-18 16:43:46 UTC
README
Repository with PHP coding standard ruleset, based on PHP-CS-Fixer.
Installation
Currently, Composer is the only supported installation tool.
$ composer require --dev facile-it/facile-coding-standard
When you install it, a plugin will ask you some questions to setup your project automatically.
The installer will add a .php-cs-fixer.dist.php
file in your project root directory,
then you can edit manually if you need some changes.
The CS config will be configured to find your project files using composer autoload sources.
Only psr-0
, psr-4
and classmap
autoloads are supported.
The installer will also add two scripts in your composer.json
;
"scripts": { "cs-check": "php-cs-fixer fix --dry-run --diff", "cs-fix": "php-cs-fixer fix --diff" }
Configuration
The installation configuration should be enough to use it.
If you need to change the CS config file, we suggest to don't edit the main .php-cs-fixer.dist.php
file.
You can create a new file .php-cs-fixer.php
with something like this:
<?php /** @var PhpCsFixer\Config $config */ $config = require __DIR__ . '/.php-cs-fixer.dist.php'; // change your configuration... $config->setUsingCache(false); return $config;
Usage
To start code style check:
$ composer cs-check
To automatically fix code style:
$ composer cs-fix
PhpCsFixer configuration
See PhpCsFixer GitHub page.
Risky rules
Risky rules may be unstable, and cause unintended behavioral changes to your code. If you want to add these rules, you can create your own .php-cs-fixer.php
configuration:
<?php /** @var \PhpCsFixer\Config $config */ $config = include __DIR__ . '/.php-cs-fixer.dist.php'; $rulesProvider = new Facile\CodingStandards\Rules\CompositeRulesProvider([ new Facile\CodingStandards\Rules\DefaultRulesProvider(), new Facile\CodingStandards\Rules\RiskyRulesProvider(), new Facile\CodingStandards\Rules\ArrayRulesProvider([ // additional rules or rules to override ]), ]); $config->setRules($rulesProvider->getRules()); return $config;
Generate configuration
If you have any problem updating to a new version, you can regenerate
the default .php-cs-fixer.dist.php
with the command:
$ composer facile-cs-create-config
$ composer facile-cs-create-config --help
Usage:
facile-cs-create-config [options]
Options:
--no-dev Do not include autoload-dev directories
--no-risky Do not include risky rules