Skip to content

Commit

Permalink
Add README.md with rule description and examples of work
Browse files Browse the repository at this point in the history
  • Loading branch information
gordinskiy committed Nov 29, 2023
1 parent 28a87f6 commit 6dad9f7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions README.md
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],
])
;
```
Binary file added diff-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6dad9f7

Please sign in to comment.