Skip to content

Commit b1b6e80

Browse files
ycerutofabpot
authored andcommitted
Add a new ErrorHandler component (mirror of the Debug component)
1 parent ea92f38 commit b1b6e80

File tree

115 files changed

+4733
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+4733
-26
lines changed

UPGRADE-4.4.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Cache
66

77
* Added argument `$prefix` to `AdapterInterface::clear()`
88

9+
Debug
10+
-----
11+
12+
* Deprecated `FlattenException`, use the `FlattenException` of the `ErrorRenderer` component
13+
* Deprecated the whole component in favor of `ErrorHandler` component
14+
915
DependencyInjection
1016
-------------------
1117

UPGRADE-5.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ Console
5151
$processHelper->run($output, Process::fromShellCommandline('ls -l'));
5252
```
5353

54+
Debug
55+
-----
56+
57+
* Removed the component
58+
5459
DependencyInjection
5560
-------------------
5661

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
use PHPUnit\Util\Blacklist;
1919
use Symfony\Bridge\PhpUnit\ClockMock;
2020
use Symfony\Bridge\PhpUnit\DnsMock;
21-
use Symfony\Component\Debug\DebugClassLoader;
21+
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
22+
use Symfony\Component\ErrorHandler\DebugClassLoader;
2223

2324
/**
2425
* PHP 5.3 compatible trait-like shared implementation.
@@ -53,7 +54,7 @@ public function __construct(array $mockedNamespaces = array())
5354
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
5455
}
5556

56-
$enableDebugClassLoader = class_exists('Symfony\Component\Debug\DebugClassLoader');
57+
$enableDebugClassLoader = class_exists(DebugClassLoader::class) || class_exists(LegacyDebugClassLoader::class);
5758

5859
foreach ($mockedNamespaces as $type => $namespaces) {
5960
if (!\is_array($namespaces)) {
@@ -74,7 +75,11 @@ public function __construct(array $mockedNamespaces = array())
7475
}
7576
}
7677
if ($enableDebugClassLoader) {
77-
DebugClassLoader::enable();
78+
if (class_exists(DebugClassLoader::class)) {
79+
DebugClassLoader::enable();
80+
} else {
81+
LegacyDebugClassLoader::enable();
82+
}
7883
}
7984
if (self::$globallyEnabled) {
8085
$this->state = -2;

src/Symfony/Bridge/PhpUnit/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"php": ">=5.5.9"
2222
},
2323
"suggest": {
24-
"symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
24+
"symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
2525
},
2626
"conflict": {
2727
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2020
use Symfony\Component\Console\Output\OutputInterface;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22-
use Symfony\Component\Debug\Exception\FatalThrowableError;
2322
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
23+
use Symfony\Component\ErrorHandler\Exception\FatalThrowableError;
2424
use Symfony\Component\HttpKernel\Bundle\Bundle;
2525
use Symfony\Component\HttpKernel\Kernel;
2626
use Symfony\Component\HttpKernel\KernelInterface;

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
use Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass;
3030
use Symfony\Component\Config\Resource\ClassExistenceResource;
3131
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
32-
use Symfony\Component\Debug\ErrorHandler;
3332
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
3433
use Symfony\Component\DependencyInjection\Compiler\RegisterReverseContainerPass;
3534
use Symfony\Component\DependencyInjection\ContainerBuilder;
35+
use Symfony\Component\ErrorHandler\ErrorHandler;
3636
use Symfony\Component\ErrorRenderer\DependencyInjection\ErrorRendererPass;
3737
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
3838
use Symfony\Component\Form\DependencyInjection\FormPass;

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"symfony/asset": "<3.4",
7171
"symfony/browser-kit": "<4.3",
7272
"symfony/console": "<4.3",
73-
"symfony/debug": "<4.4",
7473
"symfony/dotenv": "<4.2",
7574
"symfony/dom-crawler": "<4.3",
7675
"symfony/form": "<4.3",

src/Symfony/Component/Debug/BufferingLogger.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
use Psr\Log\AbstractLogger;
1515

16+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', BufferingLogger::class, \Symfony\Component\ErrorHandler\BufferingLogger::class), E_USER_DEPRECATED);
17+
1618
/**
1719
* A buffering logger that stacks logs for later.
1820
*
1921
* @author Nicolas Grekas <p@tchwork.com>
22+
*
23+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\BufferingLogger instead.
2024
*/
2125
class BufferingLogger extends AbstractLogger
2226
{

src/Symfony/Component/Debug/CHANGELOG.md

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

77
* deprecated `FlattenException`, use the `FlattenException` of the `ErrorRenderer` component
8+
* deprecated the whole component in favor of the `ErrorHandler` component
89

910
4.3.0
1011
-----

src/Symfony/Component/Debug/Debug.php

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

1212
namespace Symfony\Component\Debug;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', Debug::class, \Symfony\Component\ErrorHandler\Debug::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Registers all the debug tools.
1618
*
1719
* @author Fabien Potencier <fabien@symfony.com>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Debug instead.
1822
*/
1923
class Debug
2024
{

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\MockObject\Matcher\StatelessInvocation;
1515

16+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', DebugClassLoader::class, \Symfony\Component\ErrorHandler\DebugClassLoader::class), E_USER_DEPRECATED);
17+
1618
/**
1719
* Autoloader checking if the class is really defined in the file found.
1820
*
@@ -24,6 +26,8 @@
2426
* @author Christophe Coevoet <stof@notk.org>
2527
* @author Nicolas Grekas <p@tchwork.com>
2628
* @author Guilhem Niot <guilhem.niot@gmail.com>
29+
*
30+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\DebugClassLoader instead.
2731
*/
2832
class DebugClassLoader
2933
{

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
2424
use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
2525

26+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ErrorHandler::class, \Symfony\Component\ErrorHandler\ErrorHandler::class), E_USER_DEPRECATED);
27+
2628
/**
2729
* A generic ErrorHandler for the PHP engine.
2830
*
@@ -47,6 +49,8 @@
4749
* @author Grégoire Pineau <lyrixx@lyrixx.info>
4850
*
4951
* @final since Symfony 4.3
52+
*
53+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\ErrorHandler instead.
5054
*/
5155
class ErrorHandler
5256
{

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ClassNotFoundException::class, \Symfony\Component\ErrorHandler\Exception\ClassNotFoundException::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Class (or Trait or Interface) Not Found Exception.
1618
*
1719
* @author Konstanton Myakshin <koc-dp@yandex.ru>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\ClassNotFoundException instead.
1822
*/
1923
class ClassNotFoundException extends FatalErrorException
2024
{

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', FatalErrorException::class, \Symfony\Component\ErrorHandler\Exception\FatalErrorException::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Fatal Error Exception.
1618
*
1719
* @author Konstanton Myakshin <koc-dp@yandex.ru>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\FatalErrorException instead.
1822
*/
1923
class FatalErrorException extends \ErrorException
2024
{

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', FatalThrowableError::class, \Symfony\Component\ErrorHandler\Exception\FatalThrowableError::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Fatal Throwable Error.
1618
*
1719
* @author Nicolas Grekas <p@tchwork.com>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\FatalThrowableError instead.
1822
*/
1923
class FatalThrowableError extends FatalErrorException
2024
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
1515
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
1616

17-
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "Symfony\Component\ErrorRenderer\Exception\FlattenException" instead.', FlattenException::class), E_USER_DEPRECATED);
17+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', FlattenException::class, \Symfony\Component\ErrorRenderer\Exception\FlattenException::class), E_USER_DEPRECATED);
1818

1919
/**
2020
* FlattenException wraps a PHP Error or Exception to be able to serialize it.

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', OutOfMemoryException::class, \Symfony\Component\ErrorHandler\Exception\OutOfMemoryException::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Out of memory exception.
1618
*
1719
* @author Nicolas Grekas <p@tchwork.com>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\OutOfMemoryException instead.
1822
*/
1923
class OutOfMemoryException extends FatalErrorException
2024
{

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', SilencedErrorContext::class, \Symfony\Component\ErrorHandler\Exception\SilencedErrorContext::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Data Object that represents a Silenced Error.
1618
*
1719
* @author Grégoire Pineau <lyrixx@lyrixx.info>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext instead.
1822
*/
1923
class SilencedErrorContext implements \JsonSerializable
2024
{

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', UndefinedFunctionException::class, \Symfony\Component\ErrorHandler\Exception\UndefinedFunctionException::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Undefined Function Exception.
1618
*
1719
* @author Konstanton Myakshin <koc-dp@yandex.ru>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\UndefinedFunctionException instead.
1822
*/
1923
class UndefinedFunctionException extends FatalErrorException
2024
{

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

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

1212
namespace Symfony\Component\Debug\Exception;
1313

14+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', UndefinedMethodException::class, \Symfony\Component\ErrorHandler\Exception\UndefinedMethodException::class), E_USER_DEPRECATED);
15+
1416
/**
1517
* Undefined Method Exception.
1618
*
1719
* @author Grégoire Pineau <lyrixx@lyrixx.info>
20+
*
21+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\Exception\UndefinedMethodException instead.
1822
*/
1923
class UndefinedMethodException extends FatalErrorException
2024
{

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Debug\Exception\OutOfMemoryException;
1616
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
1717

18+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ExceptionHandler::class, \Symfony\Component\ErrorHandler\ExceptionHandler::class), E_USER_DEPRECATED);
19+
1820
/**
1921
* ExceptionHandler converts an exception to a Response object.
2022
*
@@ -28,6 +30,8 @@
2830
* @author Nicolas Grekas <p@tchwork.com>
2931
*
3032
* @final since Symfony 4.3
33+
*
34+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\ExceptionHandler instead.
3135
*/
3236
class ExceptionHandler
3337
{

src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
use Symfony\Component\Debug\Exception\ClassNotFoundException;
1818
use Symfony\Component\Debug\Exception\FatalErrorException;
1919

20+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ClassNotFoundFatalErrorHandler::class, \Symfony\Component\ErrorHandler\FatalErrorHandler\ClassNotFoundFatalErrorHandler::class), E_USER_DEPRECATED);
21+
2022
/**
2123
* ErrorHandler for classes that do not exist.
2224
*
2325
* @author Fabien Potencier <fabien@symfony.com>
26+
*
27+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\FatalErrorHandler\ClassNotFoundFatalErrorHandler instead.
2428
*/
2529
class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
2630
{

src/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
use Symfony\Component\Debug\Exception\FatalErrorException;
1515

16+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', FatalErrorHandlerInterface::class, \Symfony\Component\ErrorHandler\FatalErrorHandler\FatalErrorHandlerInterface::class), E_USER_DEPRECATED);
17+
1618
/**
1719
* Attempts to convert fatal errors to exceptions.
1820
*
1921
* @author Fabien Potencier <fabien@symfony.com>
22+
*
23+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\FatalErrorHandler\FatalErrorHandlerInterface instead.
2024
*/
2125
interface FatalErrorHandlerInterface
2226
{

src/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
use Symfony\Component\Debug\Exception\FatalErrorException;
1515
use Symfony\Component\Debug\Exception\UndefinedFunctionException;
1616

17+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', UndefinedFunctionFatalErrorHandler::class, \Symfony\Component\ErrorHandler\FatalErrorHandler\UndefinedFunctionFatalErrorHandler::class), E_USER_DEPRECATED);
18+
1719
/**
1820
* ErrorHandler for undefined functions.
1921
*
2022
* @author Fabien Potencier <fabien@symfony.com>
23+
*
24+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\FatalErrorHandler\UndefinedFunctionFatalErrorHandler instead.
2125
*/
2226
class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
2327
{

src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
use Symfony\Component\Debug\Exception\FatalErrorException;
1515
use Symfony\Component\Debug\Exception\UndefinedMethodException;
1616

17+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', UndefinedMethodFatalErrorHandler::class, \Symfony\Component\ErrorHandler\FatalErrorHandler\UndefinedMethodFatalErrorHandler::class), E_USER_DEPRECATED);
18+
1719
/**
1820
* ErrorHandler for undefined methods.
1921
*
2022
* @author Grégoire Pineau <lyrixx@lyrixx.info>
23+
*
24+
* @deprecated since Symfony 4.4, use Symfony\Component\ErrorHandler\FatalErrorHandler\UndefinedMethodFatalErrorHandler instead.
2125
*/
2226
class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
2327
{

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Debug\DebugClassLoader;
1616

17+
/**
18+
* @group legacy
19+
*/
1720
class DebugClassLoaderTest extends TestCase
1821
{
1922
/**

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*
2626
* @author Robert Schönthal <seroscho@googlemail.com>
2727
* @author Nicolas Grekas <p@tchwork.com>
28+
*
29+
* @group legacy
2830
*/
2931
class ErrorHandlerTest extends TestCase
3032
{

src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
require_once __DIR__.'/HeaderMock.php';
2121

22+
/**
23+
* @group legacy
24+
*/
2225
class ExceptionHandlerTest extends TestCase
2326
{
2427
protected function setUp()

0 commit comments

Comments
 (0)