[Yaml] removed the unused value property from Parser. Tweaked one-line check to be self explaining
This commit is contained in:
parent
930906557e
commit
62c2ef65f8
@ -19,7 +19,6 @@ namespace Symfony\Components\Yaml;
|
|||||||
*/
|
*/
|
||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
protected $value = '';
|
|
||||||
protected $offset = 0;
|
protected $offset = 0;
|
||||||
protected $lines = array();
|
protected $lines = array();
|
||||||
protected $currentLineNb = -1;
|
protected $currentLineNb = -1;
|
||||||
@ -47,10 +46,9 @@ class Parser
|
|||||||
*/
|
*/
|
||||||
public function parse($value)
|
public function parse($value)
|
||||||
{
|
{
|
||||||
$this->value = $this->cleanup($value);
|
|
||||||
$this->currentLineNb = -1;
|
$this->currentLineNb = -1;
|
||||||
$this->currentLine = '';
|
$this->currentLine = '';
|
||||||
$this->lines = explode("\n", $this->value);
|
$this->lines = explode("\n", $this->cleanup($value));
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
while ($this->moveToNextLine())
|
while ($this->moveToNextLine())
|
||||||
@ -191,8 +189,7 @@ class Parser
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// one liner?
|
if (1 == count($this->lines))
|
||||||
if (1 == count(explode("\n", rtrim($this->value, "\n"))))
|
|
||||||
{
|
{
|
||||||
$value = Inline::load($this->lines[0]);
|
$value = Inline::load($this->lines[0]);
|
||||||
if (is_array($value))
|
if (is_array($value))
|
||||||
@ -543,10 +540,8 @@ class Parser
|
|||||||
{
|
{
|
||||||
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
||||||
|
|
||||||
if (!preg_match("#\n$#", $value))
|
// remove trailing newlines
|
||||||
{
|
$value = rtrim($value, "\n");
|
||||||
$value .= "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// strip YAML header
|
// strip YAML header
|
||||||
preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);
|
preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);
|
||||||
|
Reference in New Issue
Block a user