Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Use Command::fail() method for single error messages #52387

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Illuminate/Foundation/Console/ConfigShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public function handle()
$config = $this->argument('config');

if (! config()->has($config)) {
$this->components->error("Configuration file or key <comment>{$config}</comment> does not exist.");

return Command::FAILURE;
$this->fail("Configuration file or key <comment>{$config}</comment> does not exist.");
}

$this->newLine();
Expand Down
20 changes: 5 additions & 15 deletions src/Illuminate/Foundation/Console/EnvironmentDecryptCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public function handle()
$key = $this->option('key') ?: Env::get('LARAVEL_ENV_ENCRYPTION_KEY');

if (! $key) {
$this->components->error('A decryption key is required.');

return Command::FAILURE;
$this->fail('A decryption key is required.');
}

$cipher = $this->option('cipher') ?: 'AES-256-CBC';
Expand All @@ -79,21 +77,15 @@ public function handle()
$outputFile = $this->outputFilePath();

if (Str::endsWith($outputFile, '.encrypted')) {
$this->components->error('Invalid filename.');

return Command::FAILURE;
$this->fail('Invalid filename.');
}

if (! $this->files->exists($encryptedFile)) {
$this->components->error('Encrypted environment file not found.');

return Command::FAILURE;
$this->fail('Encrypted environment file not found.');
}

if ($this->files->exists($outputFile) && ! $this->option('force')) {
$this->components->error('Environment file already exists.');

return Command::FAILURE;
$this->fail('Environment file already exists.');
}

try {
Expand All @@ -104,9 +96,7 @@ public function handle()
$encrypter->decrypt($this->files->get($encryptedFile))
);
} catch (Exception $e) {
$this->components->error($e->getMessage());

return Command::FAILURE;
$this->fail($e->getMessage());
}

$this->components->info('Environment successfully decrypted.');
Expand Down
12 changes: 3 additions & 9 deletions src/Illuminate/Foundation/Console/EnvironmentEncryptCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,11 @@ public function handle()
}

if (! $this->files->exists($environmentFile)) {
$this->components->error('Environment file not found.');

return Command::FAILURE;
$this->fail('Environment file not found.');
}

if ($this->files->exists($encryptedFile) && ! $this->option('force')) {
$this->components->error('Encrypted environment file already exists.');

return Command::FAILURE;
$this->fail('Encrypted environment file already exists.');
}

try {
Expand All @@ -94,9 +90,7 @@ public function handle()
$encrypter->encrypt($this->files->get($environmentFile))
);
} catch (Exception $e) {
$this->components->error($e->getMessage());

return Command::FAILURE;
$this->fail($e->getMessage());
}

if ($this->option('prune')) {
Expand Down