Skip to content

Commit bae77c2

Browse files
nanasessclaude
andcommitted
fix: PHPStan エラーを修正
PHPStan 静的解析で検出されたエラーを修正: - AbstractEntity::offsetGet(): 戻り値が欠落していた問題を修正 - メソッドが見つからない場合に null を返すように修正 - EntityToIdTransformer::reverseTransform(): ジェネリック型 T を使用した型宣言エラーを修正 - ネイティブ型宣言を ?T から ?object に変更(PHPDoc で @return T|null を維持) - PHPDoc の @return 型アノテーションを修正 - AdminController: array → array<string, int> - InstallController::getSessionData(): array → mixed - Controller の moveSortNo(): Response|void → Response - ItemHolderInterface 実装クラスの戻り値型を統一 - Cart/Order/CartItem/OrderItem の setter メソッド: void → static に変更 - setDiscount/setCharge/setTax: メソッドチェーン対応のため static を返すように修正 - Composer サービスの @return mixed アノテーションを追加 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 48dab98 commit bae77c2

18 files changed

+73
-67
lines changed

src/Eccube/Controller/Admin/AdminController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ protected function getOrderEachStatus(array $excludes): ?array
444444
/**
445445
* @param \DateTime $dateTime
446446
*
447-
* @return array
447+
* @return array<string, int>
448448
*
449449
* @throws \Doctrine\ORM\NonUniqueResultException
450450
*/
@@ -481,7 +481,7 @@ protected function getSalesByDay($dateTime): array
481481
/**
482482
* @param \DateTime $dateTime
483483
*
484-
* @return array
484+
* @return array<string, int>
485485
*
486486
* @throws \Doctrine\ORM\NonUniqueResultException
487487
*/

src/Eccube/Controller/Admin/Product/CategoryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public function delete(Request $request, $id, CacheUtil $cacheUtil): \Symfony\Co
277277
* @param Request $request
278278
* @param CacheUtil $cacheUtil
279279
*
280-
* @return Response|void
280+
* @return Response
281281
*
282282
* @throws BadRequestHttpException|\Exception
283283
*/

src/Eccube/Controller/Admin/Product/ClassCategoryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function visibility(Request $request, $class_name_id, $id): \Symfony\Comp
279279
/**
280280
* @param Request $request
281281
*
282-
* @return Response|void
282+
* @return Response
283283
*
284284
* @throws BadRequestHttpException
285285
*/

src/Eccube/Controller/Admin/Product/ClassNameController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function delete(Request $request, ClassName $ClassName): \Symfony\Compone
189189
/**
190190
* @param Request $request
191191
*
192-
* @return Response|void
192+
* @return Response
193193
*
194194
* @throws BadRequestHttpException
195195
*/

src/Eccube/Controller/Install/InstallController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ public function complete(Request $request): array
530530
/**
531531
* @param SessionInterface $session
532532
*
533-
* @return array
533+
* @return mixed
534534
*/
535-
protected function getSessionData(SessionInterface $session): array
535+
protected function getSessionData(SessionInterface $session): mixed
536536
{
537537
return $session->get('eccube.session.install', []);
538538
}

src/Eccube/Entity/AbstractEntity.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public function offsetGet($offset): mixed
6767
} elseif (method_exists($this, "has$method")) {
6868
return $this->{"has$method"}();
6969
}
70+
71+
return null;
7072
}
7173

7274
#[\ReturnTypeWillChange]

