@@ -122,13 +122,19 @@ protected function installMiddleware($names, $group = 'web', $modifier = 'append
122122 ->whenNotEmpty (function ($ names ) use ($ bootstrapApp , $ group , $ modifier ) {
123123 $ names = $ names ->map (fn ($ name ) => "$ name " )->implode (', ' .PHP_EOL .' ' );
124124
125- $ bootstrapApp = str_replace (
125+ $ stubs = [
126126 '->withMiddleware(function (Middleware $middleware) { ' ,
127- '->withMiddleware(function (Middleware $middleware) { '
127+ '->withMiddleware(function (Middleware $middleware): void { ' ,
128+ ];
129+
130+ $ bootstrapApp = str_replace (
131+ $ stubs ,
132+ collect ($ stubs )->transform (fn ($ stub ) => $ stub
128133 .PHP_EOL ." \$middleware-> $ group( $ modifier: [ "
129134 .PHP_EOL ." $ names, "
130135 .PHP_EOL .' ]); '
131- .PHP_EOL ,
136+ .PHP_EOL
137+ )->all (),
132138 $ bootstrapApp ,
133139 );
134140
@@ -151,13 +157,19 @@ protected function installMiddlewareAliases($aliases)
151157 ->whenNotEmpty (function ($ aliases ) use ($ bootstrapApp ) {
152158 $ aliases = $ aliases ->map (fn ($ name , $ alias ) => "' $ alias' => $ name " )->implode (', ' .PHP_EOL .' ' );
153159
154- $ bootstrapApp = str_replace (
160+ $ stubs = [
155161 '->withMiddleware(function (Middleware $middleware) { ' ,
156- '->withMiddleware(function (Middleware $middleware) { '
162+ '->withMiddleware(function (Middleware $middleware): void { ' ,
163+ ];
164+
165+ $ bootstrapApp = str_replace (
166+ $ stubs ,
167+ collect ($ stubs )->transform (fn ($ stub ) => $ stub
157168 .PHP_EOL .' $middleware->alias([ '
158169 .PHP_EOL ." $ aliases, "
159170 .PHP_EOL .' ]); '
160- .PHP_EOL ,
171+ .PHP_EOL
172+ )->all (),
161173 $ bootstrapApp ,
162174 );
163175
0 commit comments