Stars: 343
Forks: 51
Pull Requests: 19
Issues: 67
Watchers: 13
Last Updated: 2023-06-04 19:08:19
Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions.
License: BSD 3-Clause "New" or "Revised" License
Languages: PHP
PhpDeprecationDetector - analyzer of PHP code to search usages of deprecated functionality in newer interpreter versions - deprecations detector.
PhpDeprecationDetector detects:
It literally helps you find code that can fail after migration to newer PHP version.
chmod +x phpdd-x.x.x.phar
a. Local installation: use it from current folder:
./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:
sudo mv phpdd-x.x.x.phar /usr/local/bin/phpdd
phpdd -h
Another way to install phpdd is via composer.
curl -sS https://getcomposer.org/installer | php
./composer.phar global require wapmorgan/php-deprecation-detector dev-master
phpdd -h
To scan your files or folder launch phpdd
and pass file or directory names.
Description:
Analyzes PHP code and searches issues with deprecated functionality in newer interpreter versions.
Usage:
scan [options] [--] <files>...
Arguments:
files Which files you want to analyze (separate multiple names with a space)?
Options:
-t, --target[=TARGET] Sets target PHP interpreter version. [default: "8.0"]
-a, --after[=AFTER] Sets initial PHP interpreter version for checks. [default: "5.3"]
-e, --exclude[=EXCLUDE] Sets excluded file or directory names for scanning. If need to pass few names, join it with comma.
-s, --max-size[=MAX-SIZE] Sets max size of php file. If file is larger, it will be skipped. [default: "1mb"]
--file-extensions[=FILE-EXTENSIONS] Sets file extensions to be parsed. [default: "php, php5, phtml"]
--skip-checks[=SKIP-CHECKS] Skip all checks containing any of the given values. Pass a comma-separated list for multiple values.
--output[=OUTPUT] The output type required. Options: stdout, json, junit. Defaults to stdout.
--output-file[=OUTPUT-FILE] File path to store results where output is not stdout.
-h, --help Display help for the given command. When no command is given display help for the scan command
-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
--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.--exclude
option you can exclude specific folders or files from analyze. For example, --exclude vendor
will prevent checking third-party libraries.--skip-checks
option you can exclude specific checks from analyze.--file-extensions
option. By default, it uses php
, phtml
and php5
.--output-file
option to specify path to store the output file as specified on --output
(json or junit).> ./bin/phpdd tests/
Max file size set to: 1.000 MiB
Folder /media/wapmorgan/Локальный диск/Документы/PhpDeprecationDetector/tests
- PHP 5.3 (3) - your version is greater or equal
+------------+---------+---------------------------------------------------------------------+
| File:Line | Type | Issue |
+------------+---------+---------------------------------------------------------------------+
| /5.3.php:2 | removed | Function dl() is removed. |
| /5.3.php:3 | removed | Ini define_syslog_variables is removed. |
| /5.3.php:5 | changed | Function usage piet() (@call_with_passing_by_reference) is changed. |
| | | Call with passing by reference is deprecated. Problem is "&$hoho" |
+------------+---------+---------------------------------------------------------------------+
- PHP 5.4 (2) - your version is greater or equal
+------------+---------+-----------------------------------------------+
| File:Line | Type | Issue |
+------------+---------+-----------------------------------------------+
| /5.4.php:2 | removed | Function mcrypt_generic_end() is removed. |
| | | Consider replace with mcrypt_generic_deinit() |
| /5.4.php:3 | removed | Function magic_quotes_runtime() is removed. |
+------------+---------+-----------------------------------------------+
...
...
...
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.
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:
Items description:
magic_quotes_runtime
or preg_replace() (@preg_replace_e_modifier)
)preg_replace() (@preg_replace_e_modifier)
or parse_str() (@parse_str_without_argument)
)Usage of "e" modifier in preg_replace is deprecated: "asdasdsd~ie"
or Call to parse_str() without second argument is deprecated
)