8000 Merge branch '3.4' into 4.2 · enumag/symfony@caa2579 · GitHub
[go: up one dir, main page]

Skip to content

Commit caa2579

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: [TwigBridge] Fix test Remove unnecessary ProgressBar stdout writes (fixes flickering) [Validator] improve translations for albanian ("sq") locale [VarDumper] fix serializing Stub instances Don't resolve the Deprecation error handler mode until a deprecation is triggered bug symfony#30245 fix lost namespace in eval (fizzka) [Twig] removed usage of non-namespaced classes added missing dot Update validators.lt.xlf symfony#30172 Add the missing validation translations for the Luxembourgish … [Debug][ErrorHandler] Preserve next error handler
2 parents e0d1b20 + ede6c9d commit caa2579

File tree

12 files changed

+155
-67
lines changed

12 files changed

+155
-67
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,1 8000 5 @@ public static function register($mode = 0)
9898
'legacyCount' => 0,
9999
'otherCount' => 0,
100100
'remaining vendorCount' => 0,
101-
'unsilenced' => [],
102-
'remaining' => [],
103-
'legacy' => [],
104-
'other' => [],
105-
'remaining vendor' => [],
101+
'unsilenced' => array(),
102+
'remaining' => array(),
103+
'legacy' => array(),
104+
'other' => array(),
105+
'remaining vendor' => array(),
106106
];
107-
$deprecationHandler = function ($type, $msg, $file, $line, $context = []) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
107+
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
108108
$mode = $getMode();
109-
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) {
109+
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) {
110110
$ErrorHandler = $UtilPrefix.'ErrorHandler';
111111

112112
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1717
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
1818
use Twig\Environment;
19+
use Twig\Error\LoaderError;
1920
use Twig\Markup;
2021
use Twig\Profiler\Dumper\HtmlDumper;
2122
use Twig\Profiler\Profile;
@@ -70,7 +71,7 @@ public function lateCollect()
7071
if ($profile->isTemplate()) {
7172
try {
7273
$template = $this->twig->load($name = $profile->getName());
73-
} catch (\Twig_Error_Loader $e) {
74+
} catch (LoaderError $e) {
7475
$template = null;
7576
}
7677

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function getVariableGetterWithoutStrictCheck($name)
5050
protected function getVariableGetterWithStrictCheck($name)
5151
{
5252
if (Environment::MAJOR_VERSION >= 2) {
53-
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');
53+
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');
5454
}
5555

5656
return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name);

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,20 +381,17 @@ private function overwrite(string $message): void
381381
$lines = floor(Helper::strlen($message) / $this->terminal->getWidth()) + $this->formatLineCount + 1;
382382
$this->output->clear($lines);
383383
} else {
384-
// Move the cursor to the beginning of the line
385-
$this->output->write("\x0D");
386-
387-
// Erase the line
388-
$this->output->write("\x1B[2K");
389-
390384
// Erase previous lines
391385
if ($this->formatLineCount > 0) {
392-
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
386+
$message = str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount).$message;
393387
}
388+
389+
// Move the cursor to the beginning of the line and erase the line
390+
$message = "\x0D\x1B[2K$message";
394391
}
395392
}
396393
} elseif ($this->step > 0) {
397-
$this->output->writeln('');
394+
$message = PHP_EOL.$message;
398395
}
399396

400397
$this->firstRun = false;

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ public function handleError($type, $message, $file, $line)
490490
if ($this->isRecursive) {
491491
$log = 0;
492492
} else {
493+
if (!\defined('HHVM_VERSION')) {
494+
$currentErrorHandler = set_error_handler('var_dump');
495+
restore_error_handler();
496+
}
497+
493498
try {
494499
$this->isRecursive = true;
495500
$level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG;
@@ -498,7 +503,7 @@ public function handleError($type, $message, $file, $line)
498503
$this->isRecursive = false;
499504

500505
if (!\defined('HHVM_VERSION')) {
501-
set_error_handler([$this, __FUNCTION__]);
506+
set_error_handler($currentErrorHandler);
502507
}
503508
}
504509
}

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
namespace Symfony\Component\Debug\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Psr\Log\LoggerInterface;
1615
use Psr\Log\LogLevel;
1716
use Psr\Log\NullLogger;
1817
use Symfony\Component\Debug\BufferingLogger;
1918
use Symfony\Component\Debug\ErrorHandler;
2019
use Symfony\Component\Debug\Exception\SilencedErrorContext;
20+
use Symfony\Component\Debug\Tests\Fixtures\ErrorHandlerThatUsesThePreviousOne;
2121
use Symfony\Component\Debug\Tests\Fixtures\LoggerThatSetAnErrorHandler;
2222

