From 1f6df0e7a1702239eda2cbca5fea185af0147997 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 19 Sep 2022 18:58:32 +0200 Subject: [PATCH] Applied automated CS fixes --- bin/console.php | 6 +++--- src/HttpClient/LoggingHttpClient.php | 4 ++-- .../ConvertLogContextHttpRequestsIntoStrings.php | 6 ++++-- .../ConvertLogContextHttpResponsesIntoStrings.php | 6 ++++-- test/unit/HttpClient/LoggingHttpClientTest.php | 5 +---- .../ConvertLogContextHttpRequestsIntoStringsTest.php | 6 +++--- ...ConvertLogContextHttpResponsesIntoStringsTest.php | 12 +++--------- test/unit/Monolog/VerifyLoggingIntegrationTest.php | 7 +++++-- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/bin/console.php b/bin/console.php index db616ff1..25a6504c 100755 --- a/bin/console.php +++ b/bin/console.php @@ -63,14 +63,14 @@ static function (int $errorCode, string $message = '', string $file = '', int $l E_STRICT | E_NOTICE | E_WARNING, ); - $variables = EnvironmentVariables::fromEnvironment(new ImportGpgKeyFromStringViaTemporaryFile()); - $logger = new Logger( + $variables = EnvironmentVariables::fromEnvironment(new ImportGpgKeyFromStringViaTemporaryFile()); + $logger = new Logger( 'automatic-releases', [new StreamHandler(STDERR, $variables->logLevel())], [ new ConvertLogContextHttpRequestsIntoStrings(), new ConvertLogContextHttpResponsesIntoStrings(), - ] + ], ); $loadEvent = new LoadCurrentGithubEventFromGithubActionPath($variables); $fetch = new FetchAndSetCurrentUserByReplacingCurrentOriginRemote($variables); diff --git a/src/HttpClient/LoggingHttpClient.php b/src/HttpClient/LoggingHttpClient.php index 666835ba..017cdb1d 100644 --- a/src/HttpClient/LoggingHttpClient.php +++ b/src/HttpClient/LoggingHttpClient.php @@ -27,9 +27,9 @@ public function sendRequest(RequestInterface $request): ResponseInterface [ 'request' => $request, 'response' => $response, - ] + ], ); return $response; } -} \ No newline at end of file +} diff --git a/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php b/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php index e6109a1d..2848504d 100644 --- a/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php +++ b/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php @@ -8,6 +8,8 @@ use Monolog\Processor\ProcessorInterface; use Psr\Http\Message\RequestInterface; +use function array_map; + /** @internal */ final class ConvertLogContextHttpRequestsIntoStrings implements ProcessorInterface { @@ -31,7 +33,7 @@ public function __invoke(LogRecord $record): LogRecord ->__toString(); }, $record->context), $record->extra, - $record->formatted + $record->formatted, ); } -} \ No newline at end of file +} diff --git a/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php b/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php index 0551a481..77168be9 100644 --- a/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php +++ b/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php @@ -8,6 +8,8 @@ use Monolog\Processor\ProcessorInterface; use Psr\Http\Message\ResponseInterface; +use function array_map; + /** @internal */ final class ConvertLogContextHttpResponsesIntoStrings implements ProcessorInterface { @@ -31,7 +33,7 @@ public function __invoke(LogRecord $record): LogRecord . '"'; }, $record->context), $record->extra, - $record->formatted + $record->formatted, ); } -} \ No newline at end of file +} diff --git a/test/unit/HttpClient/LoggingHttpClientTest.php b/test/unit/HttpClient/LoggingHttpClientTest.php index 3bc20e3f..801152c7 100644 --- a/test/unit/HttpClient/LoggingHttpClientTest.php +++ b/test/unit/HttpClient/LoggingHttpClientTest.php @@ -6,12 +6,9 @@ use Http\Discovery\Psr17FactoryDiscovery; use Laminas\AutomaticReleases\HttpClient\LoggingHttpClient; -use Monolog\Handler\StreamHandler; -use Monolog\Logger; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientInterface; use Psr\Log\LoggerInterface; -use function fopen; /** @covers \Laminas\AutomaticReleases\HttpClient\LoggingHttpClient */ final class LoggingHttpClientTest extends TestCase @@ -48,7 +45,7 @@ public function testWillLogRequestAndResponse(): void self::assertSame( $response, (new LoggingHttpClient($next, $logger)) - ->sendRequest($request) + ->sendRequest($request), ); } } diff --git a/test/unit/Monolog/ConvertLogContextHttpRequestsIntoStringsTest.php b/test/unit/Monolog/ConvertLogContextHttpRequestsIntoStringsTest.php index a55acc11..039cdbd2 100644 --- a/test/unit/Monolog/ConvertLogContextHttpRequestsIntoStringsTest.php +++ b/test/unit/Monolog/ConvertLogContextHttpRequestsIntoStringsTest.php @@ -38,7 +38,7 @@ public function testWillScrubSensitiveRequestInformation(): void 'foo' => 'bar', 'plain request' => 'GET http://example.com/foo', 'sensitive request' => 'POST https://example.com/foo?bar=baz', - ] + ], ), (new ConvertLogContextHttpRequestsIntoStrings())(new LogRecord( $date, @@ -49,8 +49,8 @@ public function testWillScrubSensitiveRequestInformation(): void 'foo' => 'bar', 'plain request' => $plainRequest, 'sensitive request' => $sensitiveRequest, - ] - )) + ], + )), ); } } diff --git a/test/unit/Monolog/ConvertLogContextHttpResponsesIntoStringsTest.php b/test/unit/Monolog/ConvertLogContextHttpResponsesIntoStringsTest.php index 717cf7c8..748e9611 100644 --- a/test/unit/Monolog/ConvertLogContextHttpResponsesIntoStringsTest.php +++ b/test/unit/Monolog/ConvertLogContextHttpResponsesIntoStringsTest.php @@ -6,16 +6,10 @@ use DateTimeImmutable; use Http\Discovery\Psr17FactoryDiscovery; -use Laminas\AutomaticReleases\HttpClient\LoggingHttpClient; -use Laminas\AutomaticReleases\Monolog\ConvertLogContextHttpRequestsIntoStrings; use Laminas\AutomaticReleases\Monolog\ConvertLogContextHttpResponsesIntoStrings; -use Monolog\Handler\StreamHandler; use Monolog\Level; -use Monolog\Logger; use Monolog\LogRecord; use PHPUnit\Framework\TestCase; -use Psr\Http\Client\ClientInterface; -use function fopen; /** @covers \Laminas\AutomaticReleases\Monolog\ConvertLogContextHttpResponsesIntoStrings */ final class ConvertLogContextHttpResponsesIntoStringsTest extends TestCase @@ -44,7 +38,7 @@ public function testWillScrubSensitiveRequestInformation(): void 'foo' => 'bar', 'plain response' => '401 ""', 'sensitive response' => '403 "this should be printed"', - ] + ], ), (new ConvertLogContextHttpResponsesIntoStrings())(new LogRecord( $date, @@ -55,8 +49,8 @@ public function testWillScrubSensitiveRequestInformation(): void 'foo' => 'bar', 'plain response' => $plainResponse, 'sensitive response' => $sensitiveResponse, - ] - )) + ], + )), ); } } diff --git a/test/unit/Monolog/VerifyLoggingIntegrationTest.php b/test/unit/Monolog/VerifyLoggingIntegrationTest.php index 0a91c342..59afe262 100644 --- a/test/unit/Monolog/VerifyLoggingIntegrationTest.php +++ b/test/unit/Monolog/VerifyLoggingIntegrationTest.php @@ -10,7 +10,10 @@ use Monolog\Handler\StreamHandler; use Monolog\Logger; use PHPUnit\Framework\TestCase; + use function fopen; +use function rewind; +use function stream_get_contents; /** * Small integration test to ensure future compatibility with monolog in our setup. @@ -37,7 +40,7 @@ public function testLoggedRequestAndResponseBodyPartsDoNotContainSecretsAndPostD [ new ConvertLogContextHttpRequestsIntoStrings(), new ConvertLogContextHttpResponsesIntoStrings(), - ] + ], ); $logger->debug('message', ['request' => $request, 'response' => $response]); @@ -47,7 +50,7 @@ public function testLoggedRequestAndResponseBodyPartsDoNotContainSecretsAndPostD self::assertStringContainsString( ': message {"request":"GET http://example.com/foo/bar","response":"204 \"hello world\""} []', stream_get_contents($stream), - 'Request and response contents have been serialized into the final log message' + 'Request and response contents have been serialized into the final log message', ); } }