From 51162dfb2a4bfaa23be1713184d814d00c36d060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gracjan=20J=C3=B3zefczyk?= Date: Thu, 20 Jun 2024 12:12:34 +0200 Subject: [PATCH] OP-282: PHP8 Constructor --- src/Validator/InStockWishlistValidator.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Validator/InStockWishlistValidator.php b/src/Validator/InStockWishlistValidator.php index fb1ca760..3e107ec7 100644 --- a/src/Validator/InStockWishlistValidator.php +++ b/src/Validator/InStockWishlistValidator.php @@ -28,20 +28,11 @@ final class InStockWishlistValidator extends ConstraintValidator { - public RequestStack $request; - - public Router $router; - - public AvailabilityCheckerInterface $availabilityChecker; - public function __construct( - AvailabilityCheckerInterface $availabilityChecker, - RequestStack $requestStack, - Router $router, + private AvailabilityCheckerInterface $availabilityChecker, + private RequestStack $requestStack, + private Router $router, ) { - $this->request = $requestStack; - $this->availabilityChecker = $availabilityChecker; - $this->router = $router; } public function validate(mixed $value, Constraint $constraint): void @@ -50,7 +41,7 @@ public function validate(mixed $value, Constraint $constraint): void Assert::isInstanceOf($constraint, CartItemAvailability::class); - $request = $this->request->getCurrentRequest(); + $request = $this->requestStack->getCurrentRequest(); Assert::notNull($request);