Skip to content

Commit 32ac0dd

Browse files
committed
fix: resolve usort() deprecation warnings in PHP 8.1+
1 parent ddbec7e commit 32ac0dd

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

codeception/_support/Page/Admin/OrderManagePage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function assertSortedStatusList($order)
300300
// order_status でソート
301301
$statusList = ['新規受付', '注文取消し', '対応中', '発送済み', '入金済み', '決済処理中', '購入処理中', '返品'];
302302

303-
return array_search($a, $statusList) > array_search($b, $statusList);
303+
return array_search($a, $statusList) <=> array_search($b, $statusList);
304304
});
305305

306306
if ($order === 'desc') {

src/Eccube/Controller/Admin/Setting/Shop/DeliveryController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function __construct(PaymentOptionRepository $paymentOptionRepository, De
9292

9393
/**
9494
* @Route("/%eccube_admin_route%/setting/shop/delivery", name="admin_setting_shop_delivery", methods={"GET"})
95+
*
9596
* @Template("@admin/Setting/Shop/delivery.twig")
9697
*/
9798
public function index(Request $request)
@@ -115,6 +116,7 @@ public function index(Request $request)
115116
/**
116117
* @Route("/%eccube_admin_route%/setting/shop/delivery/new", name="admin_setting_shop_delivery_new", methods={"GET", "POST"})
117118
* @Route("/%eccube_admin_route%/setting/shop/delivery/{id}/edit", requirements={"id" = "\d+"}, name="admin_setting_shop_delivery_edit", methods={"GET", "POST"})
119+
*
118120
* @Template("@admin/Setting/Shop/delivery_edit.twig")
119121
*/
120122
public function edit(Request $request, EccubeExtension $extension, $id = null)
@@ -437,7 +439,7 @@ private function getMergeRules(array $PaymentsData)
437439
return 0;
438440
}
439441

440-
return ($a['min'] < $b['min']) ? -1 : 1;
442+
return $a['min'] <=> $b['min'];
441443
});
442444

443445
return $mergeRules;

