[VarDumper] Fix indentation trimming in ExceptionCaster

This commit is contained in:
Nicolas Grekas 2016-07-05 08:40:30 +02:00
parent fe17083cf9
commit ab9daeba13
4 changed files with 19 additions and 14 deletions

View File

@ -253,19 +253,24 @@ class ExceptionCaster
}
$ltrim = 0;
while (' ' === $src[0][$ltrim] || "\t" === $src[0][$ltrim]) {
$i = $srcContext << 1;
while ($i > 0 && $src[0][$ltrim] === $src[$i][$ltrim]) {
--$i;
}
if ($i) {
break;
do {
$pad = null;
for ($i = $srcContext << 1; $i >= 0; --$i) {
if (isset($src[$i][$ltrim]) && "\r" !== ($c = $src[$i][$ltrim]) && "\n" !== $c) {
if (null === $pad) {
$pad = $c;
}
if ((' ' !== $c && "\t" !== $c) || $pad !== $c) {
break;
}
}
}
++$ltrim;
}
if ($ltrim) {
} while (0 > $i && null !== $pad);
if (--$ltrim) {
foreach ($src as $i => $line) {
$src[$i] = substr($line, $ltrim);
$src[$i] = isset($line[$ltrim]) && "\r" !== $line[$ltrim] ? substr($line, $ltrim) : ltrim($line, " \t");
}
}

View File

@ -208,8 +208,8 @@ array:2 [
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo(): {
%sGeneratorDemo.php:10: """
yield 1;\n
}\n
yield 1;\n
}\n
\n
"""
}

View File

@ -200,7 +200,7 @@ EOTXT
$twig = <<<EOTXT
foo.twig:2: """
foo bar\\n
twig source\\n
twig source\\n
\\n
"""

View File

@ -29,6 +29,6 @@ class __TwigTemplate_VarDumperFixture_u75a09 extends Twig_Template
return array (19 => 2);
}
}
/* foo bar*/
/* foo bar*/
/* twig source*/
/* */