diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
index d18e161dd9..3b71124eb8 100644
--- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
@@ -98,15 +98,15 @@ class DeprecationErrorHandler
'legacyCount' => 0,
'otherCount' => 0,
'remaining vendorCount' => 0,
- 'unsilenced' => [],
- 'remaining' => [],
- 'legacy' => [],
- 'other' => [],
- 'remaining vendor' => [],
+ 'unsilenced' => array(),
+ 'remaining' => array(),
+ 'legacy' => array(),
+ 'other' => array(),
+ 'remaining vendor' => array(),
];
- $deprecationHandler = function ($type, $msg, $file, $line, $context = []) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
+ $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
$mode = $getMode();
- if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) {
+ if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) {
$ErrorHandler = $UtilPrefix.'ErrorHandler';
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
diff --git a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
index c9611e3761..800d86c20e 100644
--- a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
+++ b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
@@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
use Twig\Environment;
+use Twig\Error\LoaderError;
use Twig\Markup;
use Twig\Profiler\Dumper\HtmlDumper;
use Twig\Profiler\Profile;
@@ -70,7 +71,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
if ($profile->isTemplate()) {
try {
$template = $this->twig->load($name = $profile->getName());
- } catch (\Twig_Error_Loader $e) {
+ } catch (LoaderError $e) {
$template = null;
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
index a4e2ad1503..f974f08580 100644
--- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
@@ -50,7 +50,7 @@ class TransNodeTest extends TestCase
protected function getVariableGetterWithStrictCheck($name)
{
if (Environment::MAJOR_VERSION >= 2) {
- return sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new %2$s(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name, Environment::VERSION_ID >= 20700 ? '\Twig\Error\RuntimeError' : 'Twig_Error_Runtime');
+ return sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new %2$s(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name, Environment::VERSION_ID >= 20700 ? 'RuntimeError' : 'Twig_Error_Runtime');
}
return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name);
diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php
index b68d9fe389..12a6cf2245 100644
--- a/src/Symfony/Component/Console/Helper/ProgressBar.php
+++ b/src/Symfony/Component/Console/Helper/ProgressBar.php
@@ -381,20 +381,17 @@ final class ProgressBar
$lines = floor(Helper::strlen($message) / $this->terminal->getWidth()) + $this->formatLineCount + 1;
$this->output->clear($lines);
} else {
- // Move the cursor to the beginning of the line
- $this->output->write("\x0D");
-
- // Erase the line
- $this->output->write("\x1B[2K");
-
// Erase previous lines
if ($this->formatLineCount > 0) {
- $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
+ $message = str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount).$message;
}
+
+ // Move the cursor to the beginning of the line and erase the line
+ $message = "\x0D\x1B[2K$message";
}
}
} elseif ($this->step > 0) {
- $this->output->writeln('');
+ $message = PHP_EOL.$message;
}
$this->firstRun = false;
diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php
index b47e402116..168036c583 100644
--- a/src/Symfony/Component/Debug/ErrorHandler.php
+++ b/src/Symfony/Component/Debug/ErrorHandler.php
@@ -490,6 +490,11 @@ class ErrorHandler
if ($this->isRecursive) {
$log = 0;
} else {
+ if (!\defined('HHVM_VERSION')) {
+ $currentErrorHandler = set_error_handler('var_dump');
+ restore_error_handler();
+ }
+
try {
$this->isRecursive = true;
$level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG;
@@ -498,7 +503,7 @@ class ErrorHandler
$this->isRecursive = false;
if (!\defined('HHVM_VERSION')) {
- set_error_handler([$this, __FUNCTION__]);
+ set_error_handler($currentErrorHandler);
}
}
}
diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
index f320584055..cf23365d4f 100644
--- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
@@ -12,12 +12,12 @@
namespace Symfony\Component\Debug\Tests;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\Exception\SilencedErrorContext;
+use Symfony\Component\Debug\Tests\Fixtures\ErrorHandlerThatUsesThePreviousOne;
use Symfony\Component\Debug\Tests\Fixtures\LoggerThatSetAnErrorHandler;
/**
@@ -508,26 +508,40 @@ class ErrorHandlerTest extends TestCase
}
/**
- * @dataProvider errorHandlerIsNotLostWhenLoggingProvider
+ * @dataProvider errorHandlerWhenLoggingProvider
*/
- public function testErrorHandlerIsNotLostWhenLogging($customErrorHandlerHasBeenPreviouslyDefined, LoggerInterface $logger)
+ public function testErrorHandlerWhenLogging($previousHandlerWasDefined, $loggerSetsAnotherHandler, $nextHandlerIsDefined)
{
try {
- if ($customErrorHandlerHasBeenPreviouslyDefined) {
+ if ($previousHandlerWasDefined) {
set_error_handler('count');
}
+ $logger = $loggerSetsAnotherHandler ? new LoggerThatSetAnErrorHandler() : new NullLogger();
+
$handler = ErrorHandler::register();
$handler->setDefaultLogger($logger);
+ if ($nextHandlerIsDefined) {
+ $handler = ErrorHandlerThatUsesThePreviousOne::register();
+ }
+
@trigger_error('foo', E_USER_DEPRECATED);
@trigger_error('bar', E_USER_DEPRECATED);
$this->assertSame([$handler, 'handleError'], set_error_handler('var_dump'));
+ if ($logger instanceof LoggerThatSetAnErrorHandler) {
+ $this->assertCount(2, $logger->cleanLogs());
+ }
+
restore_error_handler();
- if ($customErrorHandlerHasBeenPreviouslyDefined) {
+ if ($previousHandlerWasDefined) {
+ restore_error_handler();
+ }
+
+ if ($nextHandlerIsDefined) {
restore_error_handler();
}
} finally {
@@ -536,13 +550,14 @@ class ErrorHandlerTest extends TestCase
}
}
- public function errorHandlerIsNotLostWhenLoggingProvider()
+ public function errorHandlerWhenLoggingProvider()
{
- return [
- [false, new NullLogger()],
- [true, new NullLogger()],
- [false, new LoggerThatSetAnErrorHandler()],
- [true, new LoggerThatSetAnErrorHandler()],
- ];
+ foreach ([false, true] as $previousHandlerWasDefined) {
+ foreach ([false, true] as $loggerSetsAnotherHandler) {
+ foreach ([false, true] as $nextHandlerIsDefined) {
+ yield [$previousHandlerWasDefined, $loggerSetsAnotherHandler, $nextHandlerIsDefined];
+ }
+ }
+ }
}
}
diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php b/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php
new file mode 100644
index 0000000000..d449c40cc7
--- /dev/null
+++ b/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php
@@ -0,0 +1,22 @@
+This is not a valid UUID.
Dëst ass keng gëlteg UUID.
+
+
+ Dëse Wäert sollt e puer vun {{ compared_value }} sinn.
+
+
+
+ Dëse "Business Identifier Code" (BIC) ass net mat IBAN verbonnen {{ iban }}.
+
+
+
+ Dëse Wäert sollt gëlteg JSON.
+