From a984b5e4ca1d3400446aef51d11625b08b018b42 Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Fri, 17 Nov 2023 17:00:56 +0100 Subject: [PATCH] Fix new Psalm and PHPStan errors (#187) --- psalm.xml | 3 ++- src/Middleware/ItemImportResultPersisterMiddleware.php | 2 +- src/Product/ProductOptionsResolver.php | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/psalm.xml b/psalm.xml index 0143fe6f..a403a70f 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,7 +10,8 @@ - + + diff --git a/src/Middleware/ItemImportResultPersisterMiddleware.php b/src/Middleware/ItemImportResultPersisterMiddleware.php index da912196..0ab2c2f7 100644 --- a/src/Middleware/ItemImportResultPersisterMiddleware.php +++ b/src/Middleware/ItemImportResultPersisterMiddleware.php @@ -36,7 +36,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope return $result; } - if (!$envelope->last(ReceivedStamp::class)) { + if (null === $envelope->last(ReceivedStamp::class)) { return $result; } diff --git a/src/Product/ProductOptionsResolver.php b/src/Product/ProductOptionsResolver.php index 4b7c2b0d..375fbdd5 100644 --- a/src/Product/ProductOptionsResolver.php +++ b/src/Product/ProductOptionsResolver.php @@ -12,6 +12,9 @@ use Sylius\Component\Product\Repository\ProductOptionRepositoryInterface; use Sylius\Component\Resource\Factory\FactoryInterface; +/** + * @psalm-type AkeneoFamilyVariant array{code: string, labels: array, variant_attribute_sets: list, attributes: list}>} + */ final class ProductOptionsResolver implements ProductOptionsResolverInterface { /** @@ -55,6 +58,7 @@ public function resolve(array $akeneoProduct): array $familyVariantCode = $productResponse['family_variant']; try { + /** @var AkeneoFamilyVariant $familyVariantResponse */ $familyVariantResponse = $this->apiClient->getFamilyVariantApi()->get($familyCode, $familyVariantCode); } catch (HttpException $e) { if ($e->getResponse()->getStatusCode() === 404) {