From 85137778a65223b5b4acfa35c6e5429bc51b7a7c Mon Sep 17 00:00:00 2001 From: Drak Date: Wed, 19 Dec 2012 14:14:03 +0000 Subject: [PATCH 01/14] [HttpFoundation] Update docblock for non-working method --- .../Component/HttpFoundation/Session/Flash/FlashBag.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index ce9308e154..f0a00d66a0 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -177,6 +177,11 @@ class FlashBag implements FlashBagInterface, \IteratorAggregate, \Countable /** * Returns the number of flashes. * + * This method does not work. + * + * @deprecated in 2.2, removed in 2.3 + * @see https://github.com/symfony/symfony/issues/6408 + * * @return int The number of flashes */ public function count() From 33e9d002a708bf54e551c7e75de57841ee105535 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Sat, 5 Jan 2013 18:04:01 +0100 Subject: [PATCH 02/14] [Form] Deleted references in FormBuilder::getFormConfig() to improve performance --- src/Symfony/Component/Form/FormBuilder.php | 15 ++++++++++++ .../Component/Form/Tests/FormBuilderTest.php | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 9d23ff565f..8560e75806 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -202,6 +202,21 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB return count($this->children); } + /** + * {@inheritdoc} + */ + public function getFormConfig() + { + $config = parent::getFormConfig(); + + $config->factory = null; + $config->parent = null; + $config->children = array(); + $config->unresolvedChildren = array(); + + return $config; + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 42d4317459..ff04006b54 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -232,6 +232,30 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase $this->builder->create('bar', 'text'); } + public function testGetFormConfigErasesReferences() + { + $builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); + $builder->setParent(new FormBuilder('parent', null, $this->dispatcher, $this->factory)); + $builder->add(new FormBuilder('child', null, $this->dispatcher, $this->factory)); + + $config = $builder->getFormConfig(); + $reflClass = new \ReflectionClass($config); + $factory = $reflClass->getProperty('factory'); + $parent = $reflClass->getProperty('parent'); + $children = $reflClass->getProperty('children'); + $unresolvedChildren = $reflClass->getProperty('unresolvedChildren'); + + $factory->setAccessible(true); + $parent->setAccessible(true); + $children->setAccessible(true); + $unresolvedChildren->setAccessible(true); + + $this->assertNull($factory->getValue($config)); + $this->assertNull($parent->getValue($config)); + $this->assertEmpty($children->getValue($config)); + $this->assertEmpty($unresolvedChildren->getValue($config)); + } + private function getFormBuilder($name = 'name') { $mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') From 1e2fb64817abd4f1e9aa4b8e1cb392a46f9a8688 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 6 Jan 2013 08:52:07 +0100 Subject: [PATCH 03/14] [DependencyInjection] refactored code to avoid logic duplication --- .../DependencyInjection/Dumper/PhpDumper.php | 66 +++++++++---------- .../Fixtures/php/services9.php | 1 + 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 18251f064c..a2536d5847 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -227,24 +227,7 @@ class PhpDumper extends Dumper throw new ServiceCircularReferenceException($id, array($id)); } - $arguments = array(); - foreach ($sDefinition->getArguments() as $argument) { - $arguments[] = $this->dumpValue($argument); - } - - if (null !== $sDefinition->getFactoryMethod()) { - if (null !== $sDefinition->getFactoryClass()) { - $code .= sprintf(" \$%s = call_user_func(array(%s, '%s')%s);\n", $name, $this->dumpValue($sDefinition->getFactoryClass()), $sDefinition->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : ''); - } elseif (null !== $sDefinition->getFactoryService()) { - $code .= sprintf(" \$%s = %s->%s(%s);\n", $name, $this->getServiceCall($sDefinition->getFactoryService()), $sDefinition->getFactoryMethod(), implode(', ', $arguments)); - } else { - throw new \RuntimeException('Factory service or factory class must be defined in service definition for '.$id); - } - } elseif (false !== strpos($class, '$')) { - $code .= sprintf(" \$class = %s;\n \$%s = new \$class(%s);\n", $class, $name, implode(', ', $arguments)); - } else { - $code .= sprintf(" \$%s = new \\%s(%s);\n", $name, substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); - } + $code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = '); if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) { $code .= $this->addServiceMethodCalls(null, $sDefinition, $name); @@ -295,11 +278,6 @@ class PhpDumper extends Dumper throw new \InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); } - $arguments = array(); - foreach ($definition->getArguments() as $value) { - $arguments[] = $this->dumpValue($value); - } - $simple = $this->isSimpleInstance($id, $definition); $instantiation = ''; @@ -318,19 +296,7 @@ class PhpDumper extends Dumper $instantiation .= ' = '; } - if (null !== $definition->getFactoryMethod()) { - if (null !== $definition->getFactoryClass()) { - $code = sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : ''); - } elseif (null !== $definition->getFactoryService()) { - $code = sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments)); - } else { - throw new \RuntimeException('Factory method requires a factory service or factory class in service definition for '.$id); - } - } elseif (false !== strpos($class, '$')) { - $code = sprintf(" \$class = %s;\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments)); - } else { - $code = sprintf(" $return{$instantiation}new \\%s(%s);\n", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); - } + $code = $this->addNewInstance($id, $definition, $return, $instantiation); if (!$simple) { $code .= "\n"; @@ -609,6 +575,34 @@ EOF; return $publicServices.$aliasServices.$privateServices; } + private function addNewInstance($id, Definition $definition, $return, $instantiation) + { + $class = $this->dumpValue($definition->getClass()); + + $arguments = array(); + foreach ($definition->getArguments() as $value) { + $arguments[] = $this->dumpValue($value); + } + + if (null !== $definition->getFactoryMethod()) { + if (null !== $definition->getFactoryClass()) { + return sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : ''); + } + + if (null !== $definition->getFactoryService()) { + return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments)); + } + + throw new RuntimeException('Factory method requires a factory service or factory class in service definition for '.$id); + } + + if (false !== strpos($class, '$')) { + return sprintf(" \$class = %s;\n\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments)); + } + + return sprintf(" $return{$instantiation}new \\%s(%s);\n", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); + } + /** * Adds the class headers. * diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php index 0d4008583e..a5d2f74449 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php @@ -118,6 +118,7 @@ class ProjectServiceContainer extends Container protected function getFooBarService() { $class = $this->getParameter('foo_class'); + return new $class(); } From 666283cb76747fa5c0158101f321eb1afa1a272d Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Mon, 7 Jan 2013 11:42:04 +0100 Subject: [PATCH 04/14] [HttpFoundation] Docblock for Request::isXmlHttpRequest() now points to Wikipedia --- src/Symfony/Component/HttpFoundation/Request.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 546d0ffbd9..f973583125 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1132,7 +1132,8 @@ class Request * Returns true if the request is a XMLHttpRequest. * * It works if your JavaScript library set an X-Requested-With HTTP header. - * It is known to work with Prototype, Mootools, jQuery. + * It is known to work with common JavaScript frameworks: + * @link http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript * * @return Boolean true if the request is an XMLHttpRequest, false otherwise * From dbafc2c365b4e2ed12465041950ba48f4ad7e933 Mon Sep 17 00:00:00 2001 From: Simon Constans Date: Tue, 11 Dec 2012 19:25:03 +0100 Subject: [PATCH 05/14] [CssSelector] added css selector with empty string --- src/Symfony/Component/CssSelector/Tokenizer.php | 2 +- tests/Symfony/Tests/Component/CssSelector/TokenizerTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/CssSelector/Tokenizer.php b/src/Symfony/Component/CssSelector/Tokenizer.php index 67d5b67470..34e8ac580a 100644 --- a/src/Symfony/Component/CssSelector/Tokenizer.php +++ b/src/Symfony/Component/CssSelector/Tokenizer.php @@ -129,7 +129,7 @@ class Tokenizer } $result = substr($s, $start, $next - $start); - if ('\\' === $result[strlen($result) - 1]) { + if (strlen($result) > 0 && '\\' === $result[strlen($result) - 1]) { // next quote character is escaped $pos = $next + 1; continue; diff --git a/tests/Symfony/Tests/Component/CssSelector/TokenizerTest.php b/tests/Symfony/Tests/Component/CssSelector/TokenizerTest.php index 4e780831c2..70f471e197 100644 --- a/tests/Symfony/Tests/Component/CssSelector/TokenizerTest.php +++ b/tests/Symfony/Tests/Component/CssSelector/TokenizerTest.php @@ -34,6 +34,7 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('foo[class=foo bar ]', $this->tokensToString($this->tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); $this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); + $this->assertEquals("img[alt= ]", $this->tokensToString($this->tokenizer->tokenize('img[alt=""]')), '->tokenize() lexes an input string and returns an array of tokens'); } /** From 3195122905f96502290407f6a04c4ed6ea94c3bc Mon Sep 17 00:00:00 2001 From: srsbiz Date: Mon, 31 Dec 2012 10:36:11 +0100 Subject: [PATCH 06/14] [HttpFoundation] Check if required shell functions for `FileBinaryMimeTypeGuesser` are not disabled --- .../HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php index 115d95deef..bf30fe8124 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php @@ -28,8 +28,9 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface */ public static function isSupported() { - return !strstr(PHP_OS, 'WIN'); + return !defined('PHP_WINDOWS_VERSION_BUILD') && function_exists('passthru') && function_exists('escapeshellarg'); } + /** * Guesses the mime type of the file with the given path * From 1d362b884937a6efac6c3ab3f39160e4080e7cf5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 7 Jan 2013 22:32:53 +0100 Subject: [PATCH 07/14] [DependencyInjection] fixed a bug where the strict flag on references were lost (closes #6607) --- .../Compiler/ResolveInvalidReferencesPass.php | 2 +- .../Compiler/ResolveInvalidReferencesPassTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php index 66e217146b..4327fdacf1 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php @@ -88,7 +88,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface // resolve invalid behavior if ($exists && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - $arguments[$k] = new Reference($id); + $arguments[$k] = new Reference($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $argument->isStrict()); } elseif (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { $arguments[$k] = null; } elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPassTest.php b/tests/Symfony/Tests/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPassTest.php index 6c8f312495..be5cdb0313 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPassTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPassTest.php @@ -61,6 +61,20 @@ class ResolveInvalidReferencesPassTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array(), $def->getProperties()); } + public function testStrictFlagIsPreserved() + { + $container = new ContainerBuilder(); + $container->register('bar'); + $def = $container + ->register('foo') + ->addArgument(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE, false)) + ; + + $this->process($container); + + $this->assertFalse($def->getArgument(0)->isStrict()); + } + protected function process(ContainerBuilder $container) { $pass = new ResolveInvalidReferencesPass(); From ae3d4541a942118413bc89b19a802b560a924a6d Mon Sep 17 00:00:00 2001 From: Douglas Greenshields Date: Mon, 7 Jan 2013 22:34:59 +0000 Subject: [PATCH 08/14] [Form] corrected source node for a Danish translation --- .../Component/Form/Resources/translations/validators.da.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Resources/translations/validators.da.xlf b/src/Symfony/Component/Form/Resources/translations/validators.da.xlf index 9663cb6f17..c2dd4601f9 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.da.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.da.xlf @@ -11,7 +11,7 @@ Den oploadede fil var for stor. Opload venligst en mindre fil. - The CSRF token is invalid. + The CSRF token is invalid. Please try to resubmit the form. CSRF nøglen er ugyldig. From 8da2b412b4380f7ef439d17eb9daf0c912539403 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 8 Jan 2013 02:14:26 +0100 Subject: [PATCH 09/14] [TwigBundle] There is no CSS visibility of display, should be visible instead --- .../TwigBundle/Resources/views/Exception/trace.html.twig | 4 ++-- .../TwigBundle/Resources/views/Exception/traces.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig index cc2e0ddf22..5df02f1b80 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig @@ -12,8 +12,8 @@ in {{ trace.file|format_file(trace.line) }}  {% spaceless %} - - - + + - + + {% endspaceless %}
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig index da0b5b8dd1..5ee11ee836 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig @@ -5,8 +5,8 @@ {{ exception.class|abbr_class }}: {{ exception.message|e|replace({"\n": '
'})|format_file_from_text }}  {% spaceless %} - - - + + - + + {% endspaceless %} From 55aa0120cf2193355b74eec509e216123e74d73d Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 8 Jan 2013 11:08:32 +0100 Subject: [PATCH 10/14] [Form] Fixed EntityChoiceList when loading objects with negative integer IDs --- .../Form/ChoiceList/EntityChoiceList.php | 19 +++++++- .../Form/ChoiceList/EntityChoiceListTest.php | 43 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php index 2e385a343f..e34c3e5bf4 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php @@ -329,7 +329,7 @@ class EntityChoiceList extends ObjectChoiceList protected function createIndex($entity) { if ($this->idAsIndex) { - return current($this->getIdentifierValues($entity)); + return $this->fixIndex(current($this->getIdentifierValues($entity))); } return parent::createIndex($entity); @@ -355,6 +355,23 @@ class EntityChoiceList extends ObjectChoiceList return parent::createValue($entity); } + /** + * {@inheritdoc} + */ + protected function fixIndex($index) + { + $index = parent::fixIndex($index); + + // If the ID is a single-field integer identifier, it is used as + // index. Replace any leading minus by underscore to make it a valid + // form name. + if ($this->idAsIndex && $index < 0) { + $index = strtr($index, '-', '_'); + } + + return $index; + } + /** * Loads the list with entities. */ diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php index 3a2e9bba9f..e93ab1078d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php @@ -312,4 +312,47 @@ class EntityChoiceListTest extends DoctrineOrmTestCase $this->assertSame(array(0 => $entity1, 1 => $entity2), $choiceList->getChoices()); } + + public function testMinusReplacedByUnderscoreInNegativeIntIds() + { + $entity1 = new SingleIdentEntity(-1, 'Foo'); + $entity2 = new SingleIdentEntity(1, 'Bar'); + + // Persist for managed state + $this->em->persist($entity1); + $this->em->persist($entity2); + $this->em->flush(); + + $choiceList = new EntityChoiceList( + $this->em, + self::SINGLE_IDENT_CLASS, + 'name' + ); + + $this->assertSame(array('_1' => $entity1, 1 => $entity2), $choiceList->getChoices()); + $this->assertSame(array('_1', 1), $choiceList->getIndicesForChoices(array($entity1, $entity2))); + $this->assertSame(array('_1', 1), $choiceList->getIndicesForValues(array('-1', '1'))); + } + + public function testMinusReplacedByUnderscoreIfNotLoaded() + { + $entity1 = new SingleIdentEntity(-1, 'Foo'); + $entity2 = new SingleIdentEntity(1, 'Bar'); + + // Persist for managed state + $this->em->persist($entity1); + $this->em->persist($entity2); + $this->em->flush(); + + $choiceList = new EntityChoiceList( + $this->em, + self::SINGLE_IDENT_CLASS, + 'name' + ); + + // no getChoices()! + + $this->assertSame(array('_1', 1), $choiceList->getIndicesForChoices(array($entity1, $entity2))); + $this->assertSame(array('_1', 1), $choiceList->getIndicesForValues(array('-1', '1'))); + } } From 2155719398132eb824280950dee3687377626ff5 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Tue, 8 Jan 2013 15:45:08 +0100 Subject: [PATCH 11/14] [Component] [Security] fixed PSR-2 coding violation in ClassUtilsTest class. --- .../Component/Security/Tests/Core/Util/ClassUtilsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Tests/Core/Util/ClassUtilsTest.php b/src/Symfony/Component/Security/Tests/Core/Util/ClassUtilsTest.php index 16378a646b..4266f21ed8 100644 --- a/src/Symfony/Component/Security/Tests/Core/Util/ClassUtilsTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Util/ClassUtilsTest.php @@ -6,7 +6,7 @@ namespace Symfony\Component\Security\Tests\Core\Util class ClassUtilsTest extends \PHPUnit_Framework_TestCase { - static public function dataGetClass() + public static function dataGetClass() { return array( array('stdClass', 'stdClass'), From 113271c2df924379fc72275f8c6514093e80eef0 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Tue, 8 Jan 2013 16:05:00 +0100 Subject: [PATCH 12/14] [Bundle] [FrameworkBundle] fixed indentation in esi.xml services file. --- src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml index 015afef397..d047196429 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml @@ -13,8 +13,8 @@ - - + + From 8ca1b805cea4d20339adf2e819688afa34e2182f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 8 Jan 2013 17:05:32 +0100 Subject: [PATCH 13/14] [Console] Make style formatter matching less greedy to avoid having to escape when not needed --- .../Component/Console/Formatter/OutputFormatter.php | 2 +- .../Console/Tests/Formatter/OutputFormatterTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index b16e8447cc..8c44e36fc3 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface /** * The pattern to phrase the format. */ - const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<).)*)#is'; + const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<(?:/?[a-z]|/>)).)*)#is'; private $decorated; private $styles = array(); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 33187a7d26..3fc4c8c361 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -73,6 +73,16 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase ); } + public function testStyleMatchingNotGreedy() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "(\033[32m>=2.0,<2.3\033[0m)", + $formatter->format('(>=2.0,<2.3)') + ); + } + public function testDeepNestedStyles() { $formatter = new OutputFormatter(true); From eb93e66aa72892b2a02c09e469a55cd889aeceb7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 8 Jan 2013 17:21:26 +0100 Subject: [PATCH 14/14] [Console] Fix style escaping parsing --- .../Component/Console/Formatter/OutputFormatter.php | 2 +- .../Console/Tests/Formatter/OutputFormatterTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 8c44e36fc3..2e7219b6df 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface /** * The pattern to phrase the format. */ - const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<(?:/?[a-z]|/>)).)*)#is'; + const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx'; private $decorated; private $styles = array(); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 3fc4c8c361..497630e87c 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -83,6 +83,16 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase ); } + public function testStyleEscaping() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "(\033[32mz>=2.0,format('('.$formatter->escape('z>=2.0,)') + ); + } + public function testDeepNestedStyles() { $formatter = new OutputFormatter(true);