2323
/**
@@ -508,26 +508,40 @@ public function testCustomExceptionHandler()
508508
}
509509

510510
/**
511-
* @dataProvider errorHandlerIsNotLostWhenLoggingProvider
511+
* @dataProvider errorHandlerWhenLoggingProvider
512512
*/
513-
public function testErrorHandlerIsNotLostWhenLogging($customErrorHandlerHasBeenPreviouslyDefined, LoggerInterface $logger)
513+
public function testErrorHandlerWhenLogging($previousHandlerWasDefined, $loggerSetsAnotherHandler, $nextHandlerIsDefined)
514514
{
515515
try {
516-
if ($customErrorHandlerHasBeenPreviouslyDefined) {
516+
if ($previousHandlerWasDefined) {
517517
set_error_handler('count');
518518
}
519519

520+
$logger = $loggerSetsAnotherHandler ? new LoggerThatSetAnErrorHandler() : new NullLogger();
521+
520522
$handler = ErrorHandler::register();
521523
$handler->setDefaultLogger($logger);
522524

525+
if ($nextHandlerIsDefined) {
526+
$handler = ErrorHandlerThatUsesThePreviousOne::register();
527+
}
528+
523529
@trigger_error('foo', E_USER_DEPRECATED);
524530
@trigger_error('bar', E_USER_DEPRECATED);
525531

526532
$this->assertSame([$handler, 'handleError'], set_error_handler('var_dump'));
527533

534+
if ($logger instanceof LoggerThatSetAnErrorHandler) {
535+
$this->assertCount(2, $logger->cleanLogs());
536+
}
537+
528538
restore_error_handler();
529539

530-
if ($customErrorHandlerHasBeenPreviouslyDefined) {
540+
if ($previousHandlerWasDefined) {
541+
restore_error_handler();
542+
}
543+
544+
if ($nextHandlerIsDefined) {
531545
restore_error_handler();
532546
}
533547
} finally {
@@ -536,13 +550,14 @@ public function testErrorHandlerIsNotLostWhenLogging($customErrorHandlerHasBeenP
536550
}
537551
}
538552

539-
public function errorHandlerIsNotLostWhenLoggingProvider()
553+
public function errorHandlerWhenLoggingProvider()
540554
{
541-
return [
542-
[false, new NullLogger()],
543-
[true, new NullLogger()],
544-
[false, new LoggerThatSetAnErrorHandler()],
545-
[true, new LoggerThatSetAnErrorHandler()],
546-
];
555+
foreach ([false, true] as $previousHandlerWasDefined) {
556+
foreach ([false, true] as $loggerSetsAnotherHandler) {
557+
foreach ([false, true] as $nextHandlerIsDefined) {
558+
yield [$previousHandlerWasDefined, $loggerSetsAnotherHandler, $nextHandlerIsDefined];
559+
}
560+
}
561+
}
547562
}
548563
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Symfony\Component\Debug\Tests\Fixtures;
4+
5+
class ErrorHandlerThatUsesThePreviousOne
6+
{
7+
private static $previous;
8+
9+
public static function register()
10+
{
11+
$handler = new static();
12+
13+
self::$previous = set_error_handler([$handler, 'handleError']);
14+
15+
return $handler;
16+
}
17+
18+
public function handleError($type, $message, $file, $line, $context)
19+
{
20+
return \call_user_func(self::$previous, $type, $message, $file, $line, $context);
21+
}
22+
}

src/Symfony/Component/Debug/Tests/Fixtures/LoggerThatSetAnErrorHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace Symfony\Component\Debug\Tests\Fixtures;
44

5-
use Psr\Log\AbstractLogger;
5+
use Symfony\Component\Debug\BufferingLogger;
66

7-
class LoggerThatSetAnErrorHandler extends AbstractLogger
7+
class LoggerThatSetAnErrorHandler extends BufferingLogger
88
{
99
public function log($level, $message, array $context = [])
1010
{
1111
set_error_handler('is_string');
12+
parent::log($level, $message, $context);
1213
restore_error_handler();
1314
}
1415
}

src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,18 @@
322322
<source>This is not a valid UUID.</source>
323323
<target>Dëst ass keng gëlteg UUID.</target>
324324
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>Dëse Wäert sollt e puer vun {{ compared_value }} sinn.</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>Dëse "Business Identifier Code" (BIC) ass net mat IBAN verbonnen {{ iban }}.</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>Dëse Wäert sollt gëlteg JSON.</target>
336+
</trans-unit>
325337
</body>
326338
</file>
327339
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,38 @@
302302
<source>An empty file is not allowed.</source>
303303
<target>Failas negali būti tuščias.</target>
304304
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>Serveris nepasiekiamas.</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>Ši reikšmė neatitinka {{ charset }} koduotės.</target>
312+
</trans-unit>
313+
<trans-unit id="81">
314+
<source>This is not a valid Business Identifier Code (BIC).</source>
315+
<target>Bendrovės Identifikavimo Kodas (BIC) nėra tinkamas.</target>
316+
</trans-unit>
305317
<trans-unit id="82">
306318
<source>Error</source>
307319
<target>Klaida</target>
308320
</trans-unit>
321+
<trans-unit id="83">
322+
<source>This is not a valid UUID.</source>
323+
<target>Ši reikšmė nėra tinkamas UUID.</target>
324+
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>Ši reikšmė turi būti skaičiaus {{ compared_value }} kartotinis.</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>Šis bendrovės identifikavimo kodas (BIC) nesusijęs su IBAN {{ iban }}.</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>Ši reikšmė turi būti tinkamo JSON formato.</target>
336+
</trans-unit>
309337
</body>
310338
</file>
311339
</xliff>

0 commit comments

Comments
 (0)
0