Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,15 @@

class Config implements ArgumentInterface
{
private ScopeConfigInterface $scopeConfig;
private CookieHelper $cookieHelper;
private StoreManagerInterface $storeManager;
private AppState $appState;
private Version $version;

/**
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param CookieHelper $cookieHelper
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
CookieHelper $cookieHelper,
AppState $appState,
Version $version
) {
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->cookieHelper = $cookieHelper;
$this->appState = $appState;
$this->version = $version;
public function __construct(private readonly ScopeConfigInterface $scopeConfig, private readonly StoreManagerInterface $storeManager, private readonly CookieHelper $cookieHelper, private readonly AppState $appState, private readonly Version $version)
{
}

/**
Expand Down Expand Up @@ -189,7 +173,7 @@ public function getConfigValue(string $key, $defaultValue = null)
ScopeInterface::SCOPE_STORE,
$this->storeManager->getStore()
);
} catch (NoSuchEntityException $e) {
} catch (NoSuchEntityException) {
return $defaultValue;
}

Expand Down
6 changes: 2 additions & 4 deletions Config/XmlConfig/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

class Converter implements ConverterInterface
{
private ObjectManagerInterface $objectManager;

public function __construct(ObjectManagerInterface $objectManager)
public function __construct(private readonly ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}

/**
Expand All @@ -23,6 +20,7 @@ public function __construct(ObjectManagerInterface $objectManager)
* @param DOMDocument $source
* @return array
*/
#[\Override]
public function convert($source): array
{
$result = [
Expand Down
10 changes: 3 additions & 7 deletions Config/XmlConfig/SchemaLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@

class SchemaLocator implements SchemaLocatorInterface
{
/**
* @var Reader
*/
private Reader $moduleReader;

/**
* @param Reader $moduleReader
*/
public function __construct(Reader $moduleReader)
public function __construct(private readonly Reader $moduleReader)
{
$this->moduleReader = $moduleReader;
}

/**
* @inheritdoc
*/
#[\Override]
public function getSchema()
{
return $this->getXsdPath();
Expand All @@ -32,6 +27,7 @@ public function getSchema()
/**
* @inheritdoc
*/
#[\Override]
public function getPerFileSchema()
{
return $this->getXsdPath();
Expand Down
26 changes: 2 additions & 24 deletions Cron/RetryFailedWebhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,8 @@

class RetryFailedWebhooks
{
private OrderRepositoryInterface $orderRepository;
private OrderPaymentRepositoryInterface $orderPaymentRepository;
private SearchCriteriaBuilder $searchCriteriaBuilder;
private FilterBuilder $filterBuilder;
private PurchaseWebhookEvent $webhookEvent;
private Debugger $debugger;
private LoggerInterface $logger;

public function __construct(
OrderRepositoryInterface $orderRepository,
OrderPaymentRepositoryInterface $orderPaymentRepository,
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder,
PurchaseWebhookEvent $webhookEvent,
Debugger $debugger,
LoggerInterface $logger
) {
$this->orderRepository = $orderRepository;
$this->orderPaymentRepository = $orderPaymentRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->webhookEvent = $webhookEvent;
$this->debugger = $debugger;
$this->logger = $logger;
public function __construct(private readonly OrderRepositoryInterface $orderRepository, private readonly OrderPaymentRepositoryInterface $orderPaymentRepository, private readonly SearchCriteriaBuilder $searchCriteriaBuilder, private readonly FilterBuilder $filterBuilder, private readonly PurchaseWebhookEvent $webhookEvent, private readonly Debugger $debugger, private readonly LoggerInterface $logger)
{
}

/**
Expand Down
9 changes: 3 additions & 6 deletions CustomerData/GtmCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@

class GtmCheckout implements SectionSourceInterface
{
private CheckoutSessionDataProviderInterface $checkoutSessionDataProvider;

/**
* @param CheckoutSessionDataProviderInterface $checkoutSessionDataProvider
*/
public function __construct(
CheckoutSessionDataProviderInterface $checkoutSessionDataProvider
) {
$this->checkoutSessionDataProvider = $checkoutSessionDataProvider;
public function __construct(private readonly CheckoutSessionDataProviderInterface $checkoutSessionDataProvider)
{
}

/**
* @return array
*/
#[\Override]
public function getSectionData(): array
{
$gtmEvents = $this->checkoutSessionDataProvider->get();
Expand Down
14 changes: 3 additions & 11 deletions DataLayer/Event/AddPaymentInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,21 @@

class AddPaymentInfo implements EventInterface
{
private CartItems $cartItems;
private CartRepositoryInterface $cartRepository;
private PriceFormatter $priceFormatter;
private int $cartId;
private string $paymentMethod;

/**
* @param CartRepositoryInterface $cartRepository
* @param CartItems $cartItems
*/
public function __construct(
CartRepositoryInterface $cartRepository,
CartItems $cartItems,
PriceFormatter $priceFormatter
) {
$this->cartItems = $cartItems;
$this->cartRepository = $cartRepository;
$this->priceFormatter = $priceFormatter;
public function __construct(private readonly CartRepositoryInterface $cartRepository, private readonly CartItems $cartItems, private readonly PriceFormatter $priceFormatter)
{
}

/**
* @return string[]
*/
#[\Override]
public function get(): array
{
/** @var Cart $cart */
Expand Down
22 changes: 6 additions & 16 deletions DataLayer/Event/AddShippingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,19 @@

class AddShippingInfo implements EventInterface
{
private CartItems $cartItems;
private ShippingMethodManagementInterface $shippingMethodManagement;
private CheckoutSession $checkoutSession;

/**
* @param CartItems $cartItems
* @param ShippingMethodManagementInterface $shippingMethodManagement
* @param CheckoutSession $checkoutSession
*/
public function __construct(
CartItems $cartItems,
ShippingMethodManagementInterface $shippingMethodManagement,
CheckoutSession $checkoutSession
) {
$this->cartItems = $cartItems;
$this->shippingMethodManagement = $shippingMethodManagement;
$this->checkoutSession = $checkoutSession;
public function __construct(private readonly CartItems $cartItems, private readonly ShippingMethodManagementInterface $shippingMethodManagement, private readonly CheckoutSession $checkoutSession)
{
}

/**
* @return string[]
*/
#[\Override]
public function get(): array
{
if (false === $this->checkoutSession->hasQuote()) {
Expand All @@ -44,7 +35,7 @@ public function get(): array

try {
$quote = $this->checkoutSession->getQuote();
} catch (NoSuchEntityException|LocalizedException $e) {
} catch (NoSuchEntityException|LocalizedException) {
return [];
}

Expand Down Expand Up @@ -74,14 +65,13 @@ public function getShippingMethodFromQuote(CartInterface $quote): ?string
if ($shippingMethod instanceof ShippingMethodInterface) {
return $shippingMethod->getCarrierCode().'_'.$shippingMethod->getMethodCode();
}
} catch (NoSuchEntityException $e) {
} catch (StateException $e) {
} catch (NoSuchEntityException|StateException) {
}

try {
// @phpstan-ignore-next-line
return $quote->getShippingAddress()->getShippingMethod();
} catch (NoSuchEntityException $e) {
} catch (NoSuchEntityException) {
}

return null;
Expand Down
19 changes: 4 additions & 15 deletions DataLayer/Event/AddToCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,23 @@

class AddToCart implements EventInterface
{
private ProductDataMapper $productDataMapper;
private CurrencyCode $currencyCode;
private PriceFormatter $priceFormatter;
private Product $product;
private ProductRepositoryInterface $productRepository;
private int $qty = 1;

/**
* @param ProductDataMapper $productDataMapper
* @param CurrencyCode $currencyCode
*/
public function __construct(
ProductDataMapper $productDataMapper,
CurrencyCode $currencyCode,
PriceFormatter $priceFormatter,
ProductRepositoryInterface $productRepository
) {
$this->productDataMapper = $productDataMapper;
$this->currencyCode = $currencyCode;
$this->priceFormatter = $priceFormatter;
$this->productRepository = $productRepository;
public function __construct(private readonly ProductDataMapper $productDataMapper, private readonly CurrencyCode $currencyCode, private readonly PriceFormatter $priceFormatter, private readonly ProductRepositoryInterface $productRepository)
{
}

/**
* @return string[]
* @throws LocalizedException
* @throws NoSuchEntityException
*/
#[\Override]
public function get(): array
{
$qty = ($this->qty > 0) ? $this->qty : 1;
Expand All @@ -50,7 +39,7 @@ public function get(): array

try {
$product = $this->productRepository->get($this->product->getSku());
} catch (Exception $e) {
} catch (Exception) {
// Continue normal product flow since the sku is not found.
}

Expand Down
8 changes: 3 additions & 5 deletions DataLayer/Event/AddToWishlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@

class AddToWishlist implements EventInterface
{
private ProductDataMapper $productDataMapper;
private ProductInterface $product;

/**
* @param ProductDataMapper $productDataMapper
*/
public function __construct(
ProductDataMapper $productDataMapper
) {
$this->productDataMapper = $productDataMapper;
public function __construct(private readonly ProductDataMapper $productDataMapper)
{
}

/**
* @return string[]
* @throws LocalizedException
* @throws NoSuchEntityException
*/
#[\Override]
public function get(): array
{
$itemData = $this->productDataMapper->mapByProduct($this->product);
Expand Down
18 changes: 3 additions & 15 deletions DataLayer/Event/BeginCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,17 @@

class BeginCheckout implements EventInterface
{
private Quote $quote;
private CartItems $cartItems;
private CartValue $cartValue;
private CurrencyCode $currencyCode;

/**
* @param Quote $quote
* @param CartItems $cartItems
* @param CartValue $cartValue
* @param CurrencyCode $currencyCode
*/
public function __construct(
Quote $quote,
CartItems $cartItems,
CartValue $cartValue,
CurrencyCode $currencyCode
) {
$this->quote = $quote;
$this->cartItems = $cartItems;
$this->cartValue = $cartValue;
$this->currencyCode = $currencyCode;
public function __construct(private readonly Quote $quote, private readonly CartItems $cartItems, private readonly CartValue $cartValue, private readonly CurrencyCode $currencyCode)
{
}

#[\Override]
public function get(): array
{
return [
Expand Down
8 changes: 3 additions & 5 deletions DataLayer/Event/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
class Login implements EventInterface
{
private CustomerInterface $customer;
private CustomerDataMapper $customerDataMapper;

public function __construct(
CustomerDataMapper $customerDataMapper
) {
$this->customerDataMapper = $customerDataMapper;
public function __construct(private readonly CustomerDataMapper $customerDataMapper)
{
}

public function setCustomer(CustomerInterface $customer): Login
Expand All @@ -24,6 +21,7 @@ public function setCustomer(CustomerInterface $customer): Login
return $this;
}

#[\Override]
public function get(): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions DataLayer/Event/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Logout implements EventInterface
{
#[\Override]
public function get(): array
{
return [
Expand Down
Loading