Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Deprecated Using ${var} in strings is deprecated, use {$var} instead #6244

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

ci-wataru-kashii
Copy link
Contributor

PHP8.2、PHP8.3 を対象に bin/console cache:clear --no-warmup を実行したところ
PHP8.2より非推奨になったエラーを検出したため、修正しました。

root@c588aed4dd3e:/var/www/html/ec-cube-4.3# bin/console cache:clear --no-warmup && bin/console cache:warmup

 // Clearing the cache for the prod environment with debug false


 [OK] Cache for the "prod" environment (debug=false) was successfully cleared.



Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/DeleteCartsCommand.php on line 141

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 253

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 280

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 307

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 336

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 338

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 341

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 342

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 365

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 365

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 366

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 394

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 396

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 400

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 404

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 460

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 462

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 510

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 512

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginGenerateCommand.php on line 553

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginSchemaUpdateCommand.php on line 45

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Command/PluginUpdateCommand.php on line 45

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Controller/Admin/Store/PluginController.php on line 305

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Controller/CartController.php on line 166

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Doctrine/ORM/Mapping/Driver/ReloadSafeAnnotationDriver.php on line 142

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Doctrine/ORM/Mapping/Driver/ReloadSafeAnnotationDriver.php on line 145

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Doctrine/ORM/Query/Extract.php on line 104

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginContext.php on line 74

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginContext.php on line 78

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginService.php on line 473

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginService.php on line 478

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginService.php on line 482

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginService.php on line 486

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Service/PluginService.php on line 681

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Util/StringUtil.php on line 332

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/ec-cube-4.3/src/Eccube/Util/StringUtil.php on line 332

Deprecated: Eccube\Entity\Customer implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /var/www/html/ec-cube-4.3/src/Eccube/Entity/Customer.php on line 34

Deprecated: Eccube\Entity\Member implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /var/www/html/ec-cube-4.3/src/Eccube/Entity/Member.php on line 34

 // Warming up the cache for the prod environment with debug false


 [OK] Cache for the "prod" environment (debug=false) was successfully warmed.


root@c588aed4dd3e:/var/www/html/ec-cube-4.3#

概要(Overview・Refs Issue)

引用元:https://www.php.net/manual/ja/migration82.deprecated.php#migration82.deprecated.core.dollar-brace-interpolation

"${var}" / "${expr}" 形式の、文字列への値の埋め込み

"${var}" と "${expr}" 形式の文字列への値の埋め込みは、推奨されなくなりました。
 "$var"/"{$var}" や "{${expr}}" 形式をそれぞれ使ってください。

方針(Policy)

考慮したもの

  • EC-CUBE上に使われているコードを参考に、プログラムの動作を確認できるツールを用いて検証に加えPHP8.1環境でも動作が可能か確認しました。 https://3v4l.org/
  • 対象ファイルを「.php」としました。

実装に関する補足(Appendix)

テスト(Test)

サンプルコード

(非推奨の場合) 結果:

<?php
        $code = 'code';
        var_dump("No such plugin `${code}`.");

結果 https://3v4l.org/b0Mmr

Output for 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/b0Mmr on line 4
string(22) "No such plugin `code`."

Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29
string(22) "No such plugin `code`."

(fix)

<?php
        $code = 'code';
        var_dump("No such plugin `{$code}`.");

結果 https://3v4l.org/nVM9p

Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
string(22) "No such plugin `code`."

相談(Discussion)

マイナーバージョン互換性保持のための制限事項チェックリスト

  • 既存機能の仕様変更はありません
  • フックポイントの呼び出しタイミングの変更はありません
  • フックポイントのパラメータの削除・データ型の変更はありません
  • twigファイルに渡しているパラメータの削除・データ型の変更はありません
  • Serviceクラスの公開関数の、引数の削除・データ型の変更はありません
  • 入出力ファイル(CSVなど)のフォーマット変更はありません

レビュワー確認項目

  • 動作確認
  • コードレビュー
  • E2E/Unit テスト確認(テストの追加・変更が必要かどうか)
  • 互換性が保持されているか
  • セキュリティ上の問題がないか
    • 権限を超えた操作が可能にならないか
    • 不要なファイルアップロードがないか
    • 外部へ公開されるファイルや機能の追加ではないか
    • テンプレートでのエスケープ漏れがないか

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.79%. Comparing base (b4250db) to head (097385e).
Report is 28 commits behind head on 4.3.

Files Patch % Lines
src/Eccube/Service/PluginService.php 40.00% 3 Missing ⚠️
src/Eccube/Service/PluginContext.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              4.3    #6244      +/-   ##
==========================================
- Coverage   82.80%   82.79%   -0.01%     
==========================================
  Files         480      480              
  Lines       26425    26425              
==========================================
- Hits        21880    21879       -1     
- Misses       4545     4546       +1     
Flag Coverage Δ
E2E 82.79% <44.44%> (-0.01%) ⬇️
Unit 82.79% <44.44%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dotani1111
Copy link
Contributor

dotani1111 commented Jul 7, 2024

@ci-wataru-kashii
PRありがとうございます!
非推奨のメッセージが出てることは認識していたので、解消してくださるのはありがたいです。
動作確認進めて行きたいと思います。

@dotani1111
Copy link
Contributor

dotani1111 commented Jul 8, 2024

メモ
テストは通っているので問題ないと思います。
カバレッジが落ちていますが、この変更だと変化することはないはずです。
気にしなくて大丈夫かと思います。

@dotani1111 dotani1111 added this to the 4.3.x milestone Jul 8, 2024
@ji-eunsoo ji-eunsoo merged commit 13ed3e8 into EC-CUBE:4.3 Aug 7, 2024
94 of 96 checks passed
@ji-eunsoo
Copy link
Contributor

@ci-wataru-kashii
ありがとうございます。マージしました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants