appsinet/arc-phpstan

Phabricator的Arcanist的PHPStan代码检查器

v1.0.3 2020-12-01 17:27 UTC

README

OSSAR

基于material-foundation/arc-tslint和一些在sascha-egerer/arc-phpstan中做出的改进。为arc lint提供对phpstan的基本支持。

arc-phpstan

使用phpstan与Phabricator的arc命令行工具检查PHP源代码。

特性

phpstan生成警告信息。

示例输出

>>> Lint for src/AppBundle/Foo.php:


Error  () phpstan violation
Error: AppBundle\Foo::__construct() does not
call parent constructor from AppBundle\Bar.

          33      * constructor
          34      */
>>>       35     public function __construct()
          36     {
          37         Bar::__construct();
          38         $this->property = 0;

安装

需要phpstan。您可以按照官方说明进行安装,并将其添加到您的$PATH中,或者您可以直接运行composer install命令,并将bin选项指向vendor/bin/phpstan,如下面的示例所示。

项目特定安装

您可以将此存储库作为git子模块添加。在您的.arcconfig中添加子模块的路径,如下所示

{
  "load": ["path/to/arc-phpstan"]
}

全局安装

arcanist可以从绝对路径加载模块。但也可以在自身上一级目录中搜索模块。

您可以将此存储库克隆到与arcanistlibphutil相同的目录中。最后它将看起来像这样

arcanist/
arc-phpstan/
libphutil/

您的.arcconfig将看起来像

{
  "load": ["arc-phpstan"]
}

设置

要使用检查器,您必须在您的.arclint文件中注册它,如下面的示例所示

{
  "linters": {
    "phpstan": {
      "type": "phpstan",
      "include": "(\\.php$)",
      "config": "var/build/phpstan.neon", /* optional */
      "bin": "vendor/bin/phpstan", /* optional */
      "level": "0" /* optional */
    }
  }
}

许可证

Apache 2.0许可证下授权。有关详细信息,请参阅LICENSE。