LoginSignup
21
16

More than 5 years have passed since last update.

php7ccを利用したPHP5.6⇒PHP7へのコンバージョンチェック

Posted at

php7ccを利用したPHP5.6⇒PHP7へのコンバージョンチェック

EC-CUBE関連のシステム開発で、PHP5.6からPHP7へのコンバージョンが必要かもしれない。ということがあったため、
その時の作業メモを残したいと思います。
PHP5系はそもそも現時点(2018/4/17時点)ではすでにサポートが切れており、セキュリティパッチなどが公開されないバージョンとなっています。
しかし、PHP界隈では多く利用されてきたバージョンということもあり、バージョンアップには四苦八苦することも多いのではないでしょうか。

php7ccを利用してコンバージョンチェックを実施

以下の記事を参考にコンバージョンチェックを実施しました。
PHP7の互換性チェック

php7ccの結果まとめ及びその対処方法の参考

この実施結果の出力ログを、DISTINCTしてエラー内容を一覧にまとめたのが、下表です。
参考情報としてまとめたものなので、不備などがあるかと思いますが、いろいろ調べた結果をログとして残しておこうと思い、表にまとめています。

エラーログ種類 概要/対処方法
1 [Error] Bitwise shift by 7128 bits 不明
2 [Error] break not in the loop or switch context 不要な箇所にbreakが指定されている
3 [Error] Class/trait/interface "Error" was added in the global namespace Errorという名前空間は予約語であるため使用できない。
4 [Error] Duplicate function parameter name "owner" 引数に指定されるパラメータ名が重複しているためエラー。
5 [Error] Name "object" that is reserved for future use (does not cause an error in PHP 7) used as a use statement alias "object"が予約語なためエラー。
6 [Error] PHP 4 constructors are now deprecated コンストラクタは「__construct()」にしないとエラー。
7 [Error] Removed "HTTP_RAW_POST_DATA" variable used この機能は PHP 5.6.0 で 非推奨 となり、 PHP 7.0.0 で 削除 されました。$HTTP_RAW_POST_DATA の代わりに、 php://input を使うべきです。
8 [Error] Removed argument $is_dst used for function "gmmktime" gmmktime関数のis_dst引数は、PHP7.0.0で削除されました。
9 [Error] Removed argument $is_dst used for function "mktime" mktime関数のis_dst引数は、PHP7.0.0で削除されました。
10 [Error] Removed function "ereg" called erep関数は削除されました。代替関数としてpreg_match()を利用する。
11 [Error] Removed function "ereg_replace" called ereg_replace関数は削除されました。preg_replaceに置き換えることで対応可能。
12 [Error] Removed function "EregI" called eregi関数は削除されました。この関数の代替として、これらが使えます。preg_match() (i (PCRE_CASELESS) 修飾子を使う)
13 [Error] Removed function "eregi_replace" called eregi_replace関数は削除されました。この関数の代替として、これらが使えます。preg_replace() (with the i (PCRE_CASELESS) modifier)
14 [Error] Removed function "mssql_bind" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::bindParam()PDOStatement::bindValue()sqlsrv_prepare()odbc_prepare()
15 [Error] Removed function "mssql_close" called この関数は削除されました。この関数の代替として、これらが使えます。sqlsrv_close()odbc_close()odbc_close_all()
16 [Error] Removed function "mssql_connect" called この関数は削除されました。この関数の代替として、これらが使えます。PDO::__construct()sqlsrv_connect()odbc_connect()
17 [Error] Removed function "mssql_data_seek" called この関数は削除されました。この関数の代替として、これらが使えます。PDO_SQLSRV、 PDO_ODBC、 SQLSRV あるいは unified ODBC ドライバ で発行したクエリで OFFSET 句を使う
18 [Error] Removed function "mssql_execute" called この関数は削除されました。この関数の代替として、これらが使えます。PDO_SQLSRV、 PDO_ODBC、 SQLSRV あるいは unified ODBC ドライバ で EXEC クエリを発行する
19 [Error] Removed function "mssql_fetch_array" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::fetch()sqlsrv_fetch_array()odbc_fetch_array()
20 [Error] Removed function "mssql_fetch_assoc" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::fetch()sqlsrv_fetch_array()odbc_fetch_array()
21 [Error] Removed function "mssql_fetch_field" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::getColumnMeta()sqlsrv_field_metadata()unified ODBC ドライバ の odbc_field_* 関数群
22 [Error] Removed function "mssql_fetch_row" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::fetch()sqlsrv_fetch_array()odbc_fetch_row()
23 [Error] Removed function "mssql_field_length" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::getColumnMeta()sqlsrv_field_metadata()odbc_field_len()
24 [Error] Removed function "mssql_field_name" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::getColumnMeta()sqlsrv_field_metadata()odbc_field_name()
25 [Error] Removed function "mssql_field_type" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::getColumnMeta()sqlsrv_field_metadata()odbc_field_type()
26 [Error] Removed function "mssql_free_result" called この関数は削除されました。この関数の代替として、これらが使えます。odbc_free_result()
27 [Error] Removed function "mssql_get_last_message" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::errorInfo()sqlsrv_errors()odbc_errormsg()
28 [Error] Removed function "mssql_init" called この関数は削除されました。この関数の代替として、これらが使えます。PDO_SQLSRV、 PDO_ODBC、 SQLSRV あるいは unified ODBC ドライバ で EXEC クエリを発行する
29 [Error] Removed function "mssql_next_result" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::nextRowset()sqlsrv_next_result()odbc_next_result()
30 [Error] Removed function "mssql_num_fields" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::columnCount()sqlsrv_num_fields()odbc_num_fields()
31 [Error] Removed function "mssql_num_rows" called この関数は削除されました。この関数の代替として、これらが使えます。PDOStatement::rowCount()sqlsrv_num_rows()odbc_num_rows()
32 [Error] Removed function "mssql_pconnect" called この関数は削除されました。この関数の代替として、これらが使えます。PDO::__construct()sqlsrv_connect()odbc_pconnect()
33 [Error] Removed function "mssql_query" called この関数は削除されました。この関数の代替として、これらが使えます。PDO::query()sqlsrv_query()odbc_exec()
34 [Error] Removed function "mssql_select_db" called この関数は削除されました。この関数の代替として、これらが使えます。PDO_SQLSRV DSNPDO_ODBC DSNsqlsrv_connect()odbc_connect()
35 [Error] Removed function "mysql_affected_rows" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_affected_rows()PDOStatement::rowCount()
36 [Error] Removed function "mysql_close" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_close()PDO: PDO オブジェクトへの NULL の代入
37 [Error] Removed function "mysql_connect" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_connect()PDO::__construct()
38 [Error] Removed function "mysql_data_seek" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_data_seek()PDO::FETCH_ORI_ABS
39 [Error] Removed function "mysql_errno" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_errno()PDO::errorCode()
40 [Error] Removed function "mysql_error" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_error()PDO::errorInfo()
41 [Error] Removed function "mysql_escape_string" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_escape_string()PDO::quote()$q = mysql_escape_string( $q );    ↓$mysqli = new mysqli('サーバ名', 'ユーザー名','パスワード', 'DB名');$q = $mysqli->real_escape_string( $q );
42 [Error] Removed function "mysql_fetch_array" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_array()PDOStatement::fetch()
43 [Error] Removed function "mysql_fetch_field" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_field()PDOStatement::getColumnMeta()
44 [Error] Removed function "mysql_fetch_row" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_row()PDOStatement::fetch(PDO::FETCH_NUM)
45 [Error] Removed function "mysql_field_flags" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_field_direct() [flags]PDOStatement::getColumnMeta() [flags]
46 [Error] Removed function "mysql_field_len" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_field_direct() [length]PDOStatement::getColumnMeta() [len]
47 [Error] Removed function "mysql_field_name" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_field_direct() [name] あるいは [orgname]PDOStatement::getColumnMeta() [name]
48 [Error] Removed function "mysql_field_table" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_field_direct() [table] あるいは [orgtable]PDOStatement::getColumnMeta() [table]
49 [Error] Removed function "mysql_field_type" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_fetch_field_direct() [type]PDOStatement::getColumnMeta() [driver:decl_type] あるいは [pdo_type]
50 [Error] Removed function "mysql_free_result" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_free_result()NULL を PDO オブジェクトに代入、あるいは PDOStatement::closeCursor()
51 [Error] Removed function "mysql_insert_id" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_insert_id()PDO::lastInsertId()
52 [Error] Removed function "mysql_list_dbs" called この関数は削除されました。この関数の代替として、これらが使えます。SQL クエリー: SHOW DATABASES
53 [Error] Removed function "mysql_list_fields" called この関数は削除されました。この関数の代替として、これらが使えます。SQL クエリー: SHOW COLUMNS FROM sometable
54 [Error] Removed function "mysql_num_fields" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_num_fields()PDOStatement::columnCount()
55 [Error] Removed function "mysql_num_rows" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_num_rows()mysqli_stmt_num_rows()PDOStatement::rowCount()
56 [Error] Removed function "mysql_pconnect" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_connect() にホストプレフィックス p: を指定PDO::__construct() のドライバオプションで PDO::ATTR_PERSISTENT を指定
57 [Error] Removed function "mysql_query" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_query()PDO::query()
58 [Error] Removed function "mysql_real_escape_string" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_real_escape_string()PDO::quote()
59 [Error] Removed function "mysql_select_db" called この関数は削除されました。この関数の代替として、これらが使えます。mysqli_select_db()PDO::__construct() (dsn で指定)
60 [Error] Removed function "mysql_tablename" called この関数は削除されました。この関数の代替として、これらが使えます。SQL クエリー: SHOW TABLES
61 [Error] Removed function "mysql_unbuffered_query" called この関数は削除されました。この関数の代替として、これらが使えます。Buffered and Unbuffered queries を参照
62 [Error] Removed function "set_magic_quotes_runtime" called magic_quotes_runtime の現在アクティブな設定をセットするこの関数は PHP 5.3.0 で 非推奨 となり、 PHP 7.0.0 で 削除 されました。これは削除(コメントアウト)するだけでOK。set_magic_quotes_runtime(true);    ↓// set_magic_quotes_runtime(true);
63 [Error] Removed function "split" called この関数は削除されました。この関数の代替として、これらが使えます。preg_split()explode()str_split()
64 [Error] Removed regular expression modifier "e" used 不明
65 [Error] Result of new is assigned by reference 不明
21
16
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
21
16