Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b08771

Browse files
committed
Restore FlattenException::create() deprecation in Debug component
1 parent 7239859 commit 2b08771

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

src/Symfony/Component/Debug/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* deprecated `FlattenException`, use the `FlattenException` of the `ErrorCatcher` component
8+
49
4.3.0
510
-----
611

src/Symfony/Component/Debug/Exception/FlattenException.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,20 @@
1111

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
use Symfony\Component\ErrorCatcher\Exception\FlattenException as BaseFlattenException;
1415
use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
1516
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
1617

18+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', FlattenException::class, BaseFlattenException::class), E_USER_DEPRECATED);
19+
1720
/**
1821
* FlattenException wraps a PHP Error or Exception to be able to serialize it.
1922
*
2023
* Basically, this class removes all objects from the trace.
2124
*
2225
* @author Fabien Potencier <[email protected]>
26+
*
27+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorCatcher\Exception\FlattenException instead.
2328
*/
2429
class FlattenException
2530
{
@@ -34,12 +39,17 @@ class FlattenException
3439
private $file;
3540
private $line;
3641

42+
/**
43+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorCatcher\Exception::createFromThrowable() instead.
44+
*/
3745
public static function create(\Exception $exception, $statusCode = null, array $headers = [])
3846
{
47+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use Symfony\Component\ErrorCatcher\Exception::createFromThrowable() instead.', __METHOD__), E_USER_DEPRECATED);
48+
3949
return static::createFromThrowable($exception, $statusCode, $headers);
4050
}
4151

42-
public static function createFromThrowable(\Throwable $exception, ?int $statusCode = null, array $headers = []): self
52+
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self
4353
{
4454
$e = new static();
4555
$e->setMessage($exception->getMessage());

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\Debug;
1313

14-
use Symfony\Component\Debug\Exception\FlattenException;
1514
use Symfony\Component\Debug\Exception\OutOfMemoryException;
15+
use Symfony\Component\ErrorCatcher\Exception\FlattenException;
1616
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
1717

1818
/**
@@ -170,12 +170,12 @@ public function handle(\Exception $exception)
170170
* This method uses plain PHP functions like header() and echo to output
171171
* the response.
172172
*
173-
* @param \Exception|FlattenException $exception An \Exception or FlattenException instance
173+
* @param \Throwable|FlattenException $exception A \Throwable or FlattenException instance
174174
*/
175175
public function sendPhpResponse($exception)
176176
{
177-
if (!$exception instanceof FlattenException) {
178-
$exception = FlattenException::create($exception);
177+
if ($exception instanceof \Throwable) {
178+
$exception = FlattenException::createFromThrowable($exception);
179179
}
180180

181181
if (!headers_sent()) {

src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
3131
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
3232

33+
/**
34+
* @group legacy
35+
*/
3336
class FlattenExceptionTest extends TestCase
3437
{
3538
public function testStatusCode()

src/Symfony/Component/Debug/composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
],
1818
"require": {
1919
"php": "^7.1.3",
20-
"psr/log": "~1.0"
20+
"psr/log": "~1.0",
21+
"symfony/error-catcher": "^4.4|^5.0"
2122
},
2223
"conflict": {
2324
"symfony/http-kernel": "<3.4"
2425
},
2526
"require-dev": {
26-
"symfony/http-kernel": "~3.4|~4.0"
27+
"symfony/http-kernel": "^3.4|^4.0|^5.0"
2728
},
2829
"autoload": {
2930
"psr-4": { "Symfony\\Component\\Debug\\": "" },
@@ -34,7 +35,7 @@
3435
"minimum-stability": "dev",
3536
"extra": {
3637
"branch-alias": {
37-
"dev-master": "4.3-dev"
38+
"dev-master": "4.4-dev"
3839
}
3940
}
4041
}

src/Symfony/Component/ErrorCatcher/Exception/FlattenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FlattenException
3737
private $file;
3838
private $line;
3939

40-
public static function createFromThrowable(\Throwable $exception, ?int $statusCode = null, array $headers = []): self
40+
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self
4141
{
4242
$e = new static();
4343
$e->setMessage($exception->getMessage());

0 commit comments

Comments
 (0)