Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
monque committed Aug 28, 2016
1 parent 5e496d4 commit bd4bbbc
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 29 deletions.
68 changes: 54 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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 - 5.6.
- 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.
Expand All @@ -30,7 +30,7 @@ Features:

1. You can download a executable [Phar](http://php.net/manual/en/book.phar.php) file
```
wget https:/monque/PHP-Migration/releases/download/v0.1.2/phpmig.phar
wget https:/monque/PHP-Migration/releases/download/v0.2.0/phpmig.phar
```

2. Use the following command to check PHP file
Expand All @@ -50,6 +50,8 @@ Features:

// Fatal error: Cannot redeclare class_alias()
function class_alias() {}

// This is fine
if (!function_exists('class_alias')) {
function class_alias() {}
}
Expand All @@ -65,25 +67,46 @@ Features:
// Fatal error: Cannot re-assign auto-global variable _GET
function ohno($_GET) {}

// Fatal error: Call to undefined function php_logo_guid()
php_logo_guid();
// 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 8 spot(s), 8 identified
--------------------------------------------------------------------------------
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
7 | WARNING | * | 5.3.0 | Constant "__DIR__" already defined
10 | FATAL | * | 5.3.0 | Cannot redeclare class_alias()
16 | FATAL | * | 5.4.0 | Call-time pass-by-reference has been removed
20 | FATAL | * | 5.4.0 | break operator with non-constant operand is no longer supported
24 | FATAL | * | 5.4.0 | Cannot re-assign auto-global variable
27 | FATAL | * | 5.5.0 | Function php_logo_guid() is removed
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.
Expand All @@ -102,10 +125,12 @@ 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.
Expand All @@ -127,16 +152,19 @@ Output:
| | |-- PhpMigration\Changes\v5dot3\Introduced
| | |-- PhpMigration\Changes\v5dot4\Introduced
| | |-- PhpMigration\Changes\v5dot5\Introduced
| | `-- PhpMigration\Changes\v5dot6\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\v5dot6\Removed
| | `-- PhpMigration\Changes\v7dot0\Removed
| |-- PhpMigration\Changes\ClassTree
| |-- PhpMigration\Changes\Dev
| |-- PhpMigration\Changes\v5dot3\Deprecated
| |-- PhpMigration\Changes\v5dot3\IncompByReference
| |-- PhpMigration\Changes\v5dot3\IncompCallFromGlobal
Expand All @@ -146,6 +174,7 @@ Output:
| |-- 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
Expand All @@ -154,9 +183,20 @@ Output:
| |-- PhpMigration\Changes\v5dot5\IncompPack
| |-- PhpMigration\Changes\v5dot6\Deprecated
| |-- PhpMigration\Changes\v5dot6\IncompMisc
| `-- PhpMigration\Changes\v5dot6\IncompPropertyArray
| |-- 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
Expand Down
66 changes: 53 additions & 13 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
码。

有以下特性:
- 检查全面,覆盖PHP 5.3至5.6中绝大部分改动
- 检查全面,覆盖PHP 5.3至**7.0**中绝大部分改动
- 严谨不遗漏,并做到尽可能精准
- 零配置,下载即用
- 可以快速开发适用于个人项目的检查
Expand All @@ -27,7 +27,7 @@

1. 你可以通过下面命令下载一个封装好的可执行的[Phar](http://php.net/manual/zh/book.phar.php)文件
```
wget https:/monque/PHP-Migration/releases/download/v0.1.2/phpmig.phar
wget https:/monque/PHP-Migration/releases/download/v0.2.0/phpmig.phar
```

2. 执行下面命令,将会对该文件进行检查,并输出报告
Expand All @@ -47,6 +47,8 @@

// Fatal error: Cannot redeclare class_alias()
function class_alias() {}

// This is fine
if (!function_exists('class_alias')) {
function class_alias() {}
}
Expand All @@ -62,25 +64,46 @@
// Fatal error: Cannot re-assign auto-global variable _GET
function ohno($_GET) {}

// Fatal error: Call to undefined function php_logo_guid()
php_logo_guid();
// 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. 报告输出内容如下
表中各列含义如下:行号,问题级别,是否确认,起始版本,详细信息
```
File: sample.php
--------------------------------------------------------------------------------
Found 8 spot(s), 8 identified
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
7 | WARNING | * | 5.3.0 | Constant "__DIR__" already defined
10 | FATAL | * | 5.3.0 | Cannot redeclare class_alias()
16 | FATAL | * | 5.4.0 | Call-time pass-by-reference has been removed
20 | FATAL | * | 5.4.0 | break operator with non-constant operand is no longer supported
24 | FATAL | * | 5.4.0 | Cannot re-assign auto-global variable
27 | FATAL | * | 5.5.0 | Function php_logo_guid() is removed
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
--------------------------------------------------------------------------------
```
> 关于第三列`是否确认`的含义,在下面会有详细的解释。
Expand All @@ -98,10 +121,12 @@ 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
```
并通过`php phpmig.phar -s <setname>`选择要使用的检查组。
Expand All @@ -125,16 +150,19 @@ v56 => Migrating from PHP 5.5.x to PHP 5.6.x
| | |-- PhpMigration\Changes\v5dot3\Introduced
| | |-- PhpMigration\Changes\v5dot4\Introduced
| | |-- PhpMigration\Changes\v5dot5\Introduced
| | `-- PhpMigration\Changes\v5dot6\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\v5dot6\Removed
| | `-- PhpMigration\Changes\v7dot0\Removed
| |-- PhpMigration\Changes\ClassTree
| |-- PhpMigration\Changes\Dev
| |-- PhpMigration\Changes\v5dot3\Deprecated
| |-- PhpMigration\Changes\v5dot3\IncompByReference
| |-- PhpMigration\Changes\v5dot3\IncompCallFromGlobal
Expand All @@ -144,6 +172,7 @@ v56 => Migrating from PHP 5.5.x to PHP 5.6.x
| |-- 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
Expand All @@ -152,9 +181,20 @@ v56 => Migrating from PHP 5.5.x to PHP 5.6.x
| |-- PhpMigration\Changes\v5dot5\IncompPack
| |-- PhpMigration\Changes\v5dot6\Deprecated
| |-- PhpMigration\Changes\v5dot6\IncompMisc
| `-- PhpMigration\Changes\v5dot6\IncompPropertyArray
| |-- 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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.4.0",
"nikic/php-parser": "^2.1.0",
"psr/log": "^1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class App
{
const VERSION = '0.1.3';
const VERSION = '0.2.0';

protected $setpath;

Expand Down
17 changes: 17 additions & 0 deletions src/Utils/Packager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class Packager
'doc/Migrating from PHP 5.3.x to PHP 5.4.x.md',
'doc/Migrating from PHP 5.4.x to PHP 5.5.x.md',
'doc/Migrating from PHP 5.5.x to PHP 5.6.x.md',
'doc/migration70.yml',
'src/App.php',
'src/Changes/AbstractChange.php',
'src/Changes/AbstractIntroduced.php',
'src/Changes/AbstractKeywordReserved.php',
'src/Changes/AbstractRemoved.php',
'src/Changes/ClassTree.php',
'src/Changes/RemoveTableItemTrait.php',
'src/Changes/v5dot3/Deprecated.php',
'src/Changes/v5dot3/IncompByReference.php',
'src/Changes/v5dot3/IncompCallFromGlobal.php',
Expand Down Expand Up @@ -52,17 +54,32 @@ class Packager
'src/Changes/v5dot6/IncompPropertyArray.php',
'src/Changes/v5dot6/Introduced.php',
'src/Changes/v5dot6/Removed.php',
'src/Changes/v7dot0/Deprecated.php',
'src/Changes/v7dot0/ExceptionHandle.php',
'src/Changes/v7dot0/ForeachLoop.php',
'src/Changes/v7dot0/FuncList.php',
'src/Changes/v7dot0/FuncParameters.php',
'src/Changes/v7dot0/IntegerOperation.php',
'src/Changes/v7dot0/Introduced.php',
'src/Changes/v7dot0/KeywordReserved.php',
'src/Changes/v7dot0/ParseDifference.php',
'src/Changes/v7dot0/Removed.php',
'src/Changes/v7dot0/StringOperation.php',
'src/Changes/v7dot0/SwitchMultipleDefaults.php',
'src/CheckVisitor.php',
'src/Logger.php',
'src/ReduceVisitor.php',
'src/Sets/classtree.json',
'src/Sets/to53.json',
'src/Sets/to54.json',
'src/Sets/to55.json',
'src/Sets/to56.json',
'src/Sets/to70.json',
'src/Sets/v53.json',
'src/Sets/v54.json',
'src/Sets/v55.json',
'src/Sets/v56.json',
'src/Sets/v70.json',
'src/SymbolTable.php',
'src/Utils/FunctionListExporter.php',
'src/Utils/Logging.php',
Expand Down

0 comments on commit bd4bbbc

Please sign in to comment.