ci: 静的解析 (Rector / PHPStan / php-cs-fixer) の導入とキャッシュ残留フレークの修正 - #100
Merged
Conversation
- coupon-plugin ほか他プラグインと同じ構成に揃える - phpstan は objectManagerLoader がカーネルを起動し EccubeExtension が dtb_plugin を 読むため本体と DB が必要。DB 種別に依存しないので SQLite 1 構成で実行する - Entity のプロパティは ?type だが該当カラムは DB 上 not-null。Symfony のフォームは バリデーションの前にデータマッピングを行い空文字が null になるため非 nullable に できず、doctrine.columnType を ignoreErrors に入れる - php-cs-fixer が検出したコンストラクタ引数の整形を反映する - 配布パッケージには静的解析の設定を含めない Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Symfony の CacheClearCommand は REQUEST_TIME と filemtime の秒精度比較で コンテナを fresh とみなし、削除せずに正常終了することがある - eccube:plugin:enable が有効化前の boot でダンプしたコンテナ (プラグイン ルートなし) が同一秒内の cache:clear を素通りすると、cache:warmup は 既存ダンプを再利用するためルートが欠けたまま phpunit に到達する - cache:clear の判定に頼らず var/cache/test を直接削除する Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ttokoro20240902
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要(Overview・Refs Issue)
#95 のレビューでご提案いただいた静的解析(Rector / PHPStan / php-cs-fixer)を導入します。
あわせて、同レビュー対応中に見つかった CI のフレーク(プラグインルートが載らず PHPUnit が落ちる)を修正します。
方針(Policy)
cache:clearの判定に頼らず、キャッシュディレクトリを直接削除する方式実装に関する補足(Appendix)
静的解析ジョブの追加
Resource/rector.php… PHP 8.2 / Symfony 7.4 / Doctrine セット。パスは本プラグインの構成に合わせていますphpstan.neon.dist… level 6。objectManagerLoaderがカーネルを起動するため、CI では本体 + SQLite をセットアップしてから実行しますResource/.php-cs-fixer.dist.php… ライセンスヘッダの URL は本体 4.4 の.php-cs-fixer.dist.phpに合わせhttp://としています(coupon-plugin はhttps://のため、そのまま流用すると全ファイルにヘッダ差分が出ます)static-analysisジョブを追加(DB 種別に依存しないため SQLite 1 構成で一度だけ実行)検出された差分は次の 2 点で、いずれも本 PR に含めています。
doctrine.columnType4 件 → ignoreErrors で抑止後者は Entity のプロパティが
?string/?intで DB カラムが not-null という不一致の指摘です。Symfony のフォームはバリデーションの前にデータマッピングを行い、空白のみの入力が empty_data で null になるため、プロパティ・setter を非 nullable にすると保存時に TypeError で 500 になります(#95 の blocker 指摘と同じ経路)。
実行時は Doctrine が必ず値を入れるため実害はなく、coupon-plugin と同じ抑止を入れています。
CI フレークの修正
「
eccube:plugin:enableしてcache:warmupしたのに、プラグインのルートがコンテナに載らず PHPUnit が RouteNotFound で落ちる」というフレークです。4.4 マージ後の run で発生しています(upstream: 1/8 失敗、fork: 5/8 失敗)。
原因は Symfony
CacheClearCommandの「Cache is fresh」ショートカットです(vendor/symfony/framework-bundle/Command/CacheClearCommand.php:124)。この比較が秒精度のため、次のシーケンスが同一秒に収まると発症します。
eccube:plugin:enableが自身の kernel boot 時(DB がenabled=0の時点)にプラグインルートなしのコンテナをダンプする(T 秒)cache:clear --no-warmup(PluginCommandTrait)が T 秒内に起動 → fresh 判定でコンテナを消さないcache:clear --no-warmupも T 秒内なら同様に素通りcache:warmupはコンテナをコンパイルせず既存ダンプを再利用 → ルートなしのまま[OK]裏取りはコマンドの boot 時間で取れています(約 2 秒 = コンパイル / 約 0.2 秒 = ダンプ再利用)。
失敗した job はすべて
Plugin Enabled以降に一度もコンパイルが起きていませんでした。修正は
rm -rf var/cache/testでの物理削除です。コンテナが存在しなければ warmup の boot が必ず enable 後の DB を読んでコンパイルし直すため、タイミング依存が消えます。
なお同型の問題は本体の
CacheUtil::forceClearCache()(cache:clearを同一プロセスで実行するため fresh 判定が常に成立)にもあり、こちらは本体側で別途対応を検討します。テスト(Test)
マイナーバージョン互換性保持のための制限事項チェックリスト
※ PHP の変更は php-cs-fixer による整形 1 ファイルのみで、挙動の変更はありません。
※ 追加した設定ファイルはパッケージングで除外するため、配布物にも変更はありません。
レビュワー確認項目
🤖 Generated with Claude Code