Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb0ccf9

Browse filesBrowse files
committed
Avoid an extra loop
...and keep the diff as small as possible
1 parent b9307ec commit fb0ccf9
Copy full SHA for fb0ccf9

File tree

1 file changed

+5
-10
lines changed
Filter options

1 file changed

+5
-10
lines changed

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,21 +421,16 @@ private function doParse($value, $flags)
421421
}
422422

423423
// try to parse the value as a multi-line string as a last resort
424-
if (0 === $this->currentLineNb && 1 < $this->totalNumberOfLines) {
425-
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
426-
if (0 === $this->offset && !$deprecatedUsage) {
427-
foreach ($this->lines as $line) {
428-
if (rtrim($line) !== trim($line)) {
429-
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
430-
}
431-
}
432-
}
433-
424+
if (0 === $this->currentLineNb) {
434425
$previousLineWasNewline = false;
435426
$previousLineWasTerminatedWithBackslash = false;
436427
$value = '';
437428

438429
foreach ($this->lines as $line) {
430+
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
431+
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
432+
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
433+
}
439434
if ('' === trim($line)) {
440435
$value .= "\n";
441436
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.