From aed317932174bd9eed8310b1820ff16ca2f83ee7 Mon Sep 17 00:00:00 2001 From: IDMarinas <35842929+idmarinas@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:14:26 +0100 Subject: [PATCH] Rector fixed --- src/Command/RegenerateAppSecretCommand.php | 10 +++++----- src/Traits/Tool/VersionTrait.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Command/RegenerateAppSecretCommand.php b/src/Command/RegenerateAppSecretCommand.php index 25c682c..12dcc0c 100644 --- a/src/Command/RegenerateAppSecretCommand.php +++ b/src/Command/RegenerateAppSecretCommand.php @@ -61,7 +61,7 @@ protected function execute (InputInterface $input, OutputInterface $output): int $secret = bin2hex(random_bytes($length)); if ($showValue) { - $io->success("New $key was generated: $secret"); + $io->success(sprintf('New %s was generated: %s', $key, $secret)); return Command::SUCCESS; } @@ -72,17 +72,17 @@ protected function execute (InputInterface $input, OutputInterface $output): int $str = file_get_contents($file); $fs = new Filesystem(); - $pattern = "/^(?$key=.+)$/m"; + $pattern = sprintf('/^(?%s=.+)$/m', $key); preg_match($pattern, $str, $matches); if (isset($matches['secret']) && is_string($matches['secret'])) { - $str = preg_replace("/{$matches['secret']}/", "{$key}={$secret}", $str); + $str = preg_replace(sprintf('/%s/', $matches['secret']), sprintf('%s=%s', $key, $secret), $str); $fs->dumpFile($file, $str); - $io->success("New {$key} was generated: {$secret}"); + $io->success(sprintf('New %s was generated: %s', $key, $secret)); } else { - $io->warning("Not find {$key} in file '{$file}'"); + $io->warning(sprintf("Not find %s in file '%s'", $key, $file)); } return Command::SUCCESS; diff --git a/src/Traits/Tool/VersionTrait.php b/src/Traits/Tool/VersionTrait.php index fe29336..00eb8d9 100644 --- a/src/Traits/Tool/VersionTrait.php +++ b/src/Traits/Tool/VersionTrait.php @@ -32,7 +32,7 @@ public function convertVersionToString (int $version): string $version = substr_replace($version, '', -4); $major = (int)substr($version, -4); - return "{$major}.{$minor}.{$path}"; + return sprintf('%d.%d.%d', $major, $minor, $path); } /** Convert string version like 1.0.0 to 100000000 */ @@ -40,7 +40,7 @@ public function convertVersionToInt (string $version): int { $re = '^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'; - preg_match_all("/$re/m", $version, $matches, PREG_SET_ORDER, 0); + preg_match_all(sprintf('/%s/m', $re), $version, $matches, PREG_SET_ORDER, 0); $matches = $matches[0]; $major = str_pad($matches['major'], 4, 0, STR_PAD_LEFT);