Skip to content

Commit 0aa7fc9

Browse files
author
Andrey Helldar
committed
Changed the type of output of exceptions from array to collection
1 parent b3bb966 commit 0aa7fc9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Models/Route.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Contracts\Support\Arrayable;
99
use Illuminate\Routing\Route as IlluminateRoute;
1010
use Illuminate\Support\Arr;
11+
use Illuminate\Support\Collection;
1112
use Illuminate\Support\Str;
1213

1314
final class Route implements Arrayable
@@ -138,7 +139,7 @@ public function getDeprecated(): bool
138139
return Annotation::isDeprecated($this->getAction());
139140
}
140141

141-
public function getExceptions(): array
142+
public function getExceptions(): Collection
142143
{
143144
return Annotation::exceptions($this->getAction());
144145
}
@@ -162,7 +163,7 @@ public function toArray()
162163
'deprecated' => $this->getDeprecated(),
163164
'summary' => $this->getSummary(),
164165
'description' => $this->getDescription(),
165-
'exceptions' => $this->getExceptions(),
166+
'exceptions' => $this->getExceptions()->toArray(),
166167
'response' => $this->getResponse(),
167168
];
168169
}

src/Support/Annotation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Helldar\LaravelRoutesCore\Models\Tags\Returns;
77
use Helldar\LaravelRoutesCore\Models\Tags\Throws;
88
use Illuminate\Support\Arr;
9+
use Illuminate\Support\Collection;
910
use phpDocumentor\Reflection\DocBlock;
1011

1112
final class Annotation
@@ -53,9 +54,9 @@ public function isDeprecated(string $controller, string $method = null)
5354
* @param string $controller
5455
* @param string|null $method
5556
*
56-
* @return array|\Helldar\LaravelRoutesCore\Models\Tags\Throws[]
57+
* @return \Illuminate\Support\Collection|\Helldar\LaravelRoutesCore\Models\Tags\Throws[]
5758
*/
58-
public function exceptions(string $controller, string $method = null): array
59+
public function exceptions(string $controller, string $method = null): Collection
5960
{
6061
$callback = static function (DocBlock $doc) {
6162
return array_map(static function (DocBlock\Tags\Throws $tag) {
@@ -73,8 +74,7 @@ public function exceptions(string $controller, string $method = null): array
7374
->unique('code')
7475
->keyBy('code')
7576
->sortBy('code')
76-
->filter()
77-
->toArray();
77+
->filter();
7878
}
7979

8080
/**

0 commit comments

Comments
 (0)