From 60ecb7ee5d5d612a37350822382fba99f2b8f4cb Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Sat, 9 Dec 2023 09:56:25 +0100 Subject: [PATCH] Fix phpstan --- src/Transformer/AbstractUniqueTypeTransformerFactory.php | 7 ++----- tools/phpstan/phpstan-baseline.neon | 5 ----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Transformer/AbstractUniqueTypeTransformerFactory.php b/src/Transformer/AbstractUniqueTypeTransformerFactory.php index 5bb4cdc2..da0c726f 100644 --- a/src/Transformer/AbstractUniqueTypeTransformerFactory.php +++ b/src/Transformer/AbstractUniqueTypeTransformerFactory.php @@ -16,14 +16,11 @@ abstract class AbstractUniqueTypeTransformerFactory implements TransformerFactor { public function getTransformer(?array $sourceTypes, ?array $targetTypes, MapperMetadataInterface $mapperMetadata): ?TransformerInterface { - $nbSourceTypes = $sourceTypes ? \count($sourceTypes) : 0; - $nbTargetTypes = $targetTypes ? \count($targetTypes) : 0; - - if (0 === $nbSourceTypes || $nbSourceTypes > 1 || !$sourceTypes[0] instanceof Type) { + if (0 === \count($sourceTypes ?? []) || \count($sourceTypes) > 1 || !$sourceTypes[0] instanceof Type) { return null; } - if (0 === $nbTargetTypes || $nbTargetTypes > 1 || !$targetTypes[0] instanceof Type) { + if (0 === \count($targetTypes ?? []) || \count($targetTypes) > 1 || !$targetTypes[0] instanceof Type) { return null; } diff --git a/tools/phpstan/phpstan-baseline.neon b/tools/phpstan/phpstan-baseline.neon index 4583a82d..9ba4eace 100644 --- a/tools/phpstan/phpstan-baseline.neon +++ b/tools/phpstan/phpstan-baseline.neon @@ -535,11 +535,6 @@ parameters: count: 1 path: ../../src/Transformer/AbstractArrayTransformer.php - - - message: "#^Offset 0 does not exist on array\\\\|null\\.$#" - count: 2 - path: ../../src/Transformer/AbstractUniqueTypeTransformerFactory.php - - message: "#^Parameter \\#1 \\$object_or_class of function is_subclass_of expects object\\|string, string\\|null given\\.$#" count: 2