From 3689c456459eb4f683f14be6c37a76e368b077d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Bedn=C3=A1=C5=99?= Date: Wed, 4 May 2022 12:32:10 +0200 Subject: [PATCH] feature - MAR-12777 - all vars and func promotions marked as deprecated --- CHANGELOG.md | 6 ++++++ psalm.xml | 16 ++++++++++++++++ src/Article/DTO/AbstractArticleRequest.php | 7 +++++++ src/Article/DTO/ProductRequest.php | 2 ++ src/Article/DTO/VariantRequest.php | 2 ++ src/Article/Entity/Common/AbstractArticle.php | 6 ++++++ src/Article/Entity/Common/Promotion.php | 1 + src/Article/Entity/Common/PromotionIterator.php | 1 + src/Article/Entity/Product.php | 2 ++ src/Article/Entity/Variant.php | 1 + src/MpApiClient.php | 2 +- 11 files changed, 45 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bc5fd0..bff260e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 4.4.0 - 2022-10-03 + +### Changed + +- `promotions` attribute is deprecated + ## 4.3.0 - 2022-10-03 ### Added diff --git a/psalm.xml b/psalm.xml index 4e9226b..f1b3bc7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -12,4 +12,20 @@ + + + + + + + + + + + + + + + + diff --git a/src/Article/DTO/AbstractArticleRequest.php b/src/Article/DTO/AbstractArticleRequest.php index 0a0543a..e3591ce 100644 --- a/src/Article/DTO/AbstractArticleRequest.php +++ b/src/Article/DTO/AbstractArticleRequest.php @@ -26,6 +26,7 @@ abstract class AbstractArticleRequest implements JsonSerializable protected ?float $purchasePrice = null; protected ?float $rrp = null; protected MediaIterator $media; + /** @deprecated */ protected PromotionIterator $promotions; protected ParameterIterator $parameters; protected LabelIterator $labels; @@ -146,11 +147,17 @@ public function setMedia(MediaIterator $media): void $this->media = $media; } + /** + * @deprecated + */ public function getPromotions(): PromotionIterator { return $this->promotions; } + /** + * @deprecated + */ public function setPromotions(PromotionIterator $promotions): void { $this->promotions = $promotions; diff --git a/src/Article/DTO/ProductRequest.php b/src/Article/DTO/ProductRequest.php index ef5b03f..7579792 100644 --- a/src/Article/DTO/ProductRequest.php +++ b/src/Article/DTO/ProductRequest.php @@ -50,6 +50,7 @@ public static function createFromProduct(Product $product): self $self->setPurchasePrice($product->getPurchasePrice()); $self->setRrp($product->getRrp()); $self->setMedia($product->getMedia()); + /** @psalm-suppress DeprecatedMethod */ $self->setPromotions($product->getPromotions()); $self->setParameters($product->getParameters()); $self->setDimensions($product->getDimensions()); @@ -78,6 +79,7 @@ public static function createFromProduct(Product $product): self */ public function getArrayForApi(): array { + /** @psalm-suppress DeprecatedMethod */ $mandatory = [ 'id' => $this->getId(), 'title' => $this->getTitle(), diff --git a/src/Article/DTO/VariantRequest.php b/src/Article/DTO/VariantRequest.php index 1357409..021175a 100644 --- a/src/Article/DTO/VariantRequest.php +++ b/src/Article/DTO/VariantRequest.php @@ -43,6 +43,7 @@ public static function createFromVariant(Variant $variant): self $self->setBarcode($variant->getBarcode()); $self->setPurchasePrice($variant->getPurchasePrice()); $self->setRrp($variant->getRrp()); + /** @psalm-suppress DeprecatedMethod */ $self->setPromotions($variant->getPromotions()); $self->setDimensions($variant->getDimensions()); $self->setAvailability($variant->getAvailability()); @@ -61,6 +62,7 @@ public static function createFromVariant(Variant $variant): self */ public function getArrayForApi(): array { + /** @psalm-suppress DeprecatedMethod */ $mandatory = [ 'id' => $this->getId(), 'title' => $this->getTitle(), diff --git a/src/Article/Entity/Common/AbstractArticle.php b/src/Article/Entity/Common/AbstractArticle.php index f4e98a8..3a42279 100644 --- a/src/Article/Entity/Common/AbstractArticle.php +++ b/src/Article/Entity/Common/AbstractArticle.php @@ -23,6 +23,9 @@ abstract class AbstractArticle implements JsonSerializable protected float $purchasePrice; protected float $rrp; protected MediaIterator $media; + /** + * @deprecated + */ protected PromotionIterator $promotions; protected ParameterIterator $parameters; protected Dimensions $dimensions; @@ -188,6 +191,9 @@ public function getMedia(): MediaIterator return $this->media; } + /** + * @deprecated + */ public function getPromotions(): PromotionIterator { return $this->promotions; diff --git a/src/Article/Entity/Common/Promotion.php b/src/Article/Entity/Common/Promotion.php index deb7024..42cad28 100644 --- a/src/Article/Entity/Common/Promotion.php +++ b/src/Article/Entity/Common/Promotion.php @@ -9,6 +9,7 @@ use MpApiClient\Common\Util\InputDataUtil; use MpApiClient\Common\Util\JsonSerializeEntityTrait; +/** @deprecated */ final class Promotion implements JsonSerializable { diff --git a/src/Article/Entity/Common/PromotionIterator.php b/src/Article/Entity/Common/PromotionIterator.php index b500efb..dd0ba68 100644 --- a/src/Article/Entity/Common/PromotionIterator.php +++ b/src/Article/Entity/Common/PromotionIterator.php @@ -8,6 +8,7 @@ /** * @extends AbstractIntKeyIterator * @property Promotion[] $data + * @deprecated */ final class PromotionIterator extends AbstractIntKeyIterator { diff --git a/src/Article/Entity/Product.php b/src/Article/Entity/Product.php index 9eff16d..489580c 100644 --- a/src/Article/Entity/Product.php +++ b/src/Article/Entity/Product.php @@ -30,6 +30,7 @@ final class Product extends AbstractArticle protected ?float $weeeFee; /** + * @psalm-suppress DeprecatedClass * @param string $id * @param int $articleId * @param ProductStageEnum $stage @@ -141,6 +142,7 @@ private function __construct( */ public static function createFromApi(array $data): self { + /** @psalm-suppress DeprecatedClass */ return new self( (string) $data['id'], (int) $data['article_id'], diff --git a/src/Article/Entity/Variant.php b/src/Article/Entity/Variant.php index d70a01a..768dd4f 100644 --- a/src/Article/Entity/Variant.php +++ b/src/Article/Entity/Variant.php @@ -25,6 +25,7 @@ final class Variant extends AbstractArticle */ public static function createFromApi(array $data): self { + /** @psalm-suppress DeprecatedClass */ return new self( (string) $data['id'], (int) $data['article_id'], diff --git a/src/MpApiClient.php b/src/MpApiClient.php index 07dfeb6..347122e 100644 --- a/src/MpApiClient.php +++ b/src/MpApiClient.php @@ -29,7 +29,7 @@ final class MpApiClient implements ClientInterface, MpApiClientInterface { const APP_NAME = 'mp-api-client'; - const APP_VERSION = '4.2.0'; + const APP_VERSION = '4.4.0'; private BrandClientInterface $brandClient; private CategoryClientInterface $categoryClient;