From 62c2ef65f80954e94ca86bf6a44203550965ba24 Mon Sep 17 00:00:00 2001 From: Fabian Lange Date: Sun, 21 Feb 2010 00:33:54 +0100 Subject: [PATCH] [Yaml] removed the unused value property from Parser. Tweaked one-line check to be self explaining --- src/Symfony/Components/Yaml/Parser.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Components/Yaml/Parser.php b/src/Symfony/Components/Yaml/Parser.php index c9720f7cca..aa8323ba9b 100644 --- a/src/Symfony/Components/Yaml/Parser.php +++ b/src/Symfony/Components/Yaml/Parser.php @@ -19,7 +19,6 @@ namespace Symfony\Components\Yaml; */ class Parser { - protected $value = ''; protected $offset = 0; protected $lines = array(); protected $currentLineNb = -1; @@ -47,10 +46,9 @@ class Parser */ public function parse($value) { - $this->value = $this->cleanup($value); $this->currentLineNb = -1; $this->currentLine = ''; - $this->lines = explode("\n", $this->value); + $this->lines = explode("\n", $this->cleanup($value)); $data = array(); while ($this->moveToNextLine()) @@ -191,8 +189,7 @@ class Parser } else { - // one liner? - if (1 == count(explode("\n", rtrim($this->value, "\n")))) + if (1 == count($this->lines)) { $value = Inline::load($this->lines[0]); if (is_array($value)) @@ -543,10 +540,8 @@ class Parser { $value = str_replace(array("\r\n", "\r"), "\n", $value); - if (!preg_match("#\n$#", $value)) - { - $value .= "\n"; - } + // remove trailing newlines + $value = rtrim($value, "\n"); // strip YAML header preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);