百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

PhpDeprecationDetector

> 编程语言
开源

分析 PHP 代码,以查找新版解释器中已过时的功能问题。

367 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

分析 PHP 代码,以查找新版解释器中已过时的功能问题。

PhpDeprecationDetector

PhpDeprecationDetector - analyzer of PHP code to search usages of deprecated functionality in newer interpreter versions - deprecations detector. PhpDeprecationDetector detects:

  • Usage of deprecated functions, variables, constants and ini-directives.
  • Usage of deprecated functions functionality.
  • Usage of forbidden names or tricks (e.g. reserved identifiers in newer versions).

It literally helps you find code that can fail after migration to newer PHP version.

  1. Installation
  2. Usage
  • Console scanner
  • Json report format

Installation

Phar file

  1. Just download a phar from releases page and make executable
bash
chmod +x phpdd-x.x.x.phar
  1. a. Local installation: use it from current folder:

    php
    ./phpdd-x.x.x.phar -h

    b. Global installation: move it in to one of folders listed in your $PATH and run from any folder:

    bash
    sudo mv phpdd-x.x.x.phar /usr/local/bin/phpdd
    phpdd -h

Composer

Another way to install phpdd is via composer.

  1. Install composer:
bash
curl -sS https://getcomposer.org/installer | php
  1. Install phpdd in global composer dir:
bash
./composer.phar global require wapmorgan/php-deprecation-detector dev-master
  1. Run from any folder:
bash
phpdd -h

Usage

Console scanner

To scan your files or folder launch phpdd and pass file or directory names.

…
  • By providing additional option --target you can specify version of PHP to perform less checks. Available target versions: 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0. A larger version includes rules for checking from all previous.
  • By providing --exclude option you can exclude specific folders or files from analyze. For example, --exclude vendor will prevent checking third-party libraries.
  • By providing --skip-checks option you can exclude specific checks from analyze.
  • If your files has unusual extension, you can specify all exts by --file-extensions option. By default, it uses php, phtml and php5.
  • If you need to generate machine-readable analyze result, use the --output-file option to specify path to store the output file as specified on --output (json or junit).

Example of usage

…

Json report format

Also, you can store analyze result in json format for automatic check. Pass --output-file=FILENAME to write result to FILENAME file or do not set to output to stdout.

Junit report format

Also, you can store analyze result in junit format for automatic check. Pass --output-file=FILENAME to write result to FILENAME file or do not set to output to stdout.

Format of json - dictionary with items:

  • InfoMessage[] info_messages - list of information messages about analyzing process.
  • Issue[] problems - list of issues found in your code.
  • ReplaceSuggestion[] replace_suggestions - list of replacement suggestions based on your code.
  • Note[] notes - list of notes about new functions behaviour.

Items description:

  • InfoMessage structure:
    • string type - message type - any of (info | warning)
    • string message - message text
  • Issue structure:
    • string version - interpreter version which has current issue (like 7.2)
    • string file - relative path to file in which issue found (like src/ProblemClass.php)
    • string path - absolute path to file in which issue found (like /var/www/html/project/src/ProblemClass.php)
    • int line - line in file in which issue found
    • int column - column in line in which issue found
    • string category - issue category - any of (changed | removed | violation)
    • string type - concrete issue type (like "constant" or "identifier")
    • string checker - concrete issue object which may cause problem (like magic_quotes_runtime or preg_replace() (@preg_replace_e_modifier))
  • ReplaceSuggestion structure:
    • string type - replacement object type (like variable or ini)
    • string problem - replacement object (like mcrypt_generic_end() or each())
    • string replacement - suggestion to replace with (like mcrypt_generic_deinit() or foreach())
  • Note structure:
    • string type - type of note (like function_usage or deprecated_feature)
    • string problem - note object (like preg_replace() (@preg_replace_e_modifier) or parse_str() (@parse_str_without_argument))
    • string note - note text (like Usage of "e" modifier in preg_replace is deprecated: "asdasdsd~ie" or Call to parse_str() without second argument is deprecated)

Build

bash
docker run --rm --interactive --tty --volume $PWD:/app composer:2.2.4 sh
# and inside a container:
docker-php-ext-install bcmath
composer require macfja/phar-builder
echo phar.readonly=0 >> /usr/local/etc/php/php-cli.ini
composer run-script build

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPprogrammer-toolrefactoringstatic-analysis

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言