Skip to content

Commit cc01b78

Browse files
committed
Add ErrorHandler component
1 parent f84766e commit cc01b78

File tree

122 files changed

+3407
-2744
lines changed

Some content is hidden

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

122 files changed

+3407
-2744
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
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\ErrorHandler\DebugClassLoader;
2222

2323
/**
2424
* PHP 5.3 compatible trait-like shared implementation.
@@ -53,7 +53,7 @@ public function __construct(array $mockedNamespaces = array())
5353
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
5454
}
5555

56-
$enableDebugClassLoader = \class_exists('Symfony\Component\Debug\DebugClassLoader');
56+
$enableDebugClassLoader = \class_exists('Symfony\Component\ErrorHandler\DebugClassLoader');
5757

5858
foreach ($mockedNamespaces as $type => $namespaces) {
5959
if (!\is_array($namespaces)) {

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

+1-1
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

+1-1
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\EventDispatcher\DependencyInjection\RegisterListenersPass;
3737
use Symfony\Component\Form\DependencyInjection\FormPass;
3838
use Symfony\Component\HttpFoundation\Request;

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

14-
use Symfony\Component\Debug\Exception\FlattenException;
14+
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;

src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Controller;
1313

14-
use Symfony\Component\Debug\Exception\FlattenException;
14+
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpKernel\HttpKernelInterface;
1717

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
1515
use Symfony\Bundle\TwigBundle\Tests\TestCase;
16-
use Symfony\Component\Debug\Exception\FlattenException;
16+
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Twig\Environment;
1919
use Twig\Loader\ArrayLoader;

src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController;
1515
use Symfony\Bundle\TwigBundle\Tests\TestCase;
16-
use Symfony\Component\Debug\Exception\FlattenException;
16+
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
1919
use Symfony\Component\HttpKernel\HttpKernelInterface;

src/Symfony/Bundle/TwigBundle/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"symfony/config": "~4.2",
2121
"symfony/twig-bridge": "^4.3",
2222
"symfony/http-foundation": "~4.3",
23-
"symfony/http-kernel": "~4.1",
23+
"symfony/http-kernel": "^4.3",
2424
"symfony/polyfill-ctype": "~1.8",
2525
"twig/twig": "~1.34|~2.4"
2626
},

src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\WebProfilerBundle\Controller;
1313

14-
use Symfony\Component\Debug\ExceptionHandler;
14+
use Symfony\Component\ErrorHandler\ErrorException;
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
1717
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -61,9 +61,9 @@ public function showAction($token)
6161
$template = $this->getTemplate();
6262

6363
if (!$this->twig->getLoader()->exists($template)) {
64-
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset(), $this->fileLinkFormat);
64+
$errorException = new ErrorException($this->debug, $this->twig->getCharset(), $this->fileLinkFormat);
6565

66-
return new Response($handler->getContent($exception), 200, ['Content-Type' => 'text/html']);
66+
return new Response($errorException->getHtmlBody($exception), 200, ['Content-Type' => 'text/html']);
6767
}
6868

6969
$code = $exception->getStatusCode();
@@ -97,13 +97,12 @@ public function cssAction($token)
9797

9898
$this->profiler->disable();
9999

100-
$exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException();
101100
$template = $this->getTemplate();
102101

103102
if (!$this->templateExists($template)) {
104-
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset(), $this->fileLinkFormat);
103+
$errorException = new ErrorException($this->debug, $this->twig->getCharset(), $this->fileLinkFormat);
105104

106-
return new Response($handler->getStylesheet($exception), 200, ['Content-Type' => 'text/css']);
105+
return new Response($errorException->getStylesheet(), 200, ['Content-Type' => 'text/css']);
107106
}
108107

109108
return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, ['Content-Type' => 'text/css']);

src/Symfony/Component/Console/Application.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
use Symfony\Component\Console\Output\ConsoleOutputInterface;
4242
use Symfony\Component\Console\Output\OutputInterface;
4343
use Symfony\Component\Console\Style\SymfonyStyle;
44-
use Symfony\Component\Debug\ErrorHandler;
45-
use Symfony\Component\Debug\Exception\FatalThrowableError;
44+
use Symfony\Component\ErrorHandler\ErrorHandler;
45+
use Symfony\Component\ErrorHandler\Exception\FatalThrowableError;
4646
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4747
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
4848

src/Symfony/Component/Debug/BufferingLogger.php

+5-19
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,13 @@
1111

1212
namespace Symfony\Component\Debug;
1313

14-
use Psr\Log\AbstractLogger;
14+
use Symfony\Component\ErrorHandler\BufferingLogger as BaseBufferingLogger;
15+
16+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', BufferingLogger::class, BaseBufferingLogger::class), E_USER_DEPRECATED);
1517

1618
/**
17-
* A buffering logger that stacks logs for later.
18-
*
19-
* @author Nicolas Grekas <p@tchwork.com>
19+
* @deprecated since Symfony 4.3, use Symfony\Component\ErrorHandler\BufferingLogger instead.
2020
*/
21-
class BufferingLogger extends AbstractLogger
21+
class BufferingLogger extends BaseBufferingLogger
2222
{
23-
private $logs = [];
24-
25-
public function log($level, $message, array $context = [])
26-
{
27-
$this->logs[] = [$level, $message, $context];
28-
}
29-
30-
public function cleanLogs()
31-
{
32-
$logs = $this->logs;
33-
$this->logs = [];
34-
35-
return $logs;
36-
}
3723
}

src/Symfony/Component/Debug/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* added `Exception\FlattenException::getAsString` and
99
`Exception\FlattenException::getTraceAsString` to increase compatibility to php
1010
exception objects
11+
* deprecated the `BufferingLogger`, `ErrorHandler` and `ExceptionHandler` classes
1112

1213
4.0.0
1314
-----

src/Symfony/Component/Debug/Debug.php

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
namespace Symfony\Component\Debug;
1313

14+
use Symfony\Component\ErrorHandler\BufferingLogger;
15+
use Symfony\Component\ErrorHandler\DebugClassLoader;
16+
use Symfony\Component\ErrorHandler\ErrorHandler;
17+
use Symfony\Component\ErrorHandler\ExceptionHandler;
18+
1419
/**
1520
* Registers all the debug tools.
1621
*

0 commit comments

Comments
 (0)