A static analyzer for PHP version migration

Overview

PHP Migration

Readme in Chinese 中文

Build Status Total Downloads Latest Stable Version License

This is a static analyzer for PHP version migration and compatibility checking.

It can suppose your current code running under the new version of PHP then do checking, and provide advice and treatment.

And it can simplify the process of upgrading PHP. Its goal is instead of manual checking.

Features:

  • Wide coverage, checks most of the changes which introduced in PHP 5.3 - 7.0.
  • Strict, without missing any risk.
  • Zero configuration, run directly after download.
  • Simply add custom checks.

Compare to the similar project PHP Compatibility PHP Compatibility is a set of sniffs for PHP_CodeSniffer, therefore it lacks flexibility and can not checks more changes. just objective comparison

Notice: this project is in beta stage, feel free to report any issues.

Install / Usage

  1. You can download a executable Phar file

    wget https://github.com/monque/PHP-Migration/releases/download/v0.2.2/phpmig.phar
    
  2. Use the following command to check PHP file

    php phpmig.phar sample.php
    

    Suppose these code stored in sample.php

    <?php
    // Fatal error: Only variables can be passed by reference
    array_shift(array(1, 2));
    sort(array(1, 2, 3));
    
    // __DIR__ is pre-defined
    define('__DIR__', dirname(__FILE__));
    
    // Fatal error: Cannot redeclare class_alias()
    function class_alias() {}
    
    // This is fine
    if (!function_exists('class_alias')) {
        function class_alias() {}
    }
    
    // Fatal error: Call-time pass-by-reference has been removed
    array_map('trim', &$_SERVER);
    
    // Fatal error: 'break' operator with non-constant operand is no longer supported
    while (true) {
        break $a;
    }
    
    // Fatal error: Cannot re-assign auto-global variable _GET
    function ohno($_GET) {}
    
    // Array keys won't be overwritten when defining an array as a property of a class via an array literal
    class C {
        const ONE = 1;
        public $array = [
            self::ONE => 'foo',
            'bar',
            'quux',
        ];
    }
    
    // set_exception_handler() is no longer guaranteed to receive Exception objects
    set_exception_handler(function (Exception $e) { });
    
    // Changes to the handling of indirect variables, properties, and methods
    echo $$foo['bar']['baz'];
    
    // foreach no longer changes the internal array pointer
    foreach ($list as &$row) {
        current($list);
    }
  3. Output report Each columns means: Line Number, Level, Identified, Version, Message

    File: sample.php
    --------------------------------------------------------------------------------
    Found 11 spot(s), 10 identified
    --------------------------------------------------------------------------------
        3 | FATAL      | * | 5.3.0 | Only variables can be passed by reference
        4 | FATAL      | * | 5.3.0 | Only variables can be passed by reference
        7 | WARNING    | * | 5.3.0 | Constant "__DIR__" already defined
       10 | FATAL      | * | 5.3.0 | Cannot redeclare class_alias()
       18 | FATAL      | * | 5.4.0 | Call-time pass-by-reference has been removed
       22 | FATAL      | * | 5.4.0 | break operator with non-constant operand is no longer supported
       26 | FATAL      | * | 5.4.0 | Cannot re-assign auto-global variable
       31 | WARNING    |   | 5.6.0 | Array key may be overwritten when defining as a property and using constants
       39 | WARNING    | * | 7.0.0 | set_exception_handler() is no longer guaranteed to receive Exception objects
       42 | WARNING    | * | 7.0.0 | Different behavior between PHP 5/7
       46 | NOTICE     | * | 7.0.0 | foreach no longer changes the internal array pointer
    --------------------------------------------------------------------------------
    

    The third field Identified will be explained at bottom.

Set Selection

A Checking Set contains muiltiple Check Class, and the dependence of Set can be specified.

List all sets through command php phpmig.phar -l.

