-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add README.md with rule description and examples of work
- Loading branch information
1 parent
28a87f6
commit 6dad9f7
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
PHP Line Length Checker | ||
======================= | ||
|
||
Custom rule for [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer). | ||
Checks that the length of lines does not exceed 120 characters. | ||
Doesn't fix anything. | ||
|
||
### How it works | ||
Searches for the line that exceed max length limit and mark it by adding comment: | ||
``` # Line too long``` | ||
|
||
To see which lines violates the rule you should run the command with the`--diff` flag. | ||
|
||
DIff example: | ||
<p> | ||
<img src="./diff-example.png" title="Diff Example" alt="Diff Example"> | ||
</p> | ||
|
||
Works only for `check` command and `fix` command with `--dry-run` flag. Does nothing in other cases. | ||
|
||
|
||
### Installation | ||
Install package: | ||
```console | ||
composer require --dev gordinskiy/line-length-checker | ||
``` | ||
Register rule in PHP-CS-Fixer config file: | ||
```php | ||
<?php | ||
// ... | ||
return (new PhpCsFixer\Config()) | ||
// ... | ||
->registerCustomFixers([ | ||
new Gordinskiy\LineLengthChecker\Rules\LineLengthLimit() | ||
]) | ||
; | ||
``` | ||
|
||
Enable rule in PHP-CS-Fixer config file: | ||
```php | ||
<?php | ||
// ... | ||
return (new PhpCsFixer\Config()) | ||
// ... | ||
->setRules([ | ||
'Gordinskiy/line_length_limit' => true, | ||
]) | ||
; | ||
``` | ||
|
||
### Configuration | ||
Default limitation is 120, but it can be configured by `max_length` option: | ||
```php | ||
<?php | ||
// ... | ||
return (new PhpCsFixer\Config()) | ||
// ... | ||
->setRules([ | ||
'Gordinskiy/line_length_limit' => ['max_length' => 115], | ||
]) | ||
; | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.