10000 [VarDumper] Fix indentation trimming in ExceptionCaster by nicolas-grekas · Pull Request #19288 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] Fix indentation trimming in ExceptionCaster #19288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[VarDumper] Fix indentation trimming in ExceptionCaster
  • Loading branch information
nicolas-grekas committed Jul 5, 2016
commit ab9daeba1333a084081f062d8415e3681cfc12e8
25 changes: 15 additions & 10 deletions src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,24 @@ private static function extractSource(array $srcArray, $line, $srcContext)
}

$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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public function testGenerator()
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo(): {
%sGeneratorDemo.php:10: """
yield 1;\n
}\n
yield 1;\n
}\n
\n
"""
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function testThrowingCaster()
$twig = <<<EOTXT
foo.twig:2: """
foo bar\\n
twig source\\n
twig source\\n
\\n
"""

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Tests/Fixtures/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public function getDebugInfo()
return array (19 => 2);
}
}
/* foo bar*/
/* foo bar*/
/* twig source*/
/* */
0