feat: EC-CUBE 4.4への対応 - #17
Conversation
📝 WalkthroughWalkthroughプラグインをEC-CUBE 4.4向けのSMS44構成へ移行し、名前空間、依存関係、Attributes、ルーティング、テンプレート、CI、PHPUnit、静的解析設定を更新した。 ChangesSMS44移行
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (5)
Entity/CustomerTrait.php (3)
78-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value戻り値の型宣言を追加
こちらも他のgetterに合わせて、明示的な戻り値の型宣言を追加することをお勧めします。
♻️ 修正案
- public function getTwoFactorAuthOneTimeTokenExpire() + public function getTwoFactorAuthOneTimeTokenExpire(): ?\DateTime { return $this->two_factor_auth_one_time_token_expire; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Entity/CustomerTrait.php` around lines 78 - 81, Update the getTwoFactorAuthOneTimeTokenExpire method to include an explicit return type declaration, matching the return type conventions used by the other getters in CustomerTrait.
38-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winプロパティの型宣言を追加
他のプロパティと同様に、明示的な型宣言(ネイティブ型)を追加することをお勧めします。
?\DateTimeのようにnullを許容する型であれば、テストのtearDown時の初期化でもエラーになりません。♻️ 修正案
#[ORM\Column(name: 'two_factor_auth_one_time_token_expire', type: Types::DATETIMETZ_MUTABLE, nullable: true)] - private $two_factor_auth_one_time_token_expire; + private ?\DateTime $two_factor_auth_one_time_token_expire = null;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Entity/CustomerTrait.php` around lines 38 - 39, Update the two_factor_auth_one_time_token_expire property declaration in CustomerTrait to add the nullable native type \DateTime, preserving its existing Doctrine mapping and nullable behavior.
83-96: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPHPDocの修正と型宣言の追加
PHPDocの
@paramがnullとなっている点や、引数名が$deviceAuthOneTimeTokenExpire(他の実装からコピーした際の名残と推測されます)となっている点を整理することをお勧めします。合わせて正確な型宣言を追加するとより安全です。♻️ 修正案
/** * Set oneTimeTokenExpire. * - * `@param` null $deviceAuthOneTimeTokenExpire - * - * `@return` Customer + * `@param` \DateTime|null $twoFactorAuthOneTimeTokenExpire */ - public function setTwoFactorAuthOneTimeTokenExpire($deviceAuthOneTimeTokenExpire = null) + public function setTwoFactorAuthOneTimeTokenExpire(?\DateTime $twoFactorAuthOneTimeTokenExpire = null): static { - $this->two_factor_auth_one_time_token_expire = $deviceAuthOneTimeTokenExpire; + $this->two_factor_auth_one_time_token_expire = $twoFactorAuthOneTimeTokenExpire; return $this; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Entity/CustomerTrait.php` around lines 83 - 96, Update setTwoFactorAuthOneTimeTokenExpire so its parameter uses the correct two-factor token expiration name consistently in the signature, assignment, and PHPDoc; replace the inaccurate `@param` null annotation with the actual nullable value type and add the corresponding parameter type declaration while preserving the method’s current behavior..github/workflows/main.yml (2)
63-63: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value
actions/checkoutでのクレデンシャル保持を無効化(オプション)セキュリティ上の観点から、リポジトリへのプッシュが不要な場合は
persist-credentials: falseを設定することが推奨されます。
※このファイル内のすべてのactions/checkoutステップ(Base PluginやEC-CUBEのチェックアウト時など)にも同様の設定を追加することをご検討ください。💡 修正案(persist-credentialsの設定)
- name: Checkout uses: actions/checkout@v4 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/main.yml at line 63, すべての actions/checkout ステップに persist-credentials: false を追加し、不要なリポジトリ認証情報の保持を無効化してください。Base Plugin や EC-CUBE のチェックアウトを含め、ワークフロー内の各 checkout 設定へ同じオプションを適用してください。Source: Linters/SAST tools
1-1: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueワークフローの権限を最小化(オプション)
セキュリティのベストプラクティスとして、トップレベルで
permissionsを明示的に制限することをお勧めします。これにより、トークンに対する不要な権限の付与を防ぐことができます。💡 修正案(permissionsの追加)
name: CI for TwoFactorAuthCustomerSms44 + +permissions: + contents: read🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/main.yml at line 1, トップレベルのワークフロー設定にpermissionsを追加し、GitHub Actionsトークンの権限を必要最小限に制限してください。既存のワークフロー名やジョブ設定は変更せず、ジョブが必要とする権限のみ明示して不要な権限を付与しないようにします。Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/main.yml:
- Line 63: すべての actions/checkout ステップに persist-credentials: false
を追加し、不要なリポジトリ認証情報の保持を無効化してください。Base Plugin や EC-CUBE のチェックアウトを含め、ワークフロー内の各
checkout 設定へ同じオプションを適用してください。
- Line 1: トップレベルのワークフロー設定にpermissionsを追加し、GitHub
Actionsトークンの権限を必要最小限に制限してください。既存のワークフロー名やジョブ設定は変更せず、ジョブが必要とする権限のみ明示して不要な権限を付与しないようにします。
In `@Entity/CustomerTrait.php`:
- Around line 78-81: Update the getTwoFactorAuthOneTimeTokenExpire method to
include an explicit return type declaration, matching the return type
conventions used by the other getters in CustomerTrait.
- Around line 38-39: Update the two_factor_auth_one_time_token_expire property
declaration in CustomerTrait to add the nullable native type \DateTime,
preserving its existing Doctrine mapping and nullable behavior.
- Around line 83-96: Update setTwoFactorAuthOneTimeTokenExpire so its parameter
uses the correct two-factor token expiration name consistently in the signature,
assignment, and PHPDoc; replace the inaccurate `@param` null annotation with the
actual nullable value type and add the corresponding parameter type declaration
while preserving the method’s current behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5ed69325-710d-42a1-86ea-86729880be16
📒 Files selected for processing (11)
.github/workflows/main.ymlController/TwoFactorAuthCustomerSmsController.phpEntity/CustomerTrait.phpEvent.phpForm/Type/Extension/Admin/TwoFactorAuthCustomerTypeExtension.phpPluginManager.phpResource/.php-cs-fixer.dist.phpResource/rector.phpTests/bootstrap.phpcomposer.jsonphpunit.xml.dist
概要
会員向けSMS認証プラグインを EC-CUBE 4.4(Symfony 7.4 / Doctrine ORM 3.0 / PHP 8.2+) に対応させ、コードを
TwoFactorAuthCustomerSms42→TwoFactorAuthCustomerSms44に改名します。親プラグイン依存もTwoFactorAuthCustomer42→TwoFactorAuthCustomer44に更新します。4.3 とは非互換(属性必須・ORM 3・PHP 8.2+)のため、新規4.4ブランチへの取り込みです。参考: 4.3→4.4 マイグレーション手順 (doc #346)
変更内容
1. EC-CUBE 4.4 対応(コア移行)
@Route/@Template→#[Route]/#[Template](Sensio依存除去)、EntityExtension の@EntityExtension→#[EntityExtension](Eccube\Attribute\EntityExtension)、Entity の@ORM\*→#[ORM\*](Types::STRING/Types::DATETIMETZ_MUTABLE等)buildForm(): void、Event の戻り値型などenable/disable/uninstallほか関連メソッドに: void@TwoFactorAuthCustomerSms44/...およびページ登録パスをTwoFactorAuthCustomerSms44に統一(SMS メッセージテンプレートは親の@TwoFactorAuthCustomer44/...を参照)requireをec-cube/twofactorauthcustomer44へ、code/version: 4.4.0をTwoFactorAuthCustomerSms44に統一phpunit.xml.distを<source>/<extensions>形式へ、Tests/bootstrap.phpを追加if ($Page !== null)に修正(存在時のみ削除)2. 静的解析・整形ツール
Resource/rector.php/Resource/.php-cs-fixer.dist.phpを追加(.php設定は本体のPlugin\:サービス検出で 500 を避けるためResource/配下に配置)3. CI(
.github/workflows/main.yml)checkout@v4・$GITHUB_OUTPUT化TwoFactorAuthCustomer44を checkout / archive し、mock-package-api+eccube:composer:requireで依存解決のうえ有効化--ignore-platform-req=ext-redis: Symfony 7.4 のsymfony/cacheが古いphp-redisと衝突して本体 composer install が失敗するのを回避(redis は未使用)cache:warmup: 有効プラグインのルート確定のため warmup を実行(Tests がある場合のみ PHPUnit 実行)テスト
Summary by CodeRabbit
新機能
改善
テスト