8000 minor #42235 [FrameworkBundle] Remove fileLinkFormat property from De… · symfony/symfony@cbe1f81 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbe1f81

Browse files
committed
minor #42235 [FrameworkBundle] Remove fileLinkFormat property from DebugHandlersListener (lyrixx)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Remove fileLinkFormat property from DebugHandlersListener | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | counter part of #41324 Commits ------- 413096a [FrameworkBundle][5.4] Remove fileLinkFormat property from DebugHandlersListener
2 parents c1c973c + 413096a commit cbe1f81

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
null, // Log levels map for enabled error levels
2626
param('debug.error_handler.throw_at'),
2727
param('kernel.debug'),
28-
service('debug.file_link_formatter'),
2928
param('kernel.debug'),
3029 10000
service('monolog.logger.deprecation')->nullOnInvalid(),
3130
])

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Deprecate `AbstractTestSessionListener::getSession` inject a session in the request instead
8+
* Deprecate the `fileLinkFormat` parameter of `DebugHandlersListener`
89

910
5.3
1011
---

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1818
use Symfony\Component\ErrorHandler\ErrorHandler;
1919
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
20-
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
2120
use Symfony\Component\HttpKernel\Event\KernelEvent;
2221
use Symfony\Component\HttpKernel\KernelEvents;
2322

@@ -39,21 +38,25 @@ class DebugHandlersListener implements EventSubscriberInterface
3938
private $levels;
4039
private $throwAt;
4140
private $scream;
42-
private $fileLinkFormat;
4341
private $scope;
4442
private $firstCall = true;
4543
private $hasTerminatedWithException;
4644

4745
/**
48-
* @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception
49-
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
50-
* @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value
51-
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
52-
* @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files
53-
* @param bool $scope Enables/disables scoping mode
46+
* @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception
47+
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
48+
* @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value
49+
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
50+
* @param bool $scope Enables/disables scoping mode
5451
*/
55-
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)
52+
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)
5653
{
54+
if (!\is_bool($scope)) {
55+
trigger_deprecation('symfony/http-kernel', '5.4', 'Passing a $fileLinkFormat is deprecated.');
56+
$scope = $deprecationLogger;
57+
$deprecationLogger = $fileLinkFormat;
58+
}
59+
5760
$handler = set_exception_handler('var_dump');
5861
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
5962
restore_exception_handler();
@@ -63,7 +66,6 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $
6366
$this->levels = $levels ?? \E_ALL;
6467
$this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null));
6568
$this->scream = $scream;
66-
$this->fileLinkFormat = $fileLinkFormat;
6769
$this->scope = $scope;
6870
$this->deprecationLogger = $deprecationLogger;
6971
}

src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Log\LoggerInterface;
1616
use Psr\Log\LogLevel;
17+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1718
use Symfony\Component\Console\Application;
1819
use Symfony\Component\Console\Command\Command;
1920
use Symfony\Component\Console\ConsoleEvents;
@@ -34,6 +35,8 @@
3435
*/
3536
class DebugHandlersListenerTest extends TestCase
3637
{
38+
use ExpectDeprecationTrait;
39+
3740
public function testConfigure()
3841
{
3942
$logger = $this->createMock(LoggerInterface::class);
@@ -219,7 +222,7 @@ public function testLevelsAssignedToLoggers(bool $hasLogger, bool $hasDeprecatio
219222
->method('setDefaultLogger')
220223
->withConsecutive(...$expectedCalls);
221224

222-
$sut = new DebugHandlersListener(null, $logger, $levels, null, true, null, true, $deprecationLogger);
225+
$sut = new DebugHandlersListener(null, $logger, $levels, null, true, true, $deprecationLogger);
223226
$prevHander = set_exception_handler([$handler, 'handleError']);
224227

225228
try {
@@ -236,4 +239,14 @@ public function testLevelsAssignedToLoggers(bool $hasLogger, bool $hasDeprecatio
236239
throw $e;
237240
}
238241
}
242+
243+
/**
244+
* @group legacy
245+
*/
246+
public function testLegacyConstructor()
247+
{
248+
$this->expectDeprecation('Since symfony/http-kernel 5.4: Passing a $fileLinkFormat is deprecated.');
249+
250+
new DebugHandlersListener(null, null, \E_ALL, \E_ALL, true, 'filelinkformat', true, $this->createMock(LoggerInterface::class));
251+
}
239252
}

0 commit comments

Comments
 (0)
0