src/Eccube/Entity/Cart.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ public function getQuantity(): string
370370
*
371371
* @param string $total
372372
*
373-
* @return Cart
373+
* @return $this
374374
*/
375375
#[\Override]
376-
public function setDeliveryFeeTotal($total): Cart
376+
public function setDeliveryFeeTotal($total): static
377377
{
378378
$this->delivery_fee_total = $total;
379379

@@ -486,40 +486,43 @@ public function getUpdateDate(): \DateTime
486486
*
487487
* @param string $total
488488
*
489-
* @return void
489+
* @return $this
490490
*/
491491
#[\Override]
492-
public function setDiscount($total): void
492+
public function setDiscount($total): static
493493
{
494-
// TODO quiet
494+
// quiet
495+
return $this;
495496
}
496497

497498
/**
498499
* {@inheritdoc}
499500
*
500501
* @param string $total
501502
*
502-
* @return void
503+
* @return $this
503504
*/
504505
#[\Override]
505-
public function setCharge($total): void
506+
public function setCharge($total): static
506507
{
507-
// TODO quiet
508+
// quiet
509+
return $this;
508510
}
509511

510512
/**
511513
* {@inheritdoc}
512514
*
513515
* @param string $total
514516
*
515-
* @return void
517+
* @return $this
516518
*
517519
* @deprecated
518520
*/
519521
#[\Override]
520-
public function setTax($total): void
522+
public function setTax($total): static
521523
{
522-
// TODO quiet
524+
// quiet
525+
return $this;
523526
}
524527

525528
/**

src/Eccube/Entity/CartItem.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public function getId(): int
107107
/**
108108
* @param string $price
109109
*
110-
* @return CartItem
110+
* @return static
111111
*/
112-
public function setPrice($price): CartItem
112+
public function setPrice($price): static
113113
{
114114
$this->price = $price;
115115

@@ -128,10 +128,10 @@ public function getPrice(): string
128128
/**
129129
* @param string $quantity
130130
*
131-
* @return CartItem
131+
* @return static
132132
*/
133133
#[\Override]
134-
public function setQuantity($quantity): CartItem
134+
public function setQuantity($quantity): static
135135
{
136136
$this->quantity = $quantity;
137137

@@ -265,18 +265,18 @@ public function getProductClassId(): ?int
265265
}
266266

267267
/**
268-
* @return float|int|string
268+
* @return string
269269
*/
270-
public function getPriceIncTax(): float|int|string
270+
public function getPriceIncTax(): string
271271
{
272272
// TODO ItemInterfaceに追加, Cart::priceは税込み金額が入っているので,フィールドを分ける必要がある
273273
return $this->price;
274274
}
275275

276276
/**
277-
* @return Cart
277+
* @return Cart|null
278278
*/
279-
public function getCart(): Cart
279+
public function getCart(): ?Cart
280280
{
281281
return $this->Cart;
282282
}

src/Eccube/Entity/ItemHolderInterface.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public function getTotal(): string;
3535
*
3636
* @param string $total
3737
*
38-
* @return ItemHolderInterface
38+
* @return $this
3939
*/
40-
public function setTotal($total): ItemHolderInterface;
40+
public function setTotal($total): static;
4141

4242
/**
4343
* 個数の合計を返します。
@@ -51,9 +51,9 @@ public function getQuantity(): string;
5151
*
5252
* @param string $total
5353
*
54-
* @return ItemHolderInterface
54+
* @return $this
5555
*/
56-
public function setDeliveryFeeTotal($total): ItemHolderInterface;
56+
public function setDeliveryFeeTotal($total): static;
5757

5858
/**
5959
* 送料合計を返します。
@@ -69,7 +69,7 @@ public function getDeliveryFeeTotal(): string;
6969
*
7070
* @return $this
7171
*/
72-
public function setDiscount($total): self;
72+
public function setDiscount($total): static;
7373

7474
/**
7575
* 手数料合計を設定します。
@@ -78,7 +78,7 @@ public function setDiscount($total): self;
7878
*
7979
* @return $this
8080
*/
81-
public function setCharge($total): self;
81+
public function setCharge($total): static;
8282

8383
/**
8484
* 税額合計を設定します。
@@ -89,16 +89,16 @@ public function setCharge($total): self;
8989
*
9090
* @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
9191
*/
92-
public function setTax($total): self;
92+
public function setTax($total): static;
9393

9494
/**
9595
* 加算ポイントを設定します。
9696
*
9797
* @param string $addPoint
9898
*
99-
* @return ItemHolderInterface
99+
* @return $this
100100
*/
101-
public function setAddPoint($addPoint): ItemHolderInterface;
101+
public function setAddPoint($addPoint): static;
102102

103103
/**
104104
* 加算ポイントを返します.
@@ -112,9 +112,9 @@ public function getAddPoint(): string;
112112
*
113113
* @param string $usePoint
114114
*
115-
* @return ItemHolderInterface
115+
* @return $this
116116
*/
117-
public function setUsePoint($usePoint): ItemHolderInterface;
117+
public function setUsePoint($usePoint): static;
118118

119119
/**
120120
* 利用ポイントを返します.

src/Eccube/Entity/ItemInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public function getQuantity(): string;
8080
/**
8181
* @param string $quantity
8282
*
83-
* @return ItemInterface
83+
* @return $this
8484
*/
85-
public function setQuantity($quantity): ItemInterface;
85+
public function setQuantity($quantity): static;
8686

8787
/**
8888
* @return int
@@ -95,7 +95,7 @@ public function getId(): int;
9595
public function getPointRate(): string;
9696

9797
/**
98-
* @param string $price
98+
* @param string|null $price
9999
*
100100
* @return $this
101101
*/

0 commit comments

Comments
 (0)