plumthedev / yii2-php-cs-fixer-config
Yii2 PHP coding standards configuration
Installs: 2 971
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- ext-json: *
- friendsofphp/php-cs-fixer: ^2.16
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-dev: ^2.0
Requires (Dev)
- phpunit/phpunit: 4.3.*
This package is auto-updated.
Last update: 2024-11-04 22:21:26 UTC
README
Yii2 PHP CS Fixer Config
PHP CS Fixer config for Yii2 projects. Contains Config and Finder which excludes by default Yii2 app basic and advanced directories.
The ruleset is grab from Yii 2 ecosystem and is automatically updated with it.
Installation
$ composer require --dev plumthedev/yii2-php-cs-fixer-config
Usage
Create a configuration file .php_cs
in the root of your project:
<?php $composerJsonPath = __DIR__ . '/composer.json'; $composerJson = file_get_contents($composerJsonPath); $composerProject = json_decode($composerJson); $currentYear = date('Y'); $projectHeader = <<<HEADER Yii2 PHP CS Fixer Config @author Kacper Pruszynski (plumthedev) @link https://github.com/plumthedev/yii2-php-cs-fixer-config @copyright Copyright (c) 2019 - {$currentYear} plumthedev @license https://github.com/plumthedev/yii2-php-cs-fixer-config/blob/master/LICENSE @version {$composerProject->version} HEADER; use plumthedev\PhpCsFixer\Config; $csConfig = Config::create(); // CS Config setup $csConfig->mergeRules([ 'header_comment' => [ 'header' => $projectHeader, 'commentType' => 'PHPDoc', 'separate' => 'bottom', ] ]); // CS Finder setup $csConfigFinder = $csConfig->getFinder(); $csConfigFinder->in(__DIR__); // set current project directory $csConfig->setFinder($csConfigFinder); return $csConfig;
Running the tests
PHPUnit
$ composer unit-tests
PHP CS Fixer
$ composer cs-fix
Contributing
This library is open source so if you want to contribute, you can.
Please submit bug reports, suggestions and pull requests to the GitHub issue tracker.
License
This project is licensed under the MIT License - see the LICENSE file for details