tengattack / phplint
A configurable linter tool for PHP.
v0.3.0
2024-08-10 15:33 UTC
Requires
- php: >=7.0
- microsoft/tolerant-php-parser: ^0.1.2
- wp-cli/php-cli-tools: ^0.11.8
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-10-10 16:01:09 UTC
README
A configurable linter tool for PHP.
Introduction
Dependencies
- htmllint-cli
- stylelint
- scss-lint (deprecated)
Installation
$ 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
Run
$ export PATH=$PATH:~/.composer/vendor/bin $ phplint /path/to/phpfile
Configuration
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
.
Example
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 |
+-----+----------+---------------------------------+-----------------+
Testing
vendor/bin/phpunit
# single rule test
vendor/bin/phpunit tests/rules/curly.php
License
MIT