From e8b16777bfd9b515b7ee51cfe40c4ed60eeb9232 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:29:46 +0700 Subject: [PATCH] fix: Fix static analysis issues. --- CHANGELOG.md | 4 ++++ src/Command/MappingCommand.php | 6 +++--- src/TypeResolver/CachingTypeResolver.php | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e5e1b0..a502f9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.5.17 + +* fix: Fix static analysis issues. + ## 0.5.16 * perf: Optimize `guessTypeFromVariable` diff --git a/src/Command/MappingCommand.php b/src/Command/MappingCommand.php index 815572a..48a93b0 100644 --- a/src/Command/MappingCommand.php +++ b/src/Command/MappingCommand.php @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $id = $entry->getId(); $variantTargetType = $entry->isVariantTargetType(); - if ($sourceOption) { + if ($sourceOption !== null) { if (preg_match('/' . preg_quote($sourceOption) . '/i', $entry->getSourceTypeString()) === 0) { continue; } @@ -71,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $sourceType = preg_replace('/(' . preg_quote($sourceOption) . ')/i', '$1', $sourceType); } - if ($targetOption) { + if ($targetOption !== null) { if (preg_match('/' . preg_quote($targetOption) . '/i', $entry->getTargetTypeString()) === 0) { continue; } @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $targetType = preg_replace('/(' . preg_quote($targetOption) . ')/i', '$1', $targetType); } - if ($classOption) { + if ($classOption !== null) { if ( preg_match('/' . preg_quote($classOption) . '/i', $entry->getClass()) === 0 && preg_match('/' . preg_quote($classOption) . '/i', $entry->getId()) === 0 diff --git a/src/TypeResolver/CachingTypeResolver.php b/src/TypeResolver/CachingTypeResolver.php index 1b51d2c..3d3a34a 100644 --- a/src/TypeResolver/CachingTypeResolver.php +++ b/src/TypeResolver/CachingTypeResolver.php @@ -37,7 +37,8 @@ public function __construct( public function getTypeString(Type|MixedType $type): string { - if ($result = $this->typeStringCache[$type] ?? null) { + $result = $this->typeStringCache[$type] ?? null; + if ($result !== null) { return $result; } @@ -62,7 +63,8 @@ public function getSimpleTypes(Type|MixedType $type): array $key = rawurlencode(serialize($type)); - if ($result = $this->simpleTypesCache[$key] ?? null) { + $result = $this->simpleTypesCache[$key] ?? null; + if ($result !== null) { return $result; }