Skip to content

Commit

Permalink
Merge branch '2.3' into 2.6
Browse files Browse the repository at this point in the history
* 2.3:
  [FrameworkBundle] Fix title and placeholder rendering in php form templates.
  RequestDataCollector - small fix
  renamed composer.phar to composer to be consistent with the Symfony docs
  [FrameworkBundle] bumped min version of Routing to 2.3
  removed composer --dev option everywhere
  fixed a test
  [Console] Fixed output bug, if escaped string in a formatted string.
  [Security] Remove ContextListener's onKernelResponse listener as it is used
  Revert "minor #12652 [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value (skler)"
  Revert "fixed assertion"
  fixed assertion
  [HttpFoundation] [Hackday] #9942 test: Request::getContent() for null value
  fixed URL
  Add reference to documentation in FormEvents phpdocs
  [YAML] Fix one-liners to work with multiple new lines
  Keep "pre" meaning for var_dump quick-and-dirty debug
  [Console][Table] Fix cell padding with multi-byte

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Component/Console/Helper/TableHelper.php
  • Loading branch information
fabpot committed Feb 11, 2015
2 parents 29557eb + bb47b64 commit 122cf2c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
13 changes: 6 additions & 7 deletions Parser.php
Expand Up @@ -52,13 +52,13 @@ public function __construct($offset = 0)
*/
public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
{
$this->currentLineNb = -1;
$this->currentLine = '';
$this->lines = explode("\n", $this->cleanup($value));

if (!preg_match('//u', $value)) {
throw new ParseException('The YAML value does not appear to be valid UTF-8.');
}
$this->currentLineNb = -1;
$this->currentLine = '';
$value = $this->cleanup($value);
$this->lines = explode("\n", $value);

if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
Expand Down Expand Up @@ -233,9 +233,8 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
throw new ParseException('Multiple documents are not supported.');
}

// 1-liner optionally followed by newline
$lineCount = count($this->lines);
if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
// 1-liner optionally followed by newline(s)
if ($this->lines[0] === trim($value)) {
try {
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
} catch (ParseException $e) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,5 +17,5 @@ Resources
You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/Yaml/
$ composer.phar install
$ composer install
$ phpunit
8 changes: 8 additions & 0 deletions Tests/ParserTest.php
Expand Up @@ -135,6 +135,14 @@ public function getBlockChompingTests()
);
$tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml);

$yaml = <<<'EOF'
{}
EOF;
$expected = array();
$tests['Literal block chomping strip with multiple trailing newlines after a 1-liner'] = array($expected, $yaml);

$yaml = <<<'EOF'
foo: |-
one
Expand Down

0 comments on commit 122cf2c

Please sign in to comment.