33
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP7の互換性チェック

Posted at

php7ccを使うと既存のソースコードがPHP7に対応しているかどうか、チェックできます。

#php7ccのインストール
composerでインスール

composer global require sstalle/php7cc

パスを通す

export PATH="$PATH:$HOME/.composer/vendor/bin"

#実行してみる

$php7cc {ファイルorディレクトリ}

##オプション

###extensions
特定の拡張子だけチェックしたい場合

php7cc --extensions=php,inc,lib /path/to/my/directory/

###except
特定のディレクトリを除外したい場合

php7cc --except=vendor --except=/path/to/my/directory/test /path/to/my/directory/

###level

エラーのレベルを指定したい場合

php7cc --level=error /path/to/my/directory/

その他のオプションはphp7cc --helpで確認できます。

##試しに


<?php

class Test
{

  function Test()
  {

  }

  function test1()
  {
    ereg('', '');

    $a = [1, 2, 3];
    list(,,) = $a;

    preg_replace('//e', '', '');
  }


}

というファイルをチェックした場合

$ php7cc test.php 

File: test.php
> Line 6: PHP 4 constructors are now deprecated
    function Test()
    {
    }
> Line 13: Removed function "ereg" called
    ereg('', '');
> Line 16: Empty list assignment
    list(, , );
> Line 18: Removed regular expression modifier "e" used
    preg_replace('//e', '', '');

Checked 1 file in 0.034 second

エラーの箇所と内容が表示される

33
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?