diff --git a/README.md b/README.md new file mode 100644 index 0000000..eb3003c --- /dev/null +++ b/README.md @@ -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: +
+ +
+ +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 +registerCustomFixers([ + new Gordinskiy\LineLengthChecker\Rules\LineLengthLimit() + ]) +; +``` + +Enable rule in PHP-CS-Fixer config file: +```php +setRules([ + 'Gordinskiy/line_length_limit' => true, + ]) +; +``` + +### Configuration +Default limitation is 120, but it can be configured by `max_length` option: +```php +setRules([ + 'Gordinskiy/line_length_limit' => ['max_length' => 115], + ]) +; +``` diff --git a/diff-example.png b/diff-example.png new file mode 100644 index 0000000..33f342f Binary files /dev/null and b/diff-example.png differ