Skip to content

deprecated の警告を修正 #6378

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

Open
wants to merge 15 commits into
base: 4.3
Choose a base branch
from
Open

Conversation

nanasess
Copy link
Contributor

@nanasess nanasess commented May 26, 2025

概要(Overview・Refs Issue)

以下の警告を修正

  • SplFileObject::fputcsv(): the $escape parameter must be provided, as its default value will change, either explicitly or via SplFileObject::setCsvControl()
  • preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated
  • mb_convert_kana(): Passing null to parameter #1 ($string) of type string is deprecated
  • auto_detect_line_endings is deprecated
  • str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
  • usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero
  • file_exists(): Passing null to parameter #1 ($filename) of type string is deprecated
  • preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated
  • NumberFormatter::formatCurrency(): Passing null to parameter #1 ($amount) of type float is deprecated
  • fgetcsv(): the $escape parameter must be provided as its default value will change
  • mb_substr(): Passing null to parameter #1 ($string) of type string is deprecated
  • strlen(): Passing null to parameter #1 ($string) of type string is deprecated
  • trim(): Passing null to parameter #1 ($string) of type string is deprecated

方針(Policy)

実装に関する補足(Appendix)

以下を実行すると、非推奨警告の出るタイミングでスタックトレースを出力するので、修正箇所を把握しやすい

SYMFONY_DEPRECATIONS_HELPER="/<非推奨警告の出る関数名>/" vendor/bin/phpunit

テスト(Test)

PHPUnit で PHP 関数の非推奨警告が出力されないのを確認

相談(Discussion)

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

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

レビュワー確認項目

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

nanasess added 2 commits May 26, 2025 11:59
…deprecation

Fixes PHP 8.4 deprecation:
fputcsv(): the $escape parameter must be provided as its default value will change

```
  1012x: fputcsv(): the $escape parameter must be provided as its default value will change
    909x in CsvImportControllerTest::testSplitCsv from Eccube\Tests\Web\Admin\Product
    12x in CategoryControllerTest::testExport from Eccube\Tests\Web\Admin\Product
    12x in CsvImportControllerTest::testCsvImportWithExistsProductsExceptOptionalColumns from Eccube\Tests\Web\Admin\Product
    12x in CsvImportControllerTest::testImportTaxRule from Eccube\Tests\Web\Admin\Product
    11x in CustomerControllerTest::testExport from Eccube\Tests\Web\Admin\Customer
```
@nanasess nanasess marked this pull request as ready for review May 27, 2025 08:32
@nanasess nanasess enabled auto-merge May 27, 2025 08:34
@nanasess nanasess marked this pull request as draft May 28, 2025 05:51
auto-merge was automatically disabled May 28, 2025 05:51

Pull request was converted to draft

@nanasess nanasess requested a review from Copilot May 28, 2025 06:52
@nanasess nanasess marked this pull request as ready for review May 28, 2025 06:53
@nanasess nanasess enabled auto-merge May 28, 2025 06:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes several deprecation warnings triggered by passing null values to PHP functions and adjusts sorting comparators to return integers rather than booleans. It also improves CSV handling by providing explicit parameters for functions such as fputcsv.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Eccube/Twig/Extension/SafeTextmailEscaperExtension.php Added null coalescing for string replacement to avoid deprecation warnings.
src/Eccube/Twig/Extension/EccubeExtension.php Ensured a default numeric value is provided to formatCurrency.
src/Eccube/Service/PurchaseFlow/ItemCollection.php Replaced boolean comparator with the spaceship operator for accurate sorting.
src/Eccube/Service/PluginService.php Added commas and a defensive isset check for file operations; adjusted plugin manager class string concatenation.
src/Eccube/Service/OrderPdfService.php Guarded postal code processing against empty/null strings.
src/Eccube/Service/CsvImportService.php Removed deprecated ini_set call.
src/Eccube/Service/CsvExportService.php Updated fputcsv call to include proper escape parameters.
src/Eccube/Form/Type/* Added null-coalescing and guard clauses for preg_split in various form types.
src/Eccube/Form/EventListener/* Introduced is_string checks to ensure safe processing of user input.
src/Eccube/Entity/Product.php Updated PHPDoc annotations and simplified usort comparators.
src/Eccube/Controller/* Ensured type validation on inputs and added missing commas in parameter lists.
codeception/_support/Page/Admin/OrderManagePage.php Adjusted comparator logic for correct sorting order.

@dotani1111 dotani1111 added the improvement 機能改善 label May 28, 2025
@dotani1111 dotani1111 modified the milestones: 4.x, 4.3.x May 28, 2025
Copy link

codecov bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 97.08738% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.83%. Comparing base (73bc474) to head (77b9368).
Report is 18 commits behind head on 4.3.

Files with missing lines Patch % Lines
.../Eccube/Controller/NonMemberShoppingController.php 66.66% 2 Missing ⚠️
src/Eccube/Entity/Product.php 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              4.3    #6378      +/-   ##
==========================================
- Coverage   82.83%   82.83%   -0.01%     
==========================================
  Files         480      480              
  Lines       27094    27117      +23     
==========================================
+ Hits        22443    22462      +19     
- Misses       4651     4655       +4     
Flag Coverage Δ
E2E 82.83% <97.08%> (-0.01%) ⬇️
Unit 82.83% <97.08%> (-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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Successfully merging this pull request may close these issues.

2 participants