@@ -256,10 +256,8 @@ private function setAutoloadHelpers(): void
256256 $ helpers = $ config ->helpers ;
257257 $ newHelpers = array_unique (array_merge ($ helpers , ['auth ' , 'setting ' ]));
258258
259- $ pattern = '/^ public \$helpers = \[.*\];/mu ' ;
260- $ replace = ' public $helpers = [ \'' . implode ("', ' " , $ newHelpers ) . '\']; ' ;
261259 $ content = file_get_contents ($ path );
262- $ output = preg_replace ( $ pattern , $ replace , $ content );
260+ $ output = $ this -> updateAutoloadHelpers ( $ content , $ newHelpers );
263261
264262 // check if the content is updated
265263 if ($ output === $ content ) {
@@ -277,6 +275,18 @@ private function setAutoloadHelpers(): void
277275 }
278276 }
279277
278+ /**
279+ * @param string $content The content of Config\Autoload.
280+ * @param list<string> $newHelpers The list of helpers.
281+ */
282+ private function updateAutoloadHelpers (string $ content , array $ newHelpers ): string
283+ {
284+ $ pattern = '/^ public \$helpers = \[.*?\];/msu ' ;
285+ $ replace = ' public $helpers = [ \'' . implode ("', ' " , $ newHelpers ) . '\']; ' ;
286+
287+ return preg_replace ($ pattern , $ replace , $ content );
288+ }
289+
280290 private function removeHelperLoadingInBaseController (): void
281291 {
282292 $ file = 'Controllers/BaseController.php ' ;
0 commit comments