File tree Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change 22
33namespace LaravelAnnotation ;
44
5+ use BackedEnum ;
56use Illuminate \Routing \ControllerMiddlewareOptions ;
67use LaravelAnnotation \Attribute \ClassMiddleware ;
78use LaravelAnnotation \Attribute \Middleware ;
@@ -31,25 +32,13 @@ public function getMiddlewaresByAttributes(): array
3132 {
3233 $ middlewares = [];
3334
34- $ isEnum = function (mixed $ obj ): bool {
35- if (gettype ($ obj ) !== 'object ' ) return false ;
36-
37- $ props = get_object_vars ($ obj );
38- return
39- count ($ props ) === 2 &&
40- isset ($ props ['name ' ]) &&
41- isset ($ props ['value ' ]) &&
42- is_string ($ props ['name ' ]) &&
43- (is_string ($ props ['value ' ]) || is_numeric ($ props ['value ' ]));
44- };
45-
4635 /** @return string[] */
47- $ filterArguments = function (array $ arguments ) use ( $ isEnum ) : array {
36+ $ filterArguments = function (array $ arguments ): array {
4837 $ items = [];
4938
5039 foreach ($ arguments as $ argument ) {
5140 if (is_string ($ argument ) && $ argument !== '' ) $ items [] = $ argument ;
52- if ($ isEnum ( $ argument) && $ argument ->value !== '' ) $ items [] = (string ) $ argument ->value ;
41+ if ($ argument instanceof BackedEnum && $ argument ->value !== '' ) $ items [] = (string ) $ argument ->value ;
5342 }
5443
5544 return $ items ;
You can’t perform that action at this time.
0 commit comments