Skip to content

Commit fb0ccf9

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

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy