2017 © Pedro Peláez
 

package php-code-fixer

A scanner that checks compatibility of your code with new interpreter versions.

image

wapmorgan/php-code-fixer

A scanner that checks compatibility of your code with new interpreter versions.

  • Friday, June 1, 2018
  • by wapmorgan
  • Repository
  • 11 Watchers
  • 148 Stars
  • 17,131 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 13 Forks
  • 2 Open issues
  • 21 Versions
  • 57 % Grown

The README.md

PhpDeprecationDetector

PhpDeprecationDetector - analyzer of PHP code to search usages of deprecated functionality in newer interpreter versions - deprecations detector., (*1)

Latest Stable Version Total Downloads License, (*2)

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)., (*3)

It literally helps you find code that can fail after migration to newer PHP version., (*4)

  1. Installation
  2. Usage

Installation

Phar file

  1. Just download a phar from releases page and make executable, (*5)

    chmod +x phpdd-x.x.x.phar
    
  2. a. Local installation: use it from current folder:, (*6)

    ./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:, (*7)

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

Composer

Another way to install phpdd is via composer., (*8)

  1. Install composer:, (*9)

    curl -sS https://getcomposer.org/installer | php
    
  2. Install phpdd in global composer dir:, (*10)

    ./composer.phar global require wapmorgan/php-deprecation-detector dev-master
    
  3. Run from any folder:, (*11)

    phpdd -h
    

Usage

Console scanner

To scan your files or folder launch phpdd and pass file or directory names., (*12)

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
  • 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

> ./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.   |
+------------+---------+-----------------------------------------------+
...
...
...

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., (*13)

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., (*14)

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., (*15)

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), (*16)

Build

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

The Versions

01/06 2018

dev-master

9999999-dev

A scanner that checks compatibility of your code with new interpreter versions.

  Sources   Download

BSD-3-Clause

The Requires

 

15/05 2018

2.0.14

2.0.14.0

A scanner that checks compatibility of your code with new interpreter versions.

  Sources   Download

BSD-3-Clause

The Requires

 

28/04 2018

2.0.13

2.0.13.0

A scanner that checks compatibility of your code with new interpreter versions.

  Sources   Download

BSD-3-Clause

The Requires

 

28/04 2018

2.0.12

2.0.12.0

A scanner that checks compatibility of your code with new interpreter versions.

  Sources   Download

BSD-3-Clause

The Requires

 

27/04 2018

2.0.11

2.0.11.0

A scanner that checks compatibility of your code with new interpreter versions.

  Sources   Download

BSD-3-Clause

The Requires

 

27/04 2018

2.0.10

2.0.10.0

A scanner that checks compatibility of your code with new interpreter versions.

  Sources   Download

BSD-3-Clause

The Requires

 

18/08 2017

2.0.9-alpha

2.0.9.0-alpha

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

18/08 2017

2.0.9

2.0.9.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

23/06 2017

2.0.8

2.0.8.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

03/06 2017

2.0.7

2.0.7.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

15/04 2017

2.0.6

2.0.6.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

15/04 2017

2.0.5

2.0.5.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

03/03 2017

2.0.4

2.0.4.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

03/03 2017

2.0.3

2.0.3.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

01/02 2017

2.0.2

2.0.2.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

13/01 2017

2.0.1

2.0.1.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

11/01 2017

2.0.0

2.0.0.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

23/11 2016

1.1.0

1.1.0.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

06/10 2015

1.0.1.1

1.0.1.1

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

05/10 2015

1.0.1

1.0.1.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires

 

06/05 2015

1.0

1.0.0.0

A program that finds usage of deprecated functions, variables and ini directives in your php code.

  Sources   Download

BSD-3-Clause

The Requires