Skip to content

Commit

Permalink
Replaced recursion by iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
drieschel committed Nov 24, 2023
1 parent ee701b3 commit 13d3f94
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/SerializerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ private function generateCodeForArray(

private static function isArrayForPrimitive(PropertyTypeArray $type): bool
{
return match ($type->getSubType()::class) {
PropertyTypePrimitive::class => true,
PropertyTypeArray::class => self::isArrayForPrimitive($type->getSubType()),
default => false,
};
do {
$type = $type->getSubType();
if ($type instanceof PropertyTypePrimitive) {
return true;
}
} while ($type instanceof PropertyTypeArray);

return false;
}
}

0 comments on commit 13d3f94

Please sign in to comment.