Skip to content

refactor(entity): DateTime および Collection プロパティにネイティブ型宣言を追加#6569

Open
nanasess wants to merge 2 commits intoEC-CUBE:4.3-symfony7from
nanasess:refactor/entity-type-declarations
Open

refactor(entity): DateTime および Collection プロパティにネイティブ型宣言を追加#6569
nanasess wants to merge 2 commits intoEC-CUBE:4.3-symfony7from
nanasess:refactor/entity-type-declarations

Conversation

@nanasess
Copy link
Contributor

概要

Entityファイルの DateTime および Collection プロパティにPHP 8のネイティブ型宣言を追加しました。

変更内容

  • 全ての日付プロパティに nullable DateTime 型宣言 (?\DateTime $property = null) を追加
  • Collection 型宣言を追加(PHPDoc のジェネリクス情報は型推論のため維持)
  • DateTime プロパティの冗長な PHPDoc @var アノテーションを削除

対象ファイル(34ファイル)

主要Entity

  • Order.php, Customer.php, Product.php, Shipping.php, Cart.php

関連Entity

  • ProductClass.php, Member.php, Payment.php, Category.php, Delivery.php

その他Entity

  • AuthorityRole.php, BaseInfo.php, Block.php, Calendar.php, ClassCategory.php, ClassName.php, Csv.php, CustomerAddress.php, CustomerFavoriteProduct.php, DeliveryTime.php, Layout.php, LoginHistory.php, MailHistory.php, MailTemplate.php, News.php, OrderPdf.php, Page.php, Plugin.php, ProductImage.php, ProductStock.php, ProductTag.php, Tag.php, TaxRule.php, Template.php

目的

  • Symfony 7/Doctrine ORM 3.x 互換性の向上
  • Symfony Form の PRE_SET_DATA イベント中の初期化エラー回避
  • Enterprise版との型宣言パターン統一

修正パターン

DateTime型

// Before
/**
 * @var \DateTime
 */
private $create_date;

// After
private ?\DateTime $create_date = null;

Collection型

// Before
/**
 * @var Collection<int, OrderItem>
 */
private $OrderItems;

// After
/**
 * @var Collection<int, OrderItem>
 */
private Collection $OrderItems;

テスト計画

  • PHPStan静的解析でエラーなし(確認済み)
  • php-cs-fixerでスタイル違反なし(確認済み)
  • 既存のPHPUnitテストが全てパス

🤖 Generated with Claude Code

- 全ての日付プロパティに 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>
@dotani1111 dotani1111 added this to the 4.4.0 milestone Jan 14, 2026
@dotani1111 dotani1111 added the refactor リファクタリング label Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor リファクタリング

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants