sensiolabs-de/deprecation-detector

此软件包已被废弃,不再维护。未建议替代软件包。

命令行工具,用于检测已弃用的代码的使用

安装次数: 539 991

依赖项: 0

建议者: 0

安全: 0

星标: 395

关注者: 26

分支: 40

开放问题: 42

类型:应用程序

0.1.0-alpha4 2016-01-07 12:36 UTC

This package is auto-updated.

Last update: 2021-01-29 14:15:16 UTC


README

Tests Gitter

注意:此软件包已被废弃,将不再接收任何更新。

SensioLabs DeprecationDetector会对您项目的源代码进行静态代码分析,以查找已弃用方法、类和接口的使用。对于Symfony项目,它还会检测已弃用服务。它通过@deprecated注解识别已弃用代码的使用。

免责声明

请注意,此工具处于非常早期的开发阶段。请期待出现错误和不稳定之处。

基础知识

SensioLabs DeprecationDetector是基于Symfony Console组件的命令行命令。它大量使用PHP-Parser库来分析PHP代码。

该命令分三个步骤工作

  1. 扫描您的供应商库中定义的弃用项,并将其作为ruleset缓存
  2. 从您的规则集中查找这些弃用项的使用情况。
  3. 输出受影响的代码部分。

安装

Composer

要通过Composer进行全局安装,您可以运行

$ composer global require sensiolabs-de/deprecation-detector

请确保您已将~/.composer/vendor/bin/添加到您的PATH中,您将能够调用deprecation-detector命令。

PHAR

您可以从发布页面下载可用的PHAR文件

curl -OL https://github.com/sensiolabs-de/deprecation-detector/releases/download/0.1.0-alpha4/deprecation-detector.phar
php deprecation-detector.phar

独立

克隆仓库

$ git clone git@github.com:sensiolabs-de/deprecation-detector.git

运行composer

$ composer install

使用Box创建phar存档(可选)

$ box build

假设您已创建phar存档,如果您想全局调用deprecation-detector,则需要将其放置在您的PATH中。例如,使用

$ chmod a+x deprecation-detector.phar
$ mv deprecation-detector.phar /usr/local/bin/deprecation-detector

否则,您可以直接调用bin/deprecation-detector

用法

要使用DeprecationDetector,您需要提供sourceruleset参数

$ deprecation-detector check src/ vendor/
$ deprecation-detector check src/ composer.lock
$ deprecation-detector check src/ .rules/some_generated_rule_set

输出

有不同类型的输出格式可用,默认情况下输出打印在命令行中。

Html

$ deprecation-detector check src/ vendor/ --log-html deprecationlog.html

您可以通过运行以下命令获取所有选项和参数的列表

$ deprecation-detector check --help

默认输出可能不适合cli。如果是这样,您可以通过设置--output=simple将输出设置为列表。

$ deprecation-detector check src/ vendor/ --output=simple

排除已弃用方法调用

您可以通过使用filter-methods选项来排除已弃用的方法调用。此选项接受一个以逗号分隔的方法引用列表来排除。

$ deprecation-detector check --filter-methods=MyClass::method,Foo::bar src/ vendor/

这将排除对MyClass::method和Foo::bar的所有已弃用调用。

贡献

目前,SensioLabs DeprecationDetector处于非常早期的状态。欢迎提交pull请求!

维护者

DeprecationDetector是由SensioLabs Deutschland团队开发的项目,由SensioLabs Deutschland维护,维护者:@marvin_klemp