From bd3801c08f56f7ed8d633e1927290eab1544a235 Mon Sep 17 00:00:00 2001 From: lotyp Date: Sat, 18 May 2024 19:17:39 +0300 Subject: [PATCH 1/2] docs: updating readme --- README.md | 143 ++++++++++++++++++++++++++++---------------------- composer.json | 11 ++++ 2 files changed, 92 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index b803264..ee61a2f 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,13 @@ Wrapper with pre-defined rules around the [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) package โ€” A tool to automatically fix PHP Coding Standards issues. -If you **like/use** this package, please consider **starring** it. Thanks! +This repository aims to provide a standardized way to apply coding standards across multiple projects, ensuring consistency and adherence to best practices. + +By using predefined rulesets, it simplifies the setup process and allows teams to quickly integrate PHP-CS-Fixer into their development workflow. + +
+ +If you **like/use** this package, please consider โญ๏ธ **starring** it. Thanks!
@@ -38,100 +44,111 @@ If you **like/use** this package, please consider **starring** it. Thanks! Require as dependency: ```bash -composer req wayofdev/cs-fixer-config +composer req --dev wayofdev/cs-fixer-config ```
## ๐Ÿ›  Configuration -1. Create PHP file and name it `.php-cs-fixer.dist.php` and place it inside root directory of project. It will be recognized by PHP CS Fixer automatically. +### โ†’ Setup -2. Example contents of `.php-cs-fixer.dist.php` file: +- Create PHP file and name it `.php-cs-fixer.dist.php` and place it inside root directory of project. It will be recognized by PHP CS Fixer automatically. + +- Example contents of `.php-cs-fixer.dist.php` file: ```php - inDir(__DIR__ . '/src') + ->inDir(__DIR__ . '/tests') + ->addFiles([__FILE__]) + ->getConfig() + ; + + $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php-cs-fixer.cache'); + + return $config; + ``` - declare(strict_types=1); +### โ†’ Composer Script - use WayOfDev\PhpCsFixer\Config\ConfigBuilder; - use WayOfDev\PhpCsFixer\Config\RuleSets\DefaultSet; +- Add `scripts` section to `composer.json`: + + ```diff + { + "scripts": { + + "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff", + + "cs:fix": "php vendor/bin/php-cs-fixer fix -v" + } + } + ``` - require_once 'vendor/autoload.php'; +### โ†’ Git - return ConfigBuilder::createFromRuleSet(new DefaultSet()) - ->inDir(__DIR__ . '/src') - ->inDir(__DIR__ . '/tests') - ->addFiles([__FILE__]) - ->getConfig(); - ``` +- Place `.build` folder file into `.gitignore` + + ```diff + +/.build/ + /vendor/ + ``` -3. Place `.php-cs-fixer.cache` file into `.gitignore` +### โ†’ GitHub Actions + +To use in GitHub Actions, do...
## ๐Ÿ’ป Usage -### โ†’ Running - Fix coding standards by simply running console command: +### โ†’ Directly + ```bash -php vendor/bin/php-cs-fixer fix -v +vendor/bin/php-cs-fixer fix -v ``` -### โ†’ Using Makefile +### โ†’ Via Composer Script -To use with our `Makefile`: +To use via composer script commands: -1. Add `scripts` section to `composer.json`: +* Fixes code to follow coding standards using php-cs-fixer: - ```json - { - "scripts": { - "cs-fix": "php vendor/bin/php-cs-fixer fix -v", - "cs-diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff" - } - } - ``` + ```bash + composer cs:diff + ``` -2. Use `Makefile` code to run PHP-CS-Fixer tests: +* Runs php-cs-fixer in dry-run mode and shows diff which will by applied: - ```bash - # Run inspections and fix code - $ make cs-fix - - # Check coding standards without applying the fix - $ make cs-diff - ``` + ```bash + composer cs:fix + ``` -
- -## ๐Ÿงช Running Tests - -### โ†’ PHPUnit tests - -To run tests, run the following command: - -```bash -make test -``` +### โ†’ Using Makefile -### โ†’ Static Analysis +**To use with `Makefile`** -Code quality using PHPStan: +- Fixes code to follow coding standards using php-cs-fixer: -```bash -make stan -``` + ```bash + make lint-php + ``` -### โ†’ Coding Standards Fixing +- Runs php-cs-fixer in dry-run mode and shows diff which will by applied: -Fix code using The PHP Coding Standards Fixer (PHP CS Fixer) to follow our standards: + ```bash + make lint-diff + ``` -```bash -make cs-fix -```
@@ -158,9 +175,11 @@ You are more than welcome. Before contributing, kindly check our [contribution g ## ๐Ÿซก Contributors - - Contributors Badge - +

+ + Contributors Badge + +


diff --git a/composer.json b/composer.json index 0d1c2a2..5dbdf80 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,17 @@ "description": "Package adds custom rule-sets to php-cs-fixer", "license": "MIT", "type": "library", + "keywords": [ + "php-cs-fixer", + "php-cs-fixer-config", + "php-cs-fixer-rules", + "configuration", + "code-style", + "code-standards", + "code-quality", + "php", + "static-analysis" + ], "authors": [ { "name": "Andrij Orlenko", From c0add683304b0cd5148fe2935cf24db09aa57119 Mon Sep 17 00:00:00 2001 From: lotyp Date: Sat, 18 May 2024 19:20:09 +0300 Subject: [PATCH 2/2] chore: lint md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee61a2f..b499756 100644 --- a/README.md +++ b/README.md @@ -121,13 +121,13 @@ vendor/bin/php-cs-fixer fix -v To use via composer script commands: -* Fixes code to follow coding standards using php-cs-fixer: +- Fixes code to follow coding standards using php-cs-fixer: ```bash composer cs:diff ``` -* Runs php-cs-fixer in dry-run mode and shows diff which will by applied: +- Runs php-cs-fixer in dry-run mode and shows diff which will by applied: ```bash composer cs:fix @@ -149,7 +149,6 @@ To use via composer script commands: make lint-diff ``` -
## ๐Ÿ”’ Security Policy