Skip to content

Commit e8b448f

Browse files
committed
add fixes
1 parent 2d7d5ba commit e8b448f

31 files changed

+118
-47
lines changed

system/Commands/Cache/InfoCache.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function run(array $params)
6363
if ($config->handler !== 'file') {
6464
CLI::error('This command only supports the file cache handler.');
6565

66-
return;
66+
return EXIT_ERROR;
6767
}
6868

6969
$cache = CacheFactory::getHandler($config);
@@ -87,5 +87,7 @@ public function run(array $params)
8787
];
8888

8989
CLI::table($tbody, $thead);
90+
91+
return EXIT_SUCCESS;
9092
}
9193
}

system/Commands/Database/CreateDatabase.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function run(array $params)
115115
CLI::error("Database \"{$dbName}\" already exists.", 'light_gray', 'red');
116116
CLI::newLine();
117117

118-
return;
118+
return EXIT_ERROR;
119119
}
120120

121121
unset($dbName);
@@ -130,22 +130,26 @@ public function run(array $params)
130130
CLI::error('Database creation failed.', 'light_gray', 'red');
131131
CLI::newLine();
132132

133-
return;
133+
return EXIT_ERROR;
134134
// @codeCoverageIgnoreEnd
135135
}
136136
} elseif (! Database::forge()->createDatabase($name)) {
137137
// @codeCoverageIgnoreStart
138138
CLI::error('Database creation failed.', 'light_gray', 'red');
139139
CLI::newLine();
140140

141-
return;
141+
return EXIT_ERROR;
142142
// @codeCoverageIgnoreEnd
143143
}
144144

145145
CLI::write("Database \"{$name}\" successfully created.", 'green');
146146
CLI::newLine();
147+
148+
return EXIT_SUCCESS;
147149
} catch (Throwable $e) {
148150
$this->showError($e);
151+
152+
return EXIT_ERROR;
149153
} finally {
150154
Factories::reset('config');
151155
Database::connect(null, false);

system/Commands/Database/Migrate.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ public function run(array $params)
9999

100100
CLI::write(lang('Migrations.migrated'), 'green');
101101

102+
return EXIT_SUCCESS;
102103
// @codeCoverageIgnoreStart
103104
} catch (Throwable $e) {
104105
$this->showError($e);
106+
107+
return EXIT_ERROR;
105108
// @codeCoverageIgnoreEnd
106109
}
107110
}

system/Commands/Database/MigrateRefresh.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,15 @@ public function run(array $params)
7979
$force = array_key_exists('f', $params) || CLI::getOption('f');
8080

8181
if (! $force && CLI::prompt(lang('Migrations.refreshConfirm'), ['y', 'n']) === 'n') {
82-
return;
82+
return EXIT_ERROR;
8383
}
8484

8585
$params['f'] = null;
8686
// @codeCoverageIgnoreEnd
8787
}
8888

89-
$this->withSignalsBlocked(function () use ($params): void {
90-
$this->call('migrate:rollback', $params);
91-
$this->call('migrate', $params);
92-
});
89+
return $this->withSignalsBlocked(
90+
fn (): int => $this->call('migrate:rollback', $params) | $this->call('migrate', $params),
91+
);
9392
}
9493
}

system/Commands/Database/MigrateRollback.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function run(array $params)
7777
$force = array_key_exists('f', $params) || CLI::getOption('f');
7878

7979
if (! $force && CLI::prompt(lang('Migrations.rollBackConfirm'), ['y', 'n']) === 'n') {
80-
return null;
80+
return EXIT_ERROR;
8181
}
8282
// @codeCoverageIgnoreEnd
8383
}
@@ -101,12 +101,20 @@ public function run(array $params)
101101

102102
CLI::write(lang('Migrations.rollingBack') . ' ' . $batch, 'yellow');
103103

104-
$this->withSignalsBlocked(static function () use ($runner, $batch): void {
104+
$exit = $this->withSignalsBlocked(static function () use ($runner, $batch): int {
105105
if (! $runner->regress($batch)) {
106106
CLI::error(lang('Migrations.generalFault'), 'light_gray', 'red'); // @codeCoverageIgnore
107+
108+
return EXIT_ERROR;
107109
}
110+
111+
return EXIT_SUCCESS;
108112
});
109113

114+
if ($exit !== EXIT_SUCCESS) {
115+
return $exit;
116+
}
117+
110118
$messages = $runner->getCliMessages();
111119

112120
foreach ($messages as $message) {
@@ -115,12 +123,13 @@ public function run(array $params)
115123

116124
CLI::write('Done rolling back migrations.', 'green');
117125

126+
return EXIT_SUCCESS;
118127
// @codeCoverageIgnoreStart
119128
} catch (Throwable $e) {
120129
$this->showError($e);
130+
131+
return EXIT_ERROR;
121132
// @codeCoverageIgnoreEnd
122133
}
123-
124-
return null;
125134
}
126135
}

system/Commands/Database/MigrateStatus.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function run(array $params)
150150
CLI::error(lang('Migrations.noneFound'), 'light_gray', 'red');
151151
CLI::newLine();
152152

153-
return;
153+
return EXIT_ERROR;
154154
// @codeCoverageIgnoreEnd
155155
}
156156

@@ -164,5 +164,7 @@ public function run(array $params)
164164
];
165165

166166
CLI::table($status, $headers);
167+
168+
return EXIT_SUCCESS;
167169
}
168170
}

system/Commands/Database/Seed.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ public function run(array $params)
7777

7878
try {
7979
$seeder->call($seedName);
80+
81+
return EXIT_SUCCESS;
8082
} catch (Throwable $e) {
8183
$this->showError($e);
84+
85+
return EXIT_ERROR;
8286
}
8387
}
8488
}

system/Commands/Encryption/GenerateKey.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ public function run(array $params)
8989
CLI::write($encodedKey, 'yellow');
9090
CLI::newLine();
9191

92-
return;
92+
return EXIT_ERROR;
9393
}
9494

9595
if (! $this->setNewEncryptionKey($encodedKey, $params)) {
9696
CLI::write('Error in setting new encryption key to .env file.', 'light_gray', 'red');
9797
CLI::newLine();
9898

99-
return;
99+
return EXIT_ERROR;
100100
}
101101

102102
// force DotEnv to reload the new env vars
@@ -107,6 +107,8 @@ public function run(array $params)
107107

108108
CLI::write('Application\'s new encryption key was successfully set.', 'green');
109109
CLI::newLine();
110+
111+
return EXIT_SUCCESS;
110112
}
111113

112114
/**

system/Commands/Generators/CellGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ public function run(array $params)
102102

103103
$this->generateView($namespace . $viewName, $params);
104104

105-
return 0;
105+
return EXIT_SUCCESS;
106106
}
107107
}

system/Commands/Generators/CommandGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public function run(array $params)
8686

8787
$this->classNameLang = 'CLI.generator.className.command';
8888
$this->generateClass($params);
89+
90+
return EXIT_SUCCESS;
8991
}
9092

9193
/**

0 commit comments

Comments
 (0)