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) { 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,