diff --git a/Handler/FirePHPHandler.php b/Handler/FirePHPHandler.php index 3627f50..8713f6c 100644 --- a/Handler/FirePHPHandler.php +++ b/Handler/FirePHPHandler.php @@ -37,7 +37,7 @@ public function onKernelResponse(ResponseEvent $event) } $request = $event->getRequest(); - if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent')) + if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent', '')) && !$request->headers->has('X-FirePHP-Version')) { self::$sendHeaders = false; $this->headers = []; diff --git a/LICENSE b/LICENSE index 0083704..0138f8f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Tests/Formatter/ConsoleFormatterTest.php b/Tests/Formatter/ConsoleFormatterTest.php index 8e847c5..bf754f4 100644 --- a/Tests/Formatter/ConsoleFormatterTest.php +++ b/Tests/Formatter/ConsoleFormatterTest.php @@ -28,7 +28,7 @@ public function testFormat(array|LogRecord $record, $expectedMessage) self::assertSame($expectedMessage, $formatter->format($record)); } - public function providerFormatTests(): array + public static function providerFormatTests(): array { $currentDateTime = new \DateTimeImmutable(); diff --git a/Tests/Handler/ConsoleHandlerTest.php b/Tests/Handler/ConsoleHandlerTest.php index f7f09c3..b2f8a79 100644 --- a/Tests/Handler/ConsoleHandlerTest.php +++ b/Tests/Handler/ConsoleHandlerTest.php @@ -65,7 +65,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map $levelName = Logger::getLevelName($level); $levelName = sprintf('%-9s', $levelName); - $realOutput = $this->getMockBuilder(Output::class)->setMethods(['doWrite'])->getMock(); + $realOutput = $this->getMockBuilder(Output::class)->onlyMethods(['doWrite'])->getMock(); $realOutput->setVerbosity($verbosity); if ($realOutput->isDebug()) { $log = "16:21:54 $levelName [app] My info message\n"; @@ -82,7 +82,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map $this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.'); } - public function provideVerbosityMappingTests() + public static function provideVerbosityMappingTests() { return [ [OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true], diff --git a/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php b/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php index a5c877b..37286d3 100644 --- a/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php +++ b/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php @@ -56,7 +56,7 @@ public function testIsActivated($url, $record, $expected) self::assertEquals($expected, $strategy->isHandlerActivated($record)); } - public function isActivatedProvider(): array + public static function isActivatedProvider(): array { return [ ['/test', RecordFactory::create(Logger::ERROR), true], @@ -72,7 +72,7 @@ public function isActivatedProvider(): array ]; } - private function getContextException(int $code): array + private static function getContextException(int $code): array { return ['exception' => new HttpException($code)]; } diff --git a/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php b/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php index 220cbe5..36c448c 100644 --- a/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php +++ b/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php @@ -36,7 +36,7 @@ public function testIsActivated(string $url, array|LogRecord $record, bool $expe self::assertEquals($expected, $strategy->isHandlerActivated($record)); } - public function isActivatedProvider(): array + public static function isActivatedProvider(): array { return [ ['/test', RecordFactory::create(Logger::DEBUG), false], diff --git a/Tests/Handler/FirePHPHandlerTest.php b/Tests/Handler/FirePHPHandlerTest.php index 70d1915..3a47eb5 100644 --- a/Tests/Handler/FirePHPHandlerTest.php +++ b/Tests/Handler/FirePHPHandlerTest.php @@ -112,6 +112,22 @@ private function createHandler(): FirePHPHandler return $handler; } + public function testOnKernelResponseShouldNotTriggerDeprecation() + { + $handler = $this->createHandler(); + + $request = Request::create('/'); + $request->headers->remove('User-Agent'); + + $error = null; + set_error_handler(function ($type, $message) use (&$error) { $error = $message; }, \E_DEPRECATED); + + $this->dispatchResponseEvent($handler, $request); + restore_error_handler(); + + $this->assertNull($error); + } + private function dispatchResponseEvent(FirePHPHandler $handler, Request $request): Response { $dispatcher = new EventDispatcher();