src/Eccube/Entity/Product.php

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
* Product
2222
*
2323
* @ORM\Table(name="dtb_product")
24+
*
2425
* @ORM\InheritanceType("SINGLE_TABLE")
26+
*
2527
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
28+
*
2629
* @ORM\HasLifecycleCallbacks()
30+
*
2731
* @ORM\Entity(repositoryClass="Eccube\Repository\ProductRepository")
2832
*/
29-
class Product extends \Eccube\Entity\AbstractEntity
33+
class Product extends AbstractEntity
3034
{
3135
private $_calc = false;
3236
private $stockFinds = [];
@@ -55,7 +59,7 @@ public function _calc()
5559
if (!$this->_calc) {
5660
$i = 0;
5761
foreach ($this->getProductClasses() as $ProductClass) {
58-
/** @var \Eccube\Entity\ProductClass $ProductClass */
62+
/** @var ProductClass $ProductClass */
5963
// stock_find
6064
if ($ProductClass->isVisible() == false) {
6165
continue;
@@ -128,7 +132,7 @@ public function _calc()
128132
*/
129133
public function isEnable()
130134
{
131-
return $this->getStatus()->getId() === \Eccube\Entity\Master\ProductStatus::DISPLAY_SHOW ? true : false;
135+
return $this->getStatus()->getId() === Master\ProductStatus::DISPLAY_SHOW ? true : false;
132136
}
133137

134138
/**
@@ -447,7 +451,9 @@ public function hasProductClass()
447451
* @var integer
448452
*
449453
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
454+
*
450455
* @ORM\Id
456+
*
451457
* @ORM\GeneratedValue(strategy="IDENTITY")
452458
*/
453459
private $id;
@@ -526,6 +532,7 @@ public function hasProductClass()
526532
* @var \Doctrine\Common\Collections\Collection
527533
*
528534
* @ORM\OneToMany(targetEntity="Eccube\Entity\ProductImage", mappedBy="Product", cascade={"remove"})
535+
*
529536
* @ORM\OrderBy({
530537
* "sort_no"="ASC"
531538
* })
@@ -547,20 +554,24 @@ public function hasProductClass()
547554
private $CustomerFavoriteProducts;
548555

549556
/**
550-
* @var \Eccube\Entity\Member
557+
* @var Member
551558
*
552559
* @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
560+
*
553561
* @ORM\JoinColumns({
562+
*
554563
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
555564
* })
556565
*/
557566
private $Creator;
558567

559568
/**
560-
* @var \Eccube\Entity\Master\ProductStatus
569+
* @var Master\ProductStatus
561570
*
562571
* @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\ProductStatus")
572+
*
563573
* @ORM\JoinColumns({
574+
*
564575
* @ORM\JoinColumn(name="product_status_id", referencedColumnName="id")
565576
* })
566577
*/
@@ -571,11 +582,11 @@ public function hasProductClass()
571582
*/
572583
public function __construct()
573584
{
574-
$this->ProductCategories = new \Doctrine\Common\Collections\ArrayCollection();
575-
$this->ProductClasses = new \Doctrine\Common\Collections\ArrayCollection();
576-
$this->ProductImage = new \Doctrine\Common\Collections\ArrayCollection();
577-
$this->ProductTag = new \Doctrine\Common\Collections\ArrayCollection();
578-
$this->CustomerFavoriteProducts = new \Doctrine\Common\Collections\ArrayCollection();
585+
$this->ProductCategories = new ArrayCollection();
586+
$this->ProductClasses = new ArrayCollection();
587+
$this->ProductImage = new ArrayCollection();
588+
$this->ProductTag = new ArrayCollection();
589+
$this->CustomerFavoriteProducts = new ArrayCollection();
579590
}
580591

581592
public function __clone()
@@ -828,7 +839,7 @@ public function getUpdateDate()
828839
/**
829840
* Add productCategory.
830841
*
831-
* @param \Eccube\Entity\ProductCategory $productCategory
842+
* @param ProductCategory $productCategory
832843
*
833844
* @return Product
834845
*/
@@ -842,7 +853,7 @@ public function addProductCategory(ProductCategory $productCategory)
842853
/**
843854
* Remove productCategory.
844855
*
845-
* @param \Eccube\Entity\ProductCategory $productCategory
856+
* @param ProductCategory $productCategory
846857
*
847858
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
848859
*/
@@ -864,7 +875,7 @@ public function getProductCategories()
864875
/**
865876
* Add productClass.
866877
*
867-
* @param \Eccube\Entity\ProductClass $productClass
878+
* @param ProductClass $productClass
868879
*
869880
* @return Product
870881
*/
@@ -878,7 +889,7 @@ public function addProductClass(ProductClass $productClass)
878889
/**
879890
* Remove productClass.
880891
*
881-
* @param \Eccube\Entity\ProductClass $productClass
892+
* @param ProductClass $productClass
882893
*
883894
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
884895
*/
@@ -900,7 +911,7 @@ public function getProductClasses()
900911
/**
901912
* Add productImage.
902913
*
903-
* @param \Eccube\Entity\ProductImage $productImage
914+
* @param ProductImage $productImage
904915
*
905916
* @return Product
906917
*/
@@ -914,7 +925,7 @@ public function addProductImage(ProductImage $productImage)
914925
/**
915926
* Remove productImage.
916927
*
917-
* @param \Eccube\Entity\ProductImage $productImage
928+
* @param ProductImage $productImage
918929
*
919930
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
920931
*/
@@ -936,7 +947,7 @@ public function getProductImage()
936947
/**
937948
* Add productTag.
938949
*
939-
* @param \Eccube\Entity\ProductTag $productTag
950+
* @param ProductTag $productTag
940951
*
941952
* @return Product
942953
*/
@@ -950,7 +961,7 @@ public function addProductTag(ProductTag $productTag)
950961
/**
951962
* Remove productTag.
952963
*
953-
* @param \Eccube\Entity\ProductTag $productTag
964+
* @param ProductTag $productTag
954965
*
955966
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
956967
*/
@@ -984,7 +995,7 @@ public function getTags()
984995
}
985996

986997
usort($tags, function (Tag $tag1, Tag $tag2) {
987-
return $tag1->getSortNo() < $tag2->getSortNo();
998+
return $tag1->getSortNo() <=> $tag2->getSortNo();
988999
});
9891000

9901001
return $tags;
@@ -993,7 +1004,7 @@ public function getTags()
9931004
/**
9941005
* Add customerFavoriteProduct.
9951006
*
996-
* @param \Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct
1007+
* @param CustomerFavoriteProduct $customerFavoriteProduct
9971008
*
9981009
* @return Product
9991010
*/
@@ -1007,7 +1018,7 @@ public function addCustomerFavoriteProduct(CustomerFavoriteProduct $customerFavo
10071018
/**
10081019
* Remove customerFavoriteProduct.
10091020
*
1010-
* @param \Eccube\Entity\CustomerFavoriteProduct $customerFavoriteProduct
1021+
* @param CustomerFavoriteProduct $customerFavoriteProduct
10111022
*
10121023
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
10131024
*/
@@ -1029,11 +1040,11 @@ public function getCustomerFavoriteProducts()
10291040
/**
10301041
* Set creator.
10311042
*
1032-
* @param \Eccube\Entity\Member|null $creator
1043+
* @param Member|null $creator
10331044
*
10341045
* @return Product
10351046
*/
1036-
public function setCreator(Member $creator = null)
1047+
public function setCreator(?Member $creator = null)
10371048
{
10381049
$this->Creator = $creator;
10391050

@@ -1043,7 +1054,7 @@ public function setCreator(Member $creator = null)
10431054
/**
10441055
* Get creator.
10451056
*
1046-
* @return \Eccube\Entity\Member|null
1057+
* @return Member|null
10471058
*/
10481059
public function getCreator()
10491060
{
@@ -1053,11 +1064,11 @@ public function getCreator()
10531064
/**
10541065
* Set status.
10551066
*
1056-
* @param \Eccube\Entity\Master\ProductStatus|null $status
1067+
* @param Master\ProductStatus|null $status
10571068
*
10581069
* @return Product
10591070
*/
1060-
public function setStatus(Master\ProductStatus $status = null)
1071+
public function setStatus(?Master\ProductStatus $status = null)
10611072
{
10621073
$this->Status = $status;
10631074

@@ -1067,7 +1078,7 @@ public function setStatus(Master\ProductStatus $status = null)
10671078
/**
10681079
* Get status.
10691080
*
1070-
* @return \Eccube\Entity\Master\ProductStatus|null
1081+
* @return Master\ProductStatus|null
10711082
*/
10721083
public function getStatus()
10731084
{

src/Eccube/Service/PurchaseFlow/ItemCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function sort()
114114
$Items = $this->toArray();
115115
usort($Items, function (ItemInterface $a, ItemInterface $b) {
116116
if ($a->getOrderItemType() === $b->getOrderItemType()) {
117-
return ($a->getId() < $b->getId()) ? -1 : 1;
117+
return $a->getId() <=> $b->getId();
118118
} elseif ($a->isProduct()) {
119119
return -1;
120120
} elseif ($a->isDeliveryFee()) {

0 commit comments

Comments
 (0)