@@ -122,9 +122,16 @@ public function __construct(IOInterface $io, Composer $composer, string $project
122122
123123 public function installHyperfScript ()
124124 {
125- $ answer = $ this ->io ->ask ('' , (string )'' );
126-
127- var_dump ($ answer );
125+ $ ask [] = "\n <question>Your time zone is ?</question> \n" ;
126+ $ ask [] = " [<comment>n</comment>] Default time zone for php.ini \n" ;
127+ $ ask [] = "Make your selection or type a time zone name, like Asia/Shanghai (n): \n" ;
128+ $ answer = $ this ->io ->ask (implode ('' , $ ask ), 'n ' );
129+
130+ if (! empty ($ answer ) || $ answer != 'n ' ) {
131+ $ content = file_get_contents ($ this ->installerSource . '/resources/bin/hyperf.php ' );
132+ $ content = str_replace ('%TIME_ZONE% ' , $ answer , $ content );
133+ file_put_contents ($ this ->projectRoot . '/bin/hyperf.php ' , $ content );
134+ }
128135 }
129136
130137 /**
@@ -137,7 +144,7 @@ public function setupRuntimeDir(): void
137144 $ this ->io ->write ('<info>Setup data and cache dir</info> ' );
138145 $ runtimeDir = $ this ->projectRoot . '/runtime ' ;
139146
140- if (!is_dir ($ runtimeDir )) {
147+ if (! is_dir ($ runtimeDir )) {
141148 mkdir ($ runtimeDir , 0775 , true );
142149 chmod ($ runtimeDir , 0775 );
143150 }
@@ -256,14 +263,14 @@ public function processAnswer(array $question, $answer): bool
256263 }
257264 // Copy files
258265 if (isset ($ question ['options ' ][$ answer ])) {
259- $ force = !empty ($ question ['force ' ]);
266+ $ force = ! empty ($ question ['force ' ]);
260267 foreach ($ question ['options ' ][$ answer ]['resources ' ] as $ resource => $ target ) {
261268 $ this ->copyResource ($ resource , $ target , $ force );
262269 }
263270 }
264271 return true ;
265272 }
266- if ($ question ['custom-package ' ] === true && preg_match (self ::PACKAGE_REGEX , (string )$ answer , $ match )) {
273+ if ($ question ['custom-package ' ] === true && preg_match (self ::PACKAGE_REGEX , (string ) $ answer , $ match )) {
267274 $ this ->addPackage ($ match ['name ' ], $ match ['version ' ], []);
268275 if (isset ($ question ['custom-package-warning ' ])) {
269276 $ this ->io ->write (sprintf (' <warning>%s</warning> ' , $ question ['custom-package-warning ' ]));
@@ -317,7 +324,7 @@ public function addPackage(string $packageName, string $packageVersion, array $w
317324 }
318325 // Whitelist packages for the component installer
319326 foreach ($ whitelist as $ package ) {
320- if (!in_array ($ package , $ this ->composerDefinition ['extra ' ]['zf ' ]['component-whitelist ' ], true )) {
327+ if (! in_array ($ package , $ this ->composerDefinition ['extra ' ]['zf ' ]['component-whitelist ' ], true )) {
321328 $ this ->composerDefinition ['extra ' ]['zf ' ]['component-whitelist ' ][] = $ package ;
322329 $ this ->io ->write (sprintf (' - Whitelist package <info>%s</info> ' , $ package ));
323330 }
@@ -338,7 +345,7 @@ public function copyResource(string $resource, string $target, bool $force = fal
338345 return ;
339346 }
340347 $ destinationPath = dirname ($ this ->projectRoot . $ target );
341- if (!is_dir ($ destinationPath )) {
348+ if (! is_dir ($ destinationPath )) {
342349 mkdir ($ destinationPath , 0775 , true );
343350 }
344351 $ this ->io ->write (sprintf (' - Copying <info>%s</info> ' , $ target ));
@@ -405,20 +412,20 @@ private function askQuestion(array $question, $defaultOption)
405412 : sprintf (' Make your selection <comment>(%s)</comment>: ' , $ defaultText );
406413 while (true ) {
407414 // Ask for user input
408- $ answer = $ this ->io ->ask (implode ($ ask ), (string )$ defaultOption );
415+ $ answer = $ this ->io ->ask (implode ($ ask ), (string ) $ defaultOption );
409416 // Handle none of the options
410417 if ($ answer === 'n ' && $ question ['required ' ] !== true ) {
411418 return 'n ' ;
412419 }
413420 // Handle numeric options
414- if (is_numeric ($ answer ) && isset ($ question ['options ' ][(int )$ answer ])) {
415- return (int )$ answer ;
421+ if (is_numeric ($ answer ) && isset ($ question ['options ' ][(int ) $ answer ])) {
422+ return (int ) $ answer ;
416423 }
417424 // Search for package
418425 if ($ question ['custom-package ' ] === true && preg_match (self ::PACKAGE_REGEX , $ answer , $ match )) {
419426 $ packageName = $ match ['name ' ];
420427 $ packageVersion = $ match ['version ' ];
421- if (!$ packageVersion ) {
428+ if (! $ packageVersion ) {
422429 $ this ->io ->write ('<error>No package version specified</error> ' );
423430 continue ;
424431 }
@@ -442,7 +449,7 @@ private function askQuestion(array $question, $defaultOption)
442449 */
443450 private function recursiveRmdir (string $ directory ): void
444451 {
445- if (!is_dir ($ directory )) {
452+ if (! is_dir ($ directory )) {
446453 return ;
447454 }
448455 $ rdi = new RecursiveDirectoryIterator ($ directory , FilesystemIterator::SKIP_DOTS );
0 commit comments