diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.php index 51492cfe1823f..f381b018f0629 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.php @@ -25,7 +25,6 @@ null, // Log levels map for enabled error levels param('debug.error_handler.throw_at'), param('kernel.debug'), - service('debug.file_link_formatter'), param('kernel.debug'), service('monolog.logger.deprecation')->nullOnInvalid(), ]) diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index ed36ac8cbfbaa..fd2bdf12154c6 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG --- * Deprecate `AbstractTestSessionListener::getSession` inject a session in the request instead + * Deprecate the `fileLinkFormat` parameter of `DebugHandlersListener` 5.3 --- diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 32742ea50a435..f4f97ccf33987 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -17,7 +17,6 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\ErrorHandler\ErrorHandler; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -39,21 +38,25 @@ class DebugHandlersListener implements EventSubscriberInterface private $levels; private $throwAt; private $scream; - private $fileLinkFormat; private $scope; private $firstCall = true; private $hasTerminatedWithException; /** - * @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants - * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value - * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged - * @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files - * @param bool $scope Enables/disables scoping mode + * @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception + * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants + * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value + * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged + * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, LoggerInterface $deprecationLogger = null) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $scope = true, $deprecationLogger = null, $fileLinkFormat = null) { + if (!\is_bool($scope)) { + trigger_deprecation('symfony/http-kernel', '5.4', 'Passing a $fileLinkFormat is deprecated.'); + $scope = $deprecationLogger; + $deprecationLogger = $fileLinkFormat; + } + $handler = set_exception_handler('var_dump'); $this->earlyHandler = \is_array($handler) ? $handler[0] : null; restore_exception_handler(); @@ -63,7 +66,6 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ $this->levels = $levels ?? \E_ALL; $this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null)); $this->scream = $scream; - $this->fileLinkFormat = $fileLinkFormat; $this->scope = $scope; $this->deprecationLogger = $deprecationLogger; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index d15820eb54ce1..c9209ee033b51 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\ConsoleEvents; @@ -34,6 +35,8 @@ */ class DebugHandlersListenerTest extends TestCase { + use ExpectDeprecationTrait; + public function testConfigure() { $logger = $this->createMock(LoggerInterface::class); @@ -219,7 +222,7 @@ public function testLevelsAssignedToLoggers(bool $hasLogger, bool $hasDeprecatio ->method('setDefaultLogger') ->withConsecutive(...$expectedCalls); - $sut = new DebugHandlersListener(null, $logger, $levels, null, true, null, true, $deprecationLogger); + $sut = new DebugHandlersListener(null, $logger, $levels, null, true, true, $deprecationLogger); $prevHander = set_exception_handler([$handler, 'handleError']); try { @@ -236,4 +239,14 @@ public function testLevelsAssignedToLoggers(bool $hasLogger, bool $hasDeprecatio throw $e; } } + + /** + * @group legacy + */ + public function testLegacyConstructor() + { + $this->expectDeprecation('Since symfony/http-kernel 5.4: Passing a $fileLinkFormat is deprecated.'); + + new DebugHandlersListener(null, null, \E_ALL, \E_ALL, true, 'filelinkformat', true, $this->createMock(LoggerInterface::class)); + } }