From 40db7e60a63e517e7412dde851f72f38c53934f6 Mon Sep 17 00:00:00 2001 From: Martin Rademacher Date: Fri, 12 Jun 2026 17:03:17 +1200 Subject: [PATCH] fix: remove redundant is_array() check in Serializer (#2020) (cherry picked from commit 3715043c4234b1b4aaa74b5f17d594b9d0cf51dc) --- src/Serializer.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Serializer.php b/src/Serializer.php index 595b17eb1..0628de60c 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -139,27 +139,24 @@ protected function doDeserializeProperty(OA\AbstractAnnotation $annotation, stri // property is embedded annotation // note: this does not support custom nested annotation classes foreach ($annotation::$_nested as $nestedClass => $declaration) { - // property is an annotation - if (is_string($declaration) && $declaration === $property) { - if (is_object($value)) { - return $this->doDeserialize($value, $nestedClass, $context); - } else { - return $value; + if (is_string($declaration)) { + // property is an annotation + if ($declaration === $property) { + if (is_object($value)) { + return $this->doDeserialize($value, $nestedClass, $context); + } else { + return $value; + } } - } - - // property is an annotation array - if (is_array($declaration) && count($declaration) === 1 && $declaration[0] === $property) { + } elseif (count($declaration) === 1 && $declaration[0] === $property) { + // property is an annotation array $annotationArr = []; foreach ($value as $v) { $annotationArr[] = $this->doDeserialize($v, $nestedClass, $context); } return $annotationArr; - } - - // property is an annotation hash map - if (is_array($declaration) && count($declaration) === 2 && $declaration[0] === $property) { + } elseif (count($declaration) === 2 && $declaration[0] === $property) { $key = $declaration[1]; $annotationHash = []; foreach ($value as $k => $v) {