refactor(entity): DateTime および Collection プロパティにネイティブ型宣言を追加#6569
refactor(entity): DateTime および Collection プロパティにネイティブ型宣言を追加#6569nanasess wants to merge 8 commits into
Conversation
- 全ての日付プロパティに nullable DateTime 型宣言 (?\DateTime $property = null) を追加 - Collection 型宣言を追加(PHPDoc のジェネリクス情報は型推論のため維持) - DateTime プロパティの冗長な PHPDoc @var アノテーションを削除 - Symfony 7/Doctrine ORM 3.x 互換性の向上 - Symfony Form の PRE_SET_DATA 初期化要件に対応 34個の Entity ファイルに一貫した型宣言パターンを適用。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughこのPRは多数のDoctrineエンティティで未型付プロパティをPHPの型付きプロパティへ置き換えます。日時フィールドを ChangesEntity Property Type Declarations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@src/Eccube/Entity/Member.php`:
- Around line 104-108: Member entity declares create_date and update_date as
nullable properties but Doctrine mapping requires NOT NULL and there are no
lifecycle callbacks found; add lifecycle callback methods to Member (or its
parent) using #[ORM\PrePersist] to set create_date and update_date when first
persisted and #[ORM\PreUpdate] (or also in PrePersist) to update update_date on
changes, ensure the class retains #[ORM\HasLifecycleCallbacks], and/or update
setPropertiesFromArray/form handling to always initialize these fields before
persist so DB NOT NULL constraints are satisfied (reference symbols:
create_date, update_date, #[ORM\HasLifecycleCallbacks], #[ORM\PrePersist],
#[ORM\PreUpdate], setPropertiesFromArray, Member.php, AbstractEntity.php).
In `@src/Eccube/Entity/OrderPdf.php`:
- Around line 61-64: The setters setCreateDate and setUpdateDate accept
\DateTime|string while the properties $create_date and $update_date are typed
?\DateTime, which can cause a TypeError when a string is assigned; change the
method signatures to accept ?\DateTime (e.g. setCreateDate(?\DateTime
$create_date): static and setUpdateDate(?\DateTime $update_date): static) and
assign directly to the typed properties, or if you need to keep string
compatibility normalize/parse strings to \DateTime inside the setters before
assigning to $create_date/$update_date.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 472995f3-0586-4720-bd71-a359bb0818f2
📒 Files selected for processing (34)
src/Eccube/Entity/AuthorityRole.phpsrc/Eccube/Entity/BaseInfo.phpsrc/Eccube/Entity/Block.phpsrc/Eccube/Entity/Calendar.phpsrc/Eccube/Entity/Cart.phpsrc/Eccube/Entity/Category.phpsrc/Eccube/Entity/ClassCategory.phpsrc/Eccube/Entity/ClassName.phpsrc/Eccube/Entity/Csv.phpsrc/Eccube/Entity/Customer.phpsrc/Eccube/Entity/CustomerAddress.phpsrc/Eccube/Entity/CustomerFavoriteProduct.phpsrc/Eccube/Entity/Delivery.phpsrc/Eccube/Entity/DeliveryTime.phpsrc/Eccube/Entity/Layout.phpsrc/Eccube/Entity/LoginHistory.phpsrc/Eccube/Entity/MailHistory.phpsrc/Eccube/Entity/MailTemplate.phpsrc/Eccube/Entity/Member.phpsrc/Eccube/Entity/News.phpsrc/Eccube/Entity/Order.phpsrc/Eccube/Entity/OrderPdf.phpsrc/Eccube/Entity/Page.phpsrc/Eccube/Entity/Payment.phpsrc/Eccube/Entity/Plugin.phpsrc/Eccube/Entity/Product.phpsrc/Eccube/Entity/ProductClass.phpsrc/Eccube/Entity/ProductImage.phpsrc/Eccube/Entity/ProductStock.phpsrc/Eccube/Entity/ProductTag.phpsrc/Eccube/Entity/Shipping.phpsrc/Eccube/Entity/Tag.phpsrc/Eccube/Entity/TaxRule.phpsrc/Eccube/Entity/Template.php
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.4 #6569 +/- ##
==========================================
- Coverage 74.91% 74.88% -0.03%
==========================================
Files 463 463
Lines 24029 24029
==========================================
- Hits 18001 17995 -6
- Misses 6028 6034 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
setCreateDate / setUpdateDate のパラメータ型を \DateTime|string から \DateTime に 変更し、本 PR で厳格化した ?\DateTime プロパティとの整合性を取る。 コードベース上、両 setter への呼び出しはすべて \DateTime オブジェクト渡しで あり、文字列リテラル渡しの実例はないため後方互換に影響なし。 なお $issue_date プロパティは PDF 出力時にフォーマット済み文字列を受け取る ケースがあるため、意図的に \DateTime|string のユニオン型を維持する旨を コメントで明記した。 Co-Authored-By: Claude <noreply@anthropic.com>
概要
Entityファイルの DateTime および Collection プロパティにPHP 8のネイティブ型宣言を追加しました。
変更内容
?\DateTime $property = null) を追加@varアノテーションを削除対象ファイル(34ファイル)
主要Entity
関連Entity
その他Entity
目的
修正パターン
DateTime型
Collection型
テスト計画
🤖 Generated with Claude Code
Summary by CodeRabbit