Skip to content

Commit

Permalink
fix(tags): Panic when the tags are not an array list
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jan 17, 2024
1 parent 0d8fb4b commit 5d78669
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -246,8 +244,6 @@ public static function getOpenAPIAttributeTagsByScope(ClassMethod|Class_|Node $n
if (!empty($foundTags)) {
$tags[$foundScopeName ?: $defaultScope] = $foundTags;
}


}
}
}
Expand Down

0 comments on commit 5d78669

Please sign in to comment.