A configurable linter tool for PHP.
- htmllint-cli
- stylelint
- scss-lint (deprecated)
$ composer global require tengattack/phplint
$ # htmllint is used by rule `html` (it has to be latest)
$ npm i -g htmllint/htmllint-cli
$ # stylelint is used by rule `html`
$ npm i -g stylelint
$ # scss-lint is used by rule `html` (deprecated)
$ gem install scss_lint
$ export PATH=$PATH:~/.composer/vendor/bin
$ phplint /path/to/phpfile
If no configuration file is specified, it will first read the file .phplint.yml
on current working directory as configuration,
and if still not exists it will use the default configuration.
You can configure it as you want base on this file: .phplint.yml
.
A php file test.php
with following content:
<?php
$a =false;
$b = $a ?? 1;
if($b) {
}
$ phplint test.php
Output:
test.php:
+-----+----------+---------------------------------+-----------------+
| loc | severity | message | ruleId |
+-----+----------+---------------------------------+-----------------+
| 3:5 | error | Infix operators must be spaced. | space-infix-ops |
| 5:1 | error | A space is required after 'if'. | keyword-spacing |
| 5:8 | error | Empty block statement. | no-empty |
+-----+----------+---------------------------------+-----------------+
vendor/bin/phpunit
# single rule test
vendor/bin/phpunit tests/rules/curly.php
MIT