Motivation / 目的
subscription_tier was already made optional at the CreateUserCommand/CreateUserUseCase level (see the recent optional-subscription_tier fixes), but the Domain-layer factories still assumed the key was always present and non-null:
UserEntityFactory::build() accessed $data['subscription_tier'] directly (no fallback)
SubscriptionFactory::build() called SubscriptionTier::from($data['tier']) directly
Any caller that omitted subscription_tier (or passed null) would hit a TypeError from SubscriptionTier::from(null) instead of getting the intended free default. Existing call sites happened to avoid this only because they resolved a default before calling into the factories — the Domain layer itself had no defense.
subscription_tierはCreateUserCommand/CreateUserUseCase側では既に任意項目化されていましたが、Domain層のファクトリ(UserEntityFactory, SubscriptionFactory)は値が必ず存在する前提のままで、省略時のフォールバックがありませんでした。
What to do / 実施内容
SubscriptionFactory::build(): default the tier to SubscriptionTier::Free->value when $data['tier'] is null
UserEntityFactory::build(): pass $data['subscription_tier'] ?? null instead of a direct array access
Tests / テスト
test_build_defaults_subscription_tier_to_free_when_omitted
Status
Fixed in #558.
Motivation / 目的
subscription_tierwas already made optional at theCreateUserCommand/CreateUserUseCaselevel (see the recent optional-subscription_tier fixes), but the Domain-layer factories still assumed the key was always present and non-null:UserEntityFactory::build()accessed$data['subscription_tier']directly (no fallback)SubscriptionFactory::build()calledSubscriptionTier::from($data['tier'])directlyAny caller that omitted
subscription_tier(or passednull) would hit aTypeErrorfromSubscriptionTier::from(null)instead of getting the intendedfreedefault. Existing call sites happened to avoid this only because they resolved a default before calling into the factories — the Domain layer itself had no defense.subscription_tierはCreateUserCommand/CreateUserUseCase側では既に任意項目化されていましたが、Domain層のファクトリ(UserEntityFactory,SubscriptionFactory)は値が必ず存在する前提のままで、省略時のフォールバックがありませんでした。What to do / 実施内容
SubscriptionFactory::build(): default the tier toSubscriptionTier::Free->valuewhen$data['tier']is nullUserEntityFactory::build(): pass$data['subscription_tier'] ?? nullinstead of a direct array accessTests / テスト
test_build_defaults_subscription_tier_to_free_when_omittedStatus
Fixed in #558.