From b07e5e392c1c2da036fa3ca209a42b798e1274c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Luciani?= Date: Thu, 1 Aug 2024 11:47:45 +0200 Subject: [PATCH] fix(ci): use sprintf native function --- CHANGELOG.md | 2 +- Command/EncryptCommand.php | 6 +++--- Controller/LogsAdminController.php | 2 +- DependencyInjection/EnvVarEncryptedProcessor.php | 2 +- Encryptor/Encryptor.php | 4 ++-- .../EkinoDataProtectionExtensionTest.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8da1fae..2aea7d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ CHANGELOG master ------ -* todo... +* Force use of sprintf native function v3.1.0 ------ diff --git a/Command/EncryptCommand.php b/Command/EncryptCommand.php index e4913a0..ceded9b 100644 --- a/Command/EncryptCommand.php +++ b/Command/EncryptCommand.php @@ -75,12 +75,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $method = $input->getOption('method'); if (!\in_array($method, openssl_get_cipher_methods())) { - throw new \InvalidArgumentException(sprintf('The method "%s" is not available. Please choose one of the following methods: %s', $method, implode(', ', openssl_get_cipher_methods()))); + throw new \InvalidArgumentException(\sprintf('The method "%s" is not available. Please choose one of the following methods: %s', $method, implode(', ', openssl_get_cipher_methods()))); } - $output->writeln(sprintf("Encryption parameters:\nText:\t\"%s\"\nSecret:\t\"%s\"\nMethod:\t\"%s\"\n", $text, $secret, $method)); + $output->writeln(\sprintf("Encryption parameters:\nText:\t\"%s\"\nSecret:\t\"%s\"\nMethod:\t\"%s\"\n", $text, $secret, $method)); $encryptor = new Encryptor($method, $secret); - $output->writeln(sprintf('Encrypted text: %s', $encryptor->encrypt($text))); + $output->writeln(\sprintf('Encrypted text: %s', $encryptor->encrypt($text))); return 0; } diff --git a/Controller/LogsAdminController.php b/Controller/LogsAdminController.php index 45696df..fd964d5 100644 --- a/Controller/LogsAdminController.php +++ b/Controller/LogsAdminController.php @@ -85,7 +85,7 @@ private function getDecryptedResults(string $content): array if (!empty($matches)) { foreach ($matches as $index => $match) { - $results[sprintf('%s_%d', $match[1], $index + 1)] = json_decode($this->encryptor->decrypt($match[2]), true); + $results[\sprintf('%s_%d', $match[1], $index + 1)] = json_decode($this->encryptor->decrypt($match[2]), true); } } else { $results['result'] = json_decode($this->encryptor->decrypt($content), true); diff --git a/DependencyInjection/EnvVarEncryptedProcessor.php b/DependencyInjection/EnvVarEncryptedProcessor.php index 634ba31..7141e9c 100644 --- a/DependencyInjection/EnvVarEncryptedProcessor.php +++ b/DependencyInjection/EnvVarEncryptedProcessor.php @@ -46,7 +46,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): string return $this->encryptor->decrypt($getEnv($name)); } - throw new RuntimeException(sprintf('Unsupported env var prefix "%s".', $prefix)); + throw new RuntimeException(\sprintf('Unsupported env var prefix "%s".', $prefix)); } /** diff --git a/Encryptor/Encryptor.php b/Encryptor/Encryptor.php index 92cf1f2..10e739b 100644 --- a/Encryptor/Encryptor.php +++ b/Encryptor/Encryptor.php @@ -57,7 +57,7 @@ public function encrypt(string $data): string $cipherText = openssl_encrypt($data, $this->method, $this->secret, OPENSSL_RAW_DATA, $iv); if ($cipherText === false) { - throw new EncryptionException(sprintf('Unexpected failure in openssl_encrypt: %s', openssl_error_string())); + throw new EncryptionException(\sprintf('Unexpected failure in openssl_encrypt: %s', openssl_error_string())); } return base64_encode($iv.$cipherText); @@ -76,7 +76,7 @@ public function decrypt(string $data): string $decrypt = openssl_decrypt($cipherText, $this->method, $this->secret, OPENSSL_RAW_DATA, $iv); if ($decrypt === false) { - throw new EncryptionException(sprintf('Unexpected failure in openssl_decrypt: %s', openssl_error_string())); + throw new EncryptionException(\sprintf('Unexpected failure in openssl_decrypt: %s', openssl_error_string())); } return $decrypt; diff --git a/Tests/DependencyInjection/EkinoDataProtectionExtensionTest.php b/Tests/DependencyInjection/EkinoDataProtectionExtensionTest.php index 36eb399..0bfd4c0 100644 --- a/Tests/DependencyInjection/EkinoDataProtectionExtensionTest.php +++ b/Tests/DependencyInjection/EkinoDataProtectionExtensionTest.php @@ -57,7 +57,7 @@ public function testLoadWithInvalidConfigs(array $configs, string $exceptionMess try { $this->extension->load($configs, $this->containerBuilder); - $this->fail(sprintf('Expecting %s with message \'%s\'', InvalidConfigurationException::class, $exceptionMessage)); + $this->fail(\sprintf('Expecting %s with message \'%s\'', InvalidConfigurationException::class, $exceptionMessage)); } catch (InvalidConfigurationException $e) { $this->assertMatchesRegularExpression($exceptionMessage, $e->getMessage()); }