marius / phplint
一个 PHP 语法检查工具。由 Overtrue 分支而来
0.3.4
2017-09-28 14:17 UTC
Requires
- php: >=5.3.0
- symfony/console: ^2.7
- symfony/finder: ^2.7
- symfony/process: ^2.7
- symfony/yaml: ^2.7
README
phplint 是一个工具,可以通过同时运行多个 lint 进程来加速 PHP 文件的 lint 检查。
安装
$ composer require overtrue/phplint -vvv
使用方法
命令行界面 (CLI)
Usage: phplint [options] [--] <path> (<path>)... Arguments: path Path to file or directory to lint. Options: --exclude=EXCLUDE Path to file or directory to exclude from linting (multiple values allowed) --extensions=EXTENSIONS Check only files with selected extensions (default: php) -j, --jobs=JOBS Number of parraled jobs to run (default: 5) -c, --configuration=CONFIGURATION Read configuration from config file (default: ./.phplint.yml). --no-configuration Ignore default configuration file (default: ./.phplint.yml). --no-cache Ignore cached data. -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: Lint something
示例
$ ./vendor/bin/phplint ./ --exclude=vendor
您还可以将配置定义为一个文件 .phplint.yml
path: ./ jobs: 10 extensions: - php exclude: - vendor
$ ./vendor/bin/phplint
默认情况下,命令将读取指定路径的 .phplint.yml 文件中的配置,您可以通过选项自定义文件名:--configuration=FILENAME 或 -c=FILENAME;
如果您想禁用任何配置文件,可以添加选项 --no-configuration。
程序
use Overtrue\PHPLint\Linter; $path = __DIR__ .'/app'; $exclude = ['vendor']; $extensions = ['php']; $linter = new Linter($path, $exclude, $extensions); // get errors $errors = $linter->lint(); // // [ // '/path/to/foo.php' => [ // 'error' => "unexpected '$key' (T_VARIABLE)", // 'line' => 168, // 'file' => '/path/to/foo.php', // ], // '/path/to/bar.php' => [ // 'error' => "unexpected 'class' (T_CLASS), expecting ',' or ';'", // 'line' => 28, // 'file' => '/path/to/bar.php', // ], // ]
许可证
MIT