From bde5a7f51a583bde8d8e30303e5df8c507b0b6a8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 8 Jan 2013 01:21:54 +0100 Subject: [PATCH 01/16] [HttpKernel] Clarify misleading comment in ExceptionListener --- .../Component/HttpKernel/EventListener/ExceptionListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 99c9fff351..399604b27d 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -89,7 +89,7 @@ class ExceptionListener implements EventSubscriberInterface // set handling to false otherwise it wont be able to handle further more $handling = false; - // re-throw the exception as this is a catch-all + // re-throw the exception from within HttpKernel as this is a catch-all return; } From b33d5bc352f7a97b6771e61fa1a0d8b087a7145d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 9 Jan 2013 09:51:07 +0100 Subject: [PATCH 02/16] removed the .gitattributes files (closes #6605, reverts #5674) --- src/Symfony/Bridge/Doctrine/.gitattributes | 2 -- src/Symfony/Bridge/Monolog/.gitattributes | 2 -- src/Symfony/Bridge/Propel1/.gitattributes | 2 -- src/Symfony/Bridge/Swiftmailer/.gitattributes | 2 -- src/Symfony/Bridge/Twig/.gitattributes | 2 -- src/Symfony/Bundle/FrameworkBundle/.gitattributes | 2 -- src/Symfony/Bundle/SecurityBundle/.gitattributes | 2 -- src/Symfony/Bundle/TwigBundle/.gitattributes | 2 -- src/Symfony/Bundle/WebProfilerBundle/.gitattributes | 2 -- src/Symfony/Component/BrowserKit/.gitattributes | 2 -- src/Symfony/Component/ClassLoader/.gitattributes | 2 -- src/Symfony/Component/Config/.gitattributes | 2 -- src/Symfony/Component/Console/.gitattributes | 2 -- src/Symfony/Component/CssSelector/.gitattributes | 2 -- src/Symfony/Component/DependencyInjection/.gitattributes | 2 -- src/Symfony/Component/DomCrawler/.gitattributes | 2 -- src/Symfony/Component/EventDispatcher/.gitattributes | 2 -- src/Symfony/Component/Filesystem/.gitattributes | 2 -- src/Symfony/Component/Finder/.gitattributes | 2 -- src/Symfony/Component/Form/.gitattributes | 2 -- src/Symfony/Component/HttpFoundation/.gitattributes | 2 -- src/Symfony/Component/HttpKernel/.gitattributes | 2 -- src/Symfony/Component/Locale/.gitattributes | 2 -- src/Symfony/Component/OptionsResolver/.gitattributes | 2 -- src/Symfony/Component/Process/.gitattributes | 2 -- src/Symfony/Component/Routing/.gitattributes | 2 -- src/Symfony/Component/Security/.gitattributes | 2 -- src/Symfony/Component/Serializer/.gitattributes | 2 -- src/Symfony/Component/Templating/.gitattributes | 2 -- src/Symfony/Component/Translation/.gitattributes | 2 -- src/Symfony/Component/Validator/.gitattributes | 2 -- src/Symfony/Component/Yaml/.gitattributes | 2 -- 32 files changed, 64 deletions(-) delete mode 100644 src/Symfony/Bridge/Doctrine/.gitattributes delete mode 100644 src/Symfony/Bridge/Monolog/.gitattributes delete mode 100644 src/Symfony/Bridge/Propel1/.gitattributes delete mode 100644 src/Symfony/Bridge/Swiftmailer/.gitattributes delete mode 100644 src/Symfony/Bridge/Twig/.gitattributes delete mode 100644 src/Symfony/Bundle/FrameworkBundle/.gitattributes delete mode 100644 src/Symfony/Bundle/SecurityBundle/.gitattributes delete mode 100644 src/Symfony/Bundle/TwigBundle/.gitattributes delete mode 100644 src/Symfony/Bundle/WebProfilerBundle/.gitattributes delete mode 100644 src/Symfony/Component/BrowserKit/.gitattributes delete mode 100644 src/Symfony/Component/ClassLoader/.gitattributes delete mode 100644 src/Symfony/Component/Config/.gitattributes delete mode 100644 src/Symfony/Component/Console/.gitattributes delete mode 100644 src/Symfony/Component/CssSelector/.gitattributes delete mode 100644 src/Symfony/Component/DependencyInjection/.gitattributes delete mode 100644 src/Symfony/Component/DomCrawler/.gitattributes delete mode 100644 src/Symfony/Component/EventDispatcher/.gitattributes delete mode 100644 src/Symfony/Component/Filesystem/.gitattributes delete mode 100644 src/Symfony/Component/Finder/.gitattributes delete mode 100644 src/Symfony/Component/Form/.gitattributes delete mode 100644 src/Symfony/Component/HttpFoundation/.gitattributes delete mode 100644 src/Symfony/Component/HttpKernel/.gitattributes delete mode 100644 src/Symfony/Component/Locale/.gitattributes delete mode 100644 src/Symfony/Component/OptionsResolver/.gitattributes delete mode 100644 src/Symfony/Component/Process/.gitattributes delete mode 100644 src/Symfony/Component/Routing/.gitattributes delete mode 100644 src/Symfony/Component/Security/.gitattributes delete mode 100644 src/Symfony/Component/Serializer/.gitattributes delete mode 100644 src/Symfony/Component/Templating/.gitattributes delete mode 100644 src/Symfony/Component/Translation/.gitattributes delete mode 100644 src/Symfony/Component/Validator/.gitattributes delete mode 100644 src/Symfony/Component/Yaml/.gitattributes diff --git a/src/Symfony/Bridge/Doctrine/.gitattributes b/src/Symfony/Bridge/Doctrine/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bridge/Doctrine/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bridge/Monolog/.gitattributes b/src/Symfony/Bridge/Monolog/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bridge/Monolog/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bridge/Propel1/.gitattributes b/src/Symfony/Bridge/Propel1/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bridge/Propel1/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bridge/Swiftmailer/.gitattributes b/src/Symfony/Bridge/Swiftmailer/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bridge/Swiftmailer/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bridge/Twig/.gitattributes b/src/Symfony/Bridge/Twig/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bridge/Twig/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bundle/FrameworkBundle/.gitattributes b/src/Symfony/Bundle/FrameworkBundle/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bundle/SecurityBundle/.gitattributes b/src/Symfony/Bundle/SecurityBundle/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bundle/SecurityBundle/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bundle/TwigBundle/.gitattributes b/src/Symfony/Bundle/TwigBundle/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bundle/TwigBundle/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Bundle/WebProfilerBundle/.gitattributes b/src/Symfony/Bundle/WebProfilerBundle/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Bundle/WebProfilerBundle/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/BrowserKit/.gitattributes b/src/Symfony/Component/BrowserKit/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/BrowserKit/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/ClassLoader/.gitattributes b/src/Symfony/Component/ClassLoader/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/ClassLoader/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Config/.gitattributes b/src/Symfony/Component/Config/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Config/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Console/.gitattributes b/src/Symfony/Component/Console/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Console/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/CssSelector/.gitattributes b/src/Symfony/Component/CssSelector/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/CssSelector/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/DependencyInjection/.gitattributes b/src/Symfony/Component/DependencyInjection/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/DependencyInjection/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/DomCrawler/.gitattributes b/src/Symfony/Component/DomCrawler/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/DomCrawler/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/EventDispatcher/.gitattributes b/src/Symfony/Component/EventDispatcher/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/EventDispatcher/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Filesystem/.gitattributes b/src/Symfony/Component/Filesystem/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Filesystem/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Finder/.gitattributes b/src/Symfony/Component/Finder/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Finder/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Form/.gitattributes b/src/Symfony/Component/Form/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Form/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/HttpFoundation/.gitattributes b/src/Symfony/Component/HttpFoundation/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/HttpFoundation/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/HttpKernel/.gitattributes b/src/Symfony/Component/HttpKernel/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/HttpKernel/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Locale/.gitattributes b/src/Symfony/Component/Locale/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Locale/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/OptionsResolver/.gitattributes b/src/Symfony/Component/OptionsResolver/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/OptionsResolver/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Process/.gitattributes b/src/Symfony/Component/Process/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Process/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Routing/.gitattributes b/src/Symfony/Component/Routing/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Routing/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Security/.gitattributes b/src/Symfony/Component/Security/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Security/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Serializer/.gitattributes b/src/Symfony/Component/Serializer/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Serializer/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Templating/.gitattributes b/src/Symfony/Component/Templating/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Templating/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Translation/.gitattributes b/src/Symfony/Component/Translation/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Translation/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Validator/.gitattributes b/src/Symfony/Component/Validator/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Validator/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/src/Symfony/Component/Yaml/.gitattributes b/src/Symfony/Component/Yaml/.gitattributes deleted file mode 100644 index 80481513cf..0000000000 --- a/src/Symfony/Component/Yaml/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore From 34def9f94ff54a1b30a5608f9d069a4fb41e917f Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Thu, 10 Jan 2013 12:41:51 +0800 Subject: [PATCH 03/16] Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5. Optionally use the new IntlDateFormatter::setTimeZone() method if it exists. --- .../Component/Form/Extension/Core/Type/DateType.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 1e44296d40..0cdedd817c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -263,7 +263,11 @@ class DateType extends AbstractType $pattern = $formatter->getPattern(); $timezone = $formatter->getTimezoneId(); - $formatter->setTimezoneId(\DateTimeZone::UTC); + if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + $formatter->setTimeZone(\DateTimeZone::UTC); + } else { + $formatter->setTimeZoneId(\DateTimeZone::UTC); + } if (preg_match($regex, $pattern, $matches)) { $formatter->setPattern($matches[0]); @@ -277,7 +281,11 @@ class DateType extends AbstractType $formatter->setPattern($pattern); } - $formatter->setTimezoneId($timezone); + if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + $formatter->setTimeZone($timezone); + } else { + $formatter->setTimeZoneId($timezone); + } return $timestamps; } From 4991607f00f2e1f1b8101ef19a26ec8b31a75be2 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Thu, 10 Jan 2013 12:41:59 +0800 Subject: [PATCH 04/16] Fix version_compare() calls for PHP 5.5. Until PHP 5.5 hits beta, the version number for Git builds is still 5.5.0-dev, which is less than 5.5.0alpha1 according to version_compare(). This means that the branches for 5.5 aren't being executed on 5.5 snapshots at present. --- .../Form/Extension/Core/Type/DateType.php | 4 +-- .../Locale/Stub/StubIntlDateFormatter.php | 6 ++-- .../Tests/Stub/StubIntlDateFormatterTest.php | 36 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 0cdedd817c..352d7b2bc8 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -263,7 +263,7 @@ class DateType extends AbstractType $pattern = $formatter->getPattern(); $timezone = $formatter->getTimezoneId(); - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { $formatter->setTimeZone(\DateTimeZone::UTC); } else { $formatter->setTimeZoneId(\DateTimeZone::UTC); @@ -281,7 +281,7 @@ class DateType extends AbstractType $formatter->setPattern($pattern); } - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { $formatter->setTimeZone($timezone); } else { $formatter->setTimeZoneId($timezone); diff --git a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php index 33e12a2d0c..5d8768d3bb 100644 --- a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php +++ b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php @@ -188,7 +188,7 @@ class StubIntlDateFormatter $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; } elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=') && !is_int($timestamp)) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=') && !is_int($timestamp)) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); } } @@ -349,7 +349,7 @@ class StubIntlDateFormatter } // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { return date_default_timezone_get(); } @@ -511,7 +511,7 @@ class StubIntlDateFormatter { if (null === $timeZoneId) { // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { $timeZoneId = date_default_timezone_get(); } else { // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will diff --git a/src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php b/src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php index a7d2c8c710..a6291e6e24 100644 --- a/src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php +++ b/src/Symfony/Component/Locale/Tests/Stub/StubIntlDateFormatterTest.php @@ -43,7 +43,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } else { $this->assertNull($formatter->getTimeZoneId()); @@ -56,7 +56,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } else { $this->assertNull($formatter->getTimeZoneId()); @@ -367,7 +367,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function formatErrorProvider() { // With PHP 5.5 IntlDateFormatter accepts empty values ('0') - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { return array( array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR') ); @@ -435,7 +435,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase ); // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC - if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { // When time zone not exists, uses UTC by default $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00'); @@ -452,7 +452,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('Pacific/Fiji'); } else { $formatter->setTimeZoneId('Pacific/Fiji'); @@ -466,7 +466,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('Pacific/Fiji'); } else { $formatter->setTimeZoneId('Pacific/Fiji'); @@ -480,7 +480,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+03:00'); } else { $formatter->setTimeZoneId('GMT+03:00'); @@ -494,7 +494,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+03:00'); } else { $formatter->setTimeZoneId('GMT+03:00'); @@ -530,7 +530,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable() { - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('StubIntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } @@ -553,7 +553,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function testFormatWithDefaultTimezoneStubShouldUseDefaultDateTimeZoneVariable() { - if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('Only in PHP 5.5 StubIntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); } @@ -583,7 +583,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase */ public function testFormatWithDefaultTimezoneIntlShouldUseTheTzEnvironmentVariableWhenAvailable() { - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } @@ -612,7 +612,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase */ public function testFormatWithDefaultTimezoneIntlShouldUseDefaultDateTimeZoneVariable() { - if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); } @@ -1131,7 +1131,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone($timeZoneId); } else { $formatter->setTimeZoneId($timeZoneId); @@ -1148,7 +1148,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone($timeZoneId); } else { $formatter->setTimeZoneId($timeZoneId); @@ -1167,7 +1167,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase ); // When time zone not exists, uses UTC by default - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $data[] = array('GMT-0300', 'UTC'); $data[] = array('Foo/Bar', 'UTC'); $data[] = array('GMT+00:AA', 'UTC'); @@ -1189,7 +1189,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+00:30'); } else { $formatter->setTimeZoneId('GMT+00:30'); @@ -1201,7 +1201,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+00:30'); } else { $formatter->setTimeZoneId('GMT+00:30'); @@ -1228,7 +1228,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase protected function createDateTime($timestamp = null) { - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $timeZone = date_default_timezone_get(); } else { $timeZone = getenv('TZ') ?: 'UTC'; From 880da01c49a9255f5022ab7e18bca38c18f56370 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 8 Jan 2013 13:27:17 +0100 Subject: [PATCH 05/16] [Process] In edge cases `getcwd()` can return `false`, then `proc_open()` should get `null` to use default value (the working dir of the current PHP process) --- src/Symfony/Component/Process/Process.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 7c6d135534..cf553ee11a 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -53,7 +53,7 @@ class Process } $this->commandline = $commandline; - $this->cwd = null === $cwd ? getcwd() : $cwd; + $this->cwd = $cwd; if (null !== $env) { $this->env = array(); foreach ($env as $key => $value) { @@ -359,6 +359,13 @@ class Process */ public function getWorkingDirectory() { + // This is for BC only + if (null === $this->cwd) { + // getcwd() will return false if any one of the parent directories does not have + // the readable or search mode set, even if the current directory does + return getcwd() ?: null; + } + return $this->cwd; } From 802426272f60c0987be874598b81ed4335790953 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Fri, 11 Jan 2013 00:31:43 +0000 Subject: [PATCH 06/16] Removed underscores from test method names to be consistent with other components. It is more common to use fully camel-cased names for test methods. Only some of the test methods are called with underscore notation. To avoid confusion it is better to be consistent. --- .../Tests/Form/Type/EntityTypeTest.php | 8 ++-- .../Tests/GenericEventTest.php | 2 +- .../ArrayToPartsTransformerTest.php | 8 ++-- .../DateTimeToArrayTransformerTest.php | 30 ++++++------- ...teTimeToLocalizedStringTransformerTest.php | 12 ++--- .../DateTimeToStringTransformerTest.php | 8 ++-- .../DateTimeToTimestampTransformerTest.php | 8 ++-- ...ntegerToLocalizedStringTransformerTest.php | 2 +- .../MoneyToLocalizedStringTransformerTest.php | 4 +- ...NumberToLocalizedStringTransformerTest.php | 8 ++-- ...ercentToLocalizedStringTransformerTest.php | 4 +- .../ValueToDuplicatesTransformerTest.php | 10 ++--- .../Extension/Core/Type/DateTimeTypeTest.php | 22 +++++----- .../Extension/Core/Type/DateTypeTest.php | 8 ++-- .../Extension/Core/Type/TimeTypeTest.php | 44 +++++++++---------- .../Form/Tests/Util/PropertyPathTest.php | 20 ++++----- .../Handler/NativeFileSessionHandlerTest.php | 6 +-- .../Process/Tests/PhpExecutableFinderTest.php | 2 +- .../Validator/Tests/ValidatorTest.php | 8 ++-- 19 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 3e67e8bed6..ffb33e3174 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -350,7 +350,7 @@ class EntityTypeTest extends TypeTestCase $this->assertSame(array('1', '3'), $field->getClientData()); } - public function testSubmitMultipleNonExpandedSingleIdentifier_existingData() + public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData() { $entity1 = new SingleIdentEntity(1, 'Foo'); $entity2 = new SingleIdentEntity(2, 'Bar'); @@ -407,7 +407,7 @@ class EntityTypeTest extends TypeTestCase $this->assertSame(array('0', '2'), $field->getClientData()); } - public function testSubmitMultipleNonExpandedCompositeIdentifier_existingData() + public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData() { $entity1 = new CompositeIdentEntity(10, 20, 'Foo'); $entity2 = new CompositeIdentEntity(30, 40, 'Bar'); @@ -583,7 +583,7 @@ class EntityTypeTest extends TypeTestCase $this->assertEquals(array(2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); } - public function testDisallowChoicesThatAreNotIncluded_choicesSingleIdentifier() + public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier() { $entity1 = new SingleIdentEntity(1, 'Foo'); $entity2 = new SingleIdentEntity(2, 'Bar'); @@ -604,7 +604,7 @@ class EntityTypeTest extends TypeTestCase $this->assertNull($field->getData()); } - public function testDisallowChoicesThatAreNotIncluded_choicesCompositeIdentifier() + public function testDisallowChoicesThatAreNotIncludedChoicesCompositeIdentifier() { $entity1 = new CompositeIdentEntity(10, 20, 'Foo'); $entity2 = new CompositeIdentEntity(30, 40, 'Bar'); diff --git a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php index 179e9a34ed..8dd6f5b419 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php @@ -48,7 +48,7 @@ class GenericEventTest extends \PHPUnit_Framework_TestCase parent::tearDown(); } - public function test__construct() + public function testConstruct() { $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php index 0ac8f44bae..1f946e4b7e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php @@ -57,7 +57,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase $this->assertSame($output, $this->transformer->transform($input)); } - public function testTransform_empty() + public function testTransformEmpty() { $output = array( 'first' => null, @@ -102,7 +102,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase $this->assertSame($output, $this->transformer->reverseTransform($input)); } - public function testReverseTransform_completelyEmpty() + public function testReverseTransformCompletelyEmpty() { $input = array( 'first' => '', @@ -112,7 +112,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase $this->assertNull($this->transformer->reverseTransform($input)); } - public function testReverseTransform_completelyNull() + public function testReverseTransformCompletelyNull() { $input = array( 'first' => null, @@ -125,7 +125,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyNull() + public function testReverseTransformPartiallyNull() { $input = array( 'first' => array( diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php index 82234d28ba..3d33e01144 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php @@ -33,7 +33,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertSame($output, $transformer->transform($input)); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new DateTimeToArrayTransformer(); @@ -49,7 +49,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertSame($output, $transformer->transform(null)); } - public function testTransform_empty_withFields() + public function testTransformEmptyWithFields() { $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second')); @@ -62,7 +62,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertSame($output, $transformer->transform(null)); } - public function testTransform_withFields() + public function testTransformWithFields() { $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second')); @@ -78,7 +78,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertSame($output, $transformer->transform($input)); } - public function testTransform_withPadding() + public function testTransformWithPadding() { $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true); @@ -96,7 +96,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertSame($output, $transformer->transform($input)); } - public function testTransform_differentTimezones() + public function testTransformDifferentTimezones() { $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); @@ -161,7 +161,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); } - public function testReverseTransform_completelyEmpty() + public function testReverseTransformCompletelyEmpty() { $transformer = new DateTimeToArrayTransformer(); @@ -177,7 +177,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase $this->assertNull($transformer->reverseTransform($input)); } - public function testReverseTransform_completelyEmpty_subsetOfFields() + public function testReverseTransformCompletelyEmptySubsetOfFields() { $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day')); @@ -193,7 +193,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyEmpty_year() + public function testReverseTransformPartiallyEmptyYear() { $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform(array( @@ -208,7 +208,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyEmpty_month() + public function testReverseTransformPartiallyEmptyMonth() { $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform(array( @@ -223,7 +223,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyEmpty_day() + public function testReverseTransformPartiallyEmptyDay() { $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform(array( @@ -238,7 +238,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyEmpty_hour() + public function testReverseTransformPartiallyEmptyHour() { $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform(array( @@ -253,7 +253,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyEmpty_minute() + public function testReverseTransformPartiallyEmptyMinute() { $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform(array( @@ -268,7 +268,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyEmpty_second() + public function testReverseTransformPartiallyEmptySecond() { $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform(array( @@ -280,14 +280,14 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase )); } - public function testReverseTransform_null() + public function testReverseTransformNull() { $transformer = new DateTimeToArrayTransformer(); $this->assertNull($transformer->reverseTransform(null)); } - public function testReverseTransform_differentTimezones() + public function testReverseTransformDifferentTimezones() { $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index f776f5e12d..25d582cfcb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -121,14 +121,14 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase $this->assertEquals('Feb 3, 2010 4:05 AM', $transformer->transform($this->dateTime)); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new DateTimeToLocalizedStringTransformer(); $this->assertSame('', $transformer->transform(null)); } - public function testTransform_differentTimezones() + public function testTransformWithDifferentTimezones() { $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); @@ -140,7 +140,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase $this->assertEquals($dateTime->format('d.m.Y H:i'), $transformer->transform($input)); } - public function testTransform_differentPatterns() + public function testTransformWithDifferentPatterns() { $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); @@ -206,7 +206,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010 04:05 AM')); } - public function testReverseTransform_differentTimezones() + public function testReverseTransformWithDifferentTimezones() { $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); @@ -216,14 +216,14 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase $this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010 04:05')); } - public function testReverseTransform_differentPatterns() + public function testReverseTransformWithDifferentPatterns() { $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06')); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $transformer = new DateTimeToLocalizedStringTransformer(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index aabad81f56..18137fef04 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -79,14 +79,14 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase $this->assertEquals($output, $transformer->transform($input)); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new DateTimeToStringTransformer(); $this->assertSame('', $transformer->transform(null)); } - public function testTransform_differentTimezones() + public function testTransformWithDifferentTimezones() { $transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s'); @@ -134,14 +134,14 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $reverseTransformer = new DateTimeToStringTransformer(); $this->assertNull($reverseTransformer->reverseTransform('')); } - public function testReverseTransform_differentTimezones() + public function testReverseTransformWithDifferentTimezones() { $reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php index 3307fb195e..5c4be26f54 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php @@ -25,14 +25,14 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase $this->assertEquals($output, $transformer->transform($input)); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new DateTimeToTimestampTransformer(); $this->assertNull($transformer->transform(null)); } - public function testTransform_differentTimezones() + public function testTransformWithDifferentTimezones() { $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); @@ -75,14 +75,14 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $reverseTransformer = new DateTimeToTimestampTransformer(); $this->assertNull($reverseTransformer->reverseTransform(null)); } - public function testReverseTransform_differentTimezones() + public function testReverseTransformWithDifferentTimezones() { $reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index a33f24003c..c3c28bd5e7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -32,7 +32,7 @@ class IntegerToLocalizedStringTransformerTest extends LocalizedTestCase $this->assertEquals(12345, $transformer->reverseTransform('12345,912')); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $transformer = new IntegerToLocalizedStringTransformer(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php index be7b3d47f8..8ff5c16ac0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -38,7 +38,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase $transformer->transform('abcd'); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new MoneyToLocalizedStringTransformer(); @@ -61,7 +61,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase $transformer->reverseTransform(12345); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $transformer = new MoneyToLocalizedStringTransformer(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 96ece87f30..9ce30d6a8a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -32,7 +32,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase $this->assertEquals('12345,912', $transformer->transform(12345.9123)); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new NumberToLocalizedStringTransformer(); @@ -75,7 +75,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase $this->assertEquals(12345.912, $transformer->reverseTransform('12345,912')); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $transformer = new NumberToLocalizedStringTransformer(); @@ -129,7 +129,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ - public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot_noGroupSep() + public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() { if ($this->isLowerThanIcuVersion('4.7')) { $this->markTestSkipped('Please upgrade ICU version to 4.7+'); @@ -185,7 +185,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ - public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma_noGroupSep() + public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() { if ($this->isLowerThanIcuVersion('4.7')) { $this->markTestSkipped('Please upgrade ICU version to 4.7+'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php index 2b38d46575..6cbca5a402 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -32,7 +32,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase $this->assertEquals('200', $transformer->transform(2)); } - public function testTransform_empty() + public function testTransformEmpty() { $transformer = new PercentToLocalizedStringTransformer(); @@ -66,7 +66,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase $this->assertEquals(2, $transformer->reverseTransform('200')); } - public function testReverseTransform_empty() + public function testReverseTransformEmpty() { $transformer = new PercentToLocalizedStringTransformer(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php index 520a4dc5f2..b8952c6850 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php @@ -38,7 +38,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase $this->assertSame($output, $this->transformer->transform('Foo')); } - public function testTransform_empty() + public function testTransformEmpty() { $output = array( 'a' => null, @@ -60,7 +60,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase $this->assertSame('Foo', $this->transformer->reverseTransform($input)); } - public function testReverseTransform_completelyEmpty() + public function testReverseTransformCompletelyEmpty() { $input = array( 'a' => '', @@ -71,7 +71,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase $this->assertNull($this->transformer->reverseTransform($input)); } - public function testReverseTransform_completelyNull() + public function testReverseTransformCompletelyNull() { $input = array( 'a' => null, @@ -85,7 +85,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_partiallyNull() + public function testReverseTransformPartiallyNull() { $input = array( 'a' => 'Foo', @@ -99,7 +99,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransform_differences() + public function testReverseTransformDifferences() { $input = array( 'a' => 'Foo', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index e394315f3e..00e5849767 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\FormError; class DateTimeTypeTest extends LocalizedTestCase { - public function testSubmit_dateTime() + public function testSubmitDateTime() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'UTC', @@ -42,7 +42,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertDateTimeEquals($dateTime, $form->getData()); } - public function testSubmit_string() + public function testSubmitString() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'UTC', @@ -67,7 +67,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertEquals('2010-06-02 03:04:00', $form->getData()); } - public function testSubmit_timestamp() + public function testSubmitTimestamp() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'UTC', @@ -94,7 +94,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertEquals($dateTime->format('U'), $form->getData()); } - public function testSubmit_withSeconds() + public function testSubmitWithSeconds() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'UTC', @@ -125,7 +125,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertDateTimeEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData()); } - public function testSubmit_differentTimezones() + public function testSubmitDifferentTimezones() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'America/New_York', @@ -156,7 +156,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertEquals($dateTime->format('Y-m-d H:i:s'), $form->getData()); } - public function testSubmit_differentTimezonesDateTime() + public function testSubmitDifferentTimezonesDateTime() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'America/New_York', @@ -175,7 +175,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData()); } - public function testSubmit_stringSingleText() + public function testSubmitStringSingleText() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'UTC', @@ -190,7 +190,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData()); } - public function testSubmit_stringSingleText_withSeconds() + public function testSubmitStringSingleTextWithSeconds() { $form = $this->factory->create('datetime', null, array( 'model_timezone' => 'UTC', @@ -206,7 +206,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData()); } - public function testSubmit_differentPattern() + public function testSubmitDifferentPattern() { $form = $this->factory->create('datetime', null, array( 'date_format' => 'MM*yyyy*dd', @@ -314,7 +314,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); } - public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired() + public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired() { $form = $this->factory->create('datetime', null, array( 'required' => false, @@ -336,7 +336,7 @@ class DateTimeTypeTest extends LocalizedTestCase $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); } - public function testPassEmptyValueAsPartialArray_addNullIfRequired() + public function testPassEmptyValueAsPartialArrayAddNullIfRequired() { $form = $this->factory->create('datetime', null, array( 'required' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index fdff501668..67fe3da938 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -313,7 +313,7 @@ class DateTypeTest extends LocalizedTestCase )); } - public function testSetData_differentTimezones() + public function testSetDataWithDifferentTimezones() { $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, @@ -328,7 +328,7 @@ class DateTypeTest extends LocalizedTestCase $this->assertEquals('01.06.2010', $form->getViewData()); } - public function testSetData_differentTimezonesDateTime() + public function testSetDataWithDifferentTimezonesDateTime() { $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, @@ -625,7 +625,7 @@ class DateTypeTest extends LocalizedTestCase $this->assertSame('Empty day', $view['day']->vars['empty_value']); } - public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired() + public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired() { $form = $this->factory->create('date', null, array( 'required' => false, @@ -641,7 +641,7 @@ class DateTypeTest extends LocalizedTestCase $this->assertSame('Empty day', $view['day']->vars['empty_value']); } - public function testPassEmptyValueAsPartialArray_addNullIfRequired() + public function testPassEmptyValueAsPartialArrayAddNullIfRequired() { $form = $this->factory->create('date', null, array( 'required' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index 1f51a9dc35..4f02733395 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\FormError; class TimeTypeTest extends LocalizedTestCase { - public function testSubmit_dateTime() + public function testSubmitDateTime() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -37,7 +37,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals($input, $form->getViewData()); } - public function testSubmit_string() + public function testSubmitString() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -56,7 +56,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals($input, $form->getViewData()); } - public function testSubmit_timestamp() + public function testSubmitTimestamp() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -77,7 +77,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals($input, $form->getViewData()); } - public function testSubmit_array() + public function testSubmitArray() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -96,7 +96,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals($input, $form->getViewData()); } - public function testSubmit_datetimeSingleText() + public function testSubmitDatetimeSingleText() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -111,7 +111,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals('03:04', $form->getViewData()); } - public function testSubmit_arraySingleText() + public function testSubmitArraySingleText() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -131,7 +131,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals('03:04', $form->getViewData()); } - public function testSubmit_arraySingleTextWithSeconds() + public function testSubmitArraySingleTextWithSeconds() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -153,7 +153,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals('03:04:05', $form->getViewData()); } - public function testSubmit_stringSingleText() + public function testSubmitStringSingleText() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -168,7 +168,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals('03:04', $form->getViewData()); } - public function testSetData_withSeconds() + public function testSetDataWithSeconds() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'UTC', @@ -182,7 +182,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData()); } - public function testSetData_differentTimezones() + public function testSetDataDifferentTimezones() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'America/New_York', @@ -208,7 +208,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertEquals($displayedData, $form->getViewData()); } - public function testSetData_differentTimezonesDateTime() + public function testSetDataDifferentTimezonesDateTime() { $form = $this->factory->create('time', null, array( 'model_timezone' => 'America/New_York', @@ -249,7 +249,7 @@ class TimeTypeTest extends LocalizedTestCase ), $view['hour']->vars['choices']); } - public function testIsMinuteWithinRange_returnsTrueIfWithin() + public function testIsMinuteWithinRangeReturnsTrueIfWithin() { $form = $this->factory->create('time', null, array( 'minutes' => array(6, 7), @@ -263,7 +263,7 @@ class TimeTypeTest extends LocalizedTestCase ), $view['minute']->vars['choices']); } - public function testIsSecondWithinRange_returnsTrueIfWithin() + public function testIsSecondWithinRangeReturnsTrueIfWithin() { $form = $this->factory->create('time', null, array( 'seconds' => array(6, 7), @@ -278,7 +278,7 @@ class TimeTypeTest extends LocalizedTestCase ), $view['second']->vars['choices']); } - public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty() + public function testIsPartiallyFilledReturnsFalseIfCompletelyEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -294,7 +294,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertFalse($form->isPartiallyFilled()); } - public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty_withSeconds() + public function testIsPartiallyFilledReturnsFalseIfCompletelyEmptyWithSeconds() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -312,7 +312,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertFalse($form->isPartiallyFilled()); } - public function testIsPartiallyFilled_returnsFalseIfCompletelyFilled() + public function testIsPartiallyFilledReturnsFalseIfCompletelyFilled() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -328,7 +328,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertFalse($form->isPartiallyFilled()); } - public function testIsPartiallyFilled_returnsFalseIfCompletelyFilled_withSeconds() + public function testIsPartiallyFilledReturnsFalseIfCompletelyFilledWithSeconds() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -346,7 +346,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertFalse($form->isPartiallyFilled()); } - public function testIsPartiallyFilled_returnsTrueIfChoiceAndHourEmpty() + public function testIsPartiallyFilledReturnsTrueIfChoiceAndHourEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -364,7 +364,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertTrue($form->isPartiallyFilled()); } - public function testIsPartiallyFilled_returnsTrueIfChoiceAndMinuteEmpty() + public function testIsPartiallyFilledReturnsTrueIfChoiceAndMinuteEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -382,7 +382,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertTrue($form->isPartiallyFilled()); } - public function testIsPartiallyFilled_returnsTrueIfChoiceAndSecondsEmpty() + public function testIsPartiallyFilledReturnsTrueIfChoiceAndSecondsEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); @@ -474,7 +474,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertSame('Empty second', $view['second']->vars['empty_value']); } - public function testPassEmptyValueAsPartialArray_addEmptyIfNotRequired() + public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired() { $form = $this->factory->create('time', null, array( 'required' => false, @@ -491,7 +491,7 @@ class TimeTypeTest extends LocalizedTestCase $this->assertSame('Empty second', $view['second']->vars['empty_value']); } - public function testPassEmptyValueAsPartialArray_addNullIfRequired() + public function testPassEmptyValueAsPartialArrayAddNullIfRequired() { $form = $this->factory->create('time', null, array( 'required' => true, diff --git a/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php b/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php index 7642def026..14610a03fb 100644 --- a/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php +++ b/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php @@ -393,7 +393,7 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException */ - public function testInvalidPropertyPath_noDotBeforeProperty() + public function testDotIsRequiredBeforeProperty() { new PropertyPath('[index]property'); } @@ -401,7 +401,7 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException */ - public function testInvalidPropertyPath_dotAtTheBeginning() + public function testDotCannotBePresentAtTheBeginning() { new PropertyPath('.property'); } @@ -409,7 +409,7 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException */ - public function testInvalidPropertyPath_unexpectedCharacters() + public function testUnexpectedCharacters() { new PropertyPath('property.$form'); } @@ -417,7 +417,7 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException */ - public function testInvalidPropertyPath_empty() + public function testPathCannotBeEmpty() { new PropertyPath(''); } @@ -425,7 +425,7 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException */ - public function testInvalidPropertyPath_null() + public function testPathCannotBeNull() { new PropertyPath(null); } @@ -433,31 +433,31 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase /** * @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException */ - public function testInvalidPropertyPath_false() + public function testPathCannotBeFalse() { new PropertyPath(false); } - public function testValidPropertyPath_zero() + public function testZeroIsValidPropertyPath() { new PropertyPath('0'); } - public function testGetParent_dot() + public function testGetParentWithDot() { $propertyPath = new PropertyPath('grandpa.parent.child'); $this->assertEquals(new PropertyPath('grandpa.parent'), $propertyPath->getParent()); } - public function testGetParent_index() + public function testGetParentWithIndex() { $propertyPath = new PropertyPath('grandpa.parent[child]'); $this->assertEquals(new PropertyPath('grandpa.parent'), $propertyPath->getParent()); } - public function testGetParent_noParent() + public function testGetParentWhenThereIsNoParent() { $propertyPath = new PropertyPath('path'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index de2c4939f0..20cefabf49 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; */ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase { - public function test__Construct() + public function testConstruct() { $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); @@ -42,7 +42,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase /** * @dataProvider savePathDataProvider */ - public function test__ConstructSavePath($savePath, $expectedSavePath, $path) + public function testConstructSavePath($savePath, $expectedSavePath, $path) { $handler = new NativeFileSessionHandler($savePath); $this->assertEquals($expectedSavePath, ini_get('session.save_path')); @@ -65,7 +65,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase /** * @expectedException \InvalidArgumentException */ - public function test__ConstructException() + public function testConstructException() { $handler = new NativeFileSessionHandler('something;invalid;with;too-many-args'); } diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index c632e31f74..99c4a1e7c9 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -21,7 +21,7 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase /** * tests find() with the env var PHP_PATH */ - public function testFindWithPHP_PATH() + public function testFindWithPhpPath() { if (defined('PHP_BINARY')) { $this->markTestSkipped('The PHP binary is easily available as of PHP 5.4'); diff --git a/src/Symfony/Component/Validator/Tests/ValidatorTest.php b/src/Symfony/Component/Validator/Tests/ValidatorTest.php index 20398e4e52..ad50d91a8b 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorTest.php @@ -39,7 +39,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->validator = null; } - public function testValidate_defaultGroup() + public function testValidateDefaultGroup() { $entity = new Entity(); $metadata = new ClassMetadata(get_class($entity)); @@ -62,7 +62,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($violations, $this->validator->validate($entity)); } - public function testValidate_oneGroup() + public function testValidateOneGroup() { $entity = new Entity(); $metadata = new ClassMetadata(get_class($entity)); @@ -85,7 +85,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($violations, $this->validator->validate($entity, 'Custom')); } - public function testValidate_multipleGroups() + public function testValidateMultipleGroups() { $entity = new Entity(); $metadata = new ClassMetadata(get_class($entity)); @@ -119,7 +119,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($violations, $result); } - public function testValidate_groupSequenceProvider() + public function testValidateGroupSequenceProvider() { $entity = new GroupSequenceProviderEntity(); $metadata = new ClassMetadata(get_class($entity)); From c7bfce9116c190a3ea0115c21830fab652f50323 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Fri, 11 Jan 2013 15:59:10 +0800 Subject: [PATCH 07/16] Fix version_compare() calls for PHP 5.5. Until PHP 5.5 hits beta, the version number for Git builds is still 5.5.0-dev, which is less than 5.5.0alpha1 according to version_compare(). This means that the branches for 5.5 aren't being executed on 5.5 snapshots at present. --- .../Core/ChoiceList/MonthChoiceList.php | 4 +-- .../Locale/Stub/StubIntlDateFormatter.php | 6 ++-- .../Locale/Stub/StubIntlDateFormatterTest.php | 36 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php index 477cb6e4e1..1eb61a755c 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/MonthChoiceList.php @@ -39,7 +39,7 @@ class MonthChoiceList extends PaddedChoiceList $pattern = $this->formatter->getPattern(); $timezone = $this->formatter->getTimezoneId(); - if (version_compare(phpversion(), '5.5.0alpha1', '<')) { + if (version_compare(phpversion(), '5.5.0-dev', '<')) { $this->formatter->setTimezoneId('UTC'); } else { $this->formatter->setTimezone('UTC'); @@ -57,7 +57,7 @@ class MonthChoiceList extends PaddedChoiceList $this->formatter->setPattern($pattern); } - if (version_compare(phpversion(), '5.5.0alpha1', '<')) { + if (version_compare(phpversion(), '5.5.0-dev', '<')) { $this->formatter->setTimezoneId($timezone); } else { $this->formatter->setTimezone($timezone); diff --git a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php index d64044710f..848858cd9b 100644 --- a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php +++ b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php @@ -188,7 +188,7 @@ class StubIntlDateFormatter $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; } elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=') && !is_int($timestamp)) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=') && !is_int($timestamp)) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); } } @@ -349,7 +349,7 @@ class StubIntlDateFormatter } // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { return date_default_timezone_get(); } @@ -513,7 +513,7 @@ class StubIntlDateFormatter { if (null === $timeZoneId) { // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method - if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) { + if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { $timeZoneId = date_default_timezone_get(); } else { // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will diff --git a/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php b/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php index ea6062546c..b00a9503f2 100644 --- a/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php +++ b/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php @@ -45,7 +45,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } else { $this->assertNull($formatter->getTimeZoneId()); @@ -58,7 +58,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $formatter = new \IntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } else { $this->assertNull($formatter->getTimeZoneId()); @@ -369,7 +369,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function formatErrorProvider() { // With PHP 5.5 IntlDateFormatter accepts empty values ('0') - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { return array( array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR') ); @@ -437,7 +437,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase ); // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC - if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { // When time zone not exists, uses UTC by default $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00'); @@ -454,7 +454,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('Pacific/Fiji'); } else { $formatter->setTimeZoneId('Pacific/Fiji'); @@ -468,7 +468,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('Pacific/Fiji'); } else { $formatter->setTimeZoneId('Pacific/Fiji'); @@ -482,7 +482,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+03:00'); } else { $formatter->setTimeZoneId('GMT+03:00'); @@ -496,7 +496,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter('zzzz'); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+03:00'); } else { $formatter->setTimeZoneId('GMT+03:00'); @@ -532,7 +532,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable() { - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('StubIntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } @@ -555,7 +555,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase public function testFormatWithDefaultTimezoneStubShouldUseDefaultDateTimeZoneVariable() { - if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('Only in PHP 5.5 StubIntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); } @@ -585,7 +585,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase */ public function testFormatWithDefaultTimezoneIntlShouldUseTheTzEnvironmentVariableWhenAvailable() { - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } @@ -614,7 +614,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase */ public function testFormatWithDefaultTimezoneIntlShouldUseDefaultDateTimeZoneVariable() { - if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if (!$this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); } @@ -1105,7 +1105,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone($timeZoneId); } else { $formatter->setTimeZoneId($timeZoneId); @@ -1122,7 +1122,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone($timeZoneId); } else { $formatter->setTimeZoneId($timeZoneId); @@ -1141,7 +1141,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase ); // When time zone not exists, uses UTC by default - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $data[] = array('GMT-0300', 'UTC'); $data[] = array('Foo/Bar', 'UTC'); $data[] = array('GMT+00:AA', 'UTC'); @@ -1163,7 +1163,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase { $formatter = $this->createStubFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+00:30'); } else { $formatter->setTimeZoneId('GMT+00:30'); @@ -1175,7 +1175,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase $this->skipIfIntlExtensionIsNotLoaded(); $formatter = $this->createIntlFormatter(); - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $formatter->setTimeZone('GMT+00:30'); } else { $formatter->setTimeZoneId('GMT+00:30'); @@ -1202,7 +1202,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase protected function createDateTime($timestamp = null) { - if ($this->isGreaterOrEqualThanPhpVersion('5.5.0alpha1')) { + if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $timeZone = date_default_timezone_get(); } else { $timeZone = getenv('TZ') ?: 'UTC'; From 9257b0371cee2aa208b3bd7fe9c3d1b71d768b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20PY?= Date: Fri, 11 Jan 2013 11:21:09 +0100 Subject: [PATCH 08/16] [Profiler] [Redis] Fix sort of profiler rows. --- .../HttpKernel/Profiler/RedisProfilerStorage.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php index 51c9f9c344..e981d75f61 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php @@ -60,7 +60,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface return array(); } - $profileList = explode("\n", $indexContent); + $profileList = array_reverse(explode("\n", $indexContent)); $result = array(); foreach ($profileList as $item) { @@ -78,7 +78,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface continue; } - $result[$itemToken] = array( + $result[] = array( 'token' => $itemToken, 'ip' => $itemIp, 'method' => $itemMethod, @@ -89,14 +89,6 @@ class RedisProfilerStorage implements ProfilerStorageInterface --$limit; } - usort($result, function($a, $b) { - if ($a['time'] === $b['time']) { - return 0; - } - - return $a['time'] > $b['time'] ? -1 : 1; - }); - return $result; } From dc2cc6b13c8664ed2ae97611d448f98d1cfae2b8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 11 Jan 2013 14:49:52 +0100 Subject: [PATCH 09/16] [Console] fixed input bug when the value of an option is empty (closes #6649, closes #6689) --- src/Symfony/Component/Console/Input/ArgvInput.php | 6 ++++-- .../Tests/Component/Console/Input/ArgvInputTest.php | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index afcbc320af..a4d09e7beb 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -210,12 +210,14 @@ class ArgvInput extends Input $option = $this->definition->getOption($name); - if (null === $value && $option->acceptValue()) { + if (null === $value && $option->acceptValue() && count($this->parsed)) { // if option accepts an optional or mandatory argument // let's see if there is one provided $next = array_shift($this->parsed); - if ('-' !== $next[0]) { + if (isset($next[0]) && '-' !== $next[0]) { $value = $next; + } elseif (empty($next)) { + $value = ''; } else { array_unshift($this->parsed, $next); } diff --git a/tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php b/tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php index 32c0393228..7b3ebccf4a 100644 --- a/tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php +++ b/tests/Symfony/Tests/Component/Console/Input/ArgvInputTest.php @@ -71,6 +71,18 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required value (with a space separator)'); + $input = new ArgvInput(array('cli.php', '-f', '')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); + $this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value'); + + $input = new ArgvInput(array('cli.php', '-f', '', 'foo')); + $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); + $this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an argument'); + + $input = new ArgvInput(array('cli.php', '-f', '', '-b')); + $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')))); + $this->assertEquals(array('foo' => '', 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an option'); + $input = new ArgvInput(array('cli.php', '-f', '-b', 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')))); $this->assertEquals(array('foo' => null, 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional value which is not present'); From 785d3655dd8e048e880e44465bf58f519a38e9aa Mon Sep 17 00:00:00 2001 From: "Johannes M. Schmitt" Date: Sat, 12 Jan 2013 11:09:29 +0100 Subject: [PATCH 10/16] fixes a bug when output/error output contains a % character --- .../Component/Process/Exception/ProcessFailedException.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Exception/ProcessFailedException.php b/src/Symfony/Component/Process/Exception/ProcessFailedException.php index a4540c0657..f778a362f9 100755 --- a/src/Symfony/Component/Process/Exception/ProcessFailedException.php +++ b/src/Symfony/Component/Process/Exception/ProcessFailedException.php @@ -30,8 +30,10 @@ class ProcessFailedException extends RuntimeException parent::__construct( sprintf( - 'The command "%s" failed.'."\n\nOutput:\n================\n".$process->getOutput()."\n\nError Output:\n================\n".$process->getErrorOutput(), - $process->getCommandLine() + 'The command "%s" failed.'."\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", + $process->getCommandLine(), + $process->getOutput(), + $process->getErrorOutput() ) ); From a62e04f8d18280d7e196d9657ab34b924be9a86c Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 8 Jan 2013 20:11:30 +0100 Subject: [PATCH 11/16] [Process] Fix docblocks, remove `return` from `PhpProcess#start()` as parent returns nothing, cleaned up `ExecutableFinder` --- .../Component/Process/ExecutableFinder.php | 21 ++++++------ src/Symfony/Component/Process/PhpProcess.php | 2 +- src/Symfony/Component/Process/Process.php | 33 ++++++++++--------- .../Process/Tests/AbstractProcessTest.php | 14 ++++++-- .../Tests/SigchildDisabledProcessTest.php | 20 ++++++----- .../Tests/SigchildEnabledProcessTest.php | 19 ++++++----- .../Process/Tests/SimpleProcessTest.php | 27 ++++++++++----- 7 files changed, 80 insertions(+), 56 deletions(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 087c94b0f2..5cc99c7692 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -19,22 +19,23 @@ namespace Symfony\Component\Process; */ class ExecutableFinder { - private static $isWindows; - private $suffixes = array('.exe', '.bat', '.cmd', '.com'); - public function __construct() - { - if (null === self::$isWindows) { - self::$isWindows = 0 === stripos(PHP_OS, 'win'); - } - } - + /** + * Replaces default suffixes of executable. + * + * @param array $suffixes + */ public function setSuffixes(array $suffixes) { $this->suffixes = $suffixes; } + /** + * Adds new possible suffix to check for executable. + * + * @param string $suffix + */ public function addSuffix($suffix) { $this->suffixes[] = $suffix; @@ -78,7 +79,7 @@ class ExecutableFinder } foreach ($suffixes as $suffix) { foreach ($dirs as $dir) { - if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (self::$isWindows || is_executable($file))) { + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (defined('PHP_WINDOWS_VERSION_BUILD') || is_executable($file))) { return $file; } } diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 5db6e134e2..7a9fd0864b 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -66,6 +66,6 @@ class PhpProcess extends Process $this->setCommandLine($php); } - return parent::start($callback); + parent::start($callback); } } diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 3ada4400e1..4af26e85a2 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -159,8 +159,8 @@ class Process * The STDOUT and STDERR are also available after the process is finished * via the getOutput() and getErrorOutput() methods. * - * @param Closure|string|array $callback A PHP callback to run whenever there is some - * output available on STDOUT or STDERR + * @param callback|null $callback A PHP callback to run whenever there is some + * output available on STDOUT or STDERR * * @return integer The exit status code * @@ -190,8 +190,8 @@ class Process * with true as a second parameter then the callback will get all data occurred * in (and since) the start call. * - * @param Closure|string|array $callback A PHP callback to run whenever there is some - * output available on STDOUT or STDERR + * @param callback|null $callback A PHP callback to run whenever there is some + * output available on STDOUT or STDERR * * @throws \RuntimeException When process can't be launch or is stopped * @throws \RuntimeException When process is already running @@ -318,11 +318,12 @@ class Process * from the output in real-time while writing the standard input to the process. * It allows to have feedback from the independent process during execution. * - * @param mixed $callback A valid PHP callback + * @param callback|null $callback A valid PHP callback * - * @return int The exitcode of the process + * @return integer The exitcode of the process * - * @throws \RuntimeException + * @throws \RuntimeException When process timed out + * @throws \RuntimeException When process stopped after receiving signal */ public function wait($callback = null) { @@ -455,8 +456,6 @@ class Process * * @return string A string representation for the exit status code * - * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled - * * @see http://tldp.org/LDP/abs/html/exitcodes.html * @see http://en.wikipedia.org/wiki/Unix_signal */ @@ -472,8 +471,6 @@ class Process * * @return Boolean true if the process ended successfully, false otherwise * - * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled - * * @api */ public function isSuccessful() @@ -576,11 +573,9 @@ class Process /** * Stops the process. * - * @param float $timeout The timeout in seconds + * @param integer|float $timeout The timeout in seconds * * @return integer The exit-code of the process - * - * @throws \RuntimeException if the process got signaled */ public function stop($timeout=10) { @@ -828,9 +823,9 @@ class Process * The callbacks adds all occurred output to the specific buffer and calls * the user callback (if present) with the received output. * - * @param mixed $callback The user defined PHP callback + * @param callback|null $callback The user defined PHP callback * - * @return mixed A PHP callable + * @return callback A PHP callable */ protected function buildCallback($callback) { @@ -870,6 +865,9 @@ class Process } } + /** + * Updates the current error output of the process (STDERR). + */ protected function updateErrorOutput() { if (isset($this->pipes[self::STDERR]) && is_resource($this->pipes[self::STDERR])) { @@ -877,6 +875,9 @@ class Process } } + /** + * Updates the current output of the process (STDOUT). + */ protected function updateOutput() { if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) { diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 8cb9e4ad26..a5a3376f72 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -16,8 +16,6 @@ namespace Symfony\Component\Process\Tests; */ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { - abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); - /** * @expectedException \InvalidArgumentException */ @@ -300,4 +298,16 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase return $defaults; } + + /** + * @param string $commandline + * @param null $cwd + * @param array $env + * @param null $stdin + * @param integer $timeout + * @param array $options + * + * @return \Symfony\Component\Process\Process + */ + abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); } diff --git a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 4a321adf55..67fc0025bd 100644 --- a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -13,15 +13,6 @@ namespace Symfony\Component\Process\Tests; class SigchildDisabledProcessTest extends AbstractProcessTest { - - protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) - { - $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options); - $process->setEnhanceSigchildCompatibility(false); - - return $process; - } - /** * @expectedException Symfony\Component\Process\Exception\RuntimeException */ @@ -96,4 +87,15 @@ class SigchildDisabledProcessTest extends AbstractProcessTest { parent::testIsNotSuccessful(); } + + /** + * {@inheritdoc} + */ + protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + { + $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options); + $process->setEnhanceSigchildCompatibility(false); + + return $process; + } } diff --git a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php index 4c04ff146b..fb9b6f8cc8 100644 --- a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php @@ -13,15 +13,6 @@ namespace Symfony\Component\Process\Tests; class SigchildEnabledProcessTest extends AbstractProcessTest { - - protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) - { - $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options); - $process->setEnhanceSigchildCompatibility(true); - - return $process; - } - /** * @expectedException Symfony\Component\Process\Exception\RuntimeException */ @@ -62,4 +53,14 @@ class SigchildEnabledProcessTest extends AbstractProcessTest $this->assertInternalType('string', $process->getExitCodeText()); } + /** + * {@inheritdoc} + */ + protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + { + $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options); + $process->setEnhanceSigchildCompatibility(true); + + return $process; + } } diff --git a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php index 8742a69e54..17dea3fe54 100644 --- a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -15,20 +15,14 @@ use Symfony\Component\Process\Process; class SimpleProcessTest extends AbstractProcessTest { + private $enabledSigchild = false; - protected function skipIfPHPSigchild() + public function setUp() { ob_start(); phpinfo(INFO_GENERAL); - if (false !== strpos(ob_get_clean(), '--enable-sigchild')) { - $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed'); - } - } - - protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) - { - return new Process($commandline, $cwd, $env, $stdin, $timeout, $options); + $this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); } public function testGetExitCode() @@ -84,4 +78,19 @@ class SimpleProcessTest extends AbstractProcessTest $this->skipIfPHPSigchild(); parent::testIsNotSuccessful(); } + + /** + * {@inheritdoc} + */ + protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + { + return new Process($commandline, $cwd, $env, $stdin, $timeout, $options); + } + + private function skipIfPHPSigchild() + { + if ($this->enabledSigchild) { + $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed'); + } + } } From 2dfe9660a26ab8f4a60509f186c648a1fa12527d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 16 Jan 2013 10:27:54 +0100 Subject: [PATCH 12/16] fixed CS --- .../Resources/views/Profiler/toolbar_style.html.twig | 2 +- src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php | 2 +- src/Symfony/Component/Process/Tests/AbstractProcessTest.php | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig index 0564d8c8ae..07a76ece70 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig @@ -17,7 +17,7 @@ bottom: 0; border-top: 1px solid #bbb; } - .sf-toolbarreset span, + .sf-toolbarreset span, .sf-toolbarreset div { font-size: 11px; } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php index ac2beee16b..1c5463995f 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php @@ -8,4 +8,4 @@ class Foo4Command extends Command { $this->setName('foo3:bar:toh'); } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index a5a3376f72..51d51f40b8 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Process\Tests; +use Symfony\Component\Process\Process; + /** * @author Robert Schönthal */ @@ -307,7 +309,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase * @param integer $timeout * @param array $options * - * @return \Symfony\Component\Process\Process + * @return Process */ abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); } From ac756bf39e646b4e130fad058d10a0228dbd9779 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 17 Jan 2013 09:31:37 +0100 Subject: [PATCH 13/16] added a way to enable/disable PHP support when parsing a YAML input via Yaml::parse() PHP support when parsing a file has been disabled by default. If you do need PHP support when parsing a YAML file, enable it via: Yaml::setPhpParsing(true); As of Symfony 2.1, PHP support is disabled by default, and support will be removed in Symfony 2.3. --- src/Symfony/Component/Yaml/Yaml.php | 73 ++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index cd5310f24e..f5e3a0e9b4 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -22,6 +22,53 @@ use Symfony\Component\Yaml\Exception\ParseException; */ class Yaml { + /** + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + static public $enablePhpParsing = true; + + /** + * Enables PHP support when parsing YAML files. + * + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static function enablePhpParsing() + { + self::$enablePhpParsing = true; + } + + /** + * Sets the PHP support flag when parsing YAML files. + * + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @param Boolean $boolean true if PHP parsing support is enabled, false otherwise + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static function setPhpParsing($boolean) + { + self::$enablePhpParsing = (Boolean) $boolean; + } + + /** + * Checks if PHP support is enabled when parsing YAML files. + * + * Be warned that PHP support will be removed in Symfony 2.3. + * + * @return Boolean true if PHP parsing support is enabled, false otherwise + * + * @deprecated Deprecated since version 2.0, to be removed in 2.3. + */ + public static function supportsPhpParsing() + { + return self::$enablePhpParsing; + } + /** * Parses YAML into a PHP array. * @@ -44,27 +91,29 @@ class Yaml */ public static function parse($input) { - $file = ''; - // if input is a file, process it + $file = ''; if (strpos($input, "\n") === false && is_file($input)) { if (false === is_readable($input)) { throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); } $file = $input; + if (self::$enablePhpParsing) { + ob_start(); + $retval = include($file); + $content = ob_get_clean(); - ob_start(); - $retval = include($input); - $content = ob_get_clean(); + // if an array is returned by the config file assume it's in plain php form else in YAML + $input = is_array($retval) ? $retval : $content; - // if an array is returned by the config file assume it's in plain php form else in YAML - $input = is_array($retval) ? $retval : $content; - } - - // if an array is returned by the config file assume it's in plain php form else in YAML - if (is_array($input)) { - return $input; + // if an array is returned by the config file assume it's in plain php form else in YAML + if (is_array($input)) { + return $input; + } + } else { + $input = file_get_contents($file); + } } $yaml = new Parser(); From ba6e3159c0eeb3b6e21db32fce8fa2535cb3aa77 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 17 Jan 2013 09:34:45 +0100 Subject: [PATCH 14/16] added a way to enable/disable object support when parsing/dumping By default, object support is disabled, and instead of throwing an exception when an object is handled, null is returned. If you do need object support, enable it via: Yaml::dump($data, false, true); If you want an exception to be thrown in case an invalid type is handled (a PHP resource or a PHP object), pass true as the second argument: Yaml::dump($data, true, true); The same can be done when parsing: Yaml::parse($data, 2, false, true); --- .../Bridge/Twig/Extension/YamlExtension.php | 10 ++-- src/Symfony/Component/Yaml/Dumper.php | 16 +++--- src/Symfony/Component/Yaml/Inline.php | 56 +++++++++++++++---- src/Symfony/Component/Yaml/Parser.php | 26 +++++---- src/Symfony/Component/Yaml/Yaml.php | 16 +++--- .../Tests/Component/Yaml/DumperTest.php | 21 ++++++- .../Tests/Component/Yaml/ParserTest.php | 28 ++++++++-- 7 files changed, 122 insertions(+), 51 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 130575cb68..f88829ee34 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -31,7 +31,7 @@ class YamlExtension extends \Twig_Extension ); } - public function encode($input, $inline = 0) + public function encode($input, $inline = 0, $dumpObjects = false) { static $dumper; @@ -39,20 +39,20 @@ class YamlExtension extends \Twig_Extension $dumper = new YamlDumper(); } - return $dumper->dump($input, $inline); + return $dumper->dump($input, $inline, false, $dumpObjects); } - public function dump($value) + public function dump($value, $inline = 0, $dumpObjects = false) { if (is_resource($value)) { return '%Resource%'; } if (is_array($value) || is_object($value)) { - return '%'.gettype($value).'% '.$this->encode($value); + return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects); } - return $this->encode($value); + return $this->encode($value, $inline, $dumpObjects); } /** diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index ec74cfc478..9829a49c93 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -21,19 +21,21 @@ class Dumper /** * Dumps a PHP value to YAML. * - * @param mixed $input The PHP value - * @param integer $inline The level where you switch to inline YAML - * @param integer $indent The level of indentation (used internally) + * @param mixed $input The PHP value + * @param integer $inline The level where you switch to inline YAML + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param integer $indent The level of indentation (used internally) * * @return string The YAML representation of the PHP value */ - public function dump($input, $inline = 0, $indent = 0) + public function dump($input, $inline = 0, $exceptionOnInvalidType = false, $objectSupport = false, $indent = 0) { $output = ''; $prefix = $indent ? str_repeat(' ', $indent) : ''; if ($inline <= 0 || !is_array($input) || empty($input)) { - $output .= $prefix.Inline::dump($input); + $output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport); } else { $isAHash = array_keys($input) !== range(0, count($input) - 1); @@ -42,9 +44,9 @@ class Dumper $output .= sprintf('%s%s%s%s', $prefix, - $isAHash ? Inline::dump($key).':' : '-', + $isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-', $willBeInlined ? ' ' : "\n", - $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2) + $this->dump($value, $inline - 1, $exceptionOnInvalidType, $objectSupport, $willBeInlined ? 0 : $indent + 2) ).($willBeInlined ? "\n" : ''); } } diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 02968d15f9..2f7855d131 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -22,15 +22,23 @@ class Inline { const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')'; + private static $exceptionOnInvalidType = false; + private static $objectSupport = false; + /** * Converts a YAML string to a PHP array. * - * @param string $value A YAML string + * @param string $value A YAML string + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise * * @return array A PHP array representing the YAML string */ - public static function parse($value) + public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { + self::$exceptionOnInvalidType = $exceptionOnInvalidType; + self::$objectSupport = $objectSupport; + $value = trim($value); if (0 == strlen($value)) { @@ -63,21 +71,35 @@ class Inline /** * Dumps a given PHP variable to a YAML string. * - * @param mixed $value The PHP variable to convert + * @param mixed $value The PHP variable to convert + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise * * @return string The YAML string representing the PHP array * * @throws DumpException When trying to dump PHP resource */ - public static function dump($value) + public static function dump($value, $exceptionOnInvalidType = false, $objectSupport = false) { switch (true) { case is_resource($value): - throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value))); + if ($exceptionOnInvalidType) { + throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value))); + } + + return 'null'; case is_object($value): - return '!!php/object:'.serialize($value); + if ($objectSupport) { + return '!!php/object:'.serialize($value); + } + + if ($exceptionOnInvalidType) { + throw new DumpException('Object support when dumping a YAML file has been disabled.'); + } + + return 'null'; case is_array($value): - return self::dumpArray($value); + return self::dumpArray($value, $exceptionOnInvalidType, $objectSupport); case null === $value: return 'null'; case true === $value: @@ -115,11 +137,13 @@ class Inline /** * Dumps a PHP array to a YAML string. * - * @param array $value The PHP array to dump + * @param array $value The PHP array to dump + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise * * @return string The YAML string representing the PHP array */ - private static function dumpArray($value) + private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport) { // array $keys = array_keys($value); @@ -128,7 +152,7 @@ class Inline ) { $output = array(); foreach ($value as $val) { - $output[] = self::dump($val); + $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport); } return sprintf('[%s]', implode(', ', $output)); @@ -137,7 +161,7 @@ class Inline // mapping $output = array(); foreach ($value as $key => $val) { - $output[] = sprintf('%s: %s', self::dump($key), self::dump($val)); + $output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport)); } return sprintf('{ %s }', implode(', ', $output)); @@ -355,7 +379,15 @@ class Inline case 0 === strpos($scalar, '! '): return intval(self::parseScalar(substr($scalar, 2))); case 0 === strpos($scalar, '!!php/object:'): - return unserialize(substr($scalar, 13)); + if (self::$objectSupport) { + return unserialize(substr($scalar, 13)); + } + + if (self::$exceptionOnInvalidType) { + throw new ParseException('Object support when parsing a YAML file has been disabled.'); + } + + return null; case ctype_digit($scalar): $raw = $scalar; $cast = intval($scalar); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 0bc4250609..1c0fdd828a 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -38,13 +38,15 @@ class Parser /** * Parses a YAML string to a PHP value. * - * @param string $value A YAML string + * @param string $value A YAML string + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise * * @return mixed A PHP value * * @throws ParseException If the YAML is not valid */ - public function parse($value) + public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { $this->currentLineNb = -1; $this->currentLine = ''; @@ -82,7 +84,7 @@ class Parser $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; - $data[] = $parser->parse($this->getNextEmbedBlock()); + $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] @@ -98,12 +100,14 @@ class Parser $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); } - $data[] = $parser->parse($block); + $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport); } else { - $data[] = $this->parseValue($values['value']); + $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { + // force correct settings + Inline::parse(null, $exceptionOnInvalidType, $objectSupport); try { $key = Inline::parseScalar($values['key']); } catch (ParseException $e) { @@ -128,7 +132,7 @@ class Parser $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; - $parsed = $parser->parse($value); + $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); $merged = array(); if (!is_array($parsed)) { @@ -165,20 +169,20 @@ class Parser $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; - $data[$key] = $parser->parse($this->getNextEmbedBlock()); + $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } } else { if ($isInPlace) { $data = $this->refs[$isInPlace]; } else { - $data[$key] = $this->parseValue($values['value']); + $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } } else { // 1-liner followed by newline if (2 == count($this->lines) && empty($this->lines[1])) { try { - $value = Inline::parse($this->lines[0]); + $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); @@ -345,7 +349,7 @@ class Parser * * @throws ParseException When reference does not exist */ - private function parseValue($value) + private function parseValue($value, $exceptionOnInvalidType, $objectSupport) { if (0 === strpos($value, '*')) { if (false !== $pos = strpos($value, '#')) { @@ -368,7 +372,7 @@ class Parser } try { - return Inline::parse($value); + return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index f5e3a0e9b4..ae175f1b0e 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -27,7 +27,7 @@ class Yaml * * @deprecated Deprecated since version 2.0, to be removed in 2.3. */ - static public $enablePhpParsing = true; + public static $enablePhpParsing = true; /** * Enables PHP support when parsing YAML files. @@ -89,7 +89,7 @@ class Yaml * * @api */ - public static function parse($input) + public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) { // if input is a file, process it $file = ''; @@ -119,7 +119,7 @@ class Yaml $yaml = new Parser(); try { - return $yaml->parse($input); + return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { if ($file) { $e->setParsedFile($file); @@ -135,17 +135,19 @@ class Yaml * The dump method, when supplied with an array, will do its best * to convert the array into friendly YAML. * - * @param array $array PHP array - * @param integer $inline The level where you switch to inline YAML + * @param array $array PHP array + * @param integer $inline The level where you switch to inline YAML + * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param Boolean $objectSupport true if object support is enabled, false otherwise * * @return string A YAML string representing the original PHP array * * @api */ - public static function dump($array, $inline = 2) + public static function dump($array, $inline = 2, $exceptionOnInvalidType = false, $objectSupport = false) { $yaml = new Dumper(); - return $yaml->dump($array, $inline); + return $yaml->dump($array, $inline, $exceptionOnInvalidType, $objectSupport); } } diff --git a/tests/Symfony/Tests/Component/Yaml/DumperTest.php b/tests/Symfony/Tests/Component/Yaml/DumperTest.php index 33b3978683..83e08ca8cb 100644 --- a/tests/Symfony/Tests/Component/Yaml/DumperTest.php +++ b/tests/Symfony/Tests/Component/Yaml/DumperTest.php @@ -152,11 +152,26 @@ EOF; $this->assertEquals($expected, $this->dumper->dump($array, 10), '->dump() takes an inline level argument'); } - public function testObjectsSupport() + public function testObjectSupportEnabled() { - $a = array('foo' => new A(), 'bar' => 1); + $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, false, true); - $this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $this->dumper->dump($a), '->dump() is able to dump objects'); + $this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects'); + } + + public function testObjectSupportDisabledButNoExceptions() + { + $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1)); + + $this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\DumpException + */ + public function testObjectSupportDisabledWithExceptions() + { + $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, true, false); } } diff --git a/tests/Symfony/Tests/Component/Yaml/ParserTest.php b/tests/Symfony/Tests/Component/Yaml/ParserTest.php index 6a684ed99f..4b3f3bf273 100644 --- a/tests/Symfony/Tests/Component/Yaml/ParserTest.php +++ b/tests/Symfony/Tests/Component/Yaml/ParserTest.php @@ -13,7 +13,6 @@ namespace Symfony\Tests\Component\Yaml; use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Parser; -use Symfony\Component\Yaml\Exception\ParseException; class ParserTest extends \PHPUnit_Framework_TestCase { @@ -106,14 +105,31 @@ EOF; $this->assertEquals('foo', $this->parser->parse($yaml)); } - public function testObjectsSupport() + public function testObjectSupportEnabled() { - $b = array('foo' => new B(), 'bar' => 1); - $this->assertEquals($this->parser->parse(<<parse() is able to dump objects'); +EOF; + $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects'); + } + + public function testObjectSupportDisabledButNoExceptions() + { + $input = <<assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testObjectsSupportDisabledWithExceptions() + { + $this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false); } public function testNonUtf8Exception() From 3c87e2ea185b54413aed92ef9738658f9be13f50 Mon Sep 17 00:00:00 2001 From: sun Date: Sun, 5 Aug 2012 00:46:53 +0200 Subject: [PATCH 15/16] Added Yaml\Dumper::setIndentation() method to allow a custom indentation level of nested nodes. YAML does not specify an absolute indentation level, but a consistent indentation of nested nodes only: http://www.yaml.org/spec/1.2/spec.html#space/indentation/ Projects that are generally using 2 spaces for indentation should be able to retain consistency with their coding standards by supplying a custom value for the new $indent parameter added to Yaml::dump(), or the new Dumper::setIndentation() method. The new parameter is a backwards-compatible API addition and defaults to the previous default of 4 (which was changed from 2 via PR #2242 only recently). Conflicts: src/Symfony/Component/Yaml/Dumper.php src/Symfony/Component/Yaml/Yaml.php --- src/Symfony/Component/Yaml/Dumper.php | 19 ++++++++++++++++++- src/Symfony/Component/Yaml/Yaml.php | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 9829a49c93..5b0baa5271 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -18,6 +18,23 @@ namespace Symfony\Component\Yaml; */ class Dumper { + /** + * The amount of spaces to use for indentation of nested nodes. + * + * @var integer + */ + protected $indentation = 2; + + /** + * Sets the indentation. + * + * @param integer $num The amount of spaces to use for intendation of nested nodes. + */ + public function setIndentation($num) + { + $this->indentation = $num; + } + /** * Dumps a PHP value to YAML. * @@ -46,7 +63,7 @@ class Dumper $prefix, $isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-', $willBeInlined ? ' ' : "\n", - $this->dump($value, $inline - 1, $exceptionOnInvalidType, $objectSupport, $willBeInlined ? 0 : $indent + 2) + $this->dump($value, $inline - 1, $exceptionOnInvalidType, $objectSupport, $willBeInlined ? 0 : $indent + $this->indentation) ).($willBeInlined ? "\n" : ''); } } diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index ae175f1b0e..205d866466 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -137,6 +137,7 @@ class Yaml * * @param array $array PHP array * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The amount of spaces to use for indentation of nested nodes. * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise * @param Boolean $objectSupport true if object support is enabled, false otherwise * @@ -144,9 +145,10 @@ class Yaml * * @api */ - public static function dump($array, $inline = 2, $exceptionOnInvalidType = false, $objectSupport = false) + public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false) { $yaml = new Dumper(); + $yaml->setIndentation($indent); return $yaml->dump($array, $inline, $exceptionOnInvalidType, $objectSupport); } From e17e2327b18ff91f89234ddc13c1525b852a88b6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 17 Jan 2013 16:16:00 +0100 Subject: [PATCH 16/16] [Yaml] fixed default value --- src/Symfony/Component/Yaml/Yaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 205d866466..ca24cffb9c 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -27,7 +27,7 @@ class Yaml * * @deprecated Deprecated since version 2.0, to be removed in 2.3. */ - public static $enablePhpParsing = true; + public static $enablePhpParsing = false; /** * Enables PHP support when parsing YAML files.