gordinskiy / line-length-checker
PHP-CS-Fixer rule to check line length
Installs: 3 329
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- friendsofphp/php-cs-fixer: ^3.35
This package is auto-updated.
Last update: 2024-10-29 23:25:30 UTC
README
Custom rule for 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:
composer require --dev gordinskiy/line-length-checker
Register rule in PHP-CS-Fixer config file:
<?php // ... return (new PhpCsFixer\Config()) // ... ->registerCustomFixers([ new Gordinskiy\LineLengthChecker\Rules\LineLengthLimit() ]) ;
Enable rule in PHP-CS-Fixer config file:
<?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 // ... return (new PhpCsFixer\Config()) // ... ->setRules([ 'Gordinskiy/line_length_limit' => ['max_length' => 115], ]) ;