From 5d78669d873abb73ce55bf01219c60dfbc822cc9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jan 2024 13:49:15 +0100 Subject: [PATCH] fix(tags): Panic when the tags are not an array list Signed-off-by: Joas Schilling --- src/Helpers.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Helpers.php b/src/Helpers.php index d37c9c1..2dd7496 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -7,7 +7,6 @@ use PhpParser\Node\Arg; use PhpParser\Node\AttributeGroup; use PhpParser\Node\Expr\Array_; -use PhpParser\Node\Expr\ArrayItem; use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\Class_; @@ -232,12 +231,11 @@ public static function getOpenAPIAttributeTagsByScope(ClassMethod|Class_|Node $n } if (!$arg->value instanceof Array_) { - - continue; + Logger::panic($routeName, 'Can not read value of tags provided in OpenAPI attribute for route ' . $routeName); } foreach ($arg->value->items as $item) { - if ($item instanceof ArrayItem && $item->value instanceof String_) { + if ($item?->value instanceof String_) { $foundTags[] = $item->value->value; } } @@ -246,8 +244,6 @@ public static function getOpenAPIAttributeTagsByScope(ClassMethod|Class_|Node $n if (!empty($foundTags)) { $tags[$foundScopeName ?: $defaultScope] = $foundTags; } - - } } }