Skip to content

Commit

Permalink
trying to fix code style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tanthammar committed Jan 31, 2025
1 parent 0dcab74 commit d84f03a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/Illuminate/Foundation/Console/KeyGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ protected function shouldSaveExistingKey(): bool
'There is already an app key. Do you want to store the old key before generating a new one?',
true
)) {

$this->call('key:rotate');

return true;
Expand Down
14 changes: 7 additions & 7 deletions src/Illuminate/Foundation/Console/RotateKeyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ protected function updateEnvFile(string $currentKey, array $previousKeys): bool
$contents = file_get_contents($envPath);

// Convert array to comma-separated string and wrap in quotes
$quotedPreviousKeys = '"' . implode(',', $previousKeys) . '"';
$quotedPreviousKeys = '"'.implode(',', $previousKeys).'"';

// Update APP_PREVIOUS_KEYS
if (str_contains($contents, 'APP_PREVIOUS_KEYS=')) {
// If APP_PREVIOUS_KEYS already exists, update its value
$contents = preg_replace($this->previousKeysPattern(), 'APP_PREVIOUS_KEYS=' . $quotedPreviousKeys, $contents);
$contents = preg_replace($this->previousKeysPattern(), 'APP_PREVIOUS_KEYS='.$quotedPreviousKeys, $contents);
} else {
// If APP_PREVIOUS_KEYS does not exist, insert it after APP_KEY
$contents = preg_replace($this->keyPattern(), "APP_KEY=\nAPP_PREVIOUS_KEYS=" . $quotedPreviousKeys, $contents);
$contents = preg_replace($this->keyPattern(), "APP_KEY=\nAPP_PREVIOUS_KEYS=".$quotedPreviousKeys, $contents);
}

// Clear APP_KEY
Expand All @@ -76,18 +76,18 @@ protected function updateEnvFile(string $currentKey, array $previousKeys): bool
}

/**
* Generate a regex pattern to match the current APP_KEY line
* Generate a regex pattern to match the current APP_KEY line.
*/
protected function keyPattern(): string
{
return '/^APP_KEY=' . preg_quote($this->laravel['config']['app.key'], '/') . '/m';
return '/^APP_KEY='.preg_quote($this->laravel['config']['app.key'], '/').'/m';
}

/**
* Generate a regex pattern to match the current APP_PREVIOUS_KEYS line
* Generate a regex pattern to match the current APP_PREVIOUS_KEYS line.
*/
protected function previousKeysPattern(): string
{
return '/^APP_PREVIOUS_KEYS="' . preg_quote(implode(',', (array) $this->laravel['config']['app.previous_keys']), '/') . '"/m';
return '/^APP_PREVIOUS_KEYS="'.preg_quote(implode(',', (array) $this->laravel['config']['app.previous_keys']), '/').'"/m';
}
}

0 comments on commit d84f03a

Please sign in to comment.