{"id":16414606,"url":"https://github.com/wapmorgan/phpdeprecationdetector","last_synced_at":"2025-04-08T02:41:51.031Z","repository":{"id":30126247,"uuid":"33676220","full_name":"wapmorgan/PhpDeprecationDetector","owner":"wapmorgan","description":"Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions.","archived":false,"fork":false,"pushed_at":"2024-02-14T12:40:26.000Z","size":233,"stargazers_count":365,"open_issues_count":20,"forks_count":37,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T23:18:40.905Z","etag":null,"topics":["programmer-tool","refactoring","static-analysis"],"latest_commit_sha":null,"homepage":"http://wapmorgan.github.io/PhpDeprecationDetector/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wapmorgan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-09T15:16:29.000Z","updated_at":"2024-10-17T06:01:22.000Z","dependencies_parsed_at":"2024-06-18T11:29:09.975Z","dependency_job_id":null,"html_url":"https://github.com/wapmorgan/PhpDeprecationDetector","commit_stats":{"total_commits":159,"total_committers":13,"mean_commits":12.23076923076923,"dds":"0.17610062893081757","last_synced_commit":"111ce055c9a2600caf5bf8e17ad099dc3837ed05"},"previous_names":["wapmorgan/phpcodefixer"],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FPhpDeprecationDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FPhpDeprecationDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FPhpDeprecationDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wapmorgan%2FPhpDeprecationDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wapmorgan","download_url":"https://codeload.github.com/wapmorgan/PhpDeprecationDetector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767232,"owners_count":20992538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["programmer-tool","refactoring","static-analysis"],"created_at":"2024-10-11T06:54:33.307Z","updated_at":"2025-04-08T02:41:51.015Z","avatar_url":"https://github.com/wapmorgan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PhpDeprecationDetector\r\n\r\nPhpDeprecationDetector - analyzer of PHP code to search usages of deprecated functionality in newer interpreter versions - deprecations detector.\r\n\r\n[![Latest Stable Version](https://poser.pugx.org/wapmorgan/php-deprecation-detector/v/stable)](https://packagist.org/packages/wapmorgan/php-deprecation-detector)\r\n[![Total Downloads](https://poser.pugx.org/wapmorgan/php-deprecation-detector/downloads)](https://packagist.org/packages/wapmorgan/php-deprecation-detector)\r\n[![License](https://poser.pugx.org/wapmorgan/php-deprecation-detector/license)](https://packagist.org/packages/wapmorgan/php-deprecation-detector)\r\n\r\nPhpDeprecationDetector detects:\r\n- Usage of deprecated **functions, variables, constants and ini-directives**.\r\n- Usage of deprecated **functions functionality**.\r\n- Usage of **forbidden names or tricks** (e.g. reserved identifiers in newer versions).\r\n\r\nIt literally helps you find code that can fail after migration to newer PHP version.\r\n\r\n1. [Installation](#installation)\r\n2. [Usage](#usage)\r\n  - [Console scanner](#console-scanner)\r\n  - [Json report format](#json-report-format)\r\n\r\n# Installation\r\n\r\n## Phar file\r\n\r\n1. Just download a phar from [releases page](https://github.com/wapmorgan/PhpDeprecationDetector/releases) and make executable\r\n  ```sh\r\n  chmod +x phpdd-x.x.x.phar\r\n  ```\r\n\r\n2. a. **Local installation**: use it from current folder:\r\n    ```php\r\n    ./phpdd-x.x.x.phar -h\r\n    ```\r\n\r\n   b. **Global installation**: move it in to one of folders listed in your `$PATH` and run from any folder:\r\n    ```sh\r\n    sudo mv phpdd-x.x.x.phar /usr/local/bin/phpdd\r\n    phpdd -h\r\n    ```\r\n\r\n## Composer\r\nAnother way to install _phpdd_ is via composer.\r\n\r\n1. Install composer:\r\n  ```sh\r\n  curl -sS https://getcomposer.org/installer | php\r\n  ```\r\n\r\n2. Install phpdd in global composer dir:\r\n  ```sh\r\n  ./composer.phar global require wapmorgan/php-deprecation-detector dev-master\r\n  ```\r\n\r\n3. Run from any folder:\r\n  ```sh\r\n  phpdd -h\r\n  ```\r\n\r\n# Usage\r\n## Console scanner\r\nTo scan your files or folder launch `phpdd` and pass file or directory names.\r\n\r\n```\r\nDescription:\r\n  Analyzes PHP code and searches issues with deprecated functionality in newer interpreter versions.\r\n\r\nUsage:\r\n  scan [options] [--] \u003cfiles\u003e...\r\n\r\nArguments:\r\n  files                                    Which files you want to analyze (separate multiple names with a space)?\r\n\r\nOptions:\r\n  -t, --target[=TARGET]                    Sets target PHP interpreter version. [default: \"8.0\"]\r\n  -a, --after[=AFTER]                      Sets initial PHP interpreter version for checks. [default: \"5.3\"]\r\n  -e, --exclude[=EXCLUDE]                  Sets excluded file or directory names for scanning. If need to pass few names, join it with comma.\r\n  -s, --max-size[=MAX-SIZE]                Sets max size of php file. If file is larger, it will be skipped. [default: \"1mb\"]\r\n      --file-extensions[=FILE-EXTENSIONS]  Sets file extensions to be parsed. [default: \"php, php5, phtml\"]\r\n      --skip-checks[=SKIP-CHECKS]          Skip all checks containing any of the given values. Pass a comma-separated list for multiple values.\r\n      --output[=OUTPUT]                    The output type required. Options: stdout, json, junit. Defaults to stdout.\r\n      --output-file[=OUTPUT-FILE]          File path to store results where output is not stdout.\r\n  -h, --help                               Display help for the given command. When no command is given display help for the scan command\r\n  -q, --quiet                              Do not output any message\r\n  -V, --version                            Display this application version\r\n      --ansi                               Force ANSI output\r\n      --no-ansi                            Disable ANSI output\r\n  -n, --no-interaction                     Do not ask any interactive question\r\n  -v|vv|vvv, --verbose                     Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\r\n```\r\n\r\n- 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.\r\n- By providing `--exclude` option you can exclude specific folders or files from analyze. For example, `--exclude vendor` will prevent checking third-party libraries.\r\n- By providing `--skip-checks` option you can exclude specific checks from analyze.\r\n- If your files has unusual extension, you can specify all exts by `--file-extensions` option. By default, it uses `php`, `phtml` and `php5`.\r\n- 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).\r\n\r\n### Example of usage\r\n```\r\n\u003e ./bin/phpdd tests/\r\nMax file size set to: 1.000 MiB\r\nFolder /media/wapmorgan/Локальный диск/Документы/PhpDeprecationDetector/tests\r\n- PHP 5.3 (3) - your version is greater or equal\r\n+------------+---------+---------------------------------------------------------------------+\r\n| File:Line  | Type    | Issue                                                               |\r\n+------------+---------+---------------------------------------------------------------------+\r\n| /5.3.php:2 | removed | Function dl() is removed.                                           |\r\n| /5.3.php:3 | removed | Ini define_syslog_variables is removed.                             |\r\n| /5.3.php:5 | changed | Function usage piet() (@call_with_passing_by_reference) is changed. |\r\n|            |         | Call with passing by reference is deprecated. Problem is \"\u0026$hoho\"   |\r\n+------------+---------+---------------------------------------------------------------------+\r\n\r\n- PHP 5.4 (2) - your version is greater or equal\r\n+------------+---------+-----------------------------------------------+\r\n| File:Line  | Type    | Issue                                         |\r\n+------------+---------+-----------------------------------------------+\r\n| /5.4.php:2 | removed | Function mcrypt_generic_end() is removed.     |\r\n|            |         | Consider replace with mcrypt_generic_deinit() |\r\n| /5.4.php:3 | removed | Function magic_quotes_runtime() is removed.   |\r\n+------------+---------+-----------------------------------------------+\r\n...\r\n...\r\n...\r\n```\r\n\r\n## Json report format\r\nAlso, 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*.\r\n\r\n## Junit report format\r\nAlso, 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*.\r\n\r\n**Format of json** - dictionary with items:\r\n- InfoMessage[] **info_messages** - list of information messages about analyzing process.\r\n- Issue[] **problems** - list of issues found in your code.\r\n- ReplaceSuggestion[] **replace_suggestions** - list of replacement suggestions based on your code.\r\n- Note[] **notes** - list of notes about new functions behaviour.\r\n\r\nItems description:\r\n- **InfoMessage** structure:\r\n  - string **type** - message type - any of (info | warning)\r\n  - string **message** - message text\r\n- **Issue** structure:\r\n  - string **version** - interpreter version which has current issue (*like 7.2*)\r\n  - string **file** - relative path to file in which issue found (*like src/ProblemClass.php*)\r\n  - string **path** - absolute path to file in which issue found (*like /var/www/html/project/src/ProblemClass.php*)\r\n  - int **line** - line in file in which issue found\r\n  - int **column** - column in line in which issue found\r\n  - string **category** - issue category - any of (changed | removed | violation)\r\n  - string **type** - concrete issue type (*like \"constant\" or \"identifier\"*)\r\n  - string **checker** - concrete issue object which may cause problem (*like `magic_quotes_runtime` or `preg_replace() (@preg_replace_e_modifier)`*)\r\n- **ReplaceSuggestion** structure:\r\n  - string **type** - replacement object type (*like variable or ini*)\r\n  - string **problem** - replacement object (*like mcrypt_generic_end() or each()*)\r\n  - string **replacement** - suggestion to replace with (*like mcrypt_generic_deinit() or foreach()*)\r\n- **Note** structure:\r\n  - string **type** - type of note (*like function_usage or deprecated_feature*)\r\n  - string **problem** - note object (*like `preg_replace() (@preg_replace_e_modifier)` or `parse_str() (@parse_str_without_argument)`*)\r\n  - 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`*)\r\n\r\n# Build\r\n\r\n```shell\r\ndocker run --rm --interactive --tty --volume $PWD:/app composer:2.2.4 sh\r\n# and inside a container:\r\ndocker-php-ext-install bcmath\r\ncomposer require macfja/phar-builder\r\necho phar.readonly=0 \u003e\u003e /usr/local/etc/php/php-cli.ini\r\ncomposer run-script build\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwapmorgan%2Fphpdeprecationdetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwapmorgan%2Fphpdeprecationdetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwapmorgan%2Fphpdeprecationdetector/lists"}