Skip to content

Commit

Permalink
Change type hint for productId, from int to string
Browse files Browse the repository at this point in the history
  • Loading branch information
ugljesaspx committed Apr 26, 2024
1 parent cc20c15 commit f6f4c9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Exception/ParentProductDisabledException.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

class ParentProductDisabledException extends NostoException
{
public function __construct(int $productId, $code = 0, Throwable $previous = null)
public function __construct(string $productId, $code = 0, Throwable $previous = null)
{
$message = "Parent product is disabled for SKU with id: " . $productId;
parent::__construct($message, $code, $previous);
Expand Down
4 changes: 2 additions & 2 deletions Model/Product/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ public function getSkusAsArray(Product $product, Store $store)

/**
* Loads (or reloads) Product object
* @param int $productId
* @param string $productId
* @param int $storeId
* @return ProductInterface|Product
* @throws NoSuchEntityException
*/
public function reloadProduct(int $productId, int $storeId)
public function reloadProduct(string $productId, int $storeId)
{
return $this->productRepository->getById(
$productId,

Check warning on line 340 in Model/Product/Repository.php

View workflow job for this annotation

GitHub Actions / Phan Analysis

Argument 1 ($productId) is $productId of type string but \Magento\Catalog\Model\ProductRepository::getById() takes int defined at vendor/magento/module-catalog/Model/ProductRepository.php:298
Expand Down
8 changes: 4 additions & 4 deletions Model/Service/Cache/CacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ public function removeByProductIds(StoreInterface $store, array $productIds)
}

/**
* @param int $productId
* @param string $productId
* @param int $storeId
* @return Product|null
*/
private function getById(int $productId, int $storeId)
private function getById(string $productId, int $storeId)
{
$cachedProduct = $this->productDataCache->load($this->generateCacheKey($productId, $storeId));
return $cachedProduct ? $this->productSerializer->fromString($cachedProduct) : null;
}

/**
* @param int $productId
* @param string $productId
* @param int $storeId
* @return string
*/
private function generateCacheKey(int $productId, int $storeId)
private function generateCacheKey(string $productId, int $storeId)
{
return sprintf(
'%s-%d-%d',
Expand Down
12 changes: 6 additions & 6 deletions Model/Service/Stock/Provider/CachingStockProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ private function getIsInStockFromCache(Product $product, Website $website)
}

/**
* @param int $productId
* @param string $productId
* @param Website $website
* @param int $quantity
*/
private function saveQuantityToCache(int $productId, Website $website, int $quantity)
private function saveQuantityToCache(string $productId, Website $website, int $quantity)
{
if (empty($this->quantityCache[$website->getId()])) {
$this->quantityCache[$website->getId()] = [];
Expand All @@ -175,11 +175,11 @@ private function saveQuantityToCache(int $productId, Website $website, int $quan
}

/**
* @param int $productId
* @param string $productId
* @param Website $website
* @return int|null
*/
private function getQuantityFromCache(int $productId, Website $website)
private function getQuantityFromCache(string $productId, Website $website)
{
if (!isset($this->quantityCache[$website->getId()][$productId])) {
return null;
Expand All @@ -198,11 +198,11 @@ private function existsInStockCache(Product $product, Website $website)
}

/**
* @param int $productId
* @param string $productId
* @param Website $website
* @return bool
*/
private function existsInQuantityCache(int $productId, Website $website)
private function existsInQuantityCache(string $productId, Website $website)
{
return isset($this->quantityCache[$website->getId()][$productId]);
}
Expand Down

0 comments on commit f6f4c9e

Please sign in to comment.