@@ -72,13 +72,13 @@ protected function initialize(InputInterface $input, OutputInterface $output)
7272 $ config = $ this ->option ('config ' ) and $ this ->configManager ->replaceFrom ($ config );
7373 }
7474
75- public function handle ()
75+ public function handle (): int
7676 {
77- $ this ->task ('1. Checking run environment ' , function () use (&$ stagedDiff ) {
78- $ isInsideWorkTree = $ this ->createProcess ('git rev-parse --is-inside-work-tree ' )
77+ $ this ->task ('1. Checking run environment ' , function () use (&$ stagedDiff ): void {
78+ $ output = $ this ->createProcess ('git rev-parse --is-inside-work-tree ' )
7979 ->mustRun ()
8080 ->getOutput ();
81- if (! \str ($ isInsideWorkTree )->rtrim ()->is ('true ' )) {
81+ if (! \str ($ output )->rtrim ()->is ('true ' )) {
8282 $ message = <<<'message'
8383It looks like you are not in a git repository.
8484Please run this command from the root of a git repository, or initialize one using `git init`.
@@ -93,7 +93,7 @@ public function handle()
9393 }
9494 }, 'checking... ' );
9595
96- $ this ->task ('2. Generating commit messages ' , function () use (&$ messages , $ stagedDiff ) {
96+ $ this ->task ('2. Generating commit messages ' , function () use (&$ messages , $ stagedDiff ): void {
9797 $ generator = $ this ->laravel ->get (GeneratorManager::class)->driver ($ this ->option ('generator ' ));
9898 $ messages = $ generator ->generate ($ this ->getPromptOfAI ($ stagedDiff ));
9999 if (\str ($ messages )->isEmpty ()) {
@@ -109,15 +109,15 @@ public function handle()
109109 $ this ->line ('' );
110110 }, 'generating... ' );
111111
112- $ this ->task ('3. Choosing commit message ' , function () use ($ messages , &$ message ) {
112+ $ this ->task ('3. Choosing commit message ' , function () use ($ messages , &$ message ): void {
113113 $ messages = collect (json_decode ($ messages , true ));
114114 $ chosenSubject = $ this ->choice ('Please choice a commit message ' , $ messages ->pluck ('subject ' , 'id ' )->all ());
115- $ message = $ messages ->first (function ($ message ) use ($ chosenSubject ) {
115+ $ message = $ messages ->first (static function ($ message ) use ($ chosenSubject ): bool {
116116 return $ message ['subject ' ] === $ chosenSubject ;
117117 });
118118 }, 'choosing... ' );
119119
120- $ this ->task ('4. Committing message ' , function () use ($ message ) {
120+ $ this ->task ('4. Committing message ' , function () use ($ message ): void {
121121 $ this ->createProcess ($ this ->getCommitCommand ($ message ))
122122 ->setTty (true )
123123 ->setTimeout (null )
@@ -153,7 +153,7 @@ protected function getPromptOfAI(string $stagedDiff): string
153153 [$ this ->configManager ->get ('diff_mark ' ), $ this ->configManager ->get ('num_mark ' )],
154154 [$ stagedDiff , $ this ->option ('num ' )]
155155 )
156- ->when ($ this ->option ('verbose ' ), function (Stringable $ diff ) {
156+ ->when ($ this ->option ('verbose ' ), function (Stringable $ diff ): void {
157157 $ this ->line ('' );
158158 $ this ->comment ('============================ start prompt ============================ ' );
159159
@@ -194,10 +194,10 @@ protected function tryFixMessages(string $messages): string
194194 protected function getCommitCommand (array $ message ): array
195195 {
196196 return collect ($ message )
197- ->filter (function ($ val ) {
197+ ->filter (static function ($ val ): bool {
198198 return $ val && is_string ($ val );
199199 })
200- ->map (function (string $ val ) {
200+ ->map (static function (string $ val ): string {
201201 return trim ($ val , " \t\n\r\x0B" );
202202 })
203203 ->pipe (function (Collection $ message ): array {
@@ -206,7 +206,7 @@ protected function getCommitCommand(array $message): array
206206 ->pipe (function (Collection $ options ): Collection {
207207 $ noEdit = $ this ->option ('no-edit ' ) ?: ! $ this ->configManager ->get ('edit ' );
208208 if ($ noEdit ) {
209- return $ options ->filter (function (string $ option ): bool {
209+ return $ options ->filter (static function (string $ option ): bool {
210210 return '--edit ' !== $ option ;
211211 });
212212 }
@@ -221,10 +221,8 @@ protected function getCommitCommand(array $message): array
221221
222222 /**
223223 * Define the command's schedule.
224- *
225- * @return void
226224 */
227- public function schedule (Schedule $ schedule )
225+ public function schedule (Schedule $ schedule ): void
228226 {
229227 // $schedule->command(static::class)->everyMinute();
230228 }
0 commit comments