PHP7 相容性檢測
  • 5,823 views,
  • 2016-08-05,
  • 上傳者: Kuann Hung,
  •  0
最近開始把公司產品要升級到 php7 (當然,只是先確定可以在 php7 的環境執行,畢竟還有一段路要走)
因為程式眾多,不可能一支一支檢視,所以就找現成的工具囉!
 
PHP 7 Compatibility Checker: https://github.com/sstalle/php7cc
 
這個專案是專門用來檢查你的程式是否有不符合 PHP7 語法的,而且可以在 PHP 5.3.3 以上的環境即可執行
檢測方式
1.
相關升級說明
在處理之前,最好把每個版本的升級說明看一下,這樣比較知道哪些可能會有問題喔!
2.
安裝 PHP 7 Compatibility Checker
最快的方法當然是透過 Composer 囉
composer global require sstalle/php7cc
3.
使用方式
直接使用 php 執行 php7cc 即可
參數如下: 
php7cc [-e|--extensions [EXTENSIONS]] [-x|--except [EXCEPT]] [-l|--level LEVEL] [-r|--relative-paths] [--integer-size INTEGER-SIZE] [--] <paths> (<paths>)...
 
只要下 php php7cc {path}
就可以列出那些檔案的語法可能有問題了,不過還是要仔細看,有些是警告,不一定需要修正的
> Line 465: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 474: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 486: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 508: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 519: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 530: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 539: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 549: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
> Line 558: Function argument(s) returned by "func_get_args" might have been modified
    func_get_args();
Facebook 討論區載入中...
資料夾 :
發表時間 :
2016-08-05 21:00:00
觀看數 :
5,823
發表人 :
Kuann Hung
部門 :
老洪的 IT 學習系統
QR Code :