[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;
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 ($i) {
if ((' ' !== $c && "\t" !== $c) || $pad !== $c) {
break;
}
++$ltrim;
}
if ($ltrim) {
}
++$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");
}
}