From 1df82bea4d08cbb74f49cc8d4a20163800eefaf7 Mon Sep 17 00:00:00 2001 From: Thomas N Date: Wed, 9 Sep 2026 10:14:27 +0100 Subject: [PATCH 1/2] Fix PHPStan error --- controllers/front/CommentGrade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/CommentGrade.php b/controllers/front/CommentGrade.php index 23e0381c..51560ca3 100644 --- a/controllers/front/CommentGrade.php +++ b/controllers/front/CommentGrade.php @@ -41,7 +41,7 @@ public function display() $idProducts = array_unique(array_map('intval', $idProducts)); - /** @var ProductCommentRepository $commentRepository */ + /** @var ProductCommentRepository|null $commentRepository */ $commentRepository = $this->context->controller->getContainer()->get('product_comment_repository'); if (!$commentRepository instanceof ProductCommentRepository) { From 8458c23c1d6a5ee2f5232e4c67ef0ccdb070989f Mon Sep 17 00:00:00 2001 From: Thomas N Date: Wed, 9 Sep 2026 10:20:23 +0100 Subject: [PATCH 2/2] Remove ignored statement --- productcomments.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/productcomments.php b/productcomments.php index ef3eb093..02c7149b 100644 --- a/productcomments.php +++ b/productcomments.php @@ -33,6 +33,7 @@ use PrestaShop\Module\ProductComment\Form\ProductCommentCriterionFormDataProvider; use PrestaShop\Module\ProductComment\Repository\ProductCommentCriterionRepository; use PrestaShop\Module\ProductComment\Repository\ProductCommentRepository; +use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray; use PrestaShop\PrestaShop\Core\Module\WidgetInterface; class ProductComments extends Module implements WidgetInterface @@ -929,7 +930,7 @@ public function hookDisplayFooterProduct($params) /** * Inject data about productcomments in the product object for frontoffice. This is the older way of adding the data before PrestaShop 9.2. * - * @param array $params + * @param array{object: ProductLazyArray} $params * * @return array */ @@ -943,7 +944,10 @@ public function hookFilterProductContent(array $params) $averageRating = $commentRepository->getAverageGrade($params['object']->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE')); $nbComments = $commentRepository->getCommentsNumber($params['object']->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE')); - /* @phpstan-ignore-next-line */ + /* + * @phpstan-ignore-next-line + * Needs #[AllowDynamicProperties] on ProductLazyArray class to avoid error in PHP 8.2+ + */ $params['object']->productComments = [ 'averageRating' => $averageRating, 'nbComments' => $nbComments,