From 4c437f6be9f4eb40387d7ce18b6229d5f47ac6bd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 18 Jan 2013 00:11:05 +0100 Subject: [PATCH 01/11] bumped Symfony version to 2.0.23-DEV --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 643d1823fd..2ebfecd621 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -56,12 +56,12 @@ abstract class Kernel implements KernelInterface protected $startTime; protected $classes; - const VERSION = '2.0.22'; - const VERSION_ID = '20022'; + const VERSION = '2.0.23-DEV'; + const VERSION_ID = '20023'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '0'; - const RELEASE_VERSION = '22'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '23'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 9155a2382ee8770bcdd2ef8c0940eee5969a5475 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 18 Jan 2013 00:11:33 +0100 Subject: [PATCH 02/11] bumped Symfony version to 2.1.8-DEV --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 87bac61e24..726912ee87 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $classes; protected $errorReportingLevel; - const VERSION = '2.1.7'; - const VERSION_ID = '20107'; + const VERSION = '2.1.8-DEV'; + const VERSION_ID = '20108'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '1'; - const RELEASE_VERSION = '7'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '8'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From fea20b7eb2029ee7c7f6c73c39d993f06d3ccb77 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 18 Jan 2013 09:32:48 +1000 Subject: [PATCH 03/11] [Yaml] fixed #6770 --- src/Symfony/Component/Yaml/Inline.php | 5 +++++ tests/Symfony/Tests/Component/Yaml/InlineTest.php | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 2f7855d131..a242e9f7ef 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -393,6 +393,11 @@ class Inline $cast = intval($scalar); return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); case 'true' === strtolower($scalar): return true; case 'false' === strtolower($scalar): diff --git a/tests/Symfony/Tests/Component/Yaml/InlineTest.php b/tests/Symfony/Tests/Component/Yaml/InlineTest.php index b98acfeaba..445a92f1ec 100644 --- a/tests/Symfony/Tests/Component/Yaml/InlineTest.php +++ b/tests/Symfony/Tests/Component/Yaml/InlineTest.php @@ -19,7 +19,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase public function testParse() { foreach ($this->getTestsForParse() as $yaml => $value) { - $this->assertEquals($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml)); + $this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml)); } } @@ -73,6 +73,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase 'false' => false, 'true' => true, '12' => 12, + '-12' => -12, '"quoted string"' => 'quoted string', "'quoted string'" => 'quoted string', '12.30e+02' => 12.30e+02, @@ -82,7 +83,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase '-.Inf' => log(0), "'686e444'" => '686e444', '686e444' => 646e444, - '123456789123456789' => '123456789123456789', + '123456789123456789123456789123456789' => '123456789123456789123456789123456789', '"foo\r\nbar"' => "foo\r\nbar", "'foo#bar'" => 'foo#bar', "'foo # bar'" => 'foo # bar', From ab0385c633f7fe50b064e8996757d3451b2c1533 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 18 Jan 2013 09:42:00 +1000 Subject: [PATCH 04/11] [Yaml] fixed #6773 --- src/Symfony/Component/Yaml/Parser.php | 9 +- .../Tests/Component/Yaml/ParserTest.php | 195 ++++++++++++++++++ 2 files changed, 198 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 1c0fdd828a..435b08948f 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -179,8 +179,9 @@ class Parser } } } else { - // 1-liner followed by newline - if (2 == count($this->lines) && empty($this->lines[1])) { + // 1-liner optionally followed by newline + $lineCount = count($this->lines); + if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { try { $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { @@ -527,10 +528,6 @@ class Parser { $value = str_replace(array("\r\n", "\r"), "\n", $value); - if (!preg_match("#\n$#", $value)) { - $value .= "\n"; - } - // strip YAML header $count = 0; $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count); diff --git a/tests/Symfony/Tests/Component/Yaml/ParserTest.php b/tests/Symfony/Tests/Component/Yaml/ParserTest.php index 4b3f3bf273..1655cd6767 100644 --- a/tests/Symfony/Tests/Component/Yaml/ParserTest.php +++ b/tests/Symfony/Tests/Component/Yaml/ParserTest.php @@ -105,6 +105,201 @@ EOF; $this->assertEquals('foo', $this->parser->parse($yaml)); } + public function getBlockChompingTests() + { + $tests = array(); + + $yaml = <<<'EOF' +foo: |- + one + two + +bar: |- + one + two + +EOF; + $expected = array( + 'foo' => "one\ntwo", + 'bar' => "one\ntwo", + ); + $tests['Literal block chomping strip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: |- + one + two +bar: |- + one + two +EOF; + $expected = array( + 'foo' => "one\ntwo", + 'bar' => "one\ntwo", + ); + $tests['Literal block chomping strip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: | + one + two + +bar: | + one + two + +EOF; + $expected = array( + 'foo' => "one\ntwo\n", + 'bar' => "one\ntwo\n", + ); + $tests['Literal block chomping clip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: | + one + two +bar: | + one + two +EOF; + $expected = array( + 'foo' => "one\ntwo\n", + 'bar' => "one\ntwo\n", + ); + $tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: |+ + one + two + +bar: |+ + one + two + +EOF; + $expected = array( + 'foo' => "one\ntwo\n\n", + 'bar' => "one\ntwo\n\n", + ); + $tests['Literal block chomping keep with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: |+ + one + two +bar: |+ + one + two +EOF; + $expected = array( + 'foo' => "one\ntwo\n", + 'bar' => "one\ntwo\n", + ); + $tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >- + one + two + +bar: >- + one + two + +EOF; + $expected = array( + 'foo' => "one two", + 'bar' => "one two", + ); + $tests['Folded block chomping strip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >- + one + two +bar: >- + one + two +EOF; + $expected = array( + 'foo' => "one two", + 'bar' => "one two", + ); + $tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: > + one + two + +bar: > + one + two + +EOF; + $expected = array( + 'foo' => "one two\n", + 'bar' => "one two\n", + ); + $tests['Folded block chomping clip with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: > + one + two +bar: > + one + two +EOF; + $expected = array( + 'foo' => "one two\n", + 'bar' => "one two\n", + ); + $tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >+ + one + two + +bar: >+ + one + two + +EOF; + $expected = array( + 'foo' => "one two\n\n", + 'bar' => "one two\n\n", + ); + $tests['Folded block chomping keep with trailing newline'] = array($expected, $yaml); + + $yaml = <<<'EOF' +foo: >+ + one + two +bar: >+ + one + two +EOF; + $expected = array( + 'foo' => "one two\n", + 'bar' => "one two\n", + ); + $tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml); + + return $tests; + } + + /** + * @dataProvider getBlockChompingTests + */ + public function testBlockChomping($expected, $yaml) + { + $this->assertSame($expected, $this->parser->parse($yaml)); + } + public function testObjectSupportEnabled() { $input = << Date: Wed, 13 Jun 2012 14:57:32 +0200 Subject: [PATCH 05/11] [Yaml] fixed ignored text when parsing an inlined mapping or sequence (closes #6786) --- src/Symfony/Component/Yaml/Inline.php | 26 ++++++++-- .../Tests/Component/Yaml/InlineTest.php | 51 +++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index a242e9f7ef..0d791ca41d 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -50,15 +50,23 @@ class Inline mb_internal_encoding('ASCII'); } + $i = 0; switch ($value[0]) { case '[': - $result = self::parseSequence($value); + $result = self::parseSequence($value, $i); + ++$i; break; case '{': - $result = self::parseMapping($value); + $result = self::parseMapping($value, $i); + ++$i; break; default: - $result = self::parseScalar($value); + $result = self::parseScalar($value, null, array('"', "'"), $i); + } + + // some comments are allowed at the end + if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { + throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i))); } if (isset($mbEncoding)) { @@ -185,6 +193,13 @@ class Inline if (in_array($scalar[$i], $stringDelimiters)) { // quoted scalar $output = self::parseQuotedScalar($scalar, $i); + + if (null !== $delimiters) { + $tmp = ltrim(substr($scalar, $i), ' '); + if (!in_array($tmp[0], $delimiters)) { + throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i))); + } + } } else { // "normal" string if (!$delimiters) { @@ -220,6 +235,11 @@ class Inline */ private static function parseQuotedScalar($scalar, &$i) { + // Only check the current item we're dealing with (for sequences) + $subject = substr($scalar, $i); + $items = preg_split('/[\'"]\s*(?:[,:]|[}\]]\s*,)/', $subject); + $subject = substr($subject, 0, strlen($items[0]) + 1); + if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i))); } diff --git a/tests/Symfony/Tests/Component/Yaml/InlineTest.php b/tests/Symfony/Tests/Component/Yaml/InlineTest.php index 445a92f1ec..252013ed2b 100644 --- a/tests/Symfony/Tests/Component/Yaml/InlineTest.php +++ b/tests/Symfony/Tests/Component/Yaml/InlineTest.php @@ -65,6 +65,57 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertSame($value, Inline::parse(Inline::dump($value))); } + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException() + { + $value = "'don't do somthin' like that'"; + Inline::parse($value); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException() + { + $value = '"don"t do somthin" like that"'; + Inline::parse($value); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseInvalidMappingKeyShouldThrowException() + { + $value = '{ "foo " bar": "bar" }'; + Inline::parse($value); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseInvalidMappingShouldThrowException() + { + Inline::parse('[foo] bar'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testParseInvalidSequenceShouldThrowException() + { + Inline::parse('{ foo: bar } bar'); + } + + public function testParseScalarWithCorrectlyQuotedStringShouldReturnString() + { + $value = "'don''t do somthin'' like that'"; + $expect = "don't do somthin' like that"; + + $this->assertSame($expect, Inline::parseScalar($value)); + } + protected function getTestsForParse() { return array( From ce38069a94cf56cc68e0986aa6207d01857c6a22 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 18 Jan 2013 11:08:30 +0100 Subject: [PATCH 06/11] [FrameworkBundle] fixed Client::doRequest that must call its parent method (closes #6737) --- src/Symfony/Bundle/FrameworkBundle/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 9898f490cf..17b268bf87 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -78,7 +78,7 @@ class Client extends BaseClient $this->hasPerformedRequest = true; } - return $this->kernel->handle($request); + return parent::doRequest($request); } /** From 5aa83ad1ebe10fcce8184473b0c836c2cc0cc649 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 18 Jan 2013 13:28:05 +0100 Subject: [PATCH 07/11] KNOWN_ISSUES with php 5.3.16 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8ec144b00d..207b2bd397 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ work for you: * before PHP 5.3.8, if you get an error involving annotations, you've hit a known PHP bug (see https://bugs.php.net/bug.php?id=55156). + * PHP 5.3.16 has a major bug in the Reflexion sub-system and is not suitable to + run Symfony2 (https://bugs.php.net/bug.php?id=62715) + Installation ------------ From 11aaa2e672940af08a8a696ce3bf3eba710bfdd0 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 18 Jan 2013 20:26:53 +0100 Subject: [PATCH 08/11] Added an error message in the DebugClassLoader when using / instead of \. --- src/Symfony/Component/ClassLoader/DebugClassLoader.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/ClassLoader/DebugClassLoader.php b/src/Symfony/Component/ClassLoader/DebugClassLoader.php index dbfb5ab1e3..54fe23eabb 100644 --- a/src/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -82,6 +82,10 @@ class DebugClassLoader require $file; if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (false !== strpos($class, '/')) { + throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".')); + } + throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); } From e6a7e4ceb7fd0f9d0914a4aa0d4fd5438813e83c Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 19 Jan 2013 11:32:41 +0100 Subject: [PATCH 09/11] Fix typos in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 207b2bd397..8f04cd8650 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ work for you: * before PHP 5.3.8, if you get an error involving annotations, you've hit a known PHP bug (see https://bugs.php.net/bug.php?id=55156). - * PHP 5.3.16 has a major bug in the Reflexion sub-system and is not suitable to + * PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to run Symfony2 (https://bugs.php.net/bug.php?id=62715) Installation From 598ae9d050a8010cc67008eec8a39989e429f00e Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Mon, 21 Jan 2013 09:57:59 +0100 Subject: [PATCH 10/11] [Security] PHPDoc in SecurityEvents --- .../Component/Security/Http/SecurityEvents.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Symfony/Component/Security/Http/SecurityEvents.php b/src/Symfony/Component/Security/Http/SecurityEvents.php index a6c4e42fc9..45fae293b3 100644 --- a/src/Symfony/Component/Security/Http/SecurityEvents.php +++ b/src/Symfony/Component/Security/Http/SecurityEvents.php @@ -13,7 +13,25 @@ namespace Symfony\Component\Security\Http; final class SecurityEvents { + /** + * The INTERACTIVE_LOGIN event occurs after a user is logged in + * interactively for authentication based on http, cookies or X509. + * + * The event listener method receives a + * Symfony\Component\Security\Http\Event\InteractiveLoginEvent instance. + * + * @var string + */ const INTERACTIVE_LOGIN = 'security.interactive_login'; + /** + * The SWITCH_USER event occurs before switch to another user and + * before exit from an already switched user. + * + * The event listener method receives a + * Symfony\Component\Security\Http\Event\SwitchUserEvent instance. + * + * @var string + */ const SWITCH_USER = 'security.switch_user'; } From 4119cafdbe9bd06ae45d23aafcfb83b50b34b0a8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 21 Jan 2013 23:08:41 +0100 Subject: [PATCH 11/11] [DependencyInjection] fixed the creation of synthetic services in ContainerBuilder --- .../DependencyInjection/ContainerBuilder.php | 4 ++++ .../DependencyInjection/ContainerBuilderTest.php | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 2af3c85bc1..b83d56750b 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -725,6 +725,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ private function createService(Definition $definition, $id) { + if ($definition->isSynthetic()) { + throw new \RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id)); + } + if (null !== $definition->getFile()) { require_once $this->getParameterBag()->resolveValue($definition->getFile()); } diff --git a/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php b/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php index c712ce66d9..2d5d311d68 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/ContainerBuilderTest.php @@ -315,6 +315,17 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase } } + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService + * @expectedException \RuntimeException + */ + public function testCreateSyntheticService() + { + $builder = new ContainerBuilder(); + $builder->register('foo', 'FooClass')->setSynthetic(true); + $builder->get('foo'); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices */