Skip to content

refactor: Rectorの適用#6690

Merged
dotani1111 merged 12 commits intoEC-CUBE:4.3-symfony7from
dotani1111:feat/apply-rector
Apr 3, 2026
Merged

refactor: Rectorの適用#6690
dotani1111 merged 12 commits intoEC-CUBE:4.3-symfony7from
dotani1111:feat/apply-rector

Conversation

@dotani1111
Copy link
Copy Markdown
Contributor

概要(Overview・Refs Issue)

Rectorを適用しました。

  • ControllerMethodInjectionToConstructorRector … アクション引数のメソッド注入をコンストラクタ注入へ移行
  • ClassPropertyAssignToConstructorPromotionRector … コンストラクタプロモーションへの整理
  • RemoveUnusedPromotedPropertyRector / RecastingRemovalRector … 未使用プロパティ・不要なキャストの整理
  • AbstractController との衝突回避 … 親が protected RouterInterface $router と #[Required] setRouter() で持つため、子クラスで private readonly RouterInterface $router を重ねないよう修正
  • PageController, EditController, ShoppingController, ProductController

方針(Policy)

実装に関する補足(Appendix)

テスト(Test)

相談(Discussion)

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

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

レビュワー確認項目

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

…fony 7.x

- Apply ControllerMethodInjectionToConstructorRector to migrate method injection to constructor injection
- Apply ClassPropertyAssignToConstructorPromotionRector for promoted properties
- Apply RemoveUnusedPromotedPropertyRector and RecastingRemovalRector
- Fix readonly property conflicts in controllers extending AbstractController (PageController, EditController, ShoppingController, ProductController)

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83926f09-df16-40a1-93d4-00a435900bdf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…ts and simplifying method calls

- Removed unused phpstan ignore comments in various entity classes and services.
- Simplified method call in LayoutController by removing an unnecessary parameter.
…pdates

- Added phpstan/extension-installer (version 1.4.3) for automatic installation of PHPStan extensions.
- Updated phpstan/phpstan to version 2.1.44.
- Added phpstan/phpstan-doctrine (version 2.0.20) for Doctrine extensions support.
- Updated content hash for the lock file.
- Updated type hints in Configuration, Cart, and CsvImportService classes for better clarity and type safety.
- Added new method getErrors() in Cart class to retrieve error details.
- Improved handling of column headers in CsvImportService for better type definition.
- Simplified random string generation in StringUtil by using random_bytes.
- Added phpstan ignore comments for nullable associations in DeliveryFee and LoginHistory entities.
- Upgraded composer/ca-bundle to version 1.5.10.
- Upgraded composer/class-map-generator to version 1.7.1 with updated Symfony finder requirements.
- Upgraded composer/composer to version 2.9.5.
- Upgraded doctrine/collections to version 2.6.0.
- Upgraded doctrine/dbal to version 3.10.5.
simplify code structure and improve readability

- Removed unnecessary else statements in various controllers and services to streamline code flow.
- Enhanced readability by directly returning values instead of using else blocks.
- Updated php-cs-fixer configuration to allow unsupported PHP versions.
- Added a new Rector rule for handling nullable arguments in PHPUnit tests.
update PHPUnit test cases to remove #[\Override] attributes
 update PHPUnit rules and clean up code

- RemoveParentDelegatingConstructorRector
- NullToStrictStringFuncCallArgRector
- ExpressionCreateMockToCreateStubRector
- RecastingRemovalRector
- AddOverrideAttribute
- RemoveVoidDocblock
- RemoveUselessVarTag
- AssertEqualsToSameRector
- LiteralGetToRequestClassConstantRector
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 69.52055% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.28%. Comparing base (9ede25f) to head (29c1c4c).
⚠️ Report is 27 commits behind head on 4.3-symfony7.

Files with missing lines Patch % Lines
...Eccube/Controller/Admin/Store/PluginController.php 2.43% 40 Missing ⚠️
src/Eccube/Service/PluginService.php 0.00% 9 Missing ⚠️
src/Eccube/Controller/InstallPluginController.php 0.00% 8 Missing ⚠️
...ube/Controller/Admin/Product/ProductController.php 66.66% 5 Missing ⚠️
...Eccube/Controller/Admin/Content/FileController.php 0.00% 4 Missing ⚠️
src/Eccube/Controller/ShoppingController.php 55.55% 4 Missing ⚠️
.../Admin/Customer/CustomerDeliveryEditController.php 33.33% 2 Missing ⚠️
...ntroller/Admin/Setting/Shop/DeliveryController.php 33.33% 2 Missing ⚠️
...r/Admin/Setting/System/TwoFactorAuthController.php 0.00% 2 Missing ⚠️
src/Eccube/Entity/Cart.php 0.00% 2 Missing ⚠️
... and 10 more
Additional details and impacted files
@@               Coverage Diff                @@
##           4.3-symfony7    #6690      +/-   ##
================================================
- Coverage         82.44%   82.28%   -0.16%     
================================================
  Files               482      482              
  Lines             25701    25711      +10     
================================================
- Hits              21188    21156      -32     
- Misses             4513     4555      +42     
Flag Coverage Δ
E2E 82.28% <69.52%> (-0.16%) ⬇️
Unit 82.28% <69.52%> (-0.16%) ⬇️

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.

- AddInstanceofAssertForNullableArgumentRector::class,
- InlineStubPropertyToCreateStubMethodCallRector::class,
- PropertyCreateMockToCreateStubRector::class,
- ControllerMethodInjectionToConstructorRector::class,
- CreateStubOverCreateMockArgRector::class,
- Removed unused Rector rules for dead code and PHP 7/8 compatibility.
- Added AttributeArgumentsOrderRector and NormalizePhpDocArrayGenericSpacingRector for improved coding style.
- Updated Symfony container XML comment for clarity.
@dotani1111
Copy link
Copy Markdown
Contributor Author

ControllerMethodInjectionToConstructorRectorについては、特定のファイルでの除外などの方針で試す。

@dotani1111 dotani1111 added this to the 4.4.0 milestone Apr 1, 2026
@dotani1111
Copy link
Copy Markdown
Contributor Author

dotani1111 commented Apr 1, 2026

ControllerMethodInjectionToConstructorRectorをInstallControllerに当ててた状態で、テストを実行すると以下のエラーが発生します。
そのためinstallControllerに対してはスキップしす。

PHP Fatal error:  Cannot redeclare non-readonly property Eccube\Controller\AbstractController::$entityManager as readonly Eccube\Controller\Install\InstallController::$entityManager in /ec-cube/src/Eccube/Controller/Install/InstallController.php on line 68

@dotani1111
Copy link
Copy Markdown
Contributor Author

テスト通ったのでマージしますー。

@dotani1111 dotani1111 merged commit 45f958f into EC-CUBE:4.3-symfony7 Apr 3, 2026
490 of 500 checks passed
@dotani1111 dotani1111 deleted the feat/apply-rector branch April 3, 2026 00:31
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.

2 participants