classtree  => List contents of classes in a tree-like format
to53       => Migrating from ANY version to PHP 5.3.x
to54       => Migrating from ANY version to PHP 5.4.x
to55       => Migrating from ANY version to PHP 5.5.x
to56       => Migrating from ANY version to PHP 5.6.x
to70       => Migrating from ANY version to PHP 7.0.x
v53        => Migrating from PHP 5.2.x to PHP 5.3.x
v54        => Migrating from PHP 5.3.x to PHP 5.4.x
v55        => Migrating from PHP 5.4.x to PHP 5.5.x
v56        => Migrating from PHP 5.5.x to PHP 5.6.x
v70        => Migrating from PHP 5.6.x to PHP 7.0.x

And add param -s like php phpmig.phar -s <setname> to select a set to use.

Utility, print class tree

Like the common linux command tree, the following command will scan files and output all classes in a tree-like format.

php phpmig.phar -s classtree .

Output:

|-- PhpMigration\App
|-- PhpMigration\Changes\AbstractChange
|   |-- PhpMigration\Changes\AbstractIntroduced
|   |   |-- PhpMigration\Changes\v5dot3\Introduced
|   |   |-- PhpMigration\Changes\v5dot4\Introduced
|   |   |-- PhpMigration\Changes\v5dot5\Introduced
|   |   |-- PhpMigration\Changes\v5dot6\Introduced
|   |   `-- PhpMigration\Changes\v7dot0\Introduced
|   |-- PhpMigration\Changes\AbstractKeywordReserved
|   |   |-- PhpMigration\Changes\v5dot3\IncompReserved
|   |   `-- PhpMigration\Changes\v5dot4\IncompReserved
|   |-- PhpMigration\Changes\AbstractRemoved
|   |   |-- PhpMigration\Changes\v5dot3\Removed
|   |   |-- PhpMigration\Changes\v5dot4\Removed
|   |   |-- PhpMigration\Changes\v5dot5\Removed
|   |   |-- PhpMigration\Changes\v5dot6\Removed
|   |   `-- PhpMigration\Changes\v7dot0\Removed
|   |-- PhpMigration\Changes\ClassTree
|   |-- PhpMigration\Changes\Dev
|   |-- PhpMigration\Changes\v5dot3\Deprecated
|   |-- PhpMigration\Changes\v5dot3\IncompByReference
|   |-- PhpMigration\Changes\v5dot3\IncompCallFromGlobal
|   |-- PhpMigration\Changes\v5dot3\IncompMagic
|   |-- PhpMigration\Changes\v5dot3\IncompMagicInvoked
|   |-- PhpMigration\Changes\v5dot3\IncompMisc
|   |-- PhpMigration\Changes\v5dot4\Deprecated
|   |-- PhpMigration\Changes\v5dot4\IncompBreakContinue
|   |-- PhpMigration\Changes\v5dot4\IncompByReference
|   |-- PhpMigration\Changes\v5dot4\IncompHashAlgo
|   |-- PhpMigration\Changes\v5dot4\IncompMisc
|   |-- PhpMigration\Changes\v5dot4\IncompParamName
|   |-- PhpMigration\Changes\v5dot4\IncompRegister
|   |-- PhpMigration\Changes\v5dot5\Deprecated
|   |-- PhpMigration\Changes\v5dot5\IncompCaseInsensitive
|   |-- PhpMigration\Changes\v5dot5\IncompPack
|   |-- PhpMigration\Changes\v5dot6\Deprecated
|   |-- PhpMigration\Changes\v5dot6\IncompMisc
|   |-- PhpMigration\Changes\v5dot6\IncompPropertyArray
|   |-- PhpMigration\Changes\v7dot0\Deprecated
|   |-- PhpMigration\Changes\v7dot0\ExceptionHandle
|   |-- PhpMigration\Changes\v7dot0\ForeachLoop
|   |-- PhpMigration\Changes\v7dot0\FuncList
|   |-- PhpMigration\Changes\v7dot0\FuncParameters
|   |-- PhpMigration\Changes\v7dot0\IntegerOperation
|   |-- PhpMigration\Changes\v7dot0\KeywordReserved
|   |-- PhpMigration\Changes\v7dot0\ParseDifference
|   |-- PhpMigration\Changes\v7dot0\StringOperation
|   `-- PhpMigration\Changes\v7dot0\SwitchMultipleDefaults
|-- PhpMigration\CheckVisitor
|-- PhpMigration\Logger
|-- PhpMigration\ReduceVisitor
|-- PhpMigration\SymbolTable
|-- PhpMigration\Utils\FunctionListExporter
|-- PhpMigration\Utils\Logging
|-- PhpMigration\Utils\Packager
`-- PhpMigration\Utils\ParserHelper

Manual Installation from Source

  1. Clone this project to your local path

    git clone https://github.com/monque/PHP-Migration.git php-migration
    cd php-migration
    
  2. Using Composer to install dependencies

    curl -sS https://getcomposer.org/installer | php
    php composer.phar install
    
  3. Verify it works

    php bin/phpmig
    

Explaination

Process Flow

flow

About the third field Identified in outputing

To be honest, not all code will be checked accurately as you expect.

Some changes will never be checked accurately, and it's has nothing to do with someone's ability or technology.

For example, unpack() changes in PHP 5.5, it now keeps trailing NULL bytes when the "a" format code is used.

Code below:

<?php
unpack($obj->getFormat(), $data); // OMG, What is $obj? How getFormat() works?
unpack('b3', $data); // Works in new version
unpack('a3', $data); // Affected

But we can guess the value of variables, and make a level table:

Level Identified Output
MUST affect Yes Yes
MUST NOT affect Yes No
MAY affect No Yes

So, finally output

--------------------------------------------------------------------------------
Found 2 spot(s), 1 identified
--------------------------------------------------------------------------------
   2 | WARNING    |   | 5.5.0 | Behavior of pack() with "a", "A" in format is changed
   4 | WARNING    | * | 5.5.0 | Behavior of pack() with "a", "A" in format is changed
--------------------------------------------------------------------------------

License

This project is released under the MIT license.

Comments
  • Keywords reserved cannot be detected with PHP 5.3 platform

    Keywords reserved cannot be detected with PHP 5.3 platform

    When your run on a PHP 5.3 plaform to detect if keywords reserved are used. E.g

    php phpmig -s to54 /path/to/keywords_reserved.php
    

    With source file (keywords_reserved.php)

    <?php
    
    class Trait
    {
        const FOO = "foo";
    }
    
    class finally
    {
        function __construct()
        {
            $trait = new Trait;
    
            $foo = Trait::FOO;
        }
    }
    

    You got following error

    File: keywords_reserved.php
    --------------------------------------------------------------------------------
        3 | PARSE      | * | NONE | Syntax error, unexpected T_TRAIT, expecting T_STRING on line 3
    --------------------------------------------------------------------------------
    

    Reason is that PHP-Parser is not yet able to catch such condition, until now. I've proposed an improvement https://github.com/nikic/PHP-Parser/issues/202

    And soon, I'll propose a migration analyser on my php-compatinfo project, based on Sniff pattern. See https://github.com/llaville/php-compat-info/issues/202 I must gave you a credit, because this future analyser (that is available to detect even keywords reserved) is due to a deeper analysis of your project architecture.

    enhancement 
    opened by llaville 8
  • Run not on Windows

    Run not on Windows

    I have downloaded the phar and want to run it on a windows machine like this "php phpmig.phar ". But always I get the error "Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 11 52 bytes) in phar://path/to/phpmig/phpmig_2015-10-15.phar/src/Ch anges/AbstractRemoved.php on line 49".

    I have tried to change the memory_limit to 1 gb than to 4 gb and the error is still there.

    opened by c-key 4
  • No support for PHP 5.3?

    No support for PHP 5.3?

    I'm trying to determine if we can upgrade some of our servers that currently run 5.3, but this code requires at least 5.4 due to the array syntax. Would you support merging a PR that changed the array syntax to support PHP 5.3?

    Just for clarity, here's the error I get when running the .phar: PHP Parse error: syntax error, unexpected '[' in phar:///home/star/phpmig.phar/src/App.php on line 83

    opened by aapis 3
  • Call to undefined method PhpParser\Node\Expr\ArrayDimFetch::toString()

    Call to undefined method PhpParser\Node\Expr\ArrayDimFetch::toString()

    php phpmig.phar app/
    
    PHP Fatal error:  Call to undefined method PhpParser\Node\Expr\ArrayDimFetch::toString() in phar://C:/dev/inos/api/phpmig.phar/src/Changes/v5dot3/IncompByReference.php on line 396
    PHP Stack trace:
    PHP   1. {main}() C:\dev\inos\api\phpmig.phar:0
    PHP   2. PhpMigration\App->run() C:\dev\inos\api\phpmig.phar:9
    PHP   3. PhpMigration\App->commandMain() phar://C:/dev/inos/api/phpmig.phar/src/App.php:194
    PHP   4. PhpParser\NodeTraverser->traverse() phar://C:/dev/inos/api/phpmig.phar/src/App.php:399
    PHP   5. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
    PHP   6. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
    PHP   7. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
    PHP   8. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
    PHP   9. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
    PHP  10. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
    PHP  11. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
    PHP  12. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
    PHP  13. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
    PHP  14. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
    PHP  15. PhpMigration\CheckVisitor->leaveNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:101
    PHP  16. PhpMigration\Changes\v5dot3\IncompByReference->leaveNode() phar://C:/dev/inos/api/phpmig.phar/src/CheckVisitor.php:176
    PHP  17. PhpMigration\Changes\v5dot3\IncompByReference->populateCall() phar://C:/dev/inos/api/phpmig.phar/src/Changes/v5dot3/IncompByReference.php:254
    
    Fatal error: Call to undefined method PhpParser\Node\Expr\ArrayDimFetch::toString() in phar://C:/dev/inos/api/phpmig.phar/src/Changes/v5dot3/IncompByReference.php on line 396
    
    Call Stack:
        0.0034     233144   1. {main}() C:\dev\inos\api\phpmig.phar:0
        0.0047     367168   2. PhpMigration\App->run() C:\dev\inos\api\phpmig.phar:9
        0.0047     369000   3. PhpMigration\App->commandMain() phar://C:/dev/inos/api/phpmig.phar/src/App.php:194
        4.9199    6224744   4. PhpParser\NodeTraverser->traverse() phar://C:/dev/inos/api/phpmig.phar/src/App.php:399
        4.9200    6195928   5. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
        4.9201    6196776   6. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
        4.9205    6197712   7. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
        4.9207    6152120   8. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
        4.9207    6152992   9. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
        4.9228    6148072  10. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
        4.9231    6149312  11. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
        4.9336    6157224  12. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
        4.9349    6159064  13. PhpParser\NodeTraverser->traverseArray() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84
        4.9374    6161328  14. PhpParser\NodeTraverser->traverseNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:135
        4.9416    6165456  15. PhpMigration\CheckVisitor->leaveNode() phar://C:/dev/inos/api/phpmig.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:101
        4.9417    6167736  16. PhpMigration\Changes\v5dot3\IncompByReference->leaveNode() phar://C:/dev/inos/api/phpmig.phar/src/CheckVisitor.php:176
        4.9417    6167784  17. PhpMigration\Changes\v5dot3\IncompByReference->populateCall() phar://C:/dev/inos/api/phpmig.phar/src/Changes/v5dot3/IncompByReference.php:254```
    

    php -v

    php -v
    PHP 5.6.19 (cli) (built: Mar  2 2016 20:08:35)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
        with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
    

    app/ contains our Laravel 5.2 project, which I am unable to share, although I could provide more pointers or other info if requested.

    bug 
    opened by theNailz 2
  • Undefined property in AbstractIntroduced.php on line 150

    Undefined property in AbstractIntroduced.php on line 150

    Notice: Undefined property: PhpParser\Node\Expr\ConstFetch::$value in /home/vagrant/Tools/vendor/monque/php-migration/src/Changes/AbstractIntroduced.php on line 150
    
    Call Stack:
        0.0005     225744   1. {main}() /home/vagrant/Tools/vendor/monque/php-migration/bin/phpmig:0
        0.0017     466224   2. PhpMigration\App->run() /home/vagrant/Tools/vendor/monque/php-migration/bin/phpmig:30
        0.0018     469144   3. PhpMigration\App->commandMain() /home/vagrant/Tools/vendor/monque/php-migration/src/App.php:203
       28.0882   11913544   4. PhpParser\NodeTraverser->traverse(array(5)) /home/vagrant/Tools/vendor/monque/php-migration/src/App.php:371
       28.0883   11913592   5. PhpParser\NodeTraverser->traverseArray(array(5)) /home/vagrant/Tools/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
       28.1168   12001232   6. PhpParser\NodeTraverser->traverseNode(class PhpParser\Node\Expr\ErrorSuppress) /home/vagrant/Tools/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:129
       28.1190   12008200   7. PhpMigration\CheckVisitor->leaveNode(class PhpParser\Node\Expr\FuncCall) /home/vagrant/Tools/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:101
       28.1192   12012304   8. PhpMigration\Changes\AbstractIntroduced->leaveNode(class PhpParser\Node\Expr\FuncCall) /home/vagrant/Tools/vendor/monque/php-migration/src/CheckVisitor.php:169
       28.1192   12012352   9. PhpMigration\Changes\AbstractIntroduced->isNewConst(class PhpParser\Node\Expr\FuncCall) /home/vagrant/Tools/vendor/monque/php-migration/src/Changes/AbstractIntroduced.php:93
    
    
    bug 
    opened by keskad 1
  • Shellscript have a wrong path

    Shellscript have a wrong path

    In version 0.1.1 that i have installed via composer on a debian, the shellscript "phpmig" under vender/../bin produce an error. I have change the path to the autoload.php an all was nice.

    opened by c-key 1
  • Running CLI in local composer installation fails

    Running CLI in local composer installation fails

    When you install PHP-Migration on CLI with command

    php composer.phar require monque/php-migration
    

    the vendor directory is not where you're supposed to be.

    NOTE: I've the same problem in past with my project https://github.com/llaville/php-compat-info/issues/126

    opened by llaville 1
  • nikic vendor dependency too restrictive

    nikic vendor dependency too restrictive

    Dependency is too restrictive, and does not allow benefit of new versions

     "nikic/php-parser": "~1.0.1",
    

    You should changed this at least to

     "nikic/php-parser": "~1.1",
    

    Better will be ~1.3 or even ~1.2

    enhancement 
    opened by llaville 1
  • Allocation memory error

    Allocation memory error

    While I've tried either phar or source code version, I got on each run an PHP Fatal error: Allowed memory size, even with the sample script

    This PR fixed issue on my side ! It may be a bit restrictive (4Mb) ;-)

    BTW, nice project idea

    opened by llaville 1
  • magic const trigger notice

    magic const trigger notice

    when magic const as class property array key, trigger notice

    PHP Notice:  Undefined property: PhpParser\Node\Scalar\MagicConst\Function_::$value in /Users/ruitao/.composer/vendor/monque/php-migration/src/Changes/v5dot6/IncompPropertyArray.php on line 48
    PHP Stack trace:
    PHP   1. {main}() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:0
    PHP   2. PhpMigration\App->run() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:22
    PHP   3. PhpMigration\App->commandMain() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:194
    PHP   4. PhpParser\NodeTraverser->traverse() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:399
    PHP   5. PhpParser\NodeTraverser->traverseArray() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
    PHP   6. PhpMigration\CheckVisitor->leaveNode() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:139
    PHP   7. PhpMigration\Changes\v5dot6\IncompPropertyArray->leaveNode() /Users/ruitao/.composer/vendor/monque/php-migration/src/CheckVisitor.php:176
    
    Notice: Undefined property: PhpParser\Node\Scalar\MagicConst\Function_::$value in /Users/ruitao/.composer/vendor/monque/php-migration/src/Changes/v5dot6/IncompPropertyArray.php on line 48
    
    Call Stack:
        0.0003     357680   1. {main}() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:0
        0.0069     647360   2. PhpMigration\App->run() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:22
        0.0069     648432   3. PhpMigration\App->commandMain() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:194
        0.1112    4250888   4. PhpParser\NodeTraverser->traverse() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:399
        0.1112    4250888   5. PhpParser\NodeTraverser->traverseArray() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
        0.2436    4381640   6. PhpMigration\CheckVisitor->leaveNode() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:139
        0.2438    4381616   7. PhpMigration\Changes\v5dot6\IncompPropertyArray->leaveNode() /Users/ruitao/.composer/vendor/monque/php-migration/src/CheckVisitor.php:176
    
    opened by aizuyan 0
  • magic const trigger notice

    magic const trigger notice

    when magic const as class property array key, trigger notice

    PHP Notice:  Undefined property: PhpParser\Node\Scalar\MagicConst\Function_::$value in /Users/ruitao/.composer/vendor/monque/php-migration/src/Changes/v5dot6/IncompPropertyArray.php on line 48
    PHP Stack trace:
    PHP   1. {main}() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:0
    PHP   2. PhpMigration\App->run() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:22
    PHP   3. PhpMigration\App->commandMain() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:194
    PHP   4. PhpParser\NodeTraverser->traverse() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:399
    PHP   5. PhpParser\NodeTraverser->traverseArray() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
    PHP   6. PhpMigration\CheckVisitor->leaveNode() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:139
    PHP   7. PhpMigration\Changes\v5dot6\IncompPropertyArray->leaveNode() /Users/ruitao/.composer/vendor/monque/php-migration/src/CheckVisitor.php:176
    
    Notice: Undefined property: PhpParser\Node\Scalar\MagicConst\Function_::$value in /Users/ruitao/.composer/vendor/monque/php-migration/src/Changes/v5dot6/IncompPropertyArray.php on line 48
    
    Call Stack:
        0.0003     357680   1. {main}() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:0
        0.0069     647360   2. PhpMigration\App->run() /Users/ruitao/.composer/vendor/monque/php-migration/bin/phpmig:22
        0.0069     648432   3. PhpMigration\App->commandMain() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:194
        0.1112    4250888   4. PhpParser\NodeTraverser->traverse() /Users/ruitao/.composer/vendor/monque/php-migration/src/App.php:399
        0.1112    4250888   5. PhpParser\NodeTraverser->traverseArray() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
        0.2436    4381640   6. PhpMigration\CheckVisitor->leaveNode() /Users/ruitao/.composer/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:139
        0.2438    4381616   7. PhpMigration\Changes\v5dot6\IncompPropertyArray->leaveNode() /Users/ruitao/.composer/vendor/monque/php-migration/src/CheckVisitor.php:176
    
    opened by aizuyan 0
  • Enhancement - Mark a file as reviewed

    Enhancement - Mark a file as reviewed

    Hi, Your tool is great. But I have a big project to migrate, and I can't do it in one shot. So I progressively check files.

    But when some alerts are not identified with the * (or they are identified but I don't care), I have no way to say "Ok this file has been reviewed", so phpmig does not need to care about it anymore. So they popup everytime I run phpmig

    I suggest phpmig watch for a "@phpmig-reviewed" tag in comments in the X first lines of the file. And if the tag exists, phpmig just ignore that file.

    Or maybe create a ~/.phpmigignore file with absolute paths and phpmig watch for it and ignore files in that file.

    Thank you.

    opened by Wilkins 1
Releases(v0.2.2)
Owner
Yuchen Wang
Yuchen Wang
SonarPHP: PHP static analyzer for SonarQube & SonarLint

Code Quality and Security for PHP This SonarSource project is a static code analyser for PHP language used as an extension for the SonarQube platform.

SonarSource 343 Dec 25, 2022
PHPSA - Smart Analyzer for PHP

PHPSA - Smart Analyzer for PHP PHPSA is a development tool aimed at bringing complex analysis for PHP applications and libraries. P.S This software is

Dmitry Patsura 647 Nov 20, 2022
Rector rules for Nette to Symfony migration

Rector Nette to Symfony Do you need to migrate from Nette to Symfony? You can ↓ How we Migrated 54 357-lines Application from Nette to Symfony in 2 Pe

Rector 8 May 30, 2022
PHP Static Analysis Tool - discover bugs in your code without running it!

PHPStan - PHP Static Analysis Tool PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even b

PHPStan 11.6k Dec 30, 2022
Beautiful and understandable static analysis tool for PHP

PhpMetrics PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report. Documentation | Twitter | Contributing

PhpMetrics 2.3k Dec 22, 2022
Performs advanced static analysis on PHP code

PHP Analyzer Please report bugs or feature requests via our website support system ? in bottom right or by emailing [email protected]. Contri

Continuous Inspection 443 Sep 23, 2022
The Exakat Engine : smart static analysis for PHP

Exakat The Exakat Engine is an automated code reviewing engine for PHP. Installation Installation with the phar Phar is the recommended installation p

Exakat 370 Dec 28, 2022
A static php code analysis tool using the Graph Theory

Mondrian Ok guyz, you have a master degree in Graph Theory, you follow Law of Demeter and you live on S.O.L.I.D principles ? Let's have some Fun ! (^ω

Florent Genette 391 Nov 30, 2022
A static analysis tool for finding errors in PHP applications

Psalm Psalm is a static analysis tool for finding errors in PHP applications. Installation To get started, check out the installation guide. Live Demo

Vimeo 5k Jan 2, 2023
Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects

Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. You can freely define your architectural layers over classes and which rules should apply to them.

QOSSMIC GmbH 2.2k Dec 30, 2022
Static code analysis to find violations in a dependency graph

PhpDependencyAnalysis PhpDependencyAnalysis is an extendable static code analysis for object-oriented PHP-Projects to generate dependency graphs from

Marco Muths 546 Dec 7, 2022
A static analysis tool for security

progpilot A static analyzer for security purposes Only PHP language is currently supported Installation Option 1: use standalone phar Download the lat

null 271 Dec 27, 2022
Parse: A Static Security Scanner

Parse: A PHP Security Scanner PLEASE NOTE: This tool is still in a very early stage. The work continues... The Parse scanner is a static scanning tool

psec.io 342 Jan 2, 2023
Static Analysis Results Baseliner

Static Analysis Results Baseliner (SARB) Why SARB Requirements Installing Using SARB Examples Further reading Why SARB? If you've tried to introduce a

Dave Liddament 151 Jan 3, 2023
Infection Static Analysis Plugin

Static analysis on top of mutation testing - prevents escaped mutants from being invalid according to static analysis

Roave, LLC 108 Jan 2, 2023
PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend.

PHPMD PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly

PHP Mess Detector 2.1k Jan 8, 2023
A PHP parser written in PHP

PHP Parser This is a PHP 5.2 to PHP 8.0 parser written in PHP. Its purpose is to simplify static code analysis and manipulation. Documentation for ver

Nikita Popov 15.9k Jan 3, 2023
A PHP VM implementation in PHP

PHPPHP A PHP VM implementation written in PHP. This is a basic VM implemented in PHP using the AST generating parser developed by @nikic To see what's

Anthony Ferrara 801 Dec 25, 2022
PHP Architecture Tester - Easy to use architectural testing tool for PHP :heavy_check_mark:

Easy to use architecture testing tool for PHP Introduction ?? PHP Architecture Tester is a static analysis tool to verify architectural requirements.

Carlos A Sastre 765 Dec 30, 2022