From 90c04ef8b9838dbdadaba8c9b117a89eefbbc97c Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 27 Aug 2013 13:58:54 -0400 Subject: [PATCH] Updated Symfony/Yaml component. --- composer.lock | 10 +- vendor/autoload.php | 2 +- vendor/composer/ClassLoader.php | 4 +- vendor/composer/autoload_real.php | 6 +- vendor/composer/installed.json | 98 +++++++++---------- .../yaml/Symfony/Component/Yaml/.gitignore | 1 - .../yaml/Symfony/Component/Yaml/Parser.php | 15 ++- .../Yaml/Tests/Fixtures/sfComments.yml | 14 +++ .../Component/Yaml/Tests/ParserTest.php | 89 +++++++++++++++++ 9 files changed, 175 insertions(+), 64 deletions(-) diff --git a/composer.lock b/composer.lock index 08c01f79de2..b984d7ef160 100644 --- a/composer.lock +++ b/composer.lock @@ -321,17 +321,17 @@ }, { "name": "symfony/yaml", - "version": "v2.3.1", + "version": "v2.3.4", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.3.1" + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", "shasum": "" }, "require": { @@ -364,7 +364,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-05-10 18:12:13" + "time": "2013-08-24 15:26:22" }, { "name": "zendframework/zendframework", diff --git a/vendor/autoload.php b/vendor/autoload.php index e936bdc71b0..5347e7c08c1 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit9c2a88ea43224869fc72b5250d94e473::getLoader(); +return ComposerAutoloaderInitead8bc6e07874aa3993992df7474c87b::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index ef9924516ae..1db8d9a0b2e 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -121,8 +121,8 @@ class ClassLoader /** * Registers a set of classes, replacing any others previously set. * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes + * @param string $prefix The classes prefix + * @param array|string $paths The location(s) of the classes */ public function set($prefix, $paths) { diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 0ab67602084..6dfdc15c513 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php generated by Composer -class ComposerAutoloaderInit9c2a88ea43224869fc72b5250d94e473 +class ComposerAutoloaderInitead8bc6e07874aa3993992df7474c87b { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit9c2a88ea43224869fc72b5250d94e473 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit9c2a88ea43224869fc72b5250d94e473', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitead8bc6e07874aa3993992df7474c87b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit9c2a88ea43224869fc72b5250d94e473', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitead8bc6e07874aa3993992df7474c87b', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index bb9092dd7ec..0345ac3982e 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -443,55 +443,6 @@ "issues": "https://github.com/zendframework/ZendService_Amazon/issues" } }, - { - "name": "symfony/yaml", - "version": "v2.3.1", - "version_normalized": "2.3.1.0", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.3.1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.1", - "reference": "v2.3.1", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "time": "2013-05-10 18:12:13", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com" - }, { "name": "zendframework/zendframework", "version": "2.2.1", @@ -608,5 +559,54 @@ "source": "https://github.com/zendframework/zf2/tree/release-2.2.1", "issues": "https://github.com/zendframework/zf2/issues" } + }, + { + "name": "symfony/yaml", + "version": "v2.3.4", + "version_normalized": "2.3.4.0", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2013-08-24 15:26:22", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com" } ] diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore b/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore index 44de97a36a6..c49a5d8df5c 100644 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore @@ -1,4 +1,3 @@ vendor/ composer.lock phpunit.xml - diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php index 680b50349c9..d852cbf9bcf 100644 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -19,6 +19,8 @@ use Symfony\Component\Yaml\Exception\ParseException; */ class Parser { + const FOLDED_SCALAR_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?'; + private $offset = 0; private $lines = array(); private $currentLineNb = -1; @@ -111,7 +113,7 @@ class Parser $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } - } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { + } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); } @@ -304,14 +306,21 @@ class Parser $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); + // Comments must not be removed inside a string block (ie. after a line ending with "|") + $removeCommentsPattern = '~'.self::FOLDED_SCALAR_PATTERN.'$~'; + $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); + while ($this->moveToNextLine()) { + if ($this->getCurrentLineIndentation() === $newIndent) { + $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); + } if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { $this->moveToPreviousLine(); break; } - if ($this->isCurrentLineEmpty()) { + if ($removeComments && $this->isCurrentLineEmpty() || $this->isCurrentLineBlank()) { if ($this->isCurrentLineBlank()) { $data[] = substr($this->currentLine, $newIndent); } @@ -389,7 +398,7 @@ class Parser return $this->refs[$value]; } - if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) { + if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml index 34225e11e0a..46addfcd3da 100644 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml @@ -49,3 +49,17 @@ yaml: | foo: bar # a comment php: | array('foo' => 'bar') +--- +test: Comment containing a colon on a hash line +brief: > + Comment containing a colon on a scalar line +yaml: 'foo # comment: this is also part of the comment' +php: | + 'foo' +--- +test: 'Hash key containing a #' +brief: > + 'Hash key containing a #' +yaml: 'foo#bar: baz' +php: | + array('foo#bar' => 'baz') diff --git a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php index a8d28b9131d..c7d3b071e6d 100644 --- a/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php @@ -522,6 +522,95 @@ EOF; $this->assertEquals(array('hash' => null), Yaml::parse($input)); } + + public function testStringBlockWithComments() + { + $this->assertEquals(array('content' => <<<EOT +# comment 1 +header + + # comment 2 + <body> + <h1>title</h1> + </body> + +footer # comment3 +EOT + ), Yaml::parse(<<<EOF +content: | + # comment 1 + header + + # comment 2 + <body> + <h1>title</h1> + </body> + + footer # comment3 +EOF + )); + } + + public function testFoldedStringBlockWithComments() + { + $this->assertEquals(array(array('content' => <<<EOT +# comment 1 +header + + # comment 2 + <body> + <h1>title</h1> + </body> + +footer # comment3 +EOT + )), Yaml::parse(<<<EOF +- + content: | + # comment 1 + header + + # comment 2 + <body> + <h1>title</h1> + </body> + + footer # comment3 +EOF + )); + } + + public function testNestedFoldedStringBlockWithComments() + { + $this->assertEquals(array(array( + 'title' => 'some title', + 'content' => <<<EOT +# comment 1 +header + + # comment 2 + <body> + <h1>title</h1> + </body> + +footer # comment3 +EOT + )), Yaml::parse(<<<EOF +- + title: some title + content: | + # comment 1 + header + + # comment 2 + <body> + <h1>title</h1> + </body> + + footer # comment3 +EOF + )); + } } class B -- GitLab