diff --git a/composer.json b/composer.json index dfe453fe6..43f258279 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "phpstan/phpstan-strict-rules": "^1.4", "phpunit/phpunit": "^10.5.17", "predis/predis": "^1.1 || ^2", + "rollbar/rollbar": "^4.0", "ruflin/elastica": "^7 || ^8", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 651297113..b84494370 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -20,9 +20,6 @@ parameters: paths: - src/Monolog/Formatter/LineFormatter.php - # can be removed when rollbar/rollbar can be added as dev require again (needs to allow monolog 3.x) - - '#Rollbar\\RollbarLogger#' - includes: - phpstan-baseline.neon - phpstan-ignore-by-php-version.neon.php diff --git a/src/Monolog/Handler/RollbarHandler.php b/src/Monolog/Handler/RollbarHandler.php index 1d124723b..6b9943265 100644 --- a/src/Monolog/Handler/RollbarHandler.php +++ b/src/Monolog/Handler/RollbarHandler.php @@ -99,7 +99,6 @@ protected function write(LogRecord $record): void $toLog = $record->message; } - // @phpstan-ignore-next-line $this->rollbarLogger->log($context['level'], $toLog, $context); $this->hasRecords = true; diff --git a/tests/Monolog/Handler/RollbarHandlerTest.php b/tests/Monolog/Handler/RollbarHandlerTest.php index 03eda4cf6..3496b673d 100644 --- a/tests/Monolog/Handler/RollbarHandlerTest.php +++ b/tests/Monolog/Handler/RollbarHandlerTest.php @@ -53,9 +53,10 @@ public function testExceptionLogLevel() { $handler = $this->createHandler(); - $handler->handle($this->createExceptionRecord(Level::Debug)); + $handler->handle($this->getRecord(Level::Debug, context: ['exception' => $e = new Exception()])); $this->assertEquals('debug', $this->reportedExceptionArguments['payload']['level']); + $this->assertSame($e, $this->reportedExceptionArguments['context']); } private function setupRollbarLoggerMock() @@ -82,11 +83,4 @@ private function createHandler(): RollbarHandler { return new RollbarHandler($this->rollbarLogger, Level::Debug); } - - private function createExceptionRecord($level = Level::Debug, $message = 'test', $exception = null): array - { - return $this->getRecord($level, $message, [ - 'exception' => $exception ?: new Exception(), - ]); - } }