From d8f839d7a1f712a8748b875df566bcbf52ad5d84 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 11 Nov 2014 09:37:22 +0100 Subject: [PATCH 001/133] updated version to 3.0 --- composer.json | 2 +- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/Monolog/composer.json | 2 +- src/Symfony/Bridge/Propel1/composer.json | 2 +- src/Symfony/Bridge/ProxyManager/composer.json | 2 +- src/Symfony/Bridge/Swiftmailer/composer.json | 2 +- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Bundle/DebugBundle/composer.json | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- src/Symfony/Bundle/SecurityBundle/composer.json | 2 +- src/Symfony/Bundle/TwigBundle/composer.json | 2 +- src/Symfony/Bundle/WebProfilerBundle/composer.json | 2 +- src/Symfony/Component/BrowserKit/composer.json | 2 +- src/Symfony/Component/ClassLoader/composer.json | 2 +- src/Symfony/Component/Config/composer.json | 2 +- src/Symfony/Component/Console/composer.json | 2 +- src/Symfony/Component/CssSelector/composer.json | 2 +- src/Symfony/Component/Debug/composer.json | 2 +- src/Symfony/Component/DependencyInjection/composer.json | 2 +- src/Symfony/Component/DomCrawler/composer.json | 2 +- src/Symfony/Component/EventDispatcher/composer.json | 2 +- src/Symfony/Component/ExpressionLanguage/composer.json | 2 +- src/Symfony/Component/Filesystem/composer.json | 2 +- src/Symfony/Component/Finder/composer.json | 2 +- src/Symfony/Component/Form/README.md | 2 +- src/Symfony/Component/Form/composer.json | 2 +- src/Symfony/Component/HttpFoundation/composer.json | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- src/Symfony/Component/HttpKernel/composer.json | 2 +- src/Symfony/Component/Intl/README.md | 2 +- src/Symfony/Component/Intl/composer.json | 2 +- src/Symfony/Component/Locale/composer.json | 2 +- src/Symfony/Component/OptionsResolver/composer.json | 2 +- src/Symfony/Component/Process/composer.json | 2 +- src/Symfony/Component/PropertyAccess/composer.json | 2 +- src/Symfony/Component/Routing/composer.json | 2 +- src/Symfony/Component/Security/Acl/README.md | 2 +- src/Symfony/Component/Security/Acl/composer.json | 2 +- src/Symfony/Component/Security/Core/README.md | 2 +- src/Symfony/Component/Security/Core/composer.json | 2 +- src/Symfony/Component/Security/Csrf/README.md | 2 +- src/Symfony/Component/Security/Csrf/composer.json | 2 +- src/Symfony/Component/Security/Http/README.md | 2 +- src/Symfony/Component/Security/Http/composer.json | 2 +- src/Symfony/Component/Security/README.md | 2 +- src/Symfony/Component/Security/composer.json | 2 +- src/Symfony/Component/Serializer/composer.json | 2 +- src/Symfony/Component/Stopwatch/composer.json | 2 +- src/Symfony/Component/Templating/composer.json | 2 +- src/Symfony/Component/Translation/README.md | 2 +- src/Symfony/Component/Translation/composer.json | 2 +- src/Symfony/Component/Validator/README.md | 2 +- src/Symfony/Component/Validator/composer.json | 2 +- src/Symfony/Component/VarDumper/composer.json | 2 +- src/Symfony/Component/Yaml/composer.json | 2 +- 55 files changed, 58 insertions(+), 58 deletions(-) diff --git a/composer.json b/composer.json index 7026ec3dfab91..fa36e75f186a8 100644 --- a/composer.json +++ b/composer.json @@ -89,7 +89,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 573c5ba5d4725..1c61595b78475 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -45,7 +45,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index fc1cc1b987186..f66bb561fb343 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -36,7 +36,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bridge/Propel1/composer.json b/src/Symfony/Bridge/Propel1/composer.json index 9ea191d20e368..b9feb6af7f1e3 100644 --- a/src/Symfony/Bridge/Propel1/composer.json +++ b/src/Symfony/Bridge/Propel1/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index 1ad48ccd1d814..5e89ce5ca0c26 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bridge/Swiftmailer/composer.json b/src/Symfony/Bridge/Swiftmailer/composer.json index 098ff0e682736..470dd54f8148d 100644 --- a/src/Symfony/Bridge/Swiftmailer/composer.json +++ b/src/Symfony/Bridge/Swiftmailer/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 22ada09185159..4fd26da0d1865 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -54,7 +54,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index 19a584c8e0498..69cd5c153ea03 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -36,7 +36,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 92bf96869933c..a960e7bc0d4bb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -58,7 +58,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index d3f79c12ca4f5..1f67c8ba19416 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 80ac4cd57e9df..45ee25d607dee 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 3f9aea4855df3..41e723019d70c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index 323202b74fbef..277ab5144746d 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/ClassLoader/composer.json b/src/Symfony/Component/ClassLoader/composer.json index 6c11dd8c3a2fd..094844814ac3c 100644 --- a/src/Symfony/Component/ClassLoader/composer.json +++ b/src/Symfony/Component/ClassLoader/composer.json @@ -28,7 +28,7 @@ "target-dir": "Symfony/Component/ClassLoader", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index dd71f7c9fbb7a..2da16c5620506 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index 743d375a39733..0e7fdc9515d48 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -35,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/CssSelector/composer.json b/src/Symfony/Component/CssSelector/composer.json index ee227439e86e6..12c782038e913 100644 --- a/src/Symfony/Component/CssSelector/composer.json +++ b/src/Symfony/Component/CssSelector/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index c4494b1645781..fa18b60ebcd1f 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 3f171a33acbae..c1d8c4560bf4a 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -35,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index dea7d2329e554..2a04cf511cdd1 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 08f1ff9ced051..6ece50892d294 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -36,7 +36,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/ExpressionLanguage/composer.json b/src/Symfony/Component/ExpressionLanguage/composer.json index 8e6193cfe4b77..40f241bdcf9c0 100644 --- a/src/Symfony/Component/ExpressionLanguage/composer.json +++ b/src/Symfony/Component/ExpressionLanguage/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Filesystem/composer.json b/src/Symfony/Component/Filesystem/composer.json index c5682684b3525..33d4dd8466c92 100644 --- a/src/Symfony/Component/Filesystem/composer.json +++ b/src/Symfony/Component/Filesystem/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Finder/composer.json b/src/Symfony/Component/Finder/composer.json index 7e3264275eb0c..f1edff50204fe 100644 --- a/src/Symfony/Component/Finder/composer.json +++ b/src/Symfony/Component/Finder/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Form/README.md b/src/Symfony/Component/Form/README.md index 2bd259debf989..3450c0161181d 100644 --- a/src/Symfony/Component/Form/README.md +++ b/src/Symfony/Component/Form/README.md @@ -14,7 +14,7 @@ https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/FormServiceProvid Documentation: -http://symfony.com/doc/2.7/book/forms.html +http://symfony.com/doc/3.0/book/forms.html Resources --------- diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index bad48b84515b1..52aed058e3abe 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -42,7 +42,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index e0d86584ad065..a6c8f51b8d8fd 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index df1742c63c649..611d5d9ac1be5 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,10 +59,10 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.0-DEV'; - const VERSION_ID = '20700'; - const MAJOR_VERSION = '2'; - const MINOR_VERSION = '7'; + const VERSION = '3.0.0-DEV'; + const VERSION_ID = '30000'; + const MAJOR_VERSION = '3'; + const MINOR_VERSION = '0'; const RELEASE_VERSION = '0'; const EXTRA_VERSION = 'DEV'; diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 063257ecc1f33..778d239aee290 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -53,7 +53,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Intl/README.md b/src/Symfony/Component/Intl/README.md index dd7b562f26cb9..f94877811d143 100644 --- a/src/Symfony/Component/Intl/README.md +++ b/src/Symfony/Component/Intl/README.md @@ -22,4 +22,4 @@ You can run the unit tests with the following command: $ phpunit [0]: http://www.php.net/manual/en/intl.setup.php -[1]: http://symfony.com/doc/2.7/components/intl.html +[1]: http://symfony.com/doc/3.0/components/intl.html diff --git a/src/Symfony/Component/Intl/composer.json b/src/Symfony/Component/Intl/composer.json index d5cbf21a8dd62..beca5c92363e3 100644 --- a/src/Symfony/Component/Intl/composer.json +++ b/src/Symfony/Component/Intl/composer.json @@ -41,7 +41,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Locale/composer.json b/src/Symfony/Component/Locale/composer.json index 02461a174dd03..cc4fb2237a3f4 100644 --- a/src/Symfony/Component/Locale/composer.json +++ b/src/Symfony/Component/Locale/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index b5f67b6f1cf4f..49a1607a1b7aa 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index 901b920e474e1..938b3987ab737 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index 276f46250d85a..796b736888182 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 2a596b95a9e94..8298506f3a20e 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Security/Acl/README.md b/src/Symfony/Component/Security/Acl/README.md index 4b68d909ead51..d640ac2ac478e 100644 --- a/src/Symfony/Component/Security/Acl/README.md +++ b/src/Symfony/Component/Security/Acl/README.md @@ -11,7 +11,7 @@ Resources Documentation: -http://symfony.com/doc/2.7/book/security.html +http://symfony.com/doc/3.0/book/security.html Tests ----- diff --git a/src/Symfony/Component/Security/Acl/composer.json b/src/Symfony/Component/Security/Acl/composer.json index 8f65f5034ae42..a1a5d6a526b33 100644 --- a/src/Symfony/Component/Security/Acl/composer.json +++ b/src/Symfony/Component/Security/Acl/composer.json @@ -36,7 +36,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Security/Core/README.md b/src/Symfony/Component/Security/Core/README.md index 8e05a92d4d60e..4cc3c6ddef499 100644 --- a/src/Symfony/Component/Security/Core/README.md +++ b/src/Symfony/Component/Security/Core/README.md @@ -11,7 +11,7 @@ Resources Documentation: -http://symfony.com/doc/2.7/book/security.html +http://symfony.com/doc/3.0/book/security.html Tests ----- diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 5182a71399662..f27b2c716ae8a 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -40,7 +40,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Security/Csrf/README.md b/src/Symfony/Component/Security/Csrf/README.md index 30d7bb284943b..85f9114ad74e4 100644 --- a/src/Symfony/Component/Security/Csrf/README.md +++ b/src/Symfony/Component/Security/Csrf/README.md @@ -9,7 +9,7 @@ Resources Documentation: -http://symfony.com/doc/2.7/book/security.html +http://symfony.com/doc/3.0/book/security.html Tests ----- diff --git a/src/Symfony/Component/Security/Csrf/composer.json b/src/Symfony/Component/Security/Csrf/composer.json index 0ed6428df09ce..16099a6e4e0c7 100644 --- a/src/Symfony/Component/Security/Csrf/composer.json +++ b/src/Symfony/Component/Security/Csrf/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Security/Http/README.md b/src/Symfony/Component/Security/Http/README.md index 35437f28cbe3b..abf0cce840235 100644 --- a/src/Symfony/Component/Security/Http/README.md +++ b/src/Symfony/Component/Security/Http/README.md @@ -11,7 +11,7 @@ Resources Documentation: -http://symfony.com/doc/2.7/book/security.html +http://symfony.com/doc/3.0/book/security.html Tests ----- diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 625353e06cadd..394267b3f0738 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -38,7 +38,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Security/README.md b/src/Symfony/Component/Security/README.md index 66c7d80a9fdac..32894b124f2b4 100644 --- a/src/Symfony/Component/Security/README.md +++ b/src/Symfony/Component/Security/README.md @@ -11,7 +11,7 @@ Resources Documentation: -http://symfony.com/doc/2.7/book/security.html +http://symfony.com/doc/3.0/book/security.html Tests ----- diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 435d92e7e0f77..2e7bf02f79bba 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -52,7 +52,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 026be84e1c900..ca4407eed8870 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Stopwatch/composer.json b/src/Symfony/Component/Stopwatch/composer.json index e2dfccbd757f1..99821957ffbbe 100644 --- a/src/Symfony/Component/Stopwatch/composer.json +++ b/src/Symfony/Component/Stopwatch/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Templating/composer.json b/src/Symfony/Component/Templating/composer.json index ab98c9d00ec39..91defd0602213 100644 --- a/src/Symfony/Component/Templating/composer.json +++ b/src/Symfony/Component/Templating/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Translation/README.md b/src/Symfony/Component/Translation/README.md index b1de2500263be..62a18ab042b39 100644 --- a/src/Symfony/Component/Translation/README.md +++ b/src/Symfony/Component/Translation/README.md @@ -28,7 +28,7 @@ https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/TranslationServic Documentation: -http://symfony.com/doc/2.7/book/translation.html +http://symfony.com/doc/3.0/book/translation.html You can run the unit tests with the following command: diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 608fd52d29c45..b6d1e21f10039 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -36,7 +36,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Validator/README.md b/src/Symfony/Component/Validator/README.md index 9788f558f3d7c..5d105640bdd67 100644 --- a/src/Symfony/Component/Validator/README.md +++ b/src/Symfony/Component/Validator/README.md @@ -113,7 +113,7 @@ https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/ValidatorServiceP Documentation: -http://symfony.com/doc/2.7/book/validation.html +http://symfony.com/doc/3.0/book/validation.html JSR-303 Specification: diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 36c9cacd016b1..c378ab7412e5b 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -49,7 +49,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 025491a528e43..58560fbcb5426 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index 1aa0018ac5609..1ca239845b934 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } } } From 0ab13b9d8eb162fba86eb7035ca75031ac82b51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Tue, 11 Nov 2014 19:15:15 +0100 Subject: [PATCH 002/133] Publics methods are protected, class become abstract --- .../FrameworkBundle/Controller/Controller.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index b3c7f42c2ce27..156d7b4aab6c9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -33,7 +33,7 @@ * * @author Fabien Potencier */ -class Controller extends ContainerAware +abstract class Controller extends ContainerAware { /** * Generates a URL from the given parameters. @@ -46,7 +46,7 @@ class Controller extends ContainerAware * * @see UrlGeneratorInterface */ - public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) + protected function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { return $this->container->get('router')->generate($route, $parameters, $referenceType); } @@ -60,7 +60,7 @@ public function generateUrl($route, $parameters = array(), $referenceType = UrlG * * @return Response A Response instance */ - public function forward($controller, array $path = array(), array $query = array()) + protected function forward($controller, array $path = array(), array $query = array()) { $path['_controller'] = $controller; $subRequest = $this->container->get('request_stack')->getCurrentRequest()->duplicate($query, null, $path); @@ -76,7 +76,7 @@ public function forward($controller, array $path = array(), array $query = array * * @return RedirectResponse */ - public function redirect($url, $status = 302) + protected function redirect($url, $status = 302) { return new RedirectResponse($url, $status); } @@ -155,7 +155,7 @@ protected function denyAccessUnlessGranted($attributes, $object = null, $message * * @return string The rendered view */ - public function renderView($view, array $parameters = array()) + protected function renderView($view, array $parameters = array()) { return $this->container->get('templating')->render($view, $parameters); } @@ -169,7 +169,7 @@ public function renderView($view, array $parameters = array()) * * @return Response A Response instance */ - public function render($view, array $parameters = array(), Response $response = null) + protected function render($view, array $parameters = array(), Response $response = null) { return $this->container->get('templating')->renderResponse($view, $parameters, $response); } @@ -183,7 +183,7 @@ public function render($view, array $parameters = array(), Response $response = * * @return StreamedResponse A StreamedResponse instance */ - public function stream($view, array $parameters = array(), StreamedResponse $response = null) + protected function stream($view, array $parameters = array(), StreamedResponse $response = null) { $templating = $this->container->get('templating'); @@ -212,7 +212,7 @@ public function stream($view, array $parameters = array(), StreamedResponse $res * * @return NotFoundHttpException */ - public function createNotFoundException($message = 'Not Found', \Exception $previous = null) + protected function createNotFoundException($message = 'Not Found', \Exception $previous = null) { return new NotFoundHttpException($message, $previous); } @@ -229,7 +229,7 @@ public function createNotFoundException($message = 'Not Found', \Exception $prev * * @return AccessDeniedException */ - public function createAccessDeniedException($message = 'Access Denied', \Exception $previous = null) + protected function createAccessDeniedException($message = 'Access Denied', \Exception $previous = null) { return new AccessDeniedException($message, $previous); } @@ -243,7 +243,7 @@ public function createAccessDeniedException($message = 'Access Denied', \Excepti * * @return Form */ - public function createForm($type, $data = null, array $options = array()) + protected function createForm($type, $data = null, array $options = array()) { return $this->container->get('form.factory')->create($type, $data, $options); } @@ -256,7 +256,7 @@ public function createForm($type, $data = null, array $options = array()) * * @return FormBuilder */ - public function createFormBuilder($data = null, array $options = array()) + protected function createFormBuilder($data = null, array $options = array()) { return $this->container->get('form.factory')->createBuilder('form', $data, $options); } @@ -270,7 +270,7 @@ public function createFormBuilder($data = null, array $options = array()) * Symfony to inject the Request object into your controller * method instead by type hinting it in the method's signature. */ - public function getRequest() + protected function getRequest() { return $this->container->get('request_stack')->getCurrentRequest(); } @@ -282,7 +282,7 @@ public function getRequest() * * @throws \LogicException If DoctrineBundle is not available */ - public function getDoctrine() + protected function getDoctrine() { if (!$this->container->has('doctrine')) { throw new \LogicException('The DoctrineBundle is not registered in your application.'); @@ -300,7 +300,7 @@ public function getDoctrine() * * @see Symfony\Component\Security\Core\Authentication\Token\TokenInterface::getUser() */ - public function getUser() + protected function getUser() { if (!$this->container->has('security.context')) { throw new \LogicException('The SecurityBundle is not registered in your application.'); @@ -324,7 +324,7 @@ public function getUser() * * @return bool true if the service id is defined, false otherwise */ - public function has($id) + protected function has($id) { return $this->container->has($id); } @@ -336,7 +336,7 @@ public function has($id) * * @return object The service */ - public function get($id) + protected function get($id) { return $this->container->get($id); } From 37b49e1095fd3a7f3df977d695e20090c50c96e2 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Wed, 12 Nov 2014 01:01:01 +0100 Subject: [PATCH 003/133] [HttpKernel] Removed deprecated Kernel::init() method --- .../FrameworkBundle/Tests/Functional/app/AppKernel.php | 4 ---- .../SecurityBundle/Tests/Functional/app/AppKernel.php | 4 ---- src/Symfony/Component/HttpKernel/CHANGELOG.md | 7 ++++++- src/Symfony/Component/HttpKernel/Kernel.php | 9 --------- .../Tests/DataCollector/ConfigDataCollectorTest.php | 4 ---- 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index 12747e6dc2be3..31cd7ef9dfc03 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -74,10 +74,6 @@ public function registerBundles() return include $filename; } - public function init() - { - } - public function getRootDir() { return __DIR__; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index 57816ccef9264..f3881788fd876 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -74,10 +74,6 @@ public function registerBundles() return include $filename; } - public function init() - { - } - public function getRootDir() { return __DIR__; diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index ed7f6035ace95..ad32deb12c81e 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +3.0.0 +----- + +* Removed `Symfony\Component\HttpKernel\Kernel::init()` + 2.6.0 ----- @@ -24,7 +29,7 @@ CHANGELOG * [BC BREAK] renamed `Symfony\Component\HttpKernel\EventListener\DeprecationLoggerListener` to `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener` and changed its constructor * deprecated `Symfony\Component\HttpKernel\Debug\ErrorHandler`, `Symfony\Component\HttpKernel\Debug\ExceptionHandler`, `Symfony\Component\HttpKernel\Exception\FatalErrorException`, and `Symfony\Component\HttpKernel\Exception\FlattenException` - * deprecated `Symfony\Component\HttpKernel\Kernel::init()`` + * deprecated `Symfony\Component\HttpKernel\Kernel::init()` * added the possibility to specify an id an extra attributes to hinclude tags * added the collect of data if a controller is a Closure in the Request collector * pass exceptions from the ExceptionListener to the logger using the logging context to allow for more diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 611d5d9ac1be5..bcc59931d31e5 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -84,15 +84,6 @@ public function __construct($environment, $debug) if ($this->debug) { $this->startTime = microtime(true); } - - $this->init(); - } - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Move your logic in the constructor instead. - */ - public function init() - { } public function __clone() diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 0c7396158631f..f9c42c0d75ae6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -69,10 +69,6 @@ public function registerBundles() { } - public function init() - { - } - public function getBundles() { return array(); From 5e9aa165fb21ede22061ad96e6bc086ba24bb092 Mon Sep 17 00:00:00 2001 From: FlorianLB Date: Sat, 29 Nov 2014 11:54:37 +0100 Subject: [PATCH 004/133] [FrameworkBundle] remove deprecated method 'createEsi' --- UPGRADE-3.0.md | 2 ++ .../Bundle/FrameworkBundle/HttpCache/HttpCache.php | 12 ------------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 14520c1c6fa7a..68c7b5d464ec4 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -369,6 +369,8 @@ UPGRADE FROM 2.x to 3.0 * The `RouterApacheDumperCommand` was removed. + * The `createEsi` method of `Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache` was removed. Use `createSurrogate` instead. + ### HttpKernel * The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php index bc5a0cc82fb89..fad4adc04434d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php @@ -71,18 +71,6 @@ protected function getOptions() } protected function createSurrogate() - { - return $this->createEsi(); - } - - /** - * Creates new ESI instance - * - * @return Esi - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use createSurrogate() instead - */ - protected function createEsi() { return new Esi(); } From e2334d9624c6ef1e9fcecd81198c5a46272fdb02 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sat, 29 Nov 2014 12:57:28 +0100 Subject: [PATCH 005/133] [Process] Remove deprecated methods --- src/Symfony/Component/Process/Process.php | 31 ----------------------- 1 file changed, 31 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index d1d0ae1066c2a..ccad5e3624ab9 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1047,19 +1047,6 @@ public function setEnv(array $env) return $this; } - /** - * Gets the contents of STDIN. - * - * @return string|null The current contents - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * This method is deprecated in favor of getInput. - */ - public function getStdin() - { - return $this->getInput(); - } - /** * Gets the Process input. * @@ -1070,24 +1057,6 @@ public function getInput() return $this->input; } - /** - * Sets the contents of STDIN. - * - * @param string|null $stdin The new contents - * - * @return self The current Process instance - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * This method is deprecated in favor of setInput. - * - * @throws LogicException In case the process is running - * @throws InvalidArgumentException In case the argument is invalid - */ - public function setStdin($stdin) - { - return $this->setInput($stdin); - } - /** * Sets the input. * From 9ecfc84564f40d18f84b91c9179fe8dc23972158 Mon Sep 17 00:00:00 2001 From: FlorianLB Date: Sat, 29 Nov 2014 13:38:54 +0100 Subject: [PATCH 006/133] [Monolog Bridge] Remove deprecated log methods + add unit tests --- UPGRADE-3.0.md | 8 +++ src/Symfony/Bridge/Monolog/Logger.php | 32 ---------- .../Bridge/Monolog/Tests/LoggerTest.php | 61 +++++++++++++++++++ 3 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 src/Symfony/Bridge/Monolog/Tests/LoggerTest.php diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 14520c1c6fa7a..7dbd53505604b 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -998,3 +998,11 @@ UPGRADE FROM 2.x to 3.0 * `Process::setStdin()` and `Process::getStdin()` have been removed. Use `Process::setInput()` and `Process::getInput()` that works the same way. * `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types. + +### Monolog Bridge + + * `Symfony\Bridge\Monolog\Logger::emerg()` was removed. Use `emergency()` which is PSR-3 compatible. + * `Symfony\Bridge\Monolog\Logger::crit()` was removed. Use `critical()` which is PSR-3 compatible. + * `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible. + * `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible. + diff --git a/src/Symfony/Bridge/Monolog/Logger.php b/src/Symfony/Bridge/Monolog/Logger.php index b675069ef762a..86ddc4a545ba5 100644 --- a/src/Symfony/Bridge/Monolog/Logger.php +++ b/src/Symfony/Bridge/Monolog/Logger.php @@ -22,38 +22,6 @@ */ class Logger extends BaseLogger implements LoggerInterface, DebugLoggerInterface { - /** - * @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible. - */ - public function emerg($message, array $context = array()) - { - return parent::addRecord(BaseLogger::EMERGENCY, $message, $context); - } - - /** - * @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible. - */ - public function crit($message, array $context = array()) - { - return parent::addRecord(BaseLogger::CRITICAL, $message, $context); - } - - /** - * @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible. - */ - public function err($message, array $context = array()) - { - return parent::addRecord(BaseLogger::ERROR, $message, $context); - } - - /** - * @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible. - */ - public function warn($message, array $context = array()) - { - return parent::addRecord(BaseLogger::WARNING, $message, $context); - } - /** * @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface */ diff --git a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php new file mode 100644 index 0000000000000..d03206eb73439 --- /dev/null +++ b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Monolog\Tests; + +use Symfony\Bridge\Monolog\Logger; + +class LoggerTest extends \PHPUnit_Framework_TestCase +{ + public function testGetLogsWithDebugHandler() + { + $expectedLogs = array('foo', 'bar'); + + $debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface'); + $debugHandler + ->expects($this->any()) + ->method('getLogs') + ->will($this->returnValue($expectedLogs)) + ; + + $logger = new Logger('foobar', array($debugHandler)); + $this->assertEquals($expectedLogs, $logger->getLogs()); + } + + public function testGetLogsWithoutDebugHandler() + { + $handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface'); + + $logger = new Logger('foobar', array($handler)); + $this->assertEquals(array(), $logger->getLogs()); + } + + public function testCountErrorsWithDebugHandler() + { + $debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface'); + $debugHandler + ->expects($this->any()) + ->method('countErrors') + ->will($this->returnValue(5)) + ; + + $logger = new Logger('foobar', array($debugHandler)); + $this->assertEquals(5, $logger->countErrors()); + } + + public function testCountErrorsWithoutDebugHandler() + { + $handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface'); + + $logger = new Logger('foobar', array($handler)); + $this->assertEquals(0, $logger->countErrors()); + } +} From 91dcca4c2fd4963805c27af8af608d2b62c7e814 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Thu, 4 Dec 2014 19:05:04 +0100 Subject: [PATCH 007/133] [HttpKernel] Remove unused method Kernel::isClassInActiveBundle Follow-up of #11869 --- src/Symfony/Component/HttpKernel/CHANGELOG.md | 1 + src/Symfony/Component/HttpKernel/Kernel.php | 18 ---------- .../Component/HttpKernel/KernelInterface.php | 13 ------- .../Tests/Fixtures/FooBarBundle.php | 19 ----------- .../Component/HttpKernel/Tests/KernelTest.php | 34 ------------------- 5 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 src/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index ad32deb12c81e..6b5d21bbc072a 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * Removed `Symfony\Component\HttpKernel\Kernel::init()` +* Removed `Symfony\Component\HttpKernel\Kernel::isClassInActiveBundle()` and `Symfony\Component\HttpKernel\KernelInterface::isClassInActiveBundle()` 2.6.0 ----- diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 5fe3da5d35d50..16bdd195168dc 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -196,24 +196,6 @@ public function getBundles() return $this->bundles; } - /** - * {@inheritdoc} - * - * @api - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. - */ - public function isClassInActiveBundle($class) - { - foreach ($this->getBundles() as $bundle) { - if (0 === strpos($class, $bundle->getNamespace())) { - return true; - } - } - - return false; - } - /** * {@inheritdoc} * diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/Component/HttpKernel/KernelInterface.php index 04e5bd640a196..f691ddde8dab8 100644 --- a/src/Symfony/Component/HttpKernel/KernelInterface.php +++ b/src/Symfony/Component/HttpKernel/KernelInterface.php @@ -69,19 +69,6 @@ public function shutdown(); */ public function getBundles(); - /** - * Checks if a given class name belongs to an active bundle. - * - * @param string $class A class name - * - * @return bool true if the class belongs to an active bundle, false otherwise - * - * @api - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. - */ - public function isClassInActiveBundle($class); - /** * Returns a bundle and optionally its descendants by its name. * diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php deleted file mode 100644 index f940f83696134..0000000000000 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class FooBarBundle extends Bundle -{ - // We need a full namespaced bundle instance to test isClassInActiveBundle -} diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 96c996528c85c..f8ce7859d01b0 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -17,7 +17,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; -use Symfony\Component\HttpKernel\Tests\Fixtures\FooBarBundle; class KernelTest extends \PHPUnit_Framework_TestCase { @@ -279,39 +278,6 @@ public function doStuff() $this->assertEquals($expected, $output); } - public function testIsClassInActiveBundleFalse() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle')); - } - - public function testIsClassInActiveBundleFalseNoNamespace() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass')); - } - - public function testIsClassInActiveBundleTrue() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertTrue($kernel->isClassInActiveBundle(__NAMESPACE__.'\Fixtures\FooBarBundle\SomeClass')); - } - - protected function getKernelMockForIsClassInActiveBundleTest() - { - $bundle = new FooBarBundle(); - - $kernel = $this->getKernel(array('getBundles')); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - return $kernel; - } - public function testGetRootDir() { $kernel = new KernelForTest('test', true); From c70a6166476bd95e3340bff40c0f19e8e3c0fdbe Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Sat, 20 Dec 2014 01:11:36 +0100 Subject: [PATCH 008/133] =?UTF-8?q?[Bridge]=C2=A0[Swiftmailer]=20removes?= =?UTF-8?q?=20Swiftmailer=20bridge=20namespace.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UPGRADE-3.0.md | 3 + composer.json | 1 - src/Symfony/Bridge/Swiftmailer/.gitignore | 3 - src/Symfony/Bridge/Swiftmailer/CHANGELOG.md | 7 -- .../DataCollector/MessageDataCollector.php | 88 ------------------- src/Symfony/Bridge/Swiftmailer/LICENSE | 19 ---- src/Symfony/Bridge/Swiftmailer/composer.json | 35 -------- 7 files changed, 3 insertions(+), 153 deletions(-) delete mode 100644 src/Symfony/Bridge/Swiftmailer/.gitignore delete mode 100644 src/Symfony/Bridge/Swiftmailer/CHANGELOG.md delete mode 100644 src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php delete mode 100644 src/Symfony/Bridge/Swiftmailer/LICENSE delete mode 100644 src/Symfony/Bridge/Swiftmailer/composer.json diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 7dbd53505604b..9b915e75dd05d 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -1006,3 +1006,6 @@ UPGRADE FROM 2.x to 3.0 * `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible. * `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible. +### Swiftmailer Bridge + + * `Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector` was removed. Use the `Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector` class instead. diff --git a/composer.json b/composer.json index fa875605b20c2..af9c9d4341976 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,6 @@ "symfony/security-bundle": "self.version", "symfony/serializer": "self.version", "symfony/stopwatch": "self.version", - "symfony/swiftmailer-bridge": "self.version", "symfony/templating": "self.version", "symfony/translation": "self.version", "symfony/twig-bridge": "self.version", diff --git a/src/Symfony/Bridge/Swiftmailer/.gitignore b/src/Symfony/Bridge/Swiftmailer/.gitignore deleted file mode 100644 index c49a5d8df5c65..0000000000000 --- a/src/Symfony/Bridge/Swiftmailer/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/src/Symfony/Bridge/Swiftmailer/CHANGELOG.md b/src/Symfony/Bridge/Swiftmailer/CHANGELOG.md deleted file mode 100644 index 67100f8b06a5e..0000000000000 --- a/src/Symfony/Bridge/Swiftmailer/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -CHANGELOG -========= - -2.1.0 ------ - - * added a data collector diff --git a/src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php b/src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php deleted file mode 100644 index 932ac6ef3ef9f..0000000000000 --- a/src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Swiftmailer\DataCollector; - -use Symfony\Component\HttpKernel\DataCollector\DataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * MessageDataCollector. - * - * @author Fabien Potencier - * @author Clément JOBEILI - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. Use - * MessageDataCollector of SwiftmailerBundle instead. - */ -class MessageDataCollector extends DataCollector -{ - private $container; - private $isSpool; - - /** - * Constructor. - * - * We don't inject the message logger and mailer here - * to avoid the creation of these objects when no emails are sent. - * - * @param ContainerInterface $container A ContainerInterface instance - * @param bool $isSpool - */ - public function __construct(ContainerInterface $container, $isSpool) - { - $this->container = $container; - $this->isSpool = $isSpool; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // only collect when Swiftmailer has already been initialized - if (class_exists('Swift_Mailer', false)) { - $logger = $this->container->get('swiftmailer.plugin.messagelogger'); - $this->data['messages'] = $logger->getMessages(); - $this->data['messageCount'] = $logger->countMessages(); - } else { - $this->data['messages'] = array(); - $this->data['messageCount'] = 0; - } - - $this->data['isSpool'] = $this->isSpool; - } - - public function getMessageCount() - { - return $this->data['messageCount']; - } - - public function getMessages() - { - return $this->data['messages']; - } - - public function isSpool() - { - return $this->data['isSpool']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'swiftmailer'; - } -} diff --git a/src/Symfony/Bridge/Swiftmailer/LICENSE b/src/Symfony/Bridge/Swiftmailer/LICENSE deleted file mode 100644 index 0b3292cf90235..0000000000000 --- a/src/Symfony/Bridge/Swiftmailer/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2014 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Symfony/Bridge/Swiftmailer/composer.json b/src/Symfony/Bridge/Swiftmailer/composer.json deleted file mode 100644 index 470dd54f8148d..0000000000000 --- a/src/Symfony/Bridge/Swiftmailer/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "symfony/swiftmailer-bridge", - "type": "symfony-bridge", - "description": "Symfony Swiftmailer Bridge", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3", - "swiftmailer/swiftmailer": ">=4.2.0,<6.0-dev" - }, - "suggest": { - "symfony/http-kernel": "" - }, - "autoload": { - "psr-0": { "Symfony\\Bridge\\Swiftmailer\\": "" } - }, - "target-dir": "Symfony/Bridge/Swiftmailer", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - } -} From 7b33d1a06074bce5c24a758eb53832cc1eb2b9c3 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Wed, 3 Dec 2014 23:04:33 +0100 Subject: [PATCH 009/133] Removed all $that variables --- .../Doctrine/Form/Type/DoctrineType.php | 5 +- .../LazyProxy/PhpDumper/ProxyDumper.php | 5 +- .../LazyProxy/Fixtures/php/lazy_service.php | 5 +- .../Fixtures/php/lazy_service_structure.txt | 7 +- .../LazyProxy/PhpDumper/ProxyDumperTest.php | 6 +- .../Bridge/Twig/Extension/CodeExtension.php | 6 +- .../Templating/Helper/CodeHelper.php | 6 +- .../Translation/PhpStringTokenParser.php | 2 +- .../Controller/PreviewErrorControllerTest.php | 13 +- .../Component/Console/Helper/DialogHelper.php | 12 +- .../Console/Helper/ProcessHelper.php | 13 +- .../Component/Console/Helper/ProgressBar.php | 20 +- .../Console/Helper/QuestionHelper.php | 6 +- .../Component/Console/Input/ArgvInput.php | 7 +- .../Component/Debug/ExceptionHandler.php | 47 +-- .../Debug/Tests/ErrorHandlerTest.php | 56 ++- .../Debug/Tests/ExceptionHandlerTest.php | 10 +- .../DependencyInjection/ContainerBuilder.php | 12 +- .../DependencyInjection/Dumper/PhpDumper.php | 7 +- .../ParameterBag/ParameterBag.php | 8 +- .../Validator/ValidatorTypeGuesser.php | 24 +- .../Component/Form/Tests/CompoundFormTest.php | 41 +- .../Form/Tests/ResolvedFormTypeTest.php | 31 +- .../Component/Form/Tests/SimpleFormTest.php | 21 +- .../Handler/MongoDbSessionHandlerTest.php | 30 +- .../DataCollector/DumpDataCollectorTest.php | 2 +- .../Tests/HttpCache/HttpCacheTest.php | 13 +- .../DateFormat/FullTransformer.php | 16 +- .../Tests/OptionsResolverTest.php | 21 +- .../OptionsResolver/Tests/OptionsTest.php | 54 +-- src/Symfony/Component/Process/Process.php | 7 +- .../Component/Templating/PhpEngine.php | 11 +- .../Templating/Tests/PhpEngineTest.php | 8 +- .../Mapping/ClassMetadataFactoryTest.php | 6 +- .../Tests/Validator/Abstract2Dot5ApiTest.php | 157 ++++---- .../Tests/Validator/AbstractLegacyApiTest.php | 77 ++-- .../Tests/Validator/AbstractValidatorTest.php | 358 +++++++++--------- .../VarDumper/Cloner/AbstractCloner.php | 33 +- src/Symfony/Component/Yaml/Unescaper.php | 5 +- 39 files changed, 497 insertions(+), 671 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 766d0caad0630..a73cb0986bc45 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -63,11 +63,10 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) $choiceListCache = & $this->choiceListCache; $registry = $this->registry; $propertyAccessor = $this->propertyAccessor; - $type = $this; - $loader = function (Options $options) use ($type) { + $loader = function (Options $options) { if (null !== $options['query_builder']) { - return $type->getLoader($options['em'], $options['query_builder'], $options['class']); + return $this->getLoader($options['em'], $options['query_builder'], $options['class']); } }; diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index d354dde227283..7549596898ecd 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -71,11 +71,10 @@ public function getProxyFactoryCode(Definition $definition, $id) return <<$methodName(false); + function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) { + \$wrappedInstance = \$this->$methodName(false); \$proxy->setProxyInitializer(null); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php index b96b8b81a29ca..4e98db2f17fe1 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php @@ -46,11 +46,10 @@ public function __construct() public function getFooService($lazyLoad = true) { if ($lazyLoad) { - $container = $this; return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8( - function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { - $wrappedInstance = $container->getFooService(false); + function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) { + $wrappedInstance = $this->getFooService(false); $proxy->setProxyInitializer(null); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt index 332370c87eb11..7bd36c13ef6a2 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt @@ -6,11 +6,10 @@ class ProjectServiceContainer extends Container public function getFooService($lazyLoad = true) { if ($lazyLoad) { - $container = $this; return $this->services['foo'] = new stdClass_%s( - function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { - $wrappedInstance = $container->getFooService(false); + function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) { + $wrappedInstance = $this->getFooService(false); $proxy->setProxyInitializer(null); @@ -24,4 +23,4 @@ class ProjectServiceContainer extends Container } class stdClass_%s extends \stdClass implements \ProxyManager\Proxy\VirtualProxyInterface -{%a}%A \ No newline at end of file +{%a}%A diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index e3ef13d8e9a9f..efb861e9f6767 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -71,10 +71,10 @@ public function testGetProxyFactoryCode() $code = $this->dumper->getProxyFactoryCode($definition, 'foo'); $this->assertStringMatchesFormat( - '%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new ' + '%wif ($lazyLoad) {%wreturn $this->services[\'foo\'] = new ' .'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction ' - .'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {' - .'%w$wrappedInstance = $container->getFooService(false);%w$proxy->setProxyInitializer(null);' + .'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {' + .'%w$wrappedInstance = $this->getFooService(false);%w$proxy->setProxyInitializer(null);' .'%wreturn true;%w}%w);%w}%w', $code ); diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 55a46f2e6f31b..d7b7898a72be4 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -205,10 +205,8 @@ public function getFileLink($file, $line) public function formatFileFromText($text) { - $that = $this; - - return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) use ($that) { - return 'in '.$that->formatFile($match[2], $match[3]); + return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { + return 'in '.$this->formatFile($match[2], $match[3]); }, $text); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index fe5ae49b2b074..5ee9fb324dea8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -197,10 +197,8 @@ public function getFileLink($file, $line) public function formatFileFromText($text) { - $that = $this; - - return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) use ($that) { - return 'in '.$that->formatFile($match[2], $match[3]); + return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { + return 'in '.$this->formatFile($match[2], $match[3]); }, $text); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php index 1bb41737637da..df03ea8e20612 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php @@ -106,7 +106,7 @@ public static function parseEscapeSequences($str, $quote) ); } - public static function parseCallback($matches) + private static function parseCallback($matches) { $str = $matches[1]; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php index 8cb276734e762..ece847feabc6f 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php @@ -21,8 +21,6 @@ class PreviewErrorControllerTest extends TestCase { public function testForwardRequestToConfiguredController() { - $self = $this; - $request = Request::create('whatever'); $response = new Response(""); $code = 123; @@ -33,15 +31,14 @@ public function testForwardRequestToConfiguredController() ->expects($this->once()) ->method('handle') ->with( - $this->callback(function (Request $request) use ($self, $logicalControllerName, $code) { + $this->callback(function (Request $request) use ($logicalControllerName, $code) { - $self->assertEquals($logicalControllerName, $request->attributes->get('_controller')); + $this->assertEquals($logicalControllerName, $request->attributes->get('_controller')); $exception = $request->attributes->get('exception'); - $self->assertInstanceOf('Symfony\Component\Debug\Exception\FlattenException', $exception); - $self->assertEquals($code, $exception->getStatusCode()); - - $self->assertFalse($request->attributes->get('showException')); + $this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\FlattenException', $exception); + $this->assertEquals($code, $exception->getStatusCode()); + $this->assertFalse($request->attributes->get('showException')); return true; }), diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php index 64b9f8167c457..5d1a249116a45 100644 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ b/src/Symfony/Component/Console/Helper/DialogHelper.php @@ -346,10 +346,8 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback */ public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null) { - $that = $this; - - $interviewer = function () use ($output, $question, $default, $autocomplete, $that) { - return $that->ask($output, $question, $default, $autocomplete); + $interviewer = function () use ($output, $question, $default, $autocomplete) { + return $this->ask($output, $question, $default, $autocomplete); }; return $this->validateAttempts($interviewer, $output, $validator, $attempts); @@ -376,10 +374,8 @@ public function askAndValidate(OutputInterface $output, $question, $validator, $ */ public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true) { - $that = $this; - - $interviewer = function () use ($output, $question, $fallback, $that) { - return $that->askHiddenResponse($output, $question, $fallback); + $interviewer = function () use ($output, $question, $fallback) { + return $this->askHiddenResponse($output, $question, $fallback); }; return $this->validateAttempts($interviewer, $output, $validator, $attempts); diff --git a/src/Symfony/Component/Console/Helper/ProcessHelper.php b/src/Symfony/Component/Console/Helper/ProcessHelper.php index 0c9da73947623..99970c9b571a0 100644 --- a/src/Symfony/Component/Console/Helper/ProcessHelper.php +++ b/src/Symfony/Component/Console/Helper/ProcessHelper.php @@ -111,10 +111,8 @@ public function wrapCallback(OutputInterface $output, Process $process, $callbac { $formatter = $this->getHelperSet()->get('debug_formatter'); - $that = $this; - - return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) { - $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type)); + return function ($type, $buffer) use ($output, $process, $callback, $formatter) { + $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); if (null !== $callback) { call_user_func($callback, $type, $buffer); @@ -122,12 +120,7 @@ public function wrapCallback(OutputInterface $output, Process $process, $callbac }; } - /** - * This method is public for PHP 5.3 compatibility, it should be private. - * - * @internal - */ - public function escapeString($str) + private function escapeString($str) { return str_replace('<', '\\<', $str); } diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 893664e412f54..417ac08195c14 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -193,11 +193,9 @@ public function getProgress() /** * Gets the progress bar step width. * - * @internal This method is public for PHP 5.3 compatibility, it should not be used. - * - * @return int The progress bar step width + * @return int The progress bar step width */ - public function getStepWidth() + private function getStepWidth() { return $this->stepWidth; } @@ -432,15 +430,11 @@ public function display() return; } - // these 3 variables can be removed in favor of using $this in the closure when support for PHP 5.3 will be dropped. - $self = $this; - $output = $this->output; - $messages = $this->messages; - $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) { - if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) { - $text = call_user_func($formatter, $self, $output); - } elseif (isset($messages[$matches[1]])) { - $text = $messages[$matches[1]]; + $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) { + if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) { + $text = call_user_func($formatter, $this, $this->output); + } elseif (isset($this->messages[$matches[1]])) { + $text = $this->messages[$matches[1]]; } else { return $matches[0]; } diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 6a3a22a35e1ed..eeb2c947384bd 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -49,10 +49,8 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu return $this->doAsk($output, $question); } - $that = $this; - - $interviewer = function () use ($output, $question, $that) { - return $that->doAsk($output, $question); + $interviewer = function () use ($output, $question) { + return $this->doAsk($output, $question); }; return $this->validateAttempts($interviewer, $output, $question); diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 68aef1ef6c5f7..0a507bd78cf56 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -333,14 +333,13 @@ public function getParameterOption($values, $default = false) */ public function __toString() { - $self = $this; - $tokens = array_map(function ($token) use ($self) { + $tokens = array_map(function ($token) { if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { - return $match[1].$self->escapeToken($match[2]); + return $match[1].$this->escapeToken($match[2]); } if ($token && $token[0] !== '-') { - return $self->escapeToken($token); + return $this->escapeToken($token); } return $token; diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 9812729071e47..cbe582eb24068 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -112,13 +112,30 @@ public function handle(\Exception $exception) $caughtLength = $this->caughtLength = 0; - ob_start(array($this, 'catchOutput')); + ob_start(function($buffer) { + $this->caughtBuffer = $buffer; + + return ''; + }); + + $this->failSafeHandle($exception); while (null === $this->caughtBuffer && ob_end_flush()) { // Empty loop, everything is in the condition } if (isset($this->caughtBuffer[0])) { - ob_start(array($this, 'cleanOutput')); + ob_start(function($buffer) { + if ($this->caughtLength) { + // use substr_replace() instead of substr() for mbstring overloading resistance + $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength); + if (isset($cleanBuffer[0])) { + $buffer = $cleanBuffer; + } + } + + return $buffer; + }); + echo $this->caughtBuffer; $caughtLength = ob_get_length(); } @@ -426,30 +443,4 @@ protected static function utf8Htmlize($str) return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8'); } - - /** - * @internal - */ - public function catchOutput($buffer) - { - $this->caughtBuffer = $buffer; - - return ''; - } - - /** - * @internal - */ - public function cleanOutput($buffer) - { - if ($this->caughtLength) { - // use substr_replace() instead of substr() for mbstring overloading resistance - $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength); - if (isset($cleanBuffer[0])) { - $buffer = $cleanBuffer; - } - } - - return $buffer; - } } diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index c0fbb4bd4ae93..3aad901654267 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -237,14 +237,13 @@ public function testHandleError() $logger = $this->getMock('Psr\Log\LoggerInterface'); - $that = $this; - $warnArgCheck = function ($logLevel, $message, $context) use ($that) { - $that->assertEquals('info', $logLevel); - $that->assertEquals('foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_USER_DEPRECATED); - $that->assertArrayHasKey('stack', $context); - $that->assertInternalType('array', $context['stack']); + $warnArgCheck = function ($logLevel, $message, $context) { + $this->assertEquals('info', $logLevel); + $this->assertEquals('foo', $message); + $this->assertArrayHasKey('type', $context); + $this->assertEquals($context['type'], E_USER_DEPRECATED); + $this->assertArrayHasKey('stack', $context); + $this->assertInternalType('array', $context['stack']); }; $logger @@ -262,11 +261,10 @@ public function testHandleError() $logger = $this->getMock('Psr\Log\LoggerInterface'); - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Undefined variable: undefVar', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_NOTICE); + $logArgCheck = function ($level, $message, $context) { + $this->assertEquals('Undefined variable: undefVar', $message); + $this->assertArrayHasKey('type', $context); + $this->assertEquals($context['type'], E_NOTICE); }; $logger @@ -300,11 +298,10 @@ public function testHandleException() $logger = $this->getMock('Psr\Log\LoggerInterface'); - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Uncaught Exception: foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_ERROR); + $logArgCheck = function ($level, $message, $context){ + $this->assertEquals('Uncaught Exception: foo', $message); + $this->assertArrayHasKey('type', $context); + $this->assertEquals($context['type'], E_ERROR); }; $logger @@ -322,9 +319,8 @@ public function testHandleException() $this->assertSame($exception, $e); } - $that = $this; - $handler->setExceptionHandler(function ($e) use ($exception, $that) { - $that->assertSame($exception, $e); + $handler->setExceptionHandler(function ($e) use ($exception) { + $this->assertSame($exception, $e); }); $handler->handleException($exception); @@ -353,11 +349,10 @@ public function testHandleFatalError() $logger = $this->getMock('Psr\Log\LoggerInterface'); - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Fatal Parse Error: foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_ERROR); + $logArgCheck = function ($level, $message, $context) { + $this->assertEquals('Fatal Parse Error: foo', $message); + $this->assertArrayHasKey('type', $context); + $this->assertEquals($context['type'], E_ERROR); }; $logger @@ -391,11 +386,10 @@ public function testDeprecatedInterface() $logger = $this->getMock('Psr\Log\LoggerInterface'); - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Undefined variable: undefVar', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_NOTICE); + $logArgCheck = function ($level, $message, $context) { + $this->assertEquals('Undefined variable: undefVar', $message); + $this->assertArrayHasKey('type', $context); + $this->assertEquals($context['type'], E_NOTICE); }; $logger diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index 26f889288ff93..e59671c1a8d7b 100644 --- a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -81,9 +81,8 @@ public function testHandle() $handler->handle($exception); - $that = $this; - $handler->setHandler(function ($e) use ($exception, $that) { - $that->assertSame($exception, $e); + $handler->setHandler(function ($e) use ($exception) { + $this->assertSame($exception, $e); }); $handler->handle($exception); @@ -106,9 +105,8 @@ public function testHandleOutOfMemoryException() ->method('sendPhpResponse'); } - $that = $this; - $handler->setHandler(function ($e) use ($that) { - $that->fail('OutOfMemoryException should bypass the handler'); + $handler->setHandler(function ($e) { + $this->fail('OutOfMemoryException should bypass the handler'); }); $handler->handle($exception); diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 3f945d157fdb1..fe4a95113564c 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -907,25 +907,21 @@ public function findDefinition($id) * @throws RuntimeException When the factory definition is incomplete * @throws RuntimeException When the service is a synthetic service * @throws InvalidArgumentException When configure callable is not callable - * - * @internal this method is public because of PHP 5.3 limitations, do not use it explicitly in your code */ - public function createService(Definition $definition, $id, $tryProxy = true) + private function createService(Definition $definition, $id, $tryProxy = true) { if ($definition->isSynthetic()) { throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id)); } if ($tryProxy && $definition->isLazy()) { - $container = $this; - $proxy = $this ->getProxyInstantiator() ->instantiateProxy( - $container, + $this, $definition, - $id, function () use ($definition, $id, $container) { - return $container->createService($definition, $id, false); + $id, function () use ($definition, $id) { + return $this->createService($definition, $id, false); } ); $this->shareService($definition, $proxy, $id); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 065eead61707c..24e6045a0d9de 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1355,9 +1355,8 @@ private function dumpValue($value, $interpolate = true) // the preg_replace_callback converts them to strings return $this->dumpParameter(strtolower($match[1])); } else { - $that = $this; - $replaceParameters = function ($match) use ($that) { - return "'.".$that->dumpParameter(strtolower($match[2])).".'"; + $replaceParameters = function ($match) { + return "'.".$this->dumpParameter(strtolower($match[2])).".'"; }; $code = str_replace('%%', '%', preg_replace_callback('/(?export($value))); @@ -1390,7 +1389,7 @@ private function dumpLiteralClass($class) * * @return string */ - public function dumpParameter($name) + private function dumpParameter($name) { if ($this->container->isFrozen() && $this->container->hasParameter($name)) { return $this->dumpValue($this->container->getParameter($name), false); diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 12cc4810d1725..99853e72ec3b6 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -232,9 +232,7 @@ public function resolveString($value, array $resolving = array()) return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving); } - $self = $this; - - return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($self, $resolving, $value) { + return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($resolving, $value) { // skip %% if (!isset($match[1])) { return '%%'; @@ -245,7 +243,7 @@ public function resolveString($value, array $resolving = array()) throw new ParameterCircularReferenceException(array_keys($resolving)); } - $resolved = $self->get($key); + $resolved = $this->get($key); if (!is_string($resolved) && !is_numeric($resolved)) { throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, gettype($resolved), $value)); @@ -254,7 +252,7 @@ public function resolveString($value, array $resolving = array()) $resolved = (string) $resolved; $resolving[$key] = true; - return $self->isResolved() ? $resolved : $self->resolveString($resolved, $resolving); + return $this->isResolved() ? $resolved : $this->resolveString($resolved, $resolving); }, $value); } diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index f0b0ac5c36638..dd87d73fad469 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -33,10 +33,8 @@ public function __construct(MetadataFactoryInterface $metadataFactory) */ public function guessType($class, $property) { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessTypeForConstraint($constraint); + return $this->guess($class, $property, function (Constraint $constraint) { + return $this->guessTypeForConstraint($constraint); }); } @@ -45,10 +43,8 @@ public function guessType($class, $property) */ public function guessRequired($class, $property) { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessRequiredForConstraint($constraint); + return $this->guess($class, $property, function (Constraint $constraint) { + return $this->guessRequiredForConstraint($constraint); // If we don't find any constraint telling otherwise, we can assume // that a field is not required (with LOW_CONFIDENCE) }, false); @@ -59,10 +55,8 @@ public function guessRequired($class, $property) */ public function guessMaxLength($class, $property) { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessMaxLengthForConstraint($constraint); + return $this->guess($class, $property, function (Constraint $constraint) { + return $this->guessMaxLengthForConstraint($constraint); }); } @@ -71,10 +65,8 @@ public function guessMaxLength($class, $property) */ public function guessPattern($class, $property) { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessPatternForConstraint($constraint); + return $this->guess($class, $property, function (Constraint $constraint) { + return $this->guessPatternForConstraint($constraint); }); } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index 9bb2528c6eb09..07482648623f0 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -316,7 +316,6 @@ public function testIterator() public function testAddMapsViewDataToFormIfInitialized() { - $test = $this; $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) @@ -332,9 +331,9 @@ public function testAddMapsViewDataToFormIfInitialized() $mapper->expects($this->once()) ->method('mapDataToForms') ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array($child), iterator_to_array($iterator)); + ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { + $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertSame(array($child), iterator_to_array($iterator)); })); $form->initialize(); @@ -410,7 +409,6 @@ public function testSetDataSupportsDynamicAdditionAndRemovalOfChildren() public function testSetDataMapsViewDataToChildren() { - $test = $this; $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) @@ -427,9 +425,9 @@ public function testSetDataMapsViewDataToChildren() $mapper->expects($this->once()) ->method('mapDataToForms') ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); + ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { + $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); })); $form->setData('foo'); @@ -465,7 +463,6 @@ public function testSubmitSupportsDynamicAdditionAndRemovalOfChildren() public function testSubmitMapsSubmittedChildrenOntoExistingViewData() { - $test = $this; $mapper = $this->getDataMapper(); $form = $this->getBuilder() ->setCompound(true) @@ -483,11 +480,11 @@ public function testSubmitMapsSubmittedChildrenOntoExistingViewData() $mapper->expects($this->once()) ->method('mapFormsToData') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); - $test->assertEquals('Bernhard', $child1->getData()); - $test->assertEquals('Schussek', $child2->getData()); + ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { + $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); + $this->assertEquals('Bernhard', $child1->getData()); + $this->assertEquals('Schussek', $child2->getData()); })); $form->submit(array( @@ -541,7 +538,6 @@ public function testSubmitRestoresViewDataIfCompoundAndEmpty() public function testSubmitMapsSubmittedChildrenOntoEmptyData() { - $test = $this; $mapper = $this->getDataMapper(); $object = new \stdClass(); $form = $this->getBuilder() @@ -556,9 +552,9 @@ public function testSubmitMapsSubmittedChildrenOntoEmptyData() $mapper->expects($this->once()) ->method('mapFormsToData') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array('name' => $child), iterator_to_array($iterator)); + ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { + $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertSame(array('name' => $child), iterator_to_array($iterator)); })); $form->submit(array( @@ -919,12 +915,9 @@ public function testCreateViewWithChildren() $this->form->add($field1); $this->form->add($field2); - $test = $this; - - $assertChildViewsEqual = function (array $childViews) use ($test) { - return function (FormView $view) use ($test, $childViews) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertSame($childViews, $view->children); + $assertChildViewsEqual = function (array $childViews) { + return function (FormView $view) use ($childViews) { + $this->assertSame($childViews, $view->children); }; }; diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index d1982c1c23036..1000c521b4030 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -62,13 +62,11 @@ public function testGetOptionsResolver() $this->markTestSkipped('This test requires PHPUnit 3.7.'); } - $test = $this; $i = 0; - $assertIndexAndAddOption = function ($index, $option, $default) use (&$i, $test) { - return function (OptionsResolverInterface $resolver) use (&$i, $test, $index, $option, $default) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); + $assertIndexAndAddOption = function ($index, $option, $default) use (&$i) { + return function (OptionsResolverInterface $resolver) use (&$i, $index, $option, $default) { + $this->assertEquals($index, $i, 'Executed at index '.$index); ++$i; @@ -173,13 +171,11 @@ public function testBuildForm() $this->markTestSkipped('This test requires PHPUnit 3.7.'); } - $test = $this; $i = 0; - $assertIndex = function ($index) use (&$i, $test) { - return function () use (&$i, $test, $index) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); + $assertIndex = function ($index) use (&$i) { + return function () use (&$i, $index) { + $this->assertEquals($index, $i, 'Executed at index '.$index); ++$i; }; @@ -241,13 +237,11 @@ public function testBuildView() $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $view = $this->getMock('Symfony\Component\Form\FormView'); - $test = $this; $i = 0; - $assertIndex = function ($index) use (&$i, $test) { - return function () use (&$i, $test, $index) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); + $assertIndex = function ($index) use (&$i) { + return function () use (&$i, $index) { + $this->assertEquals($index, $i, 'Executed at index '.$index); ++$i; }; @@ -285,13 +279,12 @@ public function testFinishView() $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $view = $this->getMock('Symfony\Component\Form\FormView'); - $test = $this; $i = 0; - $assertIndex = function ($index) use (&$i, $test) { - return function () use (&$i, $test, $index) { + $assertIndex = function ($index) use (&$i) { + return function () use (&$i, $index) { /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); + $this->assertEquals($index, $i, 'Executed at index '.$index); ++$i; }; diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 6cebba753802c..21d9848f9018c 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -654,12 +654,11 @@ public function testEmptyDataCreatedBeforeTransforming() public function testEmptyDataFromClosure() { - $test = $this; $form = $this->getBuilder() - ->setEmptyData(function ($form) use ($test) { + ->setEmptyData(function ($form) { // the form instance is passed to the closure to allow use // of form data when creating the empty value - $test->assertInstanceOf('Symfony\Component\Form\FormInterface', $form); + $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $form); return 'foo'; }) @@ -899,12 +898,10 @@ public function testSetDataCannotInvokeItself() public function testSubmittingWrongDataIsIgnored() { - $test = $this; - $child = $this->getBuilder('child', $this->dispatcher); - $child->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($test) { + $child->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { // child form doesn't receive the wrong data that is submitted on parent - $test->assertNull($event->getData()); + $this->assertNull($event->getData()); }); $parent = $this->getBuilder('parent', new EventDispatcher()) @@ -1004,10 +1001,9 @@ public function testGetViewDataRequiresParentToBeSetIfInheritData() public function testPostSubmitDataIsNullIfInheritData() { - $test = $this; $form = $this->getBuilder() - ->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($test) { - $test->assertNull($event->getData()); + ->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { + $this->assertNull($event->getData()); }) ->setInheritData(true) ->getForm(); @@ -1017,10 +1013,9 @@ public function testPostSubmitDataIsNullIfInheritData() public function testSubmitIsNeverFiredIfInheritData() { - $test = $this; $form = $this->getBuilder() - ->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) use ($test) { - $test->fail('The SUBMIT event should not be fired'); + ->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { + $this->fail('The SUBMIT event should not be fired'); }) ->setInheritData(true) ->getForm(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 63d6d1e92383d..254dc846085f9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -82,14 +82,13 @@ public function testWrite() ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); - $that = $this; $data = array(); $collection->expects($this->once()) ->method('update') - ->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) { - $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria); - $that->assertEquals(array('upsert' => true, 'multiple' => false), $options); + ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + $this->assertEquals(array($this->options['id_field'] => 'foo'), $criteria); + $this->assertEquals(array('upsert' => true, 'multiple' => false), $options); $data = $updateData['$set']; })); @@ -97,7 +96,7 @@ public function testWrite() $this->assertTrue($this->storage->write('foo', 'bar')); $this->assertEquals('bar', $data[$this->options['data_field']]->bin); - $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); + $this->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); } public function testWriteWhenUsingExpiresField() @@ -120,14 +119,13 @@ public function testWriteWhenUsingExpiresField() ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); - $that = $this; $data = array(); $collection->expects($this->once()) ->method('update') - ->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) { - $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria); - $that->assertEquals(array('upsert' => true, 'multiple' => false), $options); + ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + $this->assertEquals(array($this->options['id_field'] => 'foo'), $criteria); + $this->assertEquals(array('upsert' => true, 'multiple' => false), $options); $data = $updateData['$set']; })); @@ -135,8 +133,8 @@ public function testWriteWhenUsingExpiresField() $this->assertTrue($this->storage->write('foo', 'bar')); $this->assertEquals('bar', $data[$this->options['data_field']]->bin); - $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); - $that->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); + $this->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); + $this->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); } public function testReplaceSessionData() @@ -187,13 +185,11 @@ public function testGc() ->with($this->options['database'], $this->options['collection']) ->will($this->returnValue($collection)); - $that = $this; - $collection->expects($this->once()) ->method('remove') - ->will($this->returnCallback(function ($criteria) use ($that) { - $that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']); - $that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['time_field']]['$lt']->sec); + ->will($this->returnCallback(function ($criteria) { + $this->assertInstanceOf('MongoDate', $criteria[$this->options['time_field']]['$lt']); + $this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['time_field']]['$lt']->sec); })); $this->assertTrue($this->storage->gc(1)); @@ -217,8 +213,6 @@ public function testGcWhenUsingExpiresField() $this->mongo->expects($this->never()) ->method('selectCollection'); - $that = $this; - $collection->expects($this->never()) ->method('remove'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php index 5c8fdb6ed1788..9272bed3ef567 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php @@ -47,7 +47,7 @@ public function testDump() 'fileExcerpt' => false, ), ); - $this->assertSame($xDump, $dump); + $this->assertEquals($xDump, $dump); $this->assertStringStartsWith( 'a:1:{i:0;a:5:{s:4:"data";O:39:"Symfony\Component\VarDumper\Cloner\Data":4:{s:45:"Symfony\Component\VarDumper\Cloner\Datadata";a:1:{i:0;a:1:{i:0;i:123;}}s:49:"Symfony\Component\VarDumper\Cloner\DatamaxDepth";i:-1;s:57:"Symfony\Component\VarDumper\Cloner\DatamaxItemsPerDepth";i:-1;s:54:"Symfony\Component\VarDumper\Cloner\DatauseRefHandles";i:-1;}s:4:"name";s:25:"DumpDataCollectorTest.php";s:4:"file";s:', diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 7da3030edb526..a99d66fdfa6c4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -850,11 +850,10 @@ public function testReplacesCachedResponsesWhenValidationResultsInNon304Response public function testPassesHeadRequestsThroughDirectlyOnPass() { - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) { + $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { $response->setContent(''); $response->setStatusCode(200); - $that->assertEquals('HEAD', $request->getMethod()); + $this->assertEquals('HEAD', $request->getMethod()); }); $this->request('HEAD', '/', array('HTTP_EXPECT' => 'something ...')); @@ -864,12 +863,11 @@ public function testPassesHeadRequestsThroughDirectlyOnPass() public function testUsesCacheToRespondToHeadRequestsWhenFresh() { - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) { + $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { $response->headers->set('Cache-Control', 'public, max-age=10'); $response->setContent('Hello World'); $response->setStatusCode(200); - $that->assertNotEquals('HEAD', $request->getMethod()); + $this->assertNotEquals('HEAD', $request->getMethod()); }); $this->request('GET', '/'); @@ -886,8 +884,7 @@ public function testUsesCacheToRespondToHeadRequestsWhenFresh() public function testSendsNoContentWhenFresh() { $time = \DateTime::createFromFormat('U', time()); - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) { + $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) { $response->headers->set('Cache-Control', 'public, max-age=10'); $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); }); diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php index d3ca9451b37a7..329eef31297ee 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php @@ -88,10 +88,8 @@ public function getTransformers() */ public function format(\DateTime $dateTime) { - $that = $this; - - $formatted = preg_replace_callback($this->regExp, function ($matches) use ($that, $dateTime) { - return $that->formatReplace($matches[0], $dateTime); + $formatted = preg_replace_callback($this->regExp, function ($matches) use ($dateTime) { + return $this->formatReplace($matches[0], $dateTime); }, $this->pattern); return $formatted; @@ -176,24 +174,22 @@ public function parse(\DateTime $dateTime, $value) */ public function getReverseMatchingRegExp($pattern) { - $that = $this; - $escapedPattern = preg_quote($pattern, '/'); // ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa // when parsing a date/time value $escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern); - $reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) use ($that) { + $reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) { $length = strlen($matches[0]); $transformerIndex = $matches[0][0]; $dateChars = $matches[0]; - if ($that->isQuoteMatch($dateChars)) { - return $that->replaceQuoteMatch($dateChars); + if ($this->isQuoteMatch($dateChars)) { + return $this->replaceQuoteMatch($dateChars); } - $transformers = $that->getTransformers(); + $transformers = $this->getTransformers(); if (isset($transformers[$transformerIndex])) { $transformer = $transformers[$transformerIndex]; $captureName = str_repeat($transformerIndex, $length); diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index 064487ff68556..9becb4c8e005a 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -99,16 +99,13 @@ public function testResolveLazyDependencyOnOptional() public function testResolveLazyDependencyOnMissingOptionalWithoutDefault() { - $test = $this; - $this->resolver->setOptional(array( 'one', )); $this->resolver->setDefaults(array( - 'two' => function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertFalse(isset($options['one'])); + 'two' => function (Options $options) { + $this->assertFalse(isset($options['one'])); return '2'; }, @@ -123,16 +120,13 @@ public function testResolveLazyDependencyOnMissingOptionalWithoutDefault() public function testResolveLazyDependencyOnOptionalWithoutDefault() { - $test = $this; - $this->resolver->setOptional(array( 'one', )); $this->resolver->setDefaults(array( - 'two' => function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertTrue(isset($options['one'])); + 'two' => function (Options $options) { + $this->assertTrue(isset($options['one'])); return $options['one'].'2'; }, @@ -171,12 +165,9 @@ public function testResolveLazyDependencyOnRequired() public function testResolveLazyReplaceDefaults() { - $test = $this; - $this->resolver->setDefaults(array( - 'one' => function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->fail('Previous closure should not be executed'); + 'one' => function (Options $options) { + $this->fail('Previous closure should not be executed'); }, )); diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php index 5d569ebe02bd7..d3c9958ec1998 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php @@ -31,9 +31,7 @@ protected function setUp() public function testSetLazyOption() { - $test = $this; - - $this->options->set('foo', function (Options $options) use ($test) { + $this->options->set('foo', function (Options $options) { return 'dynamic'; }); @@ -42,15 +40,12 @@ public function testSetLazyOption() public function testOverloadKeepsPreviousValue() { - $test = $this; - // defined by superclass $this->options->set('foo', 'bar'); // defined by subclass - $this->options->overload('foo', function (Options $options, $previousValue) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals('bar', $previousValue); + $this->options->overload('foo', function (Options $options, $previousValue) { + $this->assertEquals('bar', $previousValue); return 'dynamic'; }); @@ -60,17 +55,14 @@ public function testOverloadKeepsPreviousValue() public function testPreviousValueIsEvaluatedIfLazy() { - $test = $this; - // defined by superclass $this->options->set('foo', function (Options $options) { return 'bar'; }); // defined by subclass - $this->options->overload('foo', function (Options $options, $previousValue) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals('bar', $previousValue); + $this->options->overload('foo', function (Options $options, $previousValue) { + $this->assertEquals('bar', $previousValue); return 'dynamic'; }); @@ -80,15 +72,13 @@ public function testPreviousValueIsEvaluatedIfLazy() public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() { - $test = $this; - // defined by superclass - $this->options->set('foo', function (Options $options) use ($test) { - $test->fail('Should not be called'); + $this->options->set('foo', function (Options $options) { + $this->fail('Should not be called'); }); // defined by subclass, no $previousValue argument defined! - $this->options->overload('foo', function (Options $options) use ($test) { + $this->options->overload('foo', function (Options $options) { return 'dynamic'; }); @@ -97,13 +87,10 @@ public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() public function testLazyOptionCanAccessOtherOptions() { - $test = $this; - $this->options->set('foo', 'bar'); - $this->options->set('bam', function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals('bar', $options->get('foo')); + $this->options->set('bam', function (Options $options) { + $this->assertEquals('bar', $options->get('foo')); return 'dynamic'; }); @@ -113,15 +100,12 @@ public function testLazyOptionCanAccessOtherOptions() public function testLazyOptionCanAccessOtherLazyOptions() { - $test = $this; - $this->options->set('foo', function (Options $options) { return 'bar'; }); - $this->options->set('bam', function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals('bar', $options->get('foo')); + $this->options->set('bam', function (Options $options) { + $this->assertEquals('bar', $options->get('foo')); return 'dynamic'; }); @@ -153,14 +137,11 @@ public function testNormalizerReceivesUnnormalizedValue() public function testNormalizerCanAccessOtherOptions() { - $test = $this; - $this->options->set('foo', 'bar'); $this->options->set('bam', 'baz'); - $this->options->setNormalizer('bam', function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals('bar', $options->get('foo')); + $this->options->setNormalizer('bam', function (Options $options) { + $this->assertEquals('bar', $options->get('foo')); return 'normalized'; }); @@ -170,16 +151,13 @@ public function testNormalizerCanAccessOtherOptions() public function testNormalizerCanAccessOtherLazyOptions() { - $test = $this; - $this->options->set('foo', function (Options $options) { return 'bar'; }); $this->options->set('bam', 'baz'); - $this->options->setNormalizer('bam', function (Options $options) use ($test) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals('bar', $options->get('foo')); + $this->options->setNormalizer('bam', function (Options $options) { + $this->assertEquals('bar', $options->get('foo')); return 'normalized'; }); diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index c1181ef92eb47..264312289f952 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1247,14 +1247,13 @@ private function getDescriptors() */ protected function buildCallback($callback) { - $that = $this; $out = self::OUT; $err = self::ERR; - $callback = function ($type, $data) use ($that, $callback, $out, $err) { + $callback = function ($type, $data) use ($callback, $out, $err) { if ($out == $type) { - $that->addOutput($data); + $this->addOutput($data); } else { - $that->addErrorOutput($data); + $this->addErrorOutput($data); } if (null !== $callback) { diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index db901b8cad261..60da1350cbce5 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -457,7 +457,6 @@ public function getGlobals() */ protected function initializeEscapers() { - $that = $this; if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { @@ -473,10 +472,10 @@ protected function initializeEscapers() * * @return string the escaped value */ - function ($value) use ($that, $flags) { + function ($value) use ($flags) { // Numbers and Boolean values get turned into strings which can cause problems // with type comparisons (e.g. === or is_int() etc). - return is_string($value) ? htmlspecialchars($value, $flags, $that->getCharset(), false) : $value; + return is_string($value) ? htmlspecialchars($value, $flags, $this->getCharset(), false) : $value; }, 'js' => @@ -487,7 +486,7 @@ function ($value) use ($that, $flags) { * @param string $value the value to escape * @return string the escaped value */ - function ($value) use ($that) { + function ($value) { if ('UTF-8' != $that->getCharset()) { $value = $that->convertEncoding($value, 'UTF-8', $that->getCharset()); } @@ -510,8 +509,8 @@ function ($value) use ($that) { throw new \InvalidArgumentException('The string to escape is not a valid UTF-8 string.'); } - if ('UTF-8' != $that->getCharset()) { - $value = $that->convertEncoding($value, $that->getCharset(), 'UTF-8'); + if ('UTF-8' != $this->getCharset()) { + $value = $this->convertEncoding($value, $that->getCharset(), 'UTF-8'); } return $value; diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php index fa0134aae1a9e..6fbfdb511fbee 100644 --- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php @@ -103,15 +103,15 @@ public function testExtendRender() $engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader, array(new SlotsHelper())); $engine->set(new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('bar')); - $this->loader->setTemplate('foo.php', 'extend("layout.php"); echo $view[\'foo\'].$foo ?>'); - $this->loader->setTemplate('layout.php', '-get("_content") ?>-'); + $this->loader->setTemplate('foo.php', 'extend("layout.php"); echo $this[\'foo\'].$foo ?>'); + $this->loader->setTemplate('layout.php', '-get("_content") ?>-'); $this->assertEquals('-barfoo-', $engine->render('foo.php', array('foo' => 'foo')), '->render() uses the decorator to decorate the template'); $engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader, array(new SlotsHelper())); $engine->set(new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('bar')); $this->loader->setTemplate('bar.php', 'bar'); - $this->loader->setTemplate('foo.php', 'extend("layout.php"); echo $foo ?>'); - $this->loader->setTemplate('layout.php', 'render("bar.php") ?>-get("_content") ?>-'); + $this->loader->setTemplate('foo.php', 'extend("layout.php"); echo $foo ?>'); + $this->loader->setTemplate('layout.php', 'render("bar.php") ?>-get("_content") ?>-'); $this->assertEquals('bar-foo-', $engine->render('foo.php', array('foo' => 'foo', 'bar' => 'bar')), '->render() supports render() calls in templates'); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php index b55985292d503..f54547ca18c3a 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php @@ -63,7 +63,6 @@ public function testWriteMetadataToCache() $cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface'); $factory = new ClassMetadataFactory(new TestLoader(), $cache); - $tester = $this; $constraints = array( new ConstraintA(array('groups' => array('Default', 'EntityParent'))), ); @@ -76,8 +75,8 @@ public function testWriteMetadataToCache() ->will($this->returnValue(false)); $cache->expects($this->once()) ->method('write') - ->will($this->returnCallback(function ($metadata) use ($tester, $constraints) { - $tester->assertEquals($constraints, $metadata->getConstraints()); + ->will($this->returnCallback(function ($metadata) use ($constraints) { + $this->assertEquals($constraints, $metadata->getConstraints()); })); $metadata = $factory->getMetadataFor(self::PARENTCLASS); @@ -92,7 +91,6 @@ public function testReadMetadataFromCache() $cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface'); $factory = new ClassMetadataFactory($loader, $cache); - $tester = $this; $metadata = new ClassMetadata(self::PARENTCLASS); $metadata->addConstraint(new ConstraintA()); diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php index c214b9c07bc5a..9bbaffcf81425 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php @@ -139,11 +139,10 @@ public function testGroupSequenceIncludesReferences() public function testValidateInSeparateContext() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { + $callback1 = function ($value, ExecutionContextInterface $context) use ($entity) { $violations = $context ->getValidator() // Since the validator is not context aware, the group must @@ -152,30 +151,30 @@ public function testValidateInSeparateContext() ; /** @var ConstraintViolationInterface[] $violations */ - $test->assertCount(1, $violations); - $test->assertSame('Message value', $violations[0]->getMessage()); - $test->assertSame('Message %param%', $violations[0]->getMessageTemplate()); - $test->assertSame(array('%param%' => 'value'), $violations[0]->getMessageParameters()); - $test->assertSame('', $violations[0]->getPropertyPath()); + $this->assertCount(1, $violations); + $this->assertSame('Message value', $violations[0]->getMessage()); + $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); + $this->assertSame(array('%param%' => 'value'), $violations[0]->getMessageParameters()); + $this->assertSame('', $violations[0]->getPropertyPath()); // The root is different as we're in a new context - $test->assertSame($entity->reference, $violations[0]->getRoot()); - $test->assertSame($entity->reference, $violations[0]->getInvalidValue()); - $test->assertNull($violations[0]->getMessagePluralization()); - $test->assertNull($violations[0]->getCode()); + $this->assertSame($entity->reference, $violations[0]->getRoot()); + $this->assertSame($entity->reference, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); // Verify that this method is called $context->addViolation('Separate violation'); }; - $callback2 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity->reference, $context->getRoot()); - $test->assertSame($entity->reference, $context->getValue()); - $test->assertSame($entity->reference, $value); + $callback2 = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity->reference, $context->getRoot()); + $this->assertSame($entity->reference, $context->getValue()); + $this->assertSame($entity->reference, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -193,16 +192,15 @@ public function testValidateInSeparateContext() /** @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); - $test->assertSame('Separate violation', $violations[0]->getMessage()); + $this->assertSame('Separate violation', $violations[0]->getMessage()); } public function testValidateInContext() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $callback1 = function ($value, ExecutionContextInterface $context) { $previousValue = $context->getValue(); $previousObject = $context->getObject(); $previousMetadata = $context->getMetadata(); @@ -217,22 +215,22 @@ public function testValidateInContext() ; // context changes shouldn't leak out of the validate() call - $test->assertSame($previousValue, $context->getValue()); - $test->assertSame($previousObject, $context->getObject()); - $test->assertSame($previousMetadata, $context->getMetadata()); - $test->assertSame($previousPath, $context->getPropertyPath()); - $test->assertSame($previousGroup, $context->getGroup()); + $this->assertSame($previousValue, $context->getValue()); + $this->assertSame($previousObject, $context->getObject()); + $this->assertSame($previousMetadata, $context->getMetadata()); + $this->assertSame($previousPath, $context->getPropertyPath()); + $this->assertSame($previousGroup, $context->getGroup()); }; - $callback2 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('subpath', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference, $context->getValue()); - $test->assertSame($entity->reference, $value); + $callback2 = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('subpath', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference, $context->getValue()); + $this->assertSame($entity->reference, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -262,11 +260,10 @@ public function testValidateInContext() public function testValidateArrayInContext() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $callback1 = function ($value, ExecutionContextInterface $context) { $previousValue = $context->getValue(); $previousObject = $context->getObject(); $previousMetadata = $context->getMetadata(); @@ -281,22 +278,22 @@ public function testValidateArrayInContext() ; // context changes shouldn't leak out of the validate() call - $test->assertSame($previousValue, $context->getValue()); - $test->assertSame($previousObject, $context->getObject()); - $test->assertSame($previousMetadata, $context->getMetadata()); - $test->assertSame($previousPath, $context->getPropertyPath()); - $test->assertSame($previousGroup, $context->getGroup()); + $this->assertSame($previousValue, $context->getValue()); + $this->assertSame($previousObject, $context->getObject()); + $this->assertSame($previousMetadata, $context->getMetadata()); + $this->assertSame($previousPath, $context->getPropertyPath()); + $this->assertSame($previousGroup, $context->getGroup()); }; - $callback2 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('subpath[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference, $context->getValue()); - $test->assertSame($entity->reference, $value); + $callback2 = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('subpath[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference, $context->getValue()); + $this->assertSame($entity->reference, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -326,19 +323,18 @@ public function testValidateArrayInContext() public function testTraverseTraversableByDefault() { - $test = $this; $entity = new Entity(); $traversable = new \ArrayIterator(array('key' => $entity)); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, $traversable) { - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->metadata, $context->getMetadata()); - $test->assertSame($traversable, $context->getRoot()); - $test->assertSame($entity, $context->getValue()); - $test->assertSame($entity, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity, $traversable) { + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->metadata, $context->getMetadata()); + $this->assertSame($traversable, $context->getRoot()); + $this->assertSame($entity, $context->getValue()); + $this->assertSame($entity, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -389,12 +385,11 @@ public function testTraversalEnabledOnClass() public function testTraversalDisabledOnClass() { - $test = $this; $entity = new Entity(); $traversable = new \ArrayIterator(array('key' => $entity)); - $callback = function ($value, ExecutionContextInterface $context) use ($test) { - $test->fail('Should not be called'); + $callback = function ($value, ExecutionContextInterface $context) { + $this->fail('Should not be called'); }; $traversableMetadata = new ClassMetadata('ArrayIterator'); @@ -426,12 +421,11 @@ public function testExpectTraversableIfTraversalEnabledOnClass() public function testReferenceTraversalDisabledOnClass() { - $test = $this; $entity = new Entity(); $entity->reference = new \ArrayIterator(array('key' => new Reference())); - $callback = function ($value, ExecutionContextInterface $context) use ($test) { - $test->fail('Should not be called'); + $callback = function ($value, ExecutionContextInterface $context) { + $this->fail('Should not be called'); }; $traversableMetadata = new ClassMetadata('ArrayIterator'); @@ -452,12 +446,11 @@ public function testReferenceTraversalDisabledOnClass() public function testReferenceTraversalEnabledOnReferenceDisabledOnClass() { - $test = $this; $entity = new Entity(); $entity->reference = new \ArrayIterator(array('key' => new Reference())); - $callback = function ($value, ExecutionContextInterface $context) use ($test) { - $test->fail('Should not be called'); + $callback = function ($value, ExecutionContextInterface $context) { + $this->fail('Should not be called'); }; $traversableMetadata = new ClassMetadata('ArrayIterator'); @@ -480,12 +473,11 @@ public function testReferenceTraversalEnabledOnReferenceDisabledOnClass() public function testReferenceTraversalDisabledOnReferenceEnabledOnClass() { - $test = $this; $entity = new Entity(); $entity->reference = new \ArrayIterator(array('key' => new Reference())); - $callback = function ($value, ExecutionContextInterface $context) use ($test) { - $test->fail('Should not be called'); + $callback = function ($value, ExecutionContextInterface $context) { + $this->fail('Should not be called'); }; $traversableMetadata = new ClassMetadata('ArrayIterator'); @@ -537,14 +529,13 @@ public function testReferenceTraversalRecursionEnabledOnReferenceTraversalEnable public function testReferenceTraversalRecursionDisabledOnReferenceTraversalEnabledOnClass() { - $test = $this; $entity = new Entity(); $entity->reference = new \ArrayIterator(array( 2 => new \ArrayIterator(array('key' => new Reference())), )); - $callback = function ($value, ExecutionContextInterface $context) use ($test) { - $test->fail('Should not be called'); + $callback = function ($value, ExecutionContextInterface $context) { + $this->fail('Should not be called'); }; $traversableMetadata = new ClassMetadata('ArrayIterator'); @@ -696,14 +687,13 @@ public function testValidateFailsIfNoConstraintsAndNoObjectOrArray() public function testAccessCurrentObject() { - $test = $this; $called = false; $entity = new Entity(); $entity->firstName = 'Bernhard'; - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, &$called) { + $callback = function ($value, ExecutionContextInterface $context) use ($entity, &$called) { $called = true; - $test->assertSame($entity, $context->getObject()); + $this->assertSame($entity, $context->getObject()); }; $this->metadata->addConstraint(new Callback($callback)); @@ -716,7 +706,6 @@ public function testAccessCurrentObject() public function testInitializeObjectsOnFirstValidation() { - $test = $this; $entity = new Entity(); $entity->initialized = false; @@ -743,8 +732,8 @@ public function testInitializeObjectsOnFirstValidation() // prepare constraint which // * checks that "initialized" is set to true // * validates the object again - $callback = function ($object, ExecutionContextInterface $context) use ($test) { - $test->assertTrue($object->initialized); + $callback = function ($object, ExecutionContextInterface $context) { + $this->assertTrue($object->initialized); // validate again in same group $validator = $context->getValidator()->inContext($context); diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php index 748e106d402ec..f1a8eedd44750 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php @@ -75,12 +75,11 @@ protected function validatePropertyValue($object, $propertyName, $value, $groups */ public function testTraversableTraverseDisabled() { - $test = $this; $entity = new Entity(); $traversable = new \ArrayIterator(array('key' => $entity)); - $callback = function () use ($test) { - $test->fail('Should not be called'); + $callback = function () { + $this->fail('Should not be called'); }; $this->metadata->addConstraint(new Callback(array( @@ -96,14 +95,13 @@ public function testTraversableTraverseDisabled() */ public function testRecursiveTraversableRecursiveTraversalDisabled() { - $test = $this; $entity = new Entity(); $traversable = new \ArrayIterator(array( 2 => new \ArrayIterator(array('key' => $entity)), )); - $callback = function () use ($test) { - $test->fail('Should not be called'); + $callback = function () { + $this->fail('Should not be called'); }; $this->metadata->addConstraint(new Callback(array( @@ -116,11 +114,10 @@ public function testRecursiveTraversableRecursiveTraversalDisabled() public function testValidateInContext() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $callback1 = function ($value, ExecutionContextInterface $context) { $previousValue = $context->getValue(); $previousMetadata = $context->getMetadata(); $previousPath = $context->getPropertyPath(); @@ -129,22 +126,22 @@ public function testValidateInContext() $context->validate($value->reference, 'subpath'); // context changes shouldn't leak out of the validate() call - $test->assertSame($previousValue, $context->getValue()); - $test->assertSame($previousMetadata, $context->getMetadata()); - $test->assertSame($previousPath, $context->getPropertyPath()); - $test->assertSame($previousGroup, $context->getGroup()); + $this->assertSame($previousValue, $context->getValue()); + $this->assertSame($previousMetadata, $context->getMetadata()); + $this->assertSame($previousPath, $context->getPropertyPath()); + $this->assertSame($previousGroup, $context->getGroup()); }; - $callback2 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('subpath', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($test->metadataFactory, $context->getMetadataFactory()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference, $context->getValue()); - $test->assertSame($entity->reference, $value); + $callback2 = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('subpath', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($this->metadataFactory, $context->getMetadataFactory()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference, $context->getValue()); + $this->assertSame($entity->reference, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -174,11 +171,10 @@ public function testValidateInContext() public function testValidateArrayInContext() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $callback1 = function ($value, ExecutionContextInterface $context) { $previousValue = $context->getValue(); $previousMetadata = $context->getMetadata(); $previousPath = $context->getPropertyPath(); @@ -187,22 +183,22 @@ public function testValidateArrayInContext() $context->validate(array('key' => $value->reference), 'subpath'); // context changes shouldn't leak out of the validate() call - $test->assertSame($previousValue, $context->getValue()); - $test->assertSame($previousMetadata, $context->getMetadata()); - $test->assertSame($previousPath, $context->getPropertyPath()); - $test->assertSame($previousGroup, $context->getGroup()); + $this->assertSame($previousValue, $context->getValue()); + $this->assertSame($previousMetadata, $context->getMetadata()); + $this->assertSame($previousPath, $context->getPropertyPath()); + $this->assertSame($previousGroup, $context->getGroup()); }; - $callback2 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('subpath[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($test->metadataFactory, $context->getMetadataFactory()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference, $context->getValue()); - $test->assertSame($entity->reference, $value); + $callback2 = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('subpath[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($this->metadataFactory, $context->getMetadataFactory()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference, $context->getValue()); + $this->assertSame($entity->reference, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -262,7 +258,6 @@ public function testAddCustomizedViolation() public function testInitializeObjectsOnFirstValidation() { - $test = $this; $entity = new Entity(); $entity->initialized = false; @@ -289,8 +284,8 @@ public function testInitializeObjectsOnFirstValidation() // prepare constraint which // * checks that "initialized" is set to true // * validates the object again - $callback = function ($object, ExecutionContextInterface $context) use ($test) { - $test->assertTrue($object->initialized); + $callback = function ($object, ExecutionContextInterface $context) { + $this->assertTrue($object->initialized); // validate again in same group $context->validate($object); diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php index 2236d6cb02cd3..b1f2cb0b072ca 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php @@ -71,16 +71,14 @@ abstract protected function validatePropertyValue($object, $propertyName, $value public function testValidate() { - $test = $this; - - $callback = function ($value, ExecutionContextInterface $context) use ($test) { - $test->assertNull($context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame('Bernhard', $context->getRoot()); - $test->assertSame('Bernhard', $context->getValue()); - $test->assertSame('Bernhard', $value); + $callback = function ($value, ExecutionContextInterface $context) { + $this->assertNull($context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame('Bernhard', $context->getRoot()); + $this->assertSame('Bernhard', $context->getValue()); + $this->assertSame('Bernhard', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -106,18 +104,17 @@ public function testValidate() public function testClassConstraint() { - $test = $this; $entity = new Entity(); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->metadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity, $context->getValue()); - $test->assertSame($entity, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->metadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity, $context->getValue()); + $this->assertSame($entity, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -143,21 +140,20 @@ public function testClassConstraint() public function testPropertyConstraint() { - $test = $this; $entity = new Entity(); $entity->firstName = 'Bernhard'; - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $propertyMetadatas = $test->metadata->getPropertyMetadata('firstName'); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $propertyMetadatas = $this->metadata->getPropertyMetadata('firstName'); - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertSame('firstName', $context->getPropertyName()); - $test->assertSame('firstName', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame('Bernhard', $context->getValue()); - $test->assertSame('Bernhard', $value); + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertSame('firstName', $context->getPropertyName()); + $this->assertSame('firstName', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame('Bernhard', $context->getValue()); + $this->assertSame('Bernhard', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -183,21 +179,20 @@ public function testPropertyConstraint() public function testGetterConstraint() { - $test = $this; $entity = new Entity(); $entity->setLastName('Schussek'); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $propertyMetadatas = $test->metadata->getPropertyMetadata('lastName'); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $propertyMetadatas = $this->metadata->getPropertyMetadata('lastName'); - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertSame('lastName', $context->getPropertyName()); - $test->assertSame('lastName', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame('Schussek', $context->getValue()); - $test->assertSame('Schussek', $value); + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertSame('lastName', $context->getPropertyName()); + $this->assertSame('lastName', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame('Schussek', $context->getValue()); + $this->assertSame('Schussek', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -223,19 +218,18 @@ public function testGetterConstraint() public function testArray() { - $test = $this; $entity = new Entity(); $array = array('key' => $entity); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, $array) { - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->metadata, $context->getMetadata()); - $test->assertSame($array, $context->getRoot()); - $test->assertSame($entity, $context->getValue()); - $test->assertSame($entity, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity, $array) { + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->metadata, $context->getMetadata()); + $this->assertSame($array, $context->getRoot()); + $this->assertSame($entity, $context->getValue()); + $this->assertSame($entity, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -261,19 +255,18 @@ public function testArray() public function testRecursiveArray() { - $test = $this; $entity = new Entity(); $array = array(2 => array('key' => $entity)); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, $array) { - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('[2][key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->metadata, $context->getMetadata()); - $test->assertSame($array, $context->getRoot()); - $test->assertSame($entity, $context->getValue()); - $test->assertSame($entity, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity, $array) { + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('[2][key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->metadata, $context->getMetadata()); + $this->assertSame($array, $context->getRoot()); + $this->assertSame($entity, $context->getValue()); + $this->assertSame($entity, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -299,19 +292,18 @@ public function testRecursiveArray() public function testTraversable() { - $test = $this; $entity = new Entity(); $traversable = new \ArrayIterator(array('key' => $entity)); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, $traversable) { - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->metadata, $context->getMetadata()); - $test->assertSame($traversable, $context->getRoot()); - $test->assertSame($entity, $context->getValue()); - $test->assertSame($entity, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity, $traversable) { + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->metadata, $context->getMetadata()); + $this->assertSame($traversable, $context->getRoot()); + $this->assertSame($entity, $context->getValue()); + $this->assertSame($entity, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -337,21 +329,20 @@ public function testTraversable() public function testRecursiveTraversable() { - $test = $this; $entity = new Entity(); $traversable = new \ArrayIterator(array( 2 => new \ArrayIterator(array('key' => $entity)), )); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, $traversable) { - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('[2][key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->metadata, $context->getMetadata()); - $test->assertSame($traversable, $context->getRoot()); - $test->assertSame($entity, $context->getValue()); - $test->assertSame($entity, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity, $traversable) { + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('[2][key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->metadata, $context->getMetadata()); + $this->assertSame($traversable, $context->getRoot()); + $this->assertSame($entity, $context->getValue()); + $this->assertSame($entity, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -377,19 +368,18 @@ public function testRecursiveTraversable() public function testReferenceClassConstraint() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('reference', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference, $context->getValue()); - $test->assertSame($entity->reference, $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('reference', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference, $context->getValue()); + $this->assertSame($entity->reference, $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -416,22 +406,21 @@ public function testReferenceClassConstraint() public function testReferencePropertyConstraint() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); $entity->reference->value = 'Foobar'; - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $propertyMetadatas = $test->referenceMetadata->getPropertyMetadata('value'); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $propertyMetadatas = $this->referenceMetadata->getPropertyMetadata('value'); - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertSame('value', $context->getPropertyName()); - $test->assertSame('reference.value', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame('Foobar', $context->getValue()); - $test->assertSame('Foobar', $value); + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertSame('value', $context->getPropertyName()); + $this->assertSame('reference.value', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame('Foobar', $context->getValue()); + $this->assertSame('Foobar', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -458,22 +447,21 @@ public function testReferencePropertyConstraint() public function testReferenceGetterConstraint() { - $test = $this; $entity = new Entity(); $entity->reference = new Reference(); $entity->reference->setPrivateValue('Bamboo'); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $propertyMetadatas = $test->referenceMetadata->getPropertyMetadata('privateValue'); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $propertyMetadatas = $this->referenceMetadata->getPropertyMetadata('privateValue'); - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertSame('privateValue', $context->getPropertyName()); - $test->assertSame('reference.privateValue', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame('Bamboo', $context->getValue()); - $test->assertSame('Bamboo', $value); + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertSame('privateValue', $context->getPropertyName()); + $this->assertSame('reference.privateValue', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame('Bamboo', $context->getValue()); + $this->assertSame('Bamboo', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -526,19 +514,18 @@ public function testFailOnScalarReferences() public function testArrayReference() { - $test = $this; $entity = new Entity(); $entity->reference = array('key' => new Reference()); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('reference[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference['key'], $context->getValue()); - $test->assertSame($entity->reference['key'], $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('reference[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference['key'], $context->getValue()); + $this->assertSame($entity->reference['key'], $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -566,19 +553,18 @@ public function testArrayReference() // https://github.com/symfony/symfony/issues/6246 public function testRecursiveArrayReference() { - $test = $this; $entity = new Entity(); $entity->reference = array(2 => array('key' => new Reference())); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('reference[2][key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference[2]['key'], $context->getValue()); - $test->assertSame($entity->reference[2]['key'], $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('reference[2][key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference[2]['key'], $context->getValue()); + $this->assertSame($entity->reference[2]['key'], $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -671,19 +657,18 @@ public function testIgnoreNullDuringArrayTraversal() public function testTraversableReference() { - $test = $this; $entity = new Entity(); $entity->reference = new \ArrayIterator(array('key' => new Reference())); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('reference[key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference['key'], $context->getValue()); - $test->assertSame($entity->reference['key'], $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('reference[key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference['key'], $context->getValue()); + $this->assertSame($entity->reference['key'], $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -746,21 +731,20 @@ public function testMetadataMustExistIfTraversalIsDisabled() public function testEnableRecursiveTraversableTraversal() { - $test = $this; $entity = new Entity(); $entity->reference = new \ArrayIterator(array( 2 => new \ArrayIterator(array('key' => new Reference())), )); - $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $test->assertSame($test::REFERENCE_CLASS, $context->getClassName()); - $test->assertNull($context->getPropertyName()); - $test->assertSame('reference[2][key]', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($test->referenceMetadata, $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame($entity->reference[2]['key'], $context->getValue()); - $test->assertSame($entity->reference[2]['key'], $value); + $callback = function ($value, ExecutionContextInterface $context) use ($entity) { + $this->assertSame($this::REFERENCE_CLASS, $context->getClassName()); + $this->assertNull($context->getPropertyName()); + $this->assertSame('reference[2][key]', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($this->referenceMetadata, $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame($entity->reference[2]['key'], $context->getValue()); + $this->assertSame($entity->reference[2]['key'], $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -789,22 +773,21 @@ public function testEnableRecursiveTraversableTraversal() public function testValidateProperty() { - $test = $this; $entity = new Entity(); $entity->firstName = 'Bernhard'; $entity->setLastName('Schussek'); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $propertyMetadatas = $test->metadata->getPropertyMetadata('firstName'); + $callback1 = function ($value, ExecutionContextInterface $context) use ($entity) { + $propertyMetadatas = $this->metadata->getPropertyMetadata('firstName'); - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertSame('firstName', $context->getPropertyName()); - $test->assertSame('firstName', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame('Bernhard', $context->getValue()); - $test->assertSame('Bernhard', $value); + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertSame('firstName', $context->getPropertyName()); + $this->assertSame('firstName', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame('Bernhard', $context->getValue()); + $this->assertSame('Bernhard', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -864,21 +847,20 @@ public function testValidatePropertyWithoutConstraints() public function testValidatePropertyValue() { - $test = $this; $entity = new Entity(); $entity->setLastName('Schussek'); - $callback1 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { - $propertyMetadatas = $test->metadata->getPropertyMetadata('firstName'); + $callback1 = function ($value, ExecutionContextInterface $context) use ($entity) { + $propertyMetadatas = $this->metadata->getPropertyMetadata('firstName'); - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertSame('firstName', $context->getPropertyName()); - $test->assertSame('firstName', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame($entity, $context->getRoot()); - $test->assertSame('Bernhard', $context->getValue()); - $test->assertSame('Bernhard', $value); + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertSame('firstName', $context->getPropertyName()); + $this->assertSame('firstName', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame($entity, $context->getRoot()); + $this->assertSame('Bernhard', $context->getValue()); + $this->assertSame('Bernhard', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; @@ -917,19 +899,17 @@ public function testValidatePropertyValue() public function testValidatePropertyValueWithClassName() { - $test = $this; - - $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { - $propertyMetadatas = $test->metadata->getPropertyMetadata('firstName'); - - $test->assertSame($test::ENTITY_CLASS, $context->getClassName()); - $test->assertSame('firstName', $context->getPropertyName()); - $test->assertSame('', $context->getPropertyPath()); - $test->assertSame('Group', $context->getGroup()); - $test->assertSame($propertyMetadatas[0], $context->getMetadata()); - $test->assertSame('Bernhard', $context->getRoot()); - $test->assertSame('Bernhard', $context->getValue()); - $test->assertSame('Bernhard', $value); + $callback1 = function ($value, ExecutionContextInterface $context) { + $propertyMetadatas = $this->metadata->getPropertyMetadata('firstName'); + + $this->assertSame($this::ENTITY_CLASS, $context->getClassName()); + $this->assertSame('firstName', $context->getPropertyName()); + $this->assertSame('', $context->getPropertyPath()); + $this->assertSame('Group', $context->getGroup()); + $this->assertSame($propertyMetadatas[0], $context->getMetadata()); + $this->assertSame('Bernhard', $context->getRoot()); + $this->assertSame('Bernhard', $context->getValue()); + $this->assertSame('Bernhard', $value); $context->addViolation('Message %param%', array('%param%' => 'value')); }; diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 875c0f9cf53bc..22faadc33c337 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -142,7 +142,19 @@ public function setMaxString($maxString) */ public function cloneVar($var) { - $this->prevErrorHandler = set_error_handler(array($this, 'handleError')); + $this->prevErrorHandler = set_error_handler(function($type, $msg, $file, $line, $context) { + if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) { + // Cloner never dies + throw new \ErrorException($msg, 0, $type, $file, $line); + } + + if ($this->prevErrorHandler) { + return call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context); + } + + return false; + }); + try { if (!function_exists('iconv')) { $this->maxString = -1; @@ -268,23 +280,4 @@ private function callCaster($callback, $obj, $a, $stub, $isNested) return $a; } - - /** - * Special handling for errors: cloning must be fail-safe. - * - * @internal - */ - public function handleError($type, $msg, $file, $line, $context) - { - if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) { - // Cloner never dies - throw new \ErrorException($msg, 0, $type, $file, $line); - } - - if ($this->prevErrorHandler) { - return call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context); - } - - return false; - } } diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index 50b1018c404c1..71e38e155b276 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -49,9 +49,8 @@ public function unescapeSingleQuotedString($value) */ public function unescapeDoubleQuotedString($value) { - $self = $this; - $callback = function ($match) use ($self) { - return $self->unescapeCharacter($match[0]); + $callback = function ($match) { + return $this->unescapeCharacter($match[0]); }; // evaluate the string From 20cb7139f9228cf1ead99f43303890fd37bc18d4 Mon Sep 17 00:00:00 2001 From: Jeremy Livingston Date: Mon, 15 Dec 2014 13:23:29 -0500 Subject: [PATCH 010/133] Add LegacyPdoSessionHandler class --- UPGRADE-2.6.md | 6 +- .../Handler/LegacyPdoSessionHandler.php | 268 ++++++++++++++++++ .../Handler/LegacyPdoSessionHandlerTest.php | 111 ++++++++ 3 files changed, 383 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php create mode 100644 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php diff --git a/UPGRADE-2.6.md b/UPGRADE-2.6.md index 265f9a44f511e..01d3ac5a6c3f5 100644 --- a/UPGRADE-2.6.md +++ b/UPGRADE-2.6.md @@ -1,7 +1,7 @@ UPGRADE FROM 2.5 to 2.6 ======================= -Known Backwards-Compatability Breaks +Known Backwards-Compatibility Breaks ------------------------------------ * If you use the `PdoSessionHandler`, the session table now has a different @@ -112,7 +112,7 @@ HttpFoundation -------------- * The `PdoSessionHandler` to store sessions in a database changed significantly. - This introduced a **backwards-compatability** break in the schema of the + This introduced a **backwards-compatibility** break in the schema of the session table. The following changes must be made to your session table: - Add a new integer column called `sess_lifetime`. Assuming you have the @@ -125,6 +125,8 @@ HttpFoundation There is also an [issue](https://github.com/symfony/symfony/issues/12834) that affects Windows servers. + A legacy class, `LegacyPdoSessionHandler` has been created to ease backwards-compatibility issues when upgrading. + The changes to the `PdoSessionHandler` are: - By default, it now implements session locking to prevent loss of data by concurrent access to the same session. - It does so using a transaction between opening and closing a session. For this reason, it's not diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php new file mode 100644 index 0000000000000..fff83315aacbe --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php @@ -0,0 +1,268 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; + +/** + * Session handler using a PDO connection to read and write data. + * + * Session data is a binary string that can contain non-printable characters like the null byte. + * For this reason this handler base64 encodes the data to be able to save it in a character column. + * + * This version of the PdoSessionHandler does NOT implement locking. So concurrent requests to the + * same session can result in data loss due to race conditions. + * + * @author Fabien Potencier + * @author Michael Williams + * @author Tobias Schultze + * + * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use + * {@link PdoSessionHandler} instead. + */ +class LegacyPdoSessionHandler implements \SessionHandlerInterface +{ + /** + * @var \PDO PDO instance + */ + private $pdo; + + /** + * @var string Table name + */ + private $table; + + /** + * @var string Column for session id + */ + private $idCol; + + /** + * @var string Column for session data + */ + private $dataCol; + + /** + * @var string Column for timestamp + */ + private $timeCol; + + /** + * Constructor. + * + * List of available options: + * * db_table: The name of the table [required] + * * db_id_col: The column where to store the session id [default: sess_id] + * * db_data_col: The column where to store the session data [default: sess_data] + * * db_time_col: The column where to store the timestamp [default: sess_time] + * + * @param \PDO $pdo A \PDO instance + * @param array $dbOptions An associative array of DB options + * + * @throws \InvalidArgumentException When "db_table" option is not provided + */ + public function __construct(\PDO $pdo, array $dbOptions = array()) + { + if (!array_key_exists('db_table', $dbOptions)) { + throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); + } + if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) { + throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); + } + $this->pdo = $pdo; + $dbOptions = array_merge(array( + 'db_id_col' => 'sess_id', + 'db_data_col' => 'sess_data', + 'db_time_col' => 'sess_time', + ), $dbOptions); + + $this->table = $dbOptions['db_table']; + $this->idCol = $dbOptions['db_id_col']; + $this->dataCol = $dbOptions['db_data_col']; + $this->timeCol = $dbOptions['db_time_col']; + } + + /** + * {@inheritdoc} + */ + public function open($savePath, $sessionName) + { + return true; + } + + /** + * {@inheritdoc} + */ + public function close() + { + return true; + } + + /** + * {@inheritdoc} + */ + public function destroy($sessionId) + { + // delete the record associated with this id + $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; + + try { + $stmt = $this->pdo->prepare($sql); + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $stmt->execute(); + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function gc($maxlifetime) + { + // delete the session records that have expired + $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; + + try { + $stmt = $this->pdo->prepare($sql); + $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); + $stmt->execute(); + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function read($sessionId) + { + $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; + + try { + $stmt = $this->pdo->prepare($sql); + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $stmt->execute(); + + // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed + $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); + + if ($sessionRows) { + return base64_decode($sessionRows[0][0]); + } + + return ''; + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); + } + } + + /** + * {@inheritdoc} + */ + public function write($sessionId, $data) + { + $encoded = base64_encode($data); + + try { + // We use a single MERGE SQL query when supported by the database. + $mergeSql = $this->getMergeSql(); + + if (null !== $mergeSql) { + $mergeStmt = $this->pdo->prepare($mergeSql); + $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $mergeStmt->execute(); + + return true; + } + + $updateStmt = $this->pdo->prepare( + "UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id" + ); + $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $updateStmt->execute(); + + // When MERGE is not supported, like in Postgres, we have to use this approach that can result in + // duplicate key errors when the same session is written simultaneously. We can just catch such an + // error and re-execute the update. This is similar to a serializable transaction with retry logic + // on serialization failures but without the overhead and without possible false positives due to + // longer gap locking. + if (!$updateStmt->rowCount()) { + try { + $insertStmt = $this->pdo->prepare( + "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)" + ); + $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $insertStmt->execute(); + } catch (\PDOException $e) { + // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys + if (0 === strpos($e->getCode(), '23')) { + $updateStmt->execute(); + } else { + throw $e; + } + } + } + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); + } + + return true; + } + + /** + * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. + * + * @return string|null The SQL string or null when not supported + */ + private function getMergeSql() + { + $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + + switch ($driver) { + case 'mysql': + return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". + "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; + case 'oci': + // DUAL is Oracle specific dummy table + return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". + "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; + case 'sqlsrv' === $driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): + // MERGE is only available since SQL Server 2008 and must be terminated by semicolon + // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx + return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". + "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; + case 'sqlite': + return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; + } + } + + /** + * Return a PDO instance + * + * @return \PDO + */ + protected function getConnection() + { + return $this->pdo; + } +} diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php new file mode 100644 index 0000000000000..5fa6255414a2d --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; + +use Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler; + +class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase +{ + private $pdo; + + protected function setUp() + { + if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { + $this->markTestSkipped('This test requires SQLite support in your environment'); + } + + $this->pdo = new \PDO('sqlite::memory:'); + $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $sql = 'CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'; + $this->pdo->exec($sql); + } + + public function testIncompleteOptions() + { + $this->setExpectedException('InvalidArgumentException'); + $storage = new LegacyPdoSessionHandler($this->pdo, array()); + } + + public function testWrongPdoErrMode() + { + $pdo = new \PDO('sqlite::memory:'); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); + $pdo->exec('CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'); + + $this->setExpectedException('InvalidArgumentException'); + $storage = new LegacyPdoSessionHandler($pdo, array('db_table' => 'sessions')); + } + + public function testWrongTableOptionsWrite() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); + $this->setExpectedException('RuntimeException'); + $storage->write('foo', 'bar'); + } + + public function testWrongTableOptionsRead() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); + $this->setExpectedException('RuntimeException'); + $storage->read('foo', 'bar'); + } + + public function testWriteRead() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $storage->write('foo', 'bar'); + $this->assertEquals('bar', $storage->read('foo'), 'written value can be read back correctly'); + } + + public function testMultipleInstances() + { + $storage1 = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $storage1->write('foo', 'bar'); + + $storage2 = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $this->assertEquals('bar', $storage2->read('foo'), 'values persist between instances'); + } + + public function testSessionDestroy() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $storage->write('foo', 'bar'); + $this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + + $storage->destroy('foo'); + + $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + } + + public function testSessionGC() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + + $storage->write('foo', 'bar'); + $storage->write('baz', 'bar'); + + $this->assertCount(2, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + + $storage->gc(-1); + $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + } + + public function testGetConnection() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + + $method = new \ReflectionMethod($storage, 'getConnection'); + $method->setAccessible(true); + + $this->assertInstanceOf('\PDO', $method->invoke($storage)); + } +} From 22b183cceb6494f214a2764d4a2134b02c4f2427 Mon Sep 17 00:00:00 2001 From: Jeremy Livingston Date: Mon, 15 Dec 2014 13:23:29 -0500 Subject: [PATCH 011/133] Add LegacyPdoSessionHandler class --- UPGRADE-2.6.md | 6 +- .../Handler/LegacyPdoSessionHandler.php | 268 ++++++++++++++++++ .../Handler/LegacyPdoSessionHandlerTest.php | 111 ++++++++ 3 files changed, 383 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php create mode 100644 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php diff --git a/UPGRADE-2.6.md b/UPGRADE-2.6.md index 265f9a44f511e..01d3ac5a6c3f5 100644 --- a/UPGRADE-2.6.md +++ b/UPGRADE-2.6.md @@ -1,7 +1,7 @@ UPGRADE FROM 2.5 to 2.6 ======================= -Known Backwards-Compatability Breaks +Known Backwards-Compatibility Breaks ------------------------------------ * If you use the `PdoSessionHandler`, the session table now has a different @@ -112,7 +112,7 @@ HttpFoundation -------------- * The `PdoSessionHandler` to store sessions in a database changed significantly. - This introduced a **backwards-compatability** break in the schema of the + This introduced a **backwards-compatibility** break in the schema of the session table. The following changes must be made to your session table: - Add a new integer column called `sess_lifetime`. Assuming you have the @@ -125,6 +125,8 @@ HttpFoundation There is also an [issue](https://github.com/symfony/symfony/issues/12834) that affects Windows servers. + A legacy class, `LegacyPdoSessionHandler` has been created to ease backwards-compatibility issues when upgrading. + The changes to the `PdoSessionHandler` are: - By default, it now implements session locking to prevent loss of data by concurrent access to the same session. - It does so using a transaction between opening and closing a session. For this reason, it's not diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php new file mode 100644 index 0000000000000..fff83315aacbe --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php @@ -0,0 +1,268 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; + +/** + * Session handler using a PDO connection to read and write data. + * + * Session data is a binary string that can contain non-printable characters like the null byte. + * For this reason this handler base64 encodes the data to be able to save it in a character column. + * + * This version of the PdoSessionHandler does NOT implement locking. So concurrent requests to the + * same session can result in data loss due to race conditions. + * + * @author Fabien Potencier + * @author Michael Williams + * @author Tobias Schultze + * + * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use + * {@link PdoSessionHandler} instead. + */ +class LegacyPdoSessionHandler implements \SessionHandlerInterface +{ + /** + * @var \PDO PDO instance + */ + private $pdo; + + /** + * @var string Table name + */ + private $table; + + /** + * @var string Column for session id + */ + private $idCol; + + /** + * @var string Column for session data + */ + private $dataCol; + + /** + * @var string Column for timestamp + */ + private $timeCol; + + /** + * Constructor. + * + * List of available options: + * * db_table: The name of the table [required] + * * db_id_col: The column where to store the session id [default: sess_id] + * * db_data_col: The column where to store the session data [default: sess_data] + * * db_time_col: The column where to store the timestamp [default: sess_time] + * + * @param \PDO $pdo A \PDO instance + * @param array $dbOptions An associative array of DB options + * + * @throws \InvalidArgumentException When "db_table" option is not provided + */ + public function __construct(\PDO $pdo, array $dbOptions = array()) + { + if (!array_key_exists('db_table', $dbOptions)) { + throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); + } + if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) { + throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); + } + $this->pdo = $pdo; + $dbOptions = array_merge(array( + 'db_id_col' => 'sess_id', + 'db_data_col' => 'sess_data', + 'db_time_col' => 'sess_time', + ), $dbOptions); + + $this->table = $dbOptions['db_table']; + $this->idCol = $dbOptions['db_id_col']; + $this->dataCol = $dbOptions['db_data_col']; + $this->timeCol = $dbOptions['db_time_col']; + } + + /** + * {@inheritdoc} + */ + public function open($savePath, $sessionName) + { + return true; + } + + /** + * {@inheritdoc} + */ + public function close() + { + return true; + } + + /** + * {@inheritdoc} + */ + public function destroy($sessionId) + { + // delete the record associated with this id + $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; + + try { + $stmt = $this->pdo->prepare($sql); + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $stmt->execute(); + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function gc($maxlifetime) + { + // delete the session records that have expired + $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; + + try { + $stmt = $this->pdo->prepare($sql); + $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); + $stmt->execute(); + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function read($sessionId) + { + $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; + + try { + $stmt = $this->pdo->prepare($sql); + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $stmt->execute(); + + // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed + $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); + + if ($sessionRows) { + return base64_decode($sessionRows[0][0]); + } + + return ''; + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); + } + } + + /** + * {@inheritdoc} + */ + public function write($sessionId, $data) + { + $encoded = base64_encode($data); + + try { + // We use a single MERGE SQL query when supported by the database. + $mergeSql = $this->getMergeSql(); + + if (null !== $mergeSql) { + $mergeStmt = $this->pdo->prepare($mergeSql); + $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $mergeStmt->execute(); + + return true; + } + + $updateStmt = $this->pdo->prepare( + "UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id" + ); + $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $updateStmt->execute(); + + // When MERGE is not supported, like in Postgres, we have to use this approach that can result in + // duplicate key errors when the same session is written simultaneously. We can just catch such an + // error and re-execute the update. This is similar to a serializable transaction with retry logic + // on serialization failures but without the overhead and without possible false positives due to + // longer gap locking. + if (!$updateStmt->rowCount()) { + try { + $insertStmt = $this->pdo->prepare( + "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)" + ); + $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $insertStmt->execute(); + } catch (\PDOException $e) { + // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys + if (0 === strpos($e->getCode(), '23')) { + $updateStmt->execute(); + } else { + throw $e; + } + } + } + } catch (\PDOException $e) { + throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); + } + + return true; + } + + /** + * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. + * + * @return string|null The SQL string or null when not supported + */ + private function getMergeSql() + { + $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + + switch ($driver) { + case 'mysql': + return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". + "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; + case 'oci': + // DUAL is Oracle specific dummy table + return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". + "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; + case 'sqlsrv' === $driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): + // MERGE is only available since SQL Server 2008 and must be terminated by semicolon + // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx + return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". + "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; + case 'sqlite': + return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; + } + } + + /** + * Return a PDO instance + * + * @return \PDO + */ + protected function getConnection() + { + return $this->pdo; + } +} diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php new file mode 100644 index 0000000000000..5fa6255414a2d --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; + +use Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler; + +class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase +{ + private $pdo; + + protected function setUp() + { + if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { + $this->markTestSkipped('This test requires SQLite support in your environment'); + } + + $this->pdo = new \PDO('sqlite::memory:'); + $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $sql = 'CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'; + $this->pdo->exec($sql); + } + + public function testIncompleteOptions() + { + $this->setExpectedException('InvalidArgumentException'); + $storage = new LegacyPdoSessionHandler($this->pdo, array()); + } + + public function testWrongPdoErrMode() + { + $pdo = new \PDO('sqlite::memory:'); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); + $pdo->exec('CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'); + + $this->setExpectedException('InvalidArgumentException'); + $storage = new LegacyPdoSessionHandler($pdo, array('db_table' => 'sessions')); + } + + public function testWrongTableOptionsWrite() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); + $this->setExpectedException('RuntimeException'); + $storage->write('foo', 'bar'); + } + + public function testWrongTableOptionsRead() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); + $this->setExpectedException('RuntimeException'); + $storage->read('foo', 'bar'); + } + + public function testWriteRead() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $storage->write('foo', 'bar'); + $this->assertEquals('bar', $storage->read('foo'), 'written value can be read back correctly'); + } + + public function testMultipleInstances() + { + $storage1 = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $storage1->write('foo', 'bar'); + + $storage2 = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $this->assertEquals('bar', $storage2->read('foo'), 'values persist between instances'); + } + + public function testSessionDestroy() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + $storage->write('foo', 'bar'); + $this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + + $storage->destroy('foo'); + + $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + } + + public function testSessionGC() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); + + $storage->write('foo', 'bar'); + $storage->write('baz', 'bar'); + + $this->assertCount(2, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + + $storage->gc(-1); + $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + } + + public function testGetConnection() + { + $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + + $method = new \ReflectionMethod($storage, 'getConnection'); + $method->setAccessible(true); + + $this->assertInstanceOf('\PDO', $method->invoke($storage)); + } +} From dfb97068ee46ae87ec80c49ae20c6ccc07b30558 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Fri, 26 Dec 2014 01:27:55 +0100 Subject: [PATCH 012/133] [Console] Removed DialogHelper, ProgressHelper and TableHelper --- .../Console/Descriptor/Descriptor.php | 19 +- .../Console/Descriptor/TextDescriptor.php | 29 +- .../Descriptor/AbstractDescriptorTest.php | 2 +- .../Tests/Fixtures/Descriptor/alias_1.md | 2 +- .../Tests/Fixtures/Descriptor/alias_2.md | 2 +- .../Fixtures/Descriptor/builder_1_public.md | 2 +- .../Fixtures/Descriptor/builder_1_public.txt | 13 +- .../Fixtures/Descriptor/builder_1_services.md | 2 +- .../Descriptor/builder_1_services.txt | 16 +- .../Fixtures/Descriptor/builder_1_tag1.txt | 9 +- .../Tests/Fixtures/Descriptor/callable_1.md | 1 + .../Tests/Fixtures/Descriptor/callable_1.txt | 2 +- .../Tests/Fixtures/Descriptor/callable_2.md | 1 + .../Tests/Fixtures/Descriptor/callable_2.txt | 2 +- .../Tests/Fixtures/Descriptor/callable_3.md | 1 + .../Tests/Fixtures/Descriptor/callable_3.txt | 2 +- .../Tests/Fixtures/Descriptor/callable_4.md | 1 + .../Tests/Fixtures/Descriptor/callable_4.txt | 2 +- .../Tests/Fixtures/Descriptor/callable_5.md | 1 + .../Tests/Fixtures/Descriptor/callable_5.txt | 2 +- .../Tests/Fixtures/Descriptor/callable_6.md | 1 + .../Tests/Fixtures/Descriptor/callable_6.txt | 2 +- .../Tests/Fixtures/Descriptor/callable_7.md | 2 +- .../Tests/Fixtures/Descriptor/callable_7.txt | 2 +- .../Tests/Fixtures/Descriptor/definition_1.md | 2 +- .../Tests/Fixtures/Descriptor/definition_2.md | 2 +- .../Descriptor/event_dispatcher_1_event1.txt | 2 +- .../Descriptor/event_dispatcher_1_events.txt | 10 +- .../Tests/Fixtures/Descriptor/parameter.md | 2 +- .../Tests/Fixtures/Descriptor/parameter.txt | 2 +- .../Tests/Fixtures/Descriptor/parameters_1.md | 2 +- .../Fixtures/Descriptor/parameters_1.txt | 14 +- .../Tests/Fixtures/Descriptor/route_1.md | 2 +- .../Tests/Fixtures/Descriptor/route_1.txt | 2 +- .../Tests/Fixtures/Descriptor/route_2.md | 2 +- .../Tests/Fixtures/Descriptor/route_2.txt | 2 +- .../Fixtures/Descriptor/route_collection_1.md | 1 + .../Descriptor/route_collection_1.txt | 10 +- src/Symfony/Component/Console/Application.php | 6 - .../Console/Descriptor/Descriptor.php | 2 +- .../Component/Console/Helper/DialogHelper.php | 479 ------------------ .../Component/Console/Helper/HelperSet.php | 8 - .../Console/Helper/ProgressHelper.php | 464 ----------------- .../Component/Console/Helper/TableHelper.php | 267 ---------- .../Console/Tests/ApplicationTest.php | 2 - .../Console/Tests/Helper/DialogHelperTest.php | 192 ------- .../Tests/Helper/ProgressHelperTest.php | 224 -------- .../Console/Tests/Helper/TableHelperTest.php | 294 ----------- 48 files changed, 85 insertions(+), 2026 deletions(-) delete mode 100644 src/Symfony/Component/Console/Helper/DialogHelper.php delete mode 100644 src/Symfony/Component/Console/Helper/ProgressHelper.php delete mode 100644 src/Symfony/Component/Console/Helper/TableHelper.php delete mode 100644 src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php delete mode 100644 src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php delete mode 100644 src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index 7a345938bd02d..df8f1162dee54 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; use Symfony\Component\Console\Descriptor\DescriptorInterface; -use Symfony\Component\Console\Helper\TableHelper; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -30,7 +29,7 @@ abstract class Descriptor implements DescriptorInterface /** * @var OutputInterface */ - private $output; + protected $output; /** * {@inheritdoc} @@ -89,22 +88,6 @@ protected function write($content, $decorated = false) $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); } - /** - * Writes content to output. - * - * @param TableHelper $table - * @param bool $decorated - */ - protected function renderTable(TableHelper $table, $decorated = false) - { - if (!$decorated) { - $table->setCellRowFormat('%s'); - $table->setCellHeaderFormat('%s'); - } - - $table->render($this->output); - } - /** * Describes an InputArgument instance. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 4a391b4333477..88ad0ea3bc96f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -11,7 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; -use Symfony\Component\Console\Helper\TableHelper; +use Symfony\Component\Console\Helper\Table; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -30,10 +30,10 @@ class TextDescriptor extends Descriptor */ protected function describeRouteCollection(RouteCollection $routes, array $options = array()) { + $table = new Table($this->output); + $showControllers = isset($options['show_controllers']) && $options['show_controllers']; $headers = array('Name', 'Method', 'Scheme', 'Host', 'Path'); - $table = new TableHelper(); - $table->setLayout(TableHelper::LAYOUT_COMPACT); $table->setHeaders($showControllers ? array_merge($headers, array('Controller')) : $headers); foreach ($routes->all() as $name => $route) { @@ -59,7 +59,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio } $this->writeText($this->formatSection('router', 'Current routes')."\n", $options); - $this->renderTable($table, !(isset($options['raw_output']) && $options['raw_output'])); + $table->render(); } /** @@ -100,8 +100,7 @@ protected function describeRoute(Route $route, array $options = array()) */ protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) { - $table = new TableHelper(); - $table->setLayout(TableHelper::LAYOUT_COMPACT); + $table = new Table($this->output); $table->setHeaders(array('Parameter', 'Value')); foreach ($this->sortParameters($parameters) as $parameter => $value) { @@ -109,7 +108,7 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ } $this->writeText($this->formatSection('container', 'List of parameters')."\n", $options); - $this->renderTable($table, !(isset($options['raw_output']) && $options['raw_output'])); + $table->render(); } /** @@ -201,8 +200,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $tagsCount = count($maxTags); $tagsNames = array_keys($maxTags); - $table = new TableHelper(); - $table->setLayout(TableHelper::LAYOUT_COMPACT); + $table = new Table($this->output); $table->setHeaders(array_merge(array('Service ID'), $tagsNames, array('Class name'))); foreach ($this->sortServiceIds($serviceIds) as $serviceId) { @@ -232,7 +230,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o } } - $this->renderTable($table); + $table->render(); } /** @@ -302,31 +300,30 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev $this->writeText($this->formatSection('event_dispatcher', $label)."\n", $options); $registeredListeners = $eventDispatcher->getListeners($event); + $table = new Table($this->output); + if (null !== $event) { $this->writeText("\n"); - $table = new TableHelper(); + $table->setHeaders(array('Order', 'Callable')); foreach ($registeredListeners as $order => $listener) { $table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($listener))); } - - $this->renderTable($table); } else { ksort($registeredListeners); foreach ($registeredListeners as $eventListened => $eventListeners) { $this->writeText(sprintf("\n[Event] %s\n", $eventListened), $options); - $table = new TableHelper(); $table->setHeaders(array('Order', 'Callable')); foreach ($eventListeners as $order => $eventListener) { $table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($eventListener))); } - - $this->renderTable($table); } } + + $table->render(); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php index 481744aac0a91..b0edee046b727 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -137,7 +137,7 @@ private function assertDescription($expectedDescription, $describedObject, array if ('json' === $this->getFormat()) { $this->assertEquals(json_decode($expectedDescription), json_decode($output->fetch())); } else { - $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); + $this->assertEquals($expectedDescription, $output->fetch()); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md index ec63107b93b0f..3220d5f1393f0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md @@ -1,2 +1,2 @@ - Service: `service_1` -- Public: yes +- Public: yes \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md index f2a46087c162e..73a4101d8bce3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md @@ -1,2 +1,2 @@ - Service: `service_2` -- Public: no +- Public: no \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md index 196757b13b7a2..044eade656f9d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md @@ -32,4 +32,4 @@ alias_2 Services -------- -- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` +- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt index b6debca225fea..a8243a4009f24 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt @@ -1,6 +1,9 @@ [container] Public services - Service ID Class name - alias_1 alias for "service_1" - alias_2 alias for "service_2" - definition_1 Full\Qualified\Class1 - service_container Symfony\Component\DependencyInjection\ContainerBuilder ++-------------------+--------------------------------------------------------+ +| Service ID | Class name | ++-------------------+--------------------------------------------------------+ +| alias_1 | alias for "service_1" | +| alias_2 | alias for "service_2" | +| definition_1 | Full\Qualified\Class1 | +| service_container | Symfony\Component\DependencyInjection\ContainerBuilder | ++-------------------+--------------------------------------------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md index 33cb0a93a74c9..b4d2025acd17a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md @@ -47,4 +47,4 @@ alias_2 Services -------- -- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` +- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder` \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt index e203d5a90fad7..58307ff202119 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt @@ -1,8 +1,10 @@ [container] Public and private services - Service ID Class name - alias_1 alias for "service_1" - alias_2 alias for "service_2" - definition_1 Full\Qualified\Class1 - definition_2 Full\Qualified\Class2 - service_container Symfony\Component\DependencyInjection\ContainerBuilder - ++-------------------+--------------------------------------------------------+ +| Service ID | Class name | ++-------------------+--------------------------------------------------------+ +| alias_1 | alias for "service_1" | +| alias_2 | alias for "service_2" | +| definition_1 | Full\Qualified\Class1 | +| definition_2 | Full\Qualified\Class2 | +| service_container | Symfony\Component\DependencyInjection\ContainerBuilder | ++-------------------+--------------------------------------------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt index da12899f94083..b84e5450e0d0e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt @@ -1,4 +1,7 @@ [container] Public and private services with tag tag1 - Service ID attr1 attr2 attr3 Class name - definition_2 val1 val2 Full\Qualified\Class2 - " val3 ++--------------+-------+-------+-------+-----------------------+ +| Service ID | attr1 | attr2 | attr3 | Class name | ++--------------+-------+-------+-------+-----------------------+ +| definition_2 | val1 | val2 | | Full\Qualified\Class2 | +| " | | | val3 | | ++--------------+-------+-------+-------+-----------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md index 0c3e1dd6f26dd..9cf31352e3cfd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md @@ -1,2 +1,3 @@ + - Type: `function` - Name: `array_key_exists` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt index 92ac06e2f64d5..09901c3c403c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt @@ -1 +1 @@ -array_key_exists() +array_key_exists() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md index cef6d81ed1fd6..c041ee8ea6fc4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md @@ -1,3 +1,4 @@ + - Type: `function` - Name: `staticMethod` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt index e58a2ba59a515..5e3101e1bc2c2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt @@ -1 +1 @@ -Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod() +Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md index 8b260e7074410..3b61c0da2ee77 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md @@ -1,3 +1,4 @@ + - Type: `function` - Name: `method` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt index e2f79511ee2c9..dde0dbba2e3d8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt @@ -1 +1 @@ -Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::method() +Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::method() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md index cef6d81ed1fd6..c041ee8ea6fc4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md @@ -1,3 +1,4 @@ + - Type: `function` - Name: `staticMethod` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt index e58a2ba59a515..5e3101e1bc2c2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt @@ -1 +1 @@ -Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod() +Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md index 9fd61c39ac2e2..fc69e9bafc01f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md @@ -1,3 +1,4 @@ + - Type: `function` - Name: `staticMethod` - Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt index 1c48ebc471cc6..1c06a7e9a5cfd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt @@ -1 +1 @@ -Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass::parent::staticMethod() +Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass::parent::staticMethod() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md index 0fb5bdb107b37..474a9ddc24cc2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md @@ -1 +1,2 @@ + - Type: `closure` diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt index 56996feb78930..9b030ab7913a9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt @@ -1 +1 @@ -\Closure() +\Closure() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md index b6a236ce7bac6..c9ad7af95d8c7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md @@ -1,3 +1,3 @@ + - Type: `object` - Name: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass` - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt index 66274dc2cd4d7..78ef6a6527cae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt @@ -1 +1 @@ -Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke() +Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke() \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md index 49005b12a4a47..3f85a7c305daa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md @@ -1,4 +1,4 @@ - Class: `Full\Qualified\Class1` - Scope: `container` - Public: yes -- Synthetic: no +- Synthetic: no \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md index 521b496e07609..dad1c7f470c57 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md @@ -8,4 +8,4 @@ - Attr2: val2 - Tag: `tag1` - Attr3: val3 -- Tag: `tag2` +- Tag: `tag2` \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt index 22b17a19cfb91..9cd9ca96592cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt @@ -1,7 +1,7 @@ [event_dispatcher] Registered listeners for event event1 +-------+-------------------+ -| Order | Callable | +| Order | Callable | +-------+-------------------+ | #1 | global_function() | | #2 | \Closure() | diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt index 95a5b4648e939..4cd880b0ef9f4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt @@ -1,16 +1,12 @@ [event_dispatcher] Registered listeners by event [Event] event1 -+-------+-------------------+ -| Order | Callable | -+-------+-------------------+ -| #1 | global_function() | -| #2 | \Closure() | -+-------+-------------------+ [Event] event2 +-------+-----------------------------------------------------------------------------------+ -| Order | Callable | +| Order | Callable | +-------+-----------------------------------------------------------------------------------+ +| #1 | global_function() | +| #2 | \Closure() | | #1 | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke() | +-------+-----------------------------------------------------------------------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md index 4c67978f68347..239e98d6aac72 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md @@ -1,4 +1,4 @@ database_name ============= -symfony +symfony \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt index a1435083911ce..6bc5995f62e34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt @@ -1 +1 @@ -symfony +symfony \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md index 2dfe5d640b858..c1eb4dc90fc4f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md @@ -4,4 +4,4 @@ Container parameters - `array`: `[12,"Hello world!",true]` - `boolean`: `true` - `integer`: `12` -- `string`: `Hello world!` +- `string`: `Hello world!` \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt index 1c9a2739ca63c..0d418dd07b68a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt @@ -1,7 +1,9 @@ [container] List of parameters - Parameter Value - array [12,"Hello world!",true] - boolean true - integer 12 - string Hello world! - \ No newline at end of file ++-----------+--------------------------+ +| Parameter | Value | ++-----------+--------------------------+ +| array | [12,"Hello world!",true] | +| boolean | true | +| integer | 12 | +| string | Hello world! | ++-----------+--------------------------+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md index 4ac00a8929755..269bd11a6612f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md @@ -6,4 +6,4 @@ - Defaults: - `name`: Joseph - Requirements: - - `name`: [a-z]+ \ No newline at end of file + - `name`: [a-z]+ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt index 2552c1ed88993..54bf11b4eb239 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt @@ -9,4 +9,4 @@ opt1: val1 opt2: val2 Path-Regex #^/hello(?:/(?P[a-z]+))?$#s -Host-Regex #^localhost$#s \ No newline at end of file +Host-Regex #^localhost$#s diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md index c19d75f4f3b13..494f3223a28b4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md @@ -4,4 +4,4 @@ - Method: PUT|POST - Class: Symfony\Component\Routing\Route - Defaults: NONE -- Requirements: NONE \ No newline at end of file +- Requirements: NONE diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt index 99119b6cc4e90..70eca6c7e4885 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt @@ -9,4 +9,4 @@ opt1: val1 opt2: val2 Path-Regex #^/name/add$#s -Host-Regex #^localhost$#s \ No newline at end of file +Host-Regex #^localhost$#s diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md index a148c23210bad..981adc208c7bc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md @@ -22,3 +22,4 @@ route_2 - Class: Symfony\Component\Routing\Route - Defaults: NONE - Requirements: NONE + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt index e0ade43e2afd3..ce7f760d02fd6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt @@ -1,5 +1,7 @@ [router] Current routes - Name Method Scheme Host Path - route_1 GET|HEAD http|https localhost /hello/{name} - route_2 PUT|POST http|https localhost /name/add - \ No newline at end of file ++---------+----------+------------+-----------+---------------+ +| Name | Method | Scheme | Host | Path | ++---------+----------+------------+-----------+---------------+ +| route_1 | GET|HEAD | http|https | localhost | /hello/{name} | +| route_2 | PUT|POST | http|https | localhost | /name/add | ++---------+----------+------------+-----------+---------------+ diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 3f1b6604c9647..8249fad47daa0 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -32,9 +32,6 @@ use Symfony\Component\Console\Command\ListCommand; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\FormatterHelper; -use Symfony\Component\Console\Helper\DialogHelper; -use Symfony\Component\Console\Helper\ProgressHelper; -use Symfony\Component\Console\Helper\TableHelper; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; @@ -950,9 +947,6 @@ protected function getDefaultHelperSet() { return new HelperSet(array( new FormatterHelper(), - new DialogHelper(false), - new ProgressHelper(false), - new TableHelper(false), new DebugFormatterHelper(), new ProcessHelper(), new QuestionHelper(), diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index 952341579a847..7536838f71880 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -26,7 +26,7 @@ abstract class Descriptor implements DescriptorInterface /** * @var OutputInterface */ - private $output; + protected $output; /** * {@inheritdoc} diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php deleted file mode 100644 index 4d6eccd95fde6..0000000000000 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ /dev/null @@ -1,479 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Formatter\OutputFormatterStyle; - -/** - * The Dialog class provides helpers to interact with the user. - * - * @author Fabien Potencier - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * Use {@link \Symfony\Component\Console\Helper\QuestionHelper} instead. - */ -class DialogHelper extends InputAwareHelper -{ - private $inputStream; - private static $shell; - private static $stty; - - public function __construct($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED); - } - } - - /** - * Asks the user to select a value. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param array $choices List of choices to pick from - * @param bool|string $default The default answer if the user enters nothing - * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked - * @param bool $multiselect Select more than one value separated by comma - * - * @return int|string|array The selected value or values (the key of the choices array) - * - * @throws \InvalidArgumentException - */ - public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false) - { - $width = max(array_map('strlen', array_keys($choices))); - - $messages = (array) $question; - foreach ($choices as $key => $value) { - $messages[] = sprintf(" [%-${width}s] %s", $key, $value); - } - - $output->writeln($messages); - - $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) { - // Collapse all spaces. - $selectedChoices = str_replace(" ", "", $picked); - - if ($multiselect) { - // Check for a separated comma values - if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) { - throw new \InvalidArgumentException(sprintf($errorMessage, $picked)); - } - $selectedChoices = explode(",", $selectedChoices); - } else { - $selectedChoices = array($picked); - } - - $multiselectChoices = array(); - - foreach ($selectedChoices as $value) { - if (empty($choices[$value])) { - throw new \InvalidArgumentException(sprintf($errorMessage, $value)); - } - array_push($multiselectChoices, $value); - } - - if ($multiselect) { - return $multiselectChoices; - } - - return $picked; - }, $attempts, $default); - - return $result; - } - - /** - * Asks a question to the user. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param string $default The default answer if none is given by the user - * @param array $autocomplete List of values to autocomplete - * - * @return string The user answer - * - * @throws \RuntimeException If there is no data to read in the input stream - */ - public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null) - { - if ($this->input && !$this->input->isInteractive()) { - return $default; - } - - $output->write($question); - - $inputStream = $this->inputStream ?: STDIN; - - if (null === $autocomplete || !$this->hasSttyAvailable()) { - $ret = fgets($inputStream, 4096); - if (false === $ret) { - throw new \RuntimeException('Aborted'); - } - $ret = trim($ret); - } else { - $ret = ''; - - $i = 0; - $ofs = -1; - $matches = $autocomplete; - $numMatches = count($matches); - - $sttyMode = shell_exec('stty -g'); - - // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) - shell_exec('stty -icanon -echo'); - - // Add highlighted text style - $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white')); - - // Read a keypress - while (!feof($inputStream)) { - $c = fread($inputStream, 1); - - // Backspace Character - if ("\177" === $c) { - if (0 === $numMatches && 0 !== $i) { - $i--; - // Move cursor backwards - $output->write("\033[1D"); - } - - if ($i === 0) { - $ofs = -1; - $matches = $autocomplete; - $numMatches = count($matches); - } else { - $numMatches = 0; - } - - // Pop the last character off the end of our string - $ret = substr($ret, 0, $i); - } elseif ("\033" === $c) { - // Did we read an escape sequence? - $c .= fread($inputStream, 2); - - // A = Up Arrow. B = Down Arrow - if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) { - if ('A' === $c[2] && -1 === $ofs) { - $ofs = 0; - } - - if (0 === $numMatches) { - continue; - } - - $ofs += ('A' === $c[2]) ? -1 : 1; - $ofs = ($numMatches + $ofs) % $numMatches; - } - } elseif (ord($c) < 32) { - if ("\t" === $c || "\n" === $c) { - if ($numMatches > 0 && -1 !== $ofs) { - $ret = $matches[$ofs]; - // Echo out remaining chars for current match - $output->write(substr($ret, $i)); - $i = strlen($ret); - } - - if ("\n" === $c) { - $output->write($c); - break; - } - - $numMatches = 0; - } - - continue; - } else { - $output->write($c); - $ret .= $c; - $i++; - - $numMatches = 0; - $ofs = 0; - - foreach ($autocomplete as $value) { - // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle) - if (0 === strpos($value, $ret) && $i !== strlen($value)) { - $matches[$numMatches++] = $value; - } - } - } - - // Erase characters from cursor to end of line - $output->write("\033[K"); - - if ($numMatches > 0 && -1 !== $ofs) { - // Save cursor position - $output->write("\0337"); - // Write highlighted text - $output->write(''.substr($matches[$ofs], $i).''); - // Restore cursor position - $output->write("\0338"); - } - } - - // Reset stty so it behaves normally again - shell_exec(sprintf('stty %s', $sttyMode)); - } - - return strlen($ret) > 0 ? $ret : $default; - } - - /** - * Asks a confirmation to the user. - * - * The question will be asked until the user answers by nothing, yes, or no. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param bool $default The default answer if the user enters nothing - * - * @return bool true if the user has confirmed, false otherwise - */ - public function askConfirmation(OutputInterface $output, $question, $default = true) - { - $answer = 'z'; - while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) { - $answer = $this->ask($output, $question); - } - - if (false === $default) { - return $answer && 'y' == strtolower($answer[0]); - } - - return !$answer || 'y' == strtolower($answer[0]); - } - - /** - * Asks a question to the user, the response is hidden. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question - * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not - * - * @return string The answer - * - * @throws \RuntimeException In case the fallback is deactivated and the response can not be hidden - */ - public function askHiddenResponse(OutputInterface $output, $question, $fallback = true) - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; - - // handle code running from a phar - if ('phar:' === substr(__FILE__, 0, 5)) { - $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; - copy($exe, $tmpExe); - $exe = $tmpExe; - } - - $output->write($question); - $value = rtrim(shell_exec($exe)); - $output->writeln(''); - - if (isset($tmpExe)) { - unlink($tmpExe); - } - - return $value; - } - - if ($this->hasSttyAvailable()) { - $output->write($question); - - $sttyMode = shell_exec('stty -g'); - - shell_exec('stty -echo'); - $value = fgets($this->inputStream ?: STDIN, 4096); - shell_exec(sprintf('stty %s', $sttyMode)); - - if (false === $value) { - throw new \RuntimeException('Aborted'); - } - - $value = trim($value); - $output->writeln(''); - - return $value; - } - - if (false !== $shell = $this->getShell()) { - $output->write($question); - $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; - $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); - $value = rtrim(shell_exec($command)); - $output->writeln(''); - - return $value; - } - - if ($fallback) { - return $this->ask($output, $question); - } - - throw new \RuntimeException('Unable to hide the response'); - } - - /** - * Asks for a value and validates the response. - * - * The validator receives the data to validate. It must return the - * validated data when the data is valid and throw an exception - * otherwise. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param string $default The default answer if none is given by the user - * @param array $autocomplete List of values to autocomplete - * - * @return mixed - * - * @throws \Exception When any of the validators return an error - */ - public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null) - { - $interviewer = function () use ($output, $question, $default, $autocomplete) { - return $this->ask($output, $question, $default, $autocomplete); - }; - - return $this->validateAttempts($interviewer, $output, $validator, $attempts); - } - - /** - * Asks for a value, hide and validates the response. - * - * The validator receives the data to validate. It must return the - * validated data when the data is valid and throw an exception - * otherwise. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not - * - * @return string The response - * - * @throws \Exception When any of the validators return an error - * @throws \RuntimeException In case the fallback is deactivated and the response can not be hidden - */ - public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true) - { - $interviewer = function () use ($output, $question, $fallback) { - return $this->askHiddenResponse($output, $question, $fallback); - }; - - return $this->validateAttempts($interviewer, $output, $validator, $attempts); - } - - /** - * Sets the input stream to read from when interacting with the user. - * - * This is mainly useful for testing purpose. - * - * @param resource $stream The input stream - */ - public function setInputStream($stream) - { - $this->inputStream = $stream; - } - - /** - * Returns the helper's input stream. - * - * @return string - */ - public function getInputStream() - { - return $this->inputStream; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'dialog'; - } - - /** - * Return a valid Unix shell. - * - * @return string|bool The valid shell name, false in case no valid shell is found - */ - private function getShell() - { - if (null !== self::$shell) { - return self::$shell; - } - - self::$shell = false; - - if (file_exists('/usr/bin/env')) { - // handle other OSs with bash/zsh/ksh/csh if available to hide the answer - $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; - foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { - if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { - self::$shell = $sh; - break; - } - } - } - - return self::$shell; - } - - private function hasSttyAvailable() - { - if (null !== self::$stty) { - return self::$stty; - } - - exec('stty 2>&1', $output, $exitcode); - - return self::$stty = $exitcode === 0; - } - - /** - * Validate an attempt. - * - * @param callable $interviewer A callable that will ask for a question and return the result - * @param OutputInterface $output An Output instance - * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up ; false will ask infinitely - * - * @return string The validated response - * - * @throws \Exception In case the max number of attempts has been reached and no valid response has been given - */ - private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts) - { - $error = null; - while (false === $attempts || $attempts--) { - if (null !== $error) { - $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error')); - } - - try { - return call_user_func($validator, $interviewer()); - } catch (\Exception $error) { - } - } - - throw $error; - } -} diff --git a/src/Symfony/Component/Console/Helper/HelperSet.php b/src/Symfony/Component/Console/Helper/HelperSet.php index 52a669d48542b..467be86a85d75 100644 --- a/src/Symfony/Component/Console/Helper/HelperSet.php +++ b/src/Symfony/Component/Console/Helper/HelperSet.php @@ -78,14 +78,6 @@ public function get($name) throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); } - if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) { - trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED); - } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) { - trigger_error('"Symfony\Component\Console\Helper\ProgressHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\ProgressBar" instead.', E_USER_DEPRECATED); - } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) { - trigger_error('"Symfony\Component\Console\Helper\TableHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Table" instead.', E_USER_DEPRECATED); - } - return $this->helpers[$name]; } diff --git a/src/Symfony/Component/Console/Helper/ProgressHelper.php b/src/Symfony/Component/Console/Helper/ProgressHelper.php deleted file mode 100644 index d1ab241ac0027..0000000000000 --- a/src/Symfony/Component/Console/Helper/ProgressHelper.php +++ /dev/null @@ -1,464 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Output\NullOutput; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * The Progress class provides helpers to display progress output. - * - * @author Chris Jones - * @author Fabien Potencier - * - * @deprecated Deprecated since 2.5, to be removed in 3.0; use ProgressBar instead. - */ -class ProgressHelper extends Helper -{ - const FORMAT_QUIET = ' %percent%%'; - const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%'; - const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%'; - const FORMAT_QUIET_NOMAX = ' %current%'; - const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]'; - const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%'; - - // options - private $barWidth = 28; - private $barChar = '='; - private $emptyBarChar = '-'; - private $progressChar = '>'; - private $format = null; - private $redrawFreq = 1; - - private $lastMessagesLength; - private $barCharOriginal; - - /** - * @var OutputInterface - */ - private $output; - - /** - * Current step. - * - * @var int - */ - private $current; - - /** - * Maximum number of steps. - * - * @var int - */ - private $max; - - /** - * Start time of the progress bar. - * - * @var int - */ - private $startTime; - - /** - * List of formatting variables. - * - * @var array - */ - private $defaultFormatVars = array( - 'current', - 'max', - 'bar', - 'percent', - 'elapsed', - ); - - /** - * Available formatting variables. - * - * @var array - */ - private $formatVars; - - /** - * Stored format part widths (used for padding). - * - * @var array - */ - private $widths = array( - 'current' => 4, - 'max' => 4, - 'percent' => 3, - 'elapsed' => 6, - ); - - /** - * Various time formats. - * - * @var array - */ - private $timeFormats = array( - array(0, '???'), - array(2, '1 sec'), - array(59, 'secs', 1), - array(60, '1 min'), - array(3600, 'mins', 60), - array(5400, '1 hr'), - array(86400, 'hrs', 3600), - array(129600, '1 day'), - array(604800, 'days', 86400), - ); - - public function __construct($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - trigger_error('"Symfony\Component\Console\Helper\ProgressHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\ProgressBar" instead.', E_USER_DEPRECATED); - } - } - - /** - * Sets the progress bar width. - * - * @param int $size The progress bar size - */ - public function setBarWidth($size) - { - $this->barWidth = (int) $size; - } - - /** - * Sets the bar character. - * - * @param string $char A character - */ - public function setBarCharacter($char) - { - $this->barChar = $char; - } - - /** - * Sets the empty bar character. - * - * @param string $char A character - */ - public function setEmptyBarCharacter($char) - { - $this->emptyBarChar = $char; - } - - /** - * Sets the progress bar character. - * - * @param string $char A character - */ - public function setProgressCharacter($char) - { - $this->progressChar = $char; - } - - /** - * Sets the progress bar format. - * - * @param string $format The format - */ - public function setFormat($format) - { - $this->format = $format; - } - - /** - * Sets the redraw frequency. - * - * @param int $freq The frequency in steps - */ - public function setRedrawFrequency($freq) - { - $this->redrawFreq = (int) $freq; - } - - /** - * Starts the progress output. - * - * @param OutputInterface $output An Output instance - * @param int|null $max Maximum steps - */ - public function start(OutputInterface $output, $max = null) - { - $this->startTime = time(); - $this->current = 0; - $this->max = (int) $max; - - // Disabling output when it does not support ANSI codes as it would result in a broken display anyway. - $this->output = $output->isDecorated() ? $output : new NullOutput(); - $this->lastMessagesLength = 0; - $this->barCharOriginal = ''; - - if (null === $this->format) { - switch ($output->getVerbosity()) { - case OutputInterface::VERBOSITY_QUIET: - $this->format = self::FORMAT_QUIET_NOMAX; - if ($this->max > 0) { - $this->format = self::FORMAT_QUIET; - } - break; - case OutputInterface::VERBOSITY_VERBOSE: - case OutputInterface::VERBOSITY_VERY_VERBOSE: - case OutputInterface::VERBOSITY_DEBUG: - $this->format = self::FORMAT_VERBOSE_NOMAX; - if ($this->max > 0) { - $this->format = self::FORMAT_VERBOSE; - } - break; - default: - $this->format = self::FORMAT_NORMAL_NOMAX; - if ($this->max > 0) { - $this->format = self::FORMAT_NORMAL; - } - break; - } - } - - $this->initialize(); - } - - /** - * Advances the progress output X steps. - * - * @param int $step Number of steps to advance - * @param bool $redraw Whether to redraw or not - * - * @throws \LogicException - */ - public function advance($step = 1, $redraw = false) - { - $this->setCurrent($this->current + $step, $redraw); - } - - /** - * Sets the current progress. - * - * @param int $current The current progress - * @param bool $redraw Whether to redraw or not - * - * @throws \LogicException - */ - public function setCurrent($current, $redraw = false) - { - if (null === $this->startTime) { - throw new \LogicException('You must start the progress bar before calling setCurrent().'); - } - - $current = (int) $current; - - if ($current < $this->current) { - throw new \LogicException('You can\'t regress the progress bar'); - } - - if (0 === $this->current) { - $redraw = true; - } - - $prevPeriod = intval($this->current / $this->redrawFreq); - - $this->current = $current; - - $currPeriod = intval($this->current / $this->redrawFreq); - if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) { - $this->display(); - } - } - - /** - * Outputs the current progress string. - * - * @param bool $finish Forces the end result - * - * @throws \LogicException - */ - public function display($finish = false) - { - if (null === $this->startTime) { - throw new \LogicException('You must start the progress bar before calling display().'); - } - - $message = $this->format; - foreach ($this->generate($finish) as $name => $value) { - $message = str_replace("%{$name}%", $value, $message); - } - $this->overwrite($this->output, $message); - } - - /** - * Removes the progress bar from the current line. - * - * This is useful if you wish to write some output - * while a progress bar is running. - * Call display() to show the progress bar again. - */ - public function clear() - { - $this->overwrite($this->output, ''); - } - - /** - * Finishes the progress output. - */ - public function finish() - { - if (null === $this->startTime) { - throw new \LogicException('You must start the progress bar before calling finish().'); - } - - if (null !== $this->startTime) { - if (!$this->max) { - $this->barChar = $this->barCharOriginal; - $this->display(true); - } - $this->startTime = null; - $this->output->writeln(''); - $this->output = null; - } - } - - /** - * Initializes the progress helper. - */ - private function initialize() - { - $this->formatVars = array(); - foreach ($this->defaultFormatVars as $var) { - if (false !== strpos($this->format, "%{$var}%")) { - $this->formatVars[$var] = true; - } - } - - if ($this->max > 0) { - $this->widths['max'] = $this->strlen($this->max); - $this->widths['current'] = $this->widths['max']; - } else { - $this->barCharOriginal = $this->barChar; - $this->barChar = $this->emptyBarChar; - } - } - - /** - * Generates the array map of format variables to values. - * - * @param bool $finish Forces the end result - * - * @return array Array of format vars and values - */ - private function generate($finish = false) - { - $vars = array(); - $percent = 0; - if ($this->max > 0) { - $percent = (float) $this->current / $this->max; - } - - if (isset($this->formatVars['bar'])) { - $completeBars = 0; - - if ($this->max > 0) { - $completeBars = floor($percent * $this->barWidth); - } else { - if (!$finish) { - $completeBars = floor($this->current % $this->barWidth); - } else { - $completeBars = $this->barWidth; - } - } - - $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar); - $bar = str_repeat($this->barChar, $completeBars); - if ($completeBars < $this->barWidth) { - $bar .= $this->progressChar; - $bar .= str_repeat($this->emptyBarChar, $emptyBars); - } - - $vars['bar'] = $bar; - } - - if (isset($this->formatVars['elapsed'])) { - $elapsed = time() - $this->startTime; - $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT); - } - - if (isset($this->formatVars['current'])) { - $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT); - } - - if (isset($this->formatVars['max'])) { - $vars['max'] = $this->max; - } - - if (isset($this->formatVars['percent'])) { - $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT); - } - - return $vars; - } - - /** - * Converts seconds into human-readable format. - * - * @param int $secs Number of seconds - * - * @return string Time in readable format - */ - private function humaneTime($secs) - { - $text = ''; - foreach ($this->timeFormats as $format) { - if ($secs < $format[0]) { - if (count($format) == 2) { - $text = $format[1]; - break; - } else { - $text = ceil($secs / $format[2]).' '.$format[1]; - break; - } - } - } - - return $text; - } - - /** - * Overwrites a previous message to the output. - * - * @param OutputInterface $output An Output instance - * @param string $message The message - */ - private function overwrite(OutputInterface $output, $message) - { - $length = $this->strlen($message); - - // append whitespace to match the last line's length - if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) { - $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); - } - - // carriage return - $output->write("\x0D"); - $output->write($message); - - $this->lastMessagesLength = $this->strlen($message); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'progress'; - } -} diff --git a/src/Symfony/Component/Console/Helper/TableHelper.php b/src/Symfony/Component/Console/Helper/TableHelper.php deleted file mode 100644 index eec3f362a3673..0000000000000 --- a/src/Symfony/Component/Console/Helper/TableHelper.php +++ /dev/null @@ -1,267 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\NullOutput; - -/** - * Provides helpers to display table output. - * - * @author Саша Стаменковић - * @author Fabien Potencier - * - * @deprecated Deprecated since 2.5, to be removed in 3.0; use Table instead. - */ -class TableHelper extends Helper -{ - const LAYOUT_DEFAULT = 0; - const LAYOUT_BORDERLESS = 1; - const LAYOUT_COMPACT = 2; - - /** - * @var Table - */ - private $table; - - public function __construct($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - trigger_error('"Symfony\Component\Console\Helper\TableHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Table" instead.', E_USER_DEPRECATED); - } - - $this->table = new Table(new NullOutput()); - } - - /** - * Sets table layout type. - * - * @param int $layout self::LAYOUT_* - * - * @return TableHelper - * - * @throws \InvalidArgumentException when the table layout is not known - */ - public function setLayout($layout) - { - switch ($layout) { - case self::LAYOUT_BORDERLESS: - $this->table->setStyle('borderless'); - break; - - case self::LAYOUT_COMPACT: - $this->table->setStyle('compact'); - break; - - case self::LAYOUT_DEFAULT: - $this->table->setStyle('default'); - break; - - default: - throw new \InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout)); - }; - - return $this; - } - - public function setHeaders(array $headers) - { - $this->table->setHeaders($headers); - - return $this; - } - - public function setRows(array $rows) - { - $this->table->setRows($rows); - - return $this; - } - - public function addRows(array $rows) - { - $this->table->addRows($rows); - - return $this; - } - - public function addRow(array $row) - { - $this->table->addRow($row); - - return $this; - } - - public function setRow($column, array $row) - { - $this->table->setRow($column, $row); - - return $this; - } - - /** - * Sets padding character, used for cell padding. - * - * @param string $paddingChar - * - * @return TableHelper - */ - public function setPaddingChar($paddingChar) - { - $this->table->getStyle()->setPaddingChar($paddingChar); - - return $this; - } - - /** - * Sets horizontal border character. - * - * @param string $horizontalBorderChar - * - * @return TableHelper - */ - public function setHorizontalBorderChar($horizontalBorderChar) - { - $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar); - - return $this; - } - - /** - * Sets vertical border character. - * - * @param string $verticalBorderChar - * - * @return TableHelper - */ - public function setVerticalBorderChar($verticalBorderChar) - { - $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar); - - return $this; - } - - /** - * Sets crossing character. - * - * @param string $crossingChar - * - * @return TableHelper - */ - public function setCrossingChar($crossingChar) - { - $this->table->getStyle()->setCrossingChar($crossingChar); - - return $this; - } - - /** - * Sets header cell format. - * - * @param string $cellHeaderFormat - * - * @return TableHelper - */ - public function setCellHeaderFormat($cellHeaderFormat) - { - $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat); - - return $this; - } - - /** - * Sets row cell format. - * - * @param string $cellRowFormat - * - * @return TableHelper - */ - public function setCellRowFormat($cellRowFormat) - { - $this->table->getStyle()->setCellHeaderFormat($cellRowFormat); - - return $this; - } - - /** - * Sets row cell content format. - * - * @param string $cellRowContentFormat - * - * @return TableHelper - */ - public function setCellRowContentFormat($cellRowContentFormat) - { - $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat); - - return $this; - } - - /** - * Sets table border format. - * - * @param string $borderFormat - * - * @return TableHelper - */ - public function setBorderFormat($borderFormat) - { - $this->table->getStyle()->setBorderFormat($borderFormat); - - return $this; - } - - /** - * Sets cell padding type. - * - * @param int $padType STR_PAD_* - * - * @return TableHelper - */ - public function setPadType($padType) - { - $this->table->getStyle()->setPadType($padType); - - return $this; - } - - /** - * Renders table to output. - * - * Example: - * +---------------+-----------------------+------------------+ - * | ISBN | Title | Author | - * +---------------+-----------------------+------------------+ - * | 99921-58-10-7 | Divine Comedy | Dante Alighieri | - * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | - * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | - * +---------------+-----------------------+------------------+ - * - * @param OutputInterface $output - */ - public function render(OutputInterface $output) - { - $p = new \ReflectionProperty($this->table, 'output'); - $p->setAccessible(true); - $p->setValue($this->table, $output); - - $this->table->render(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'table'; - } -} diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 27cf58775e231..a280845c58bcb 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -749,8 +749,6 @@ public function testGetDefaultHelperSetReturnsDefaultValues() $helperSet = $application->getHelperSet(); $this->assertTrue($helperSet->has('formatter')); - $this->assertTrue($helperSet->has('dialog')); - $this->assertTrue($helperSet->has('progress')); } public function testAddingSingleHelperSetOverwritesDefaultValues() diff --git a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php deleted file mode 100644 index e8404a4a687d3..0000000000000 --- a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php +++ /dev/null @@ -1,192 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Tests\Helper; - -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Helper\DialogHelper; -use Symfony\Component\Console\Helper\HelperSet; -use Symfony\Component\Console\Helper\FormatterHelper; -use Symfony\Component\Console\Output\StreamOutput; - -class DialogHelperTest extends \PHPUnit_Framework_TestCase -{ - public function testSelect() - { - $dialog = new DialogHelper(); - - $helperSet = new HelperSet(array(new FormatterHelper())); - $dialog->setHelperSet($helperSet); - - $heroes = array('Superman', 'Batman', 'Spiderman'); - - $dialog->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n")); - $this->assertEquals('2', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, '2')); - $this->assertEquals('1', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes)); - $this->assertEquals('1', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes)); - $this->assertEquals('1', $dialog->select($output = $this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', false)); - - rewind($output->getStream()); - $this->assertContains('Input "Fabien" is not a superhero!', stream_get_contents($output->getStream())); - - try { - $this->assertEquals('1', $dialog->select($output = $this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, 1)); - $this->fail(); - } catch (\InvalidArgumentException $e) { - $this->assertEquals('Value "Fabien" is invalid', $e->getMessage()); - } - - $this->assertEquals(array('1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true)); - $this->assertEquals(array('0', '2'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true)); - $this->assertEquals(array('0', '2'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true)); - $this->assertEquals(array('0', '1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, '0,1', false, 'Input "%s" is not a superhero!', true)); - $this->assertEquals(array('0', '1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, ' 0 , 1 ', false, 'Input "%s" is not a superhero!', true)); - } - - public function testAsk() - { - $dialog = new DialogHelper(); - - $dialog->setInputStream($this->getInputStream("\n8AM\n")); - - $this->assertEquals('2PM', $dialog->ask($this->getOutputStream(), 'What time is it?', '2PM')); - $this->assertEquals('8AM', $dialog->ask($output = $this->getOutputStream(), 'What time is it?', '2PM')); - - rewind($output->getStream()); - $this->assertEquals('What time is it?', stream_get_contents($output->getStream())); - } - - public function testAskWithAutocomplete() - { - if (!$this->hasSttyAvailable()) { - $this->markTestSkipped('`stty` is required to test autocomplete functionality'); - } - - // Acm - // AcsTest - // - // - // Test - // - // S - // F00oo - $inputStream = $this->getInputStream("Acm\nAc\177\177s\tTest\n\n\033[A\033[A\n\033[A\033[A\033[A\033[A\033[A\tTest\n\033[B\nS\177\177\033[B\033[B\nF00\177\177oo\t\n"); - - $dialog = new DialogHelper(); - $dialog->setInputStream($inputStream); - - $bundles = array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle'); - - $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('AsseticBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('FrameworkBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('SecurityBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('FooBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('AsseticBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - $this->assertEquals('FooBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); - } - - /** - * @group tty - */ - public function testAskHiddenResponse() - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('This test is not supported on Windows'); - } - - $dialog = new DialogHelper(); - - $dialog->setInputStream($this->getInputStream("8AM\n")); - - $this->assertEquals('8AM', $dialog->askHiddenResponse($this->getOutputStream(), 'What time is it?')); - } - - public function testAskConfirmation() - { - $dialog = new DialogHelper(); - - $dialog->setInputStream($this->getInputStream("\n\n")); - $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?')); - $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false)); - - $dialog->setInputStream($this->getInputStream("y\nyes\n")); - $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false)); - $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false)); - - $dialog->setInputStream($this->getInputStream("n\nno\n")); - $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true)); - $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true)); - } - - public function testAskAndValidate() - { - $dialog = new DialogHelper(); - $helperSet = new HelperSet(array(new FormatterHelper())); - $dialog->setHelperSet($helperSet); - - $question = 'What color was the white horse of Henry IV?'; - $error = 'This is not a color!'; - $validator = function ($color) use ($error) { - if (!in_array($color, array('white', 'black'))) { - throw new \InvalidArgumentException($error); - } - - return $color; - }; - - $dialog->setInputStream($this->getInputStream("\nblack\n")); - $this->assertEquals('white', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white')); - $this->assertEquals('black', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white')); - - $dialog->setInputStream($this->getInputStream("green\nyellow\norange\n")); - try { - $this->assertEquals('white', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white')); - $this->fail(); - } catch (\InvalidArgumentException $e) { - $this->assertEquals($error, $e->getMessage()); - } - } - - public function testNoInteraction() - { - $dialog = new DialogHelper(); - - $input = new ArrayInput(array()); - $input->setInteractive(false); - - $dialog->setInput($input); - - $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet')); - } - - protected function getInputStream($input) - { - $stream = fopen('php://memory', 'r+', false); - fputs($stream, $input); - rewind($stream); - - return $stream; - } - - protected function getOutputStream() - { - return new StreamOutput(fopen('php://memory', 'r+', false)); - } - - private function hasSttyAvailable() - { - exec('stty 2>&1', $output, $exitcode); - - return $exitcode === 0; - } -} diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php deleted file mode 100644 index 7bc475fce001b..0000000000000 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php +++ /dev/null @@ -1,224 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Tests\Helper; - -use Symfony\Component\Console\Helper\ProgressHelper; -use Symfony\Component\Console\Output\StreamOutput; - -class ProgressHelperTest extends \PHPUnit_Framework_TestCase -{ - public function testAdvance() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream()); - $progress->advance(); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 1 [->--------------------------]'), stream_get_contents($output->getStream())); - } - - public function testAdvanceWithStep() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream()); - $progress->advance(5); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 5 [----->----------------------]'), stream_get_contents($output->getStream())); - } - - public function testAdvanceMultipleTimes() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream()); - $progress->advance(3); - $progress->advance(2); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 3 [--->------------------------]').$this->generateOutput(' 5 [----->----------------------]'), stream_get_contents($output->getStream())); - } - - public function testCustomizations() - { - $progress = new ProgressHelper(); - $progress->setBarWidth(10); - $progress->setBarCharacter('_'); - $progress->setEmptyBarCharacter(' '); - $progress->setProgressCharacter('/'); - $progress->setFormat(' %current%/%max% [%bar%] %percent%%'); - $progress->start($output = $this->getOutputStream(), 10); - $progress->advance(); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 1/10 [_/ ] 10%'), stream_get_contents($output->getStream())); - } - - public function testPercent() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream(), 50); - $progress->display(); - $progress->advance(); - $progress->advance(); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 0/50 [>---------------------------] 0%').$this->generateOutput(' 1/50 [>---------------------------] 2%').$this->generateOutput(' 2/50 [=>--------------------------] 4%'), stream_get_contents($output->getStream())); - } - - public function testOverwriteWithShorterLine() - { - $progress = new ProgressHelper(); - $progress->setFormat(' %current%/%max% [%bar%] %percent%%'); - $progress->start($output = $this->getOutputStream(), 50); - $progress->display(); - $progress->advance(); - - // set shorter format - $progress->setFormat(' %current%/%max% [%bar%]'); - $progress->advance(); - - rewind($output->getStream()); - $this->assertEquals( - $this->generateOutput(' 0/50 [>---------------------------] 0%'). - $this->generateOutput(' 1/50 [>---------------------------] 2%'). - $this->generateOutput(' 2/50 [=>--------------------------] '), - stream_get_contents($output->getStream()) - ); - } - - public function testSetCurrentProgress() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream(), 50); - $progress->display(); - $progress->advance(); - $progress->setCurrent(15); - $progress->setCurrent(25); - - rewind($output->getStream()); - $this->assertEquals( - $this->generateOutput(' 0/50 [>---------------------------] 0%'). - $this->generateOutput(' 1/50 [>---------------------------] 2%'). - $this->generateOutput(' 15/50 [========>-------------------] 30%'). - $this->generateOutput(' 25/50 [==============>-------------] 50%'), - stream_get_contents($output->getStream()) - ); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage You must start the progress bar - */ - public function testSetCurrentBeforeStarting() - { - $progress = new ProgressHelper(); - $progress->setCurrent(15); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage You can't regress the progress bar - */ - public function testRegressProgress() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream(), 50); - $progress->setCurrent(15); - $progress->setCurrent(10); - } - - public function testRedrawFrequency() - { - $progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display')); - $progress->expects($this->exactly(4)) - ->method('display'); - - $progress->setRedrawFrequency(2); - - $progress->start($output = $this->getOutputStream(), 6); - $progress->setCurrent(1); - $progress->advance(2); - $progress->advance(2); - $progress->advance(1); - } - - public function testMultiByteSupport() - { - if (!function_exists('mb_strlen') || (false === $encoding = mb_detect_encoding('■'))) { - $this->markTestSkipped('The mbstring extension is needed for multi-byte support'); - } - - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream()); - $progress->setBarCharacter('■'); - $progress->advance(3); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 3 [■■■>------------------------]'), stream_get_contents($output->getStream())); - } - - public function testClear() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream(), 50); - $progress->setCurrent(25); - $progress->clear(); - - rewind($output->getStream()); - $this->assertEquals( - $this->generateOutput(' 25/50 [==============>-------------] 50%').$this->generateOutput(''), - stream_get_contents($output->getStream()) - ); - } - - public function testPercentNotHundredBeforeComplete() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream(), 200); - $progress->display(); - $progress->advance(199); - $progress->advance(); - - rewind($output->getStream()); - $this->assertEquals($this->generateOutput(' 0/200 [>---------------------------] 0%').$this->generateOutput(' 199/200 [===========================>] 99%').$this->generateOutput(' 200/200 [============================] 100%'), stream_get_contents($output->getStream())); - } - - public function testNonDecoratedOutput() - { - $progress = new ProgressHelper(); - $progress->start($output = $this->getOutputStream(false)); - $progress->advance(); - - rewind($output->getStream()); - $this->assertEquals('', stream_get_contents($output->getStream())); - } - - protected function getOutputStream($decorated = true) - { - return new StreamOutput(fopen('php://memory', 'r+', false), StreamOutput::VERBOSITY_NORMAL, $decorated); - } - - protected $lastMessagesLength; - - protected function generateOutput($expected) - { - $expectedout = $expected; - - if ($this->lastMessagesLength !== null) { - $expectedout = str_pad($expected, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); - } - - $this->lastMessagesLength = strlen($expectedout); - - return "\x0D".$expectedout; - } -} diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php deleted file mode 100644 index f3cda0dabf9c1..0000000000000 --- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php +++ /dev/null @@ -1,294 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Tests\Helper; - -use Symfony\Component\Console\Helper\TableHelper; -use Symfony\Component\Console\Output\StreamOutput; - -class TableHelperTest extends \PHPUnit_Framework_TestCase -{ - protected $stream; - - protected function setUp() - { - $this->stream = fopen('php://memory', 'r+'); - } - - protected function tearDown() - { - fclose($this->stream); - $this->stream = null; - } - - /** - * @dataProvider testRenderProvider - */ - public function testRender($headers, $rows, $layout, $expected) - { - $table = new TableHelper(); - $table - ->setHeaders($headers) - ->setRows($rows) - ->setLayout($layout) - ; - $table->render($output = $this->getOutputStream()); - - $this->assertEquals($expected, $this->getOutputContent($output)); - } - - /** - * @dataProvider testRenderProvider - */ - public function testRenderAddRows($headers, $rows, $layout, $expected) - { - $table = new TableHelper(); - $table - ->setHeaders($headers) - ->addRows($rows) - ->setLayout($layout) - ; - $table->render($output = $this->getOutputStream()); - - $this->assertEquals($expected, $this->getOutputContent($output)); - } - - /** - * @dataProvider testRenderProvider - */ - public function testRenderAddRowsOneByOne($headers, $rows, $layout, $expected) - { - $table = new TableHelper(); - $table - ->setHeaders($headers) - ->setLayout($layout) - ; - foreach ($rows as $row) { - $table->addRow($row); - } - $table->render($output = $this->getOutputStream()); - - $this->assertEquals($expected, $this->getOutputContent($output)); - } - - public function testRenderProvider() - { - $books = array( - array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), - array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), - array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), - array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), - ); - - return array( - array( - array('ISBN', 'Title', 'Author'), - $books, - TableHelper::LAYOUT_DEFAULT, -<< array( - array('ISBN', 'Title', 'Author'), - array( - array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), - array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), - ), - TableHelper::LAYOUT_DEFAULT, -<<
array( - array('ISBN', 'Title', 'Author'), - array( - array('99921-58-10-700', 'Divine Com', 'Dante Alighieri'), - array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), - ), - TableHelper::LAYOUT_DEFAULT, -<<
99921-58-10-700 | Divine Com | Dante Alighieri | -| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | -+----------------------------------+----------------------+-----------------+ - -TABLE - ), - ); - } - - public function testRenderMultiByte() - { - if (!function_exists('mb_strlen')) { - $this->markTestSkipped('The "mbstring" extension is not available'); - } - - $table = new TableHelper(); - $table - ->setHeaders(array('■■')) - ->setRows(array(array(1234))) - ->setLayout(TableHelper::LAYOUT_DEFAULT) - ; - $table->render($output = $this->getOutputStream()); - - $expected = -<<
assertEquals($expected, $this->getOutputContent($output)); - } - - protected function getOutputStream() - { - return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false); - } - - protected function getOutputContent(StreamOutput $output) - { - rewind($output->getStream()); - - return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream())); - } -} From c6b049f4e06cef6bb47610cafcb0d42f3984e67f Mon Sep 17 00:00:00 2001 From: Saro0h Date: Fri, 26 Dec 2014 19:00:47 +0100 Subject: [PATCH 013/133] [Form] Removed deprecated form_enctype() --- .../Bridge/Twig/Extension/FormExtension.php | 1 - .../Bridge/Twig/Node/FormEnctypeNode.php | 28 ------------------- .../views/Form/form_div_layout.html.twig | 4 --- 3 files changed, 33 deletions(-) delete mode 100644 src/Symfony/Bridge/Twig/Node/FormEnctypeNode.php diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index fff092f012cb0..015c892289c6c 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -61,7 +61,6 @@ public function getTokenParsers() public function getFunctions() { return array( - new \Twig_SimpleFunction('form_enctype', null, array('node_class' => 'Symfony\Bridge\Twig\Node\FormEnctypeNode', 'is_safe' => array('html'))), new \Twig_SimpleFunction('form_widget', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new \Twig_SimpleFunction('form_errors', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), new \Twig_SimpleFunction('form_label', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))), diff --git a/src/Symfony/Bridge/Twig/Node/FormEnctypeNode.php b/src/Symfony/Bridge/Twig/Node/FormEnctypeNode.php deleted file mode 100644 index 447a54c448d05..0000000000000 --- a/src/Symfony/Bridge/Twig/Node/FormEnctypeNode.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Twig\Node; - -/** - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * the helper "form_start()" instead. - */ -class FormEnctypeNode extends SearchAndRenderBlockNode -{ - public function compile(\Twig_Compiler $compiler) - { - parent::compile($compiler); - - $compiler->write('trigger_error(\'The helper form_enctype(form) is deprecated since version 2.3 and will be removed in 3.0. Use form_start(form) instead.\', E_USER_DEPRECATED)'); - } -} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index 8938637548bb6..1d25570db8457 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -281,10 +281,6 @@ {%- endblock form_end %} -{% block form_enctype -%} - {% if multipart %}enctype="multipart/form-data"{% endif %} -{%- endblock form_enctype %} - {% block form_errors -%} {% if errors|length > 0 -%}
    From e93b571ab52a2eb672db1fcce9b33ac8495e6f33 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Fri, 26 Dec 2014 19:26:05 +0100 Subject: [PATCH 014/133] [HttpKernel] Removed deprecated ErrorHandler and ExceptionHandler classes --- .../HttpKernel/Debug/ErrorHandler.php | 27 ------------------- .../HttpKernel/Debug/ExceptionHandler.php | 27 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php delete mode 100644 src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php diff --git a/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php b/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php deleted file mode 100644 index 38203d4adf7ff..0000000000000 --- a/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -trigger_error('Symfony\Component\HttpKernel\Debug\ErrorHandler is deprecated since version 2.3 and will be removed in 3.0. Use the same class from the Debug component instead.', E_USER_DEPRECATED); - -use Symfony\Component\Debug\ErrorHandler as DebugErrorHandler; - -/** - * ErrorHandler. - * - * @author Fabien Potencier - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class ErrorHandler extends DebugErrorHandler -{ -} diff --git a/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php b/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php deleted file mode 100644 index 7e31b090c284a..0000000000000 --- a/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -trigger_error('Symfony\Component\HttpKernel\Debug\ExceptionHandler is deprecated since version 2.3 and will be removed in 3.0. Use the same class from the Debug component instead.', E_USER_DEPRECATED); - -use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler; - -/** - * ExceptionHandler converts an exception to a Response object. - * - * @author Fabien Potencier - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class ExceptionHandler extends DebugExceptionHandler -{ -} From b552b1b18276d10db2480fb40df0e54882b4fbe0 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Fri, 26 Dec 2014 18:51:38 +0100 Subject: [PATCH 015/133] [FrameworkBundle] Removed the deprecated RouterApacheDumperCommand --- .../Command/RouterApacheDumperCommand.php | 93 ------ .../Routing/Matcher/ApacheUrlMatcher.php | 124 -------- .../Matcher/Dumper/ApacheMatcherDumper.php | 283 ------------------ .../Tests/Matcher/ApacheUrlMatcherTest.php | 152 ---------- .../Dumper/ApacheMatcherDumperTest.php | 196 ------------ 5 files changed, 848 deletions(-) delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php delete mode 100644 src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php delete mode 100644 src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php delete mode 100644 src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php delete mode 100644 src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php deleted file mode 100644 index 79cd7870f0583..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Command; - -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper; -use Symfony\Component\Routing\RouterInterface; - -/** - * RouterApacheDumperCommand. - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - */ -class RouterApacheDumperCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - public function isEnabled() - { - if (!$this->getContainer()->has('router')) { - return false; - } - $router = $this->getContainer()->get('router'); - if (!$router instanceof RouterInterface) { - return false; - } - - return parent::isEnabled(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('router:dump-apache') - ->setDefinition(array( - new InputArgument('script_name', InputArgument::OPTIONAL, 'The script name of the application\'s front controller.'), - new InputOption('base-uri', null, InputOption::VALUE_REQUIRED, 'The base URI'), - )) - ->setDescription('[DEPRECATED] Dumps all routes as Apache rewrite rules') - ->setHelp(<<%command.name% dumps all routes as Apache rewrite rules. -These can then be used with the ApacheUrlMatcher to use Apache for route -matching. - - php %command.full_name% - -EOF - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - trigger_error('The router:dump-apache command is deprecated since 2.5 and will be removed in 3.0', E_USER_DEPRECATED); - - $router = $this->getContainer()->get('router'); - - $dumpOptions = array(); - if ($input->getArgument('script_name')) { - $dumpOptions['script_name'] = $input->getArgument('script_name'); - } - if ($input->getOption('base-uri')) { - $dumpOptions['base_uri'] = $input->getOption('base-uri'); - } - - $dumper = new ApacheMatcherDumper($router->getRouteCollection()); - - $output->writeln($dumper->dump($dumpOptions), OutputInterface::OUTPUT_RAW); - } -} diff --git a/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php deleted file mode 100644 index adc435c5cd487..0000000000000 --- a/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -trigger_error('The Symfony\Component\Routing\Matcher\Dumper\ApacheUrlMatcher is deprecated since it\'s hard to replicate the behaviour of the PHP implementation and the performance gains are minimal.', E_USER_DEPRECATED); - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper). - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - * @author Arnaud Le Blanc - */ -class ApacheUrlMatcher extends UrlMatcher -{ - /** - * Tries to match a URL based on Apache mod_rewrite matching. - * - * Returns false if no route matches the URL. - * - * @param string $pathinfo The pathinfo to be parsed - * - * @return array An array of parameters - * - * @throws MethodNotAllowedException If the current method is not allowed - */ - public function match($pathinfo) - { - $parameters = array(); - $defaults = array(); - $allow = array(); - $route = null; - - foreach ($this->denormalizeValues($_SERVER) as $key => $value) { - $name = $key; - - // skip non-routing variables - // this improves performance when $_SERVER contains many usual - // variables like HTTP_*, DOCUMENT_ROOT, REQUEST_URI, ... - if (false === strpos($name, '_ROUTING_')) { - continue; - } - - while (0 === strpos($name, 'REDIRECT_')) { - $name = substr($name, 9); - } - - // expect _ROUTING__ - // or _ROUTING_ - - if (0 !== strpos($name, '_ROUTING_')) { - continue; - } - if (false !== $pos = strpos($name, '_', 9)) { - $type = substr($name, 9, $pos-9); - $name = substr($name, $pos+1); - } else { - $type = substr($name, 9); - } - - if ('param' === $type) { - if ('' !== $value) { - $parameters[$name] = $value; - } - } elseif ('default' === $type) { - $defaults[$name] = $value; - } elseif ('route' === $type) { - $route = $value; - } elseif ('allow' === $type) { - $allow[] = $name; - } - - unset($_SERVER[$key]); - } - - if (null !== $route) { - $parameters['_route'] = $route; - - return $this->mergeDefaults($parameters, $defaults); - } elseif (0 < count($allow)) { - throw new MethodNotAllowedException($allow); - } else { - return parent::match($pathinfo); - } - } - - /** - * Denormalizes an array of values. - * - * @param string[] $values - * - * @return array - */ - private function denormalizeValues(array $values) - { - $normalizedValues = array(); - foreach ($values as $key => $value) { - if (preg_match('~^(.*)\[(\d+)\]$~', $key, $matches)) { - if (!isset($normalizedValues[$matches[1]])) { - $normalizedValues[$matches[1]] = array(); - } - $normalizedValues[$matches[1]][(int) $matches[2]] = $value; - } else { - $normalizedValues[$key] = $value; - } - } - - return $normalizedValues; - } -} diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php deleted file mode 100644 index b03d596bbd54e..0000000000000 --- a/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ /dev/null @@ -1,283 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - -trigger_error('The Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper is deprecated since it\'s hard to replicate the behaviour of the PHP implementation and the performance gains are minimal.', E_USER_DEPRECATED); - -use Symfony\Component\Routing\Route; - -/** - * Dumps a set of Apache mod_rewrite rules. - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - * @author Kris Wallsmith - */ -class ApacheMatcherDumper extends MatcherDumper -{ - /** - * Dumps a set of Apache mod_rewrite rules. - * - * Available options: - * - * * script_name: The script name (app.php by default) - * * base_uri: The base URI ("" by default) - * - * @param array $options An array of options - * - * @return string A string to be used as Apache rewrite rules - * - * @throws \LogicException When the route regex is invalid - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'script_name' => 'app.php', - 'base_uri' => '', - ), $options); - - $options['script_name'] = self::escape($options['script_name'], ' ', '\\'); - - $rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]"); - $methodVars = array(); - $hostRegexUnique = 0; - $prevHostRegex = ''; - - foreach ($this->getRoutes()->all() as $name => $route) { - if ($route->getCondition()) { - throw new \LogicException(sprintf('Unable to dump the routes for Apache as route "%s" has a condition.', $name)); - } - - $compiledRoute = $route->compile(); - $hostRegex = $compiledRoute->getHostRegex(); - - if (null !== $hostRegex && $prevHostRegex !== $hostRegex) { - $prevHostRegex = $hostRegex; - $hostRegexUnique++; - - $rule = array(); - - $regex = $this->regexToApacheRegex($hostRegex); - $regex = self::escape($regex, ' ', '\\'); - - $rule[] = sprintf('RewriteCond %%{HTTP:Host} %s', $regex); - - $variables = array(); - $variables[] = sprintf('E=__ROUTING_host_%s:1', $hostRegexUnique); - - foreach ($compiledRoute->getHostVariables() as $i => $variable) { - $variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i+1); - } - - $variables = implode(',', $variables); - - $rule[] = sprintf('RewriteRule .? - [%s]', $variables); - - $rules[] = implode("\n", $rule); - } - - $rules[] = $this->dumpRoute($name, $route, $options, $hostRegexUnique); - - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - $methodVars = array_merge($methodVars, $methods); - } - } - if (0 < count($methodVars)) { - $rule = array('# 405 Method Not Allowed'); - $methodVars = array_values(array_unique($methodVars)); - if (in_array('GET', $methodVars) && !in_array('HEAD', $methodVars)) { - $methodVars[] = 'HEAD'; - } - foreach ($methodVars as $i => $methodVar) { - $rule[] = sprintf('RewriteCond %%{ENV:_ROUTING__allow_%s} =1%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : ''); - } - $rule[] = sprintf('RewriteRule .* %s [QSA,L]', $options['script_name']); - - $rules[] = implode("\n", $rule); - } - - return implode("\n\n", $rules)."\n"; - } - - /** - * Dumps a single route. - * - * @param string $name Route name - * @param Route $route The route - * @param array $options Options - * @param bool $hostRegexUnique Unique identifier for the host regex - * - * @return string The compiled route - */ - private function dumpRoute($name, $route, array $options, $hostRegexUnique) - { - $compiledRoute = $route->compile(); - - // prepare the apache regex - $regex = $this->regexToApacheRegex($compiledRoute->getRegex()); - $regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\'); - - $methods = $this->getRouteMethods($route); - - $hasTrailingSlash = (!$methods || in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex; - - $variables = array('E=_ROUTING_route:'.$name); - foreach ($compiledRoute->getHostVariables() as $variable) { - $variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_host_%s_%s}', $variable, $hostRegexUnique, $variable); - } - foreach ($compiledRoute->getPathVariables() as $i => $variable) { - $variables[] = 'E=_ROUTING_param_'.$variable.':%'.($i + 1); - } - foreach ($this->normalizeValues($route->getDefaults()) as $key => $value) { - $variables[] = 'E=_ROUTING_default_'.$key.':'.strtr($value, array( - ':' => '\\:', - '=' => '\\=', - '\\' => '\\\\', - ' ' => '\\ ', - )); - } - $variables = implode(',', $variables); - - $rule = array("# $name"); - - // method mismatch - if (0 < count($methods)) { - $allow = array(); - foreach ($methods as $method) { - $allow[] = 'E=_ROUTING_allow_'.$method.':1'; - } - - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique); - } - - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = sprintf("RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]", implode('|', $methods)); - $rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow)); - } - - // redirect with trailing slash appended - if ($hasTrailingSlash) { - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique); - } - - $rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$'; - $rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]'; - } - - // the main rule - - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique); - } - - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = "RewriteRule .* {$options['script_name']} [QSA,L,$variables]"; - - return implode("\n", $rule); - } - - /** - * Returns methods allowed for a route. - * - * @param Route $route The route - * - * @return array The methods - */ - private function getRouteMethods(Route $route) - { - $methods = array(); - if ($req = $route->getRequirement('_method')) { - $methods = explode('|', strtoupper($req)); - // GET and HEAD are equivalent - if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - } - - return $methods; - } - - /** - * Converts a regex to make it suitable for mod_rewrite. - * - * @param string $regex The regex - * - * @return string The converted regex - */ - private function regexToApacheRegex($regex) - { - $regexPatternEnd = strrpos($regex, $regex[0]); - - return preg_replace('/\?P<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1)); - } - - /** - * Escapes a string. - * - * @param string $string The string to be escaped - * @param string $char The character to be escaped - * @param string $with The character to be used for escaping - * - * @return string The escaped string - */ - private static function escape($string, $char, $with) - { - $escaped = false; - $output = ''; - foreach (str_split($string) as $symbol) { - if ($escaped) { - $output .= $symbol; - $escaped = false; - continue; - } - if ($symbol === $char) { - $output .= $with.$char; - continue; - } - if ($symbol === $with) { - $escaped = true; - } - $output .= $symbol; - } - - return $output; - } - - /** - * Normalizes an array of values. - * - * @param array $values - * - * @return string[] - */ - private function normalizeValues(array $values) - { - $normalizedValues = array(); - foreach ($values as $key => $value) { - if (is_array($value)) { - foreach ($value as $index => $bit) { - $normalizedValues[sprintf('%s[%s]', $key, $index)] = $bit; - } - } else { - $normalizedValues[$key] = (string) $value; - } - } - - return $normalizedValues; - } -} diff --git a/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php deleted file mode 100644 index 05e6261a5f737..0000000000000 --- a/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Matcher\ApacheUrlMatcher; - -class ApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase -{ - protected $server; - - protected function setUp() - { - $this->server = $_SERVER; - } - - protected function tearDown() - { - $_SERVER = $this->server; - } - - /** - * @dataProvider getMatchData - */ - public function testMatch($name, $pathinfo, $server, $expect) - { - $collection = new RouteCollection(); - $context = new RequestContext(); - $matcher = new ApacheUrlMatcher($collection, $context); - - $_SERVER = $server; - - $result = $matcher->match($pathinfo); - $this->assertSame(var_export($expect, true), var_export($result, true)); - } - - public function getMatchData() - { - return array( - array( - 'Simple route', - '/hello/world', - array( - '_ROUTING_route' => 'hello', - '_ROUTING_param__controller' => 'AcmeBundle:Default:index', - '_ROUTING_param_name' => 'world', - ), - array( - '_controller' => 'AcmeBundle:Default:index', - 'name' => 'world', - '_route' => 'hello', - ), - ), - array( - 'Route with params and defaults', - '/hello/hugo', - array( - '_ROUTING_route' => 'hello', - '_ROUTING_param__controller' => 'AcmeBundle:Default:index', - '_ROUTING_param_name' => 'hugo', - '_ROUTING_default_name' => 'world', - ), - array( - 'name' => 'hugo', - '_controller' => 'AcmeBundle:Default:index', - '_route' => 'hello', - ), - ), - array( - 'Route with defaults only', - '/hello', - array( - '_ROUTING_route' => 'hello', - '_ROUTING_param__controller' => 'AcmeBundle:Default:index', - '_ROUTING_default_name' => 'world', - ), - array( - 'name' => 'world', - '_controller' => 'AcmeBundle:Default:index', - '_route' => 'hello', - ), - ), - array( - 'Redirect with many ignored attributes', - '/legacy/{cat1}/{cat2}/{id}.html', - array( - '_ROUTING_route' => 'product_view', - '_ROUTING_param__controller' => 'FrameworkBundle:Redirect:redirect', - '_ROUTING_default_ignoreAttributes[0]' => 'attr_a', - '_ROUTING_default_ignoreAttributes[1]' => 'attr_b', - ), - array( - 'ignoreAttributes' => array('attr_a', 'attr_b'), - '_controller' => 'FrameworkBundle:Redirect:redirect', - '_route' => 'product_view', - ), - ), - array( - 'REDIRECT_ envs', - '/hello/world', - array( - 'REDIRECT__ROUTING_route' => 'hello', - 'REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index', - 'REDIRECT__ROUTING_param_name' => 'world', - ), - array( - '_controller' => 'AcmeBundle:Default:index', - 'name' => 'world', - '_route' => 'hello', - ), - ), - array( - 'REDIRECT_REDIRECT_ envs', - '/hello/world', - array( - 'REDIRECT_REDIRECT__ROUTING_route' => 'hello', - 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index', - 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world', - ), - array( - '_controller' => 'AcmeBundle:Default:index', - 'name' => 'world', - '_route' => 'hello', - ), - ), - array( - 'REDIRECT_REDIRECT_ envs', - '/hello/world', - array( - 'REDIRECT_REDIRECT__ROUTING_route' => 'hello', - 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index', - 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world', - ), - array( - '_controller' => 'AcmeBundle:Default:index', - 'name' => 'world', - '_route' => 'hello', - ), - ), - ); - } -} diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php deleted file mode 100644 index 72bee7100228b..0000000000000 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php +++ /dev/null @@ -1,196 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher\Dumper; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper; - -class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase -{ - protected static $fixturesPath; - - public static function setUpBeforeClass() - { - self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/'); - } - - public function testDump() - { - $dumper = new ApacheMatcherDumper($this->getRouteCollection()); - - $this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.apache', $dumper->dump(), '->dump() dumps basic routes to the correct apache format.'); - } - - /** - * @dataProvider provideEscapeFixtures - */ - public function testEscapePattern($src, $dest, $char, $with, $message) - { - $r = new \ReflectionMethod(new ApacheMatcherDumper($this->getRouteCollection()), 'escape'); - $r->setAccessible(true); - $this->assertEquals($dest, $r->invoke(null, $src, $char, $with), $message); - } - - public function provideEscapeFixtures() - { - return array( - array('foo', 'foo', ' ', '-', 'Preserve string that should not be escaped'), - array('fo-o', 'fo-o', ' ', '-', 'Preserve string that should not be escaped'), - array('fo o', 'fo- o', ' ', '-', 'Escape special characters'), - array('fo-- o', 'fo--- o', ' ', '-', 'Escape special characters'), - array('fo- o', 'fo- o', ' ', '-', 'Do not escape already escaped string'), - ); - } - - public function testEscapeScriptName() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - $dumper = new ApacheMatcherDumper($collection); - $this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher2.apache', $dumper->dump(array('script_name' => 'ap p_d\ ev.php'))); - } - - private function getRouteCollection() - { - $collection = new RouteCollection(); - - // defaults and requirements - $collection->add('foo', new Route( - '/foo/{bar}', - array('def' => 'test'), - array('bar' => 'baz|symfony') - )); - // defaults parameters in pattern - $collection->add('foobar', new Route( - '/foo/{bar}', - array('bar' => 'toto') - )); - // method requirement - $collection->add('bar', new Route( - '/bar/{foo}', - array(), - array('_method' => 'GET|head') - )); - // method requirement (again) - $collection->add('baragain', new Route( - '/baragain/{foo}', - array(), - array('_method' => 'get|post') - )); - // simple - $collection->add('baz', new Route( - '/test/baz' - )); - // simple with extension - $collection->add('baz2', new Route( - '/test/baz.html' - )); - // trailing slash - $collection->add('baz3', new Route( - '/test/baz3/' - )); - // trailing slash with variable - $collection->add('baz4', new Route( - '/test/{foo}/' - )); - // trailing slash and safe method - $collection->add('baz5', new Route( - '/test/{foo}/', - array(), - array('_method' => 'get') - )); - // trailing slash and unsafe method - $collection->add('baz5unsafe', new Route( - '/testunsafe/{foo}/', - array(), - array('_method' => 'post') - )); - // complex - $collection->add('baz6', new Route( - '/test/baz', - array('foo' => 'bar baz') - )); - // space in path - $collection->add('baz7', new Route( - '/te st/baz' - )); - // space preceded with \ in path - $collection->add('baz8', new Route( - '/te\\ st/baz' - )); - // space preceded with \ in requirement - $collection->add('baz9', new Route( - '/test/{baz}', - array(), - array( - 'baz' => 'te\\\\ st', - ) - )); - - $collection1 = new RouteCollection(); - - $route1 = new Route('/route1', array(), array(), array(), 'a.example.com'); - $collection1->add('route1', $route1); - - $collection2 = new RouteCollection(); - - $route2 = new Route('/route2', array(), array(), array(), 'a.example.com'); - $collection2->add('route2', $route2); - - $route3 = new Route('/route3', array(), array(), array(), 'b.example.com'); - $collection2->add('route3', $route3); - - $collection2->addPrefix('/c2'); - $collection1->addCollection($collection2); - - $route4 = new Route('/route4', array(), array(), array(), 'a.example.com'); - $collection1->add('route4', $route4); - - $route5 = new Route('/route5', array(), array(), array(), 'c.example.com'); - $collection1->add('route5', $route5); - - $route6 = new Route('/route6', array(), array(), array(), null); - $collection1->add('route6', $route6); - - $collection->addCollection($collection1); - - // host and variables - - $collection1 = new RouteCollection(); - - $route11 = new Route('/route11', array(), array(), array(), '{var1}.example.com'); - $collection1->add('route11', $route11); - - $route12 = new Route('/route12', array('var1' => 'val'), array(), array(), '{var1}.example.com'); - $collection1->add('route12', $route12); - - $route13 = new Route('/route13/{name}', array(), array(), array(), '{var1}.example.com'); - $collection1->add('route13', $route13); - - $route14 = new Route('/route14/{name}', array('var1' => 'val'), array(), array(), '{var1}.example.com'); - $collection1->add('route14', $route14); - - $route15 = new Route('/route15/{name}', array(), array(), array(), 'c.example.com'); - $collection1->add('route15', $route15); - - $route16 = new Route('/route16/{name}', array('var1' => 'val'), array(), array(), null); - $collection1->add('route16', $route16); - - $route17 = new Route('/route17', array(), array(), array(), null); - $collection1->add('route17', $route17); - - $collection->addCollection($collection1); - - return $collection; - } -} From e1c19f8941d0079d44f35282b6307dd9b346059b Mon Sep 17 00:00:00 2001 From: Saro0h Date: Fri, 26 Dec 2014 19:16:39 +0100 Subject: [PATCH 016/133] [Yaml] Removed the ability to parse a file in Yaml::parse() --- src/Symfony/Component/Yaml/Tests/YamlTest.php | 9 ------ src/Symfony/Component/Yaml/Yaml.php | 31 ++----------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/Symfony/Component/Yaml/Tests/YamlTest.php b/src/Symfony/Component/Yaml/Tests/YamlTest.php index 53b0bfaaebfee..ee008cf1cd140 100644 --- a/src/Symfony/Component/Yaml/Tests/YamlTest.php +++ b/src/Symfony/Component/Yaml/Tests/YamlTest.php @@ -22,13 +22,4 @@ public function testParseAndDump() $parsed = Yaml::parse($yml); $this->assertEquals($data, $parsed); } - - public function testParseFromFile() - { - $filename = __DIR__.'/Fixtures/index.yml'; - $contents = file_get_contents($filename); - $parsedByFilename = Yaml::parse($filename); - $parsedByContents = Yaml::parse($contents); - $this->assertEquals($parsedByFilename, $parsedByContents); - } } diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 0c3ada73568dc..7d9e298169b53 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -34,11 +34,7 @@ class Yaml * print_r($array); * * - * As this method accepts both plain strings and file names as an input, - * you must validate the input before calling this method. Passing a file - * as an input is a deprecated feature and will be removed in 3.0. - * - * @param string $input Path to a YAML file or a string containing YAML + * @param string $input A string containing YAML * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise * @param bool $objectSupport True if object support is enabled, false otherwise * @@ -46,36 +42,13 @@ class Yaml * * @throws ParseException If the YAML is not valid * - * @deprecated The ability to pass file names to Yaml::parse() was deprecated in 2.2 and will be removed in 3.0. Please, pass the contents of the file instead. - * * @api */ public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) { - // if input is a file, process it - $file = ''; - if (strpos($input, "\n") === false && is_file($input)) { - trigger_error('The ability to pass file names to Yaml::parse() was deprecated in 2.2 and will be removed in 3.0. Please, pass the contents of the file instead.', E_USER_DEPRECATED); - - if (false === is_readable($input)) { - throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); - } - - $file = $input; - $input = file_get_contents($file); - } - $yaml = new Parser(); - try { - return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); - } catch (ParseException $e) { - if ($file) { - $e->setParsedFile($file); - } - - throw $e; - } + return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); } /** From fddcb86c31a7bde7b70bad8c3e3d2c45bf8588c5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 19 Nov 2014 22:23:28 +0100 Subject: [PATCH 017/133] [3.0] Update required PHP to 5.5.9 --- .travis.yml | 5 +- composer.json | 29 ++++++----- src/Symfony/Bridge/Doctrine/composer.json | 20 ++++---- src/Symfony/Bridge/Monolog/composer.json | 8 ++-- src/Symfony/Bridge/Propel1/composer.json | 12 ++--- src/Symfony/Bridge/ProxyManager/composer.json | 6 +-- src/Symfony/Bridge/Twig/composer.json | 30 ++++++------ src/Symfony/Bundle/DebugBundle/composer.json | 12 ++--- .../Bundle/FrameworkBundle/composer.json | 48 +++++++++---------- .../Bundle/SecurityBundle/composer.json | 34 ++++++------- src/Symfony/Bundle/TwigBundle/composer.json | 22 ++++----- .../Bundle/WebProfilerBundle/composer.json | 16 +++---- .../Component/BrowserKit/composer.json | 8 ++-- .../Component/ClassLoader/composer.json | 4 +- src/Symfony/Component/Config/composer.json | 4 +- src/Symfony/Component/Console/composer.json | 6 +-- .../Component/CssSelector/composer.json | 2 +- src/Symfony/Component/Debug/composer.json | 6 +-- .../DependencyInjection/composer.json | 8 ++-- .../Component/DomCrawler/composer.json | 4 +- .../Component/EventDispatcher/composer.json | 10 ++-- .../ExpressionLanguage/composer.json | 2 +- .../Component/Filesystem/composer.json | 2 +- src/Symfony/Component/Finder/composer.json | 2 +- src/Symfony/Component/Form/composer.json | 20 ++++---- .../Component/HttpFoundation/composer.json | 4 +- .../Component/HttpKernel/composer.json | 38 +++++++-------- src/Symfony/Component/Intl/composer.json | 4 +- src/Symfony/Component/Locale/composer.json | 4 +- .../Component/OptionsResolver/composer.json | 2 +- src/Symfony/Component/Process/composer.json | 2 +- .../Component/PropertyAccess/composer.json | 2 +- src/Symfony/Component/Routing/composer.json | 10 ++-- .../Component/Security/Acl/composer.json | 4 +- .../Component/Security/Core/composer.json | 18 ++++--- .../Component/Security/Csrf/composer.json | 6 +-- .../Component/Security/Http/composer.json | 14 +++--- src/Symfony/Component/Security/composer.json | 22 ++++----- .../Component/Serializer/composer.json | 6 +-- src/Symfony/Component/Stopwatch/composer.json | 2 +- .../Component/Templating/composer.json | 2 +- .../Component/Translation/composer.json | 8 ++-- src/Symfony/Component/Validator/composer.json | 16 +++---- src/Symfony/Component/VarDumper/composer.json | 2 +- src/Symfony/Component/Yaml/composer.json | 2 +- 45 files changed, 240 insertions(+), 248 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb1f213fa6f86..1e12bd699ad19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,10 @@ language: php matrix: include: - - php: 5.3.3 + - php: 5.5.9 env: components=low - php: 5.6 env: components=high - - php: 5.3.3 - - php: 5.3 - - php: 5.4 - php: 5.5 - php: 5.6 - php: hhvm-nightly diff --git a/composer.json b/composer.json index a0c83fd521f79..51c0e9a5853e8 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.5.9", "doctrine/common": "~2.3", "twig/twig": "~1.12,>=1.12.3", "psr/log": "~1.0" @@ -24,47 +24,47 @@ "replace": { "symfony/browser-kit": "self.version", "symfony/class-loader": "self.version", - "symfony/config": "self.version", - "symfony/console": "self.version", + "symfony/config": "2.99.99", + "symfony/console": "2.99.99", "symfony/css-selector": "self.version", - "symfony/dependency-injection": "self.version", + "symfony/dependency-injection": "2.99.99", "symfony/debug": "self.version", "symfony/debug-bundle": "self.version", - "symfony/doctrine-bridge": "self.version", + "symfony/doctrine-bridge": "2.99.99", "symfony/dom-crawler": "self.version", - "symfony/event-dispatcher": "self.version", - "symfony/expression-language": "self.version", - "symfony/filesystem": "self.version", + "symfony/event-dispatcher": "2.99.99", + "symfony/expression-language": "2.99.99", + "symfony/filesystem": "2.99.99", "symfony/finder": "self.version", "symfony/form": "self.version", - "symfony/framework-bundle": "self.version", + "symfony/framework-bundle": "2.99.99", "symfony/http-foundation": "self.version", "symfony/http-kernel": "self.version", "symfony/intl": "self.version", "symfony/locale": "self.version", "symfony/monolog-bridge": "self.version", "symfony/options-resolver": "self.version", - "symfony/process": "self.version", + "symfony/process": "2.99.99", "symfony/propel1-bridge": "self.version", "symfony/property-access": "self.version", "symfony/proxy-manager-bridge": "self.version", "symfony/routing": "self.version", - "symfony/security": "self.version", + "symfony/security": "2.99.99", "symfony/security-acl": "self.version", "symfony/security-core": "self.version", "symfony/security-csrf": "self.version", "symfony/security-http": "self.version", "symfony/security-bundle": "self.version", "symfony/serializer": "self.version", - "symfony/stopwatch": "self.version", + "symfony/stopwatch": "2.99.99", "symfony/templating": "self.version", "symfony/translation": "self.version", "symfony/twig-bridge": "self.version", "symfony/twig-bundle": "self.version", - "symfony/validator": "self.version", + "symfony/validator": "2.99.99", "symfony/var-dumper": "self.version", "symfony/web-profiler-bundle": "self.version", - "symfony/yaml": "self.version" + "symfony/yaml": "2.99.99" }, "require-dev": { "doctrine/data-fixtures": "1.0.*", @@ -73,7 +73,6 @@ "doctrine/doctrine-bundle": "~1.2", "monolog/monolog": "~1.11", "propel/propel1": "~1.6", - "ircmaxell/password-compat": "~1.0", "ocramius/proxy-manager": "~0.4|~1.0", "egulias/email-validator": "~1.2" }, diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 1624c0418795b..05935fac073e6 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -16,19 +16,19 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.5.9", "doctrine/common": "~2.3" }, "require-dev": { - "symfony/stopwatch": "~2.2|~3.0.0", - "symfony/dependency-injection": "~2.2|~3.0.0", - "symfony/form": "~2.3,>=2.3.8|~3.0.0", - "symfony/http-kernel": "~2.2|~3.0.0", - "symfony/property-access": "~2.3|~3.0.0", - "symfony/security": "~2.2|~3.0.0", - "symfony/expression-language": "~2.2|~3.0.0", - "symfony/validator": "~2.5,>=2.5.5|~3.0.0", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0", + "symfony/stopwatch": "~2.7|~3.0", + "symfony/dependency-injection": "~2.7|~3.0", + "symfony/form": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/property-access": "~2.7|~3.0", + "symfony/security": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", + "symfony/validator": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.2", "doctrine/orm": "~2.2,>=2.2.3" diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index e74c3920c6773..436b059722841 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -16,13 +16,13 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.5.9", "monolog/monolog": "~1.11" }, "require-dev": { - "symfony/http-kernel": "~2.4|~3.0.0", - "symfony/console": "~2.4|~3.0.0", - "symfony/event-dispatcher": "~2.2|~3.0.0" + "symfony/http-kernel": "~2.7|~3.0", + "symfony/console": "~2.7|~3.0", + "symfony/event-dispatcher": "~2.7|~3.0" }, "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", diff --git a/src/Symfony/Bridge/Propel1/composer.json b/src/Symfony/Bridge/Propel1/composer.json index 3132e49804c79..966d0d036c213 100644 --- a/src/Symfony/Bridge/Propel1/composer.json +++ b/src/Symfony/Bridge/Propel1/composer.json @@ -16,15 +16,15 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/http-foundation": "~2.0,>=2.0.5|~3.0.0", - "symfony/http-kernel": "~2.0,>=2.0.5|~3.0.0", - "symfony/form": "~2.3,>=2.3.8|~3.0.0", - "symfony/property-access": "~2.3|~3.0.0", + "php": ">=5.5.9", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/form": "~2.7|~3.0", + "symfony/property-access": "~2.7|~3.0", "propel/propel1": "~1.6,>=1.6.5" }, "require-dev": { - "symfony/stopwatch": "~2.2|~3.0.0" + "symfony/stopwatch": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Bridge\\Propel1\\": "" } diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index e5115b4e649e7..2fba72ffe7ca9 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/dependency-injection": "~2.3|~3.0.0", + "php": ">=5.5.9", + "symfony/dependency-injection": "~2.7|~3.0", "ocramius/proxy-manager": "~0.4|~1.0" }, "require-dev": { - "symfony/config": "~2.3|~3.0.0" + "symfony/config": "~2.7|~3.0" }, "autoload": { "psr-0": { diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index e6066dfcbb561..11e35095d5bfe 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -16,24 +16,24 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/security-csrf": "~2.4|~3.0.0", + "php": ">=5.5.9", + "symfony/security-csrf": "~2.7|~3.0", "twig/twig": "~1.13,>=1.13.1" }, "require-dev": { - "symfony/finder": "~2.3|~3.0.0", - "symfony/form": "~2.6|~3.0.0", - "symfony/http-kernel": "~2.3|~3.0.0", - "symfony/locale": "~2.0,>=2.0.5|~3.0.0", - "symfony/routing": "~2.2|~3.0.0", - "symfony/templating": "~2.1|~3.0.0", - "symfony/translation": "~2.2|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0", - "symfony/security": "~2.4|~3.0.0", - "symfony/stopwatch": "~2.2|~3.0.0", - "symfony/console": "~2.4|~3.0.0", - "symfony/var-dumper": "~2.6|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0" + "symfony/finder": "~2.7|~3.0", + "symfony/form": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/locale": "~2.7|~3.0", + "symfony/routing": "~2.7|~3.0", + "symfony/templating": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0", + "symfony/yaml": "~2.7|~3.0", + "symfony/security": "~2.7|~3.0", + "symfony/stopwatch": "~2.7|~3.0", + "symfony/console": "~2.7|~3.0", + "symfony/var-dumper": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0" }, "suggest": { "symfony/finder": "", diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index 45a463bf8cf11..c5f6ff910ac4d 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -16,14 +16,14 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/http-kernel": "~2.6|~3.0.0", - "symfony/twig-bridge": "~2.6|~3.0.0", - "symfony/var-dumper": "~2.6|~3.0.0" + "php": ">=5.5.9", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/twig-bridge": "~2.7|~3.0", + "symfony/var-dumper": "~2.7|~3.0" }, "require-dev": { - "symfony/config": "~2.3|~3.0.0", - "symfony/dependency-injection": "~2.3|~3.0.0" + "symfony/config": "~2.7|~3.0", + "symfony/dependency-injection": "~2.7|~3.0" }, "suggest": { "symfony/config": "For service container configuration", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index e4121069f0d92..bcf474ecda9fe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -16,35 +16,35 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.5.9", "symfony/dependency-injection" : "~2.6,>=2.6.2", "symfony/config" : "~2.4", - "symfony/event-dispatcher": "~2.5|~3.0.0", - "symfony/http-foundation": "~2.4.9|~2.5,>=2.5.4|~3.0.0", - "symfony/http-kernel": "~2.6|~3.0.0", - "symfony/filesystem": "~2.3|~3.0.0", - "symfony/routing": "~2.2|~3.0.0", - "symfony/security-core": "~2.6|~3.0.0", - "symfony/security-csrf": "~2.6|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0", - "symfony/templating": "~2.1|~3.0.0", - "symfony/translation": "~2.6|~3.0.0", + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/filesystem": "~2.7|~3.0", + "symfony/routing": "~2.7|~3.0", + "symfony/security-core": "~2.7|~3.0", + "symfony/security-csrf": "~2.7|~3.0", + "symfony/stopwatch": "~2.7|~3.0", + "symfony/templating": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0", "doctrine/annotations": "~1.0" }, "require-dev": { - "symfony/browser-kit": "~2.4|~3.0.0", - "symfony/console": "~2.4,>=2.4.8|~3.0.0", - "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0", - "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0", - "symfony/finder": "~2.0,>=2.0.5|~3.0.0", - "symfony/locale": "~2.0,>=2.0.5|~3.0.0", - "symfony/security": "~2.6|~3.0.0", - "symfony/form": "~2.6|~3.0.0", - "symfony/class-loader": "~2.1|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/process": "~2.0,>=2.0.5|~3.0.0", - "symfony/validator": "~2.5|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0" + "symfony/browser-kit": "~2.7|~3.0", + "symfony/console": "~2.7|~3.0", + "symfony/css-selector": "~2.7|~3.0", + "symfony/dom-crawler": "~2.7|~3.0", + "symfony/finder": "~2.7|~3.0", + "symfony/locale": "~2.7|~3.0", + "symfony/security": "~2.7|~3.0", + "symfony/form": "~2.7|~3.0", + "symfony/class-loader": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", + "symfony/process": "~2.7|~3.0", + "symfony/validator": "~2.7|~3.0", + "symfony/yaml": "~2.7|~3.0" }, "suggest": { "symfony/console": "For using the console commands", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 1a6522ba0e7da..f07244f2d21c0 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -16,25 +16,25 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/security": "~2.6|~3.0.0", - "symfony/http-kernel": "~2.2|~3.0.0" + "php": ">=5.5.9", + "symfony/security": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0" }, "require-dev": { - "symfony/browser-kit": "~2.4|~3.0.0", - "symfony/console": "~2.3|~3.0.0", - "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.3|~3.0.0", - "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0", - "symfony/form": "~2.4|~3.0.0", - "symfony/framework-bundle": "~2.6|~3.0.0", - "symfony/http-foundation": "~2.3|~3.0.0", - "symfony/twig-bundle": "~2.2|~3.0.0", - "symfony/twig-bridge": "~2.2,>=2.2.6|~3.0.0", - "symfony/process": "~2.0,>=2.0.5|~3.0.0", - "symfony/validator": "~2.5|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", + "symfony/browser-kit": "~2.7|~3.0", + "symfony/console": "~2.7|~3.0", + "symfony/css-selector": "~2.7|~3.0", + "symfony/dependency-injection": "~2.7|~3.0", + "symfony/dom-crawler": "~2.7|~3.0", + "symfony/form": "~2.7|~3.0", + "symfony/framework-bundle": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/twig-bundle": "~2.7|~3.0", + "symfony/twig-bridge": "~2.7|~3.0", + "symfony/process": "~2.7|~3.0", + "symfony/validator": "~2.7|~3.0", + "symfony/yaml": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", "doctrine/doctrine-bundle": "~1.2", "twig/twig": "~1.12" }, diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 5bced5988f4ec..2e95720d40e71 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -16,19 +16,19 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/twig-bridge": "~2.6|~3.0.0", - "symfony/http-foundation": "~2.5|~3.0.0", - "symfony/http-kernel": "~2.1|~3.0.0" + "php": ">=5.5.9", + "symfony/twig-bridge": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0" }, "require-dev": { - "symfony/stopwatch": "~2.2|~3.0.0", - "symfony/dependency-injection": "~2.2|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/config": "~2.2|~3.0.0", - "symfony/routing": "~2.1|~3.0.0", - "symfony/templating": "~2.1|~3.0.0", - "symfony/framework-bundle": "~2.1|~3.0.0" + "symfony/stopwatch": "~2.7|~3.0", + "symfony/dependency-injection": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", + "symfony/config": "~2.7|~3.0", + "symfony/routing": "~2.7|~3.0", + "symfony/templating": "~2.7|~3.0", + "symfony/framework-bundle": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Bundle\\TwigBundle\\": "" } diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index d364af6b14e7b..1cd566f417282 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -16,16 +16,16 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/http-kernel": "~2.4|~3.0.0", - "symfony/routing": "~2.2|~3.0.0", - "symfony/twig-bridge": "~2.2|~3.0.0" + "php": ">=5.5.9", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/routing": "~2.7|~3.0", + "symfony/twig-bridge": "~2.7|~3.0" }, "require-dev": { - "symfony/config": "~2.2|~3.0.0", - "symfony/console": "~2.3|~3.0.0", - "symfony/dependency-injection": "~2.2|~3.0.0", - "symfony/stopwatch": "~2.2|~3.0.0" + "symfony/config": "~2.7|~3.0", + "symfony/console": "~2.7|~3.0", + "symfony/dependency-injection": "~2.7|~3.0", + "symfony/stopwatch": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Bundle\\WebProfilerBundle\\": "" } diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index 922b2af27b208..59146d6b1a14d 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0" + "php": ">=5.5.9", + "symfony/dom-crawler": "~2.7|~3.0" }, "require-dev": { - "symfony/process": "~2.0,>=2.0.5|~3.0.0", - "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0" + "symfony/process": "~2.7|~3.0", + "symfony/css-selector": "~2.7|~3.0" }, "suggest": { "symfony/process": "" diff --git a/src/Symfony/Component/ClassLoader/composer.json b/src/Symfony/Component/ClassLoader/composer.json index 8f9456f225e9e..d8cd20757f298 100644 --- a/src/Symfony/Component/ClassLoader/composer.json +++ b/src/Symfony/Component/ClassLoader/composer.json @@ -17,10 +17,10 @@ ], "minimum-stability": "dev", "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/finder": "~2.0,>=2.0.5|~3.0.0" + "symfony/finder": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Component\\ClassLoader\\": "" } diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index e0688bbc5a8b8..2061297ca075f 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -16,8 +16,8 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/filesystem": "~2.3|~3.0.0" + "php": ">=5.5.9", + "symfony/filesystem": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Component\\Config\\": "" } diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index f9b3e4421f708..85b4ed4594a60 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -16,11 +16,11 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/process": "~2.1|~3.0.0", + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/process": "~2.7|~3.0", "psr/log": "~1.0" }, "suggest": { diff --git a/src/Symfony/Component/CssSelector/composer.json b/src/Symfony/Component/CssSelector/composer.json index 12c782038e913..cc016520ba040 100644 --- a/src/Symfony/Component/CssSelector/composer.json +++ b/src/Symfony/Component/CssSelector/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\CssSelector\\": "" } diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index 73ec28931dfcc..6b52249008ab9 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.5.9", "psr/log": "~1.0" }, "require-dev": { - "symfony/http-kernel": "~2.2|~3.0.0", - "symfony/http-foundation": "~2.1|~3.0.0" + "symfony/http-kernel": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0" }, "suggest": { "symfony/http-foundation": "", diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index edae1f7ffde95..39c0ea612ed3b 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/yaml": "~2.1|~3.0.0", - "symfony/config": "~2.2|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0" + "symfony/yaml": "~2.7|~3.0", + "symfony/config": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0" }, "suggest": { "symfony/yaml": "", diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index 3e2a910d9ac1a..d2e57ff6f0a5e 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -16,10 +16,10 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/css-selector": "~2.3|~3.0.0" + "symfony/css-selector": "~2.7|~3.0" }, "suggest": { "symfony/css-selector": "" diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 238d8c0de1850..2699e9e0101c3 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -16,13 +16,13 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/dependency-injection": "~2.6|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/config": "~2.0,>=2.0.5|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0", + "symfony/dependency-injection": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", + "symfony/config": "~2.7|~3.0", + "symfony/stopwatch": "~2.7|~3.0", "psr/log": "~1.0" }, "suggest": { diff --git a/src/Symfony/Component/ExpressionLanguage/composer.json b/src/Symfony/Component/ExpressionLanguage/composer.json index 40f241bdcf9c0..dcb6eafc5c807 100644 --- a/src/Symfony/Component/ExpressionLanguage/composer.json +++ b/src/Symfony/Component/ExpressionLanguage/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\ExpressionLanguage\\": "" } diff --git a/src/Symfony/Component/Filesystem/composer.json b/src/Symfony/Component/Filesystem/composer.json index 33d4dd8466c92..baa284321c8d2 100644 --- a/src/Symfony/Component/Filesystem/composer.json +++ b/src/Symfony/Component/Filesystem/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\Filesystem\\": "" } diff --git a/src/Symfony/Component/Finder/composer.json b/src/Symfony/Component/Finder/composer.json index f1edff50204fe..f16da48e45c5b 100644 --- a/src/Symfony/Component/Finder/composer.json +++ b/src/Symfony/Component/Finder/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\Finder\\": "" } diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 660118d51dd5f..44ea9b63f9573 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -16,19 +16,19 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/intl": "~2.3|~3.0.0", - "symfony/options-resolver": "~2.1|~3.0.0", - "symfony/property-access": "~2.3|~3.0.0" + "php": ">=5.5.9", + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/intl": "~2.7|~3.0", + "symfony/options-resolver": "~2.7|~3.0", + "symfony/property-access": "~2.7|~3.0" }, "require-dev": { "doctrine/collections": "~1.0", - "symfony/validator": "~2.6|~3.0.0", - "symfony/http-foundation": "~2.2|~3.0.0", - "symfony/http-kernel": "~2.4|~3.0.0", - "symfony/security-csrf": "~2.4|~3.0.0", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0" + "symfony/validator": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0", + "symfony/security-csrf": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0" }, "suggest": { "symfony/validator": "For form validation.", diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index 83f120c28799d..12d9acae1ff95 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -16,10 +16,10 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/expression-language": "~2.4|~3.0.0" + "symfony/expression-language": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Component\\HttpFoundation\\": "" }, diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 426145eb9623a..2790be1058edf 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -16,28 +16,28 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.5.9|~2.6,>=2.6.2|~3.0.0", - "symfony/http-foundation": "~2.5,>=2.5.4|~3.0.0", - "symfony/debug": "~2.6|~3.0.0", + "php": ">=5.5.9", + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/debug": "~2.7|~3.0", "psr/log": "~1.0" }, "require-dev": { - "symfony/browser-kit": "~2.3|~3.0.0", - "symfony/class-loader": "~2.1|~3.0.0", - "symfony/config": "~2.0,>=2.0.5|~3.0.0", - "symfony/console": "~2.3|~3.0.0", - "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.2|~3.0.0", - "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/finder": "~2.0,>=2.0.5|~3.0.0", - "symfony/process": "~2.0,>=2.0.5|~3.0.0", - "symfony/routing": "~2.2|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0", - "symfony/templating": "~2.2|~3.0.0", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0", - "symfony/var-dumper": "~2.6|~3.0.0" + "symfony/browser-kit": "~2.7|~3.0", + "symfony/class-loader": "~2.7|~3.0", + "symfony/config": "~2.7|~3.0", + "symfony/console": "~2.7|~3.0", + "symfony/css-selector": "~2.7|~3.0", + "symfony/dependency-injection": "~2.7|~3.0", + "symfony/dom-crawler": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", + "symfony/finder": "~2.7|~3.0", + "symfony/process": "~2.7|~3.0", + "symfony/routing": "~2.7|~3.0", + "symfony/stopwatch": "~2.7|~3.0", + "symfony/templating": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0", + "symfony/var-dumper": "~2.7|~3.0" }, "suggest": { "symfony/browser-kit": "", diff --git a/src/Symfony/Component/Intl/composer.json b/src/Symfony/Component/Intl/composer.json index cae7b626d9b93..97c9cbcdd3022 100644 --- a/src/Symfony/Component/Intl/composer.json +++ b/src/Symfony/Component/Intl/composer.json @@ -24,10 +24,10 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/filesystem": "~2.1|~3.0.0" + "symfony/filesystem": "~2.7|~3.0" }, "suggest": { "ext-intl": "to use the component with locales other than \"en\"" diff --git a/src/Symfony/Component/Locale/composer.json b/src/Symfony/Component/Locale/composer.json index 87e5b08d120d6..e392082383a02 100644 --- a/src/Symfony/Component/Locale/composer.json +++ b/src/Symfony/Component/Locale/composer.json @@ -16,8 +16,8 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/intl": "~2.3|~3.0.0" + "php": ">=5.5.9", + "symfony/intl": "~2.7|~3.0" }, "autoload": { "psr-0": { "Symfony\\Component\\Locale\\": "" } diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index 49a1607a1b7aa..e55aea9d34965 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\OptionsResolver\\": "" } diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index 938b3987ab737..6a62b1a7a41c4 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\Process\\": "" } diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index 796b736888182..8252b14003963 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\PropertyAccess\\": "" } diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index dfb721221307e..038dfaa1b50df 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -16,13 +16,13 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/config": "~2.2|~3.0.0", - "symfony/http-foundation": "~2.3|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", + "symfony/config": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/yaml": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", "doctrine/annotations": "~1.0", "doctrine/common": "~2.2", "psr/log": "~1.0" diff --git a/src/Symfony/Component/Security/Acl/composer.json b/src/Symfony/Component/Security/Acl/composer.json index da751c6360fb1..3a1e904016555 100644 --- a/src/Symfony/Component/Security/Acl/composer.json +++ b/src/Symfony/Component/Security/Acl/composer.json @@ -16,8 +16,8 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/security-core": "~2.4|~3.0.0" + "php": ">=5.5.9", + "symfony/security-core": "~2.7|~3.0" }, "require-dev": { "doctrine/common": "~2.2", diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 15a3a4bab9eb0..018f72a458971 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -16,23 +16,21 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/http-foundation": "~2.4|~3.0.0", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0", - "symfony/validator": "~2.5,>=2.5.5|~3.0.0", - "psr/log": "~1.0", - "ircmaxell/password-compat": "1.0.*" + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0", + "symfony/validator": "~2.7|~3.0", + "psr/log": "~1.0" }, "suggest": { "symfony/event-dispatcher": "", "symfony/http-foundation": "", "symfony/validator": "For using the user password constraint", - "symfony/expression-language": "For using the expression voter", - "ircmaxell/password-compat": "For using the BCrypt password encoder in PHP <5.5" + "symfony/expression-language": "For using the expression voter" }, "autoload": { "psr-0": { "Symfony\\Component\\Security\\Core\\": "" } diff --git a/src/Symfony/Component/Security/Csrf/composer.json b/src/Symfony/Component/Security/Csrf/composer.json index e2cada07a3ff2..805b63e8ef087 100644 --- a/src/Symfony/Component/Security/Csrf/composer.json +++ b/src/Symfony/Component/Security/Csrf/composer.json @@ -16,11 +16,11 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/security-core": "~2.4|~3.0.0" + "php": ">=5.5.9", + "symfony/security-core": "~2.7|~3.0" }, "require-dev": { - "symfony/http-foundation": "~2.1|~3.0.0" + "symfony/http-foundation": "~2.7|~3.0" }, "suggest": { "symfony/http-foundation": "For using the class SessionTokenStorage." diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 647da05fe1f07..a5cccca1e164f 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -16,15 +16,15 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/security-core": "~2.6|~3.0.0", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/http-foundation": "~2.4|~3.0.0", - "symfony/http-kernel": "~2.4|~3.0.0" + "php": ">=5.5.9", + "symfony/security-core": "~2.7|~3.0", + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0" }, "require-dev": { - "symfony/routing": "~2.2|~3.0.0", - "symfony/security-csrf": "~2.4|~3.0.0", + "symfony/routing": "~2.7|~3.0", + "symfony/security-csrf": "~2.7|~3.0", "psr/log": "~1.0" }, "suggest": { diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 556bd11089914..b7b735daa285c 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -16,10 +16,10 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.2|~3.0.0", - "symfony/http-foundation": "~2.1|~3.0.0", - "symfony/http-kernel": "~2.4|~3.0.0" + "php": ">=5.5.9", + "symfony/event-dispatcher": "~2.7|~3.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/http-kernel": "~2.7|~3.0" }, "replace": { "symfony/security-acl": "self.version", @@ -28,15 +28,14 @@ "symfony/security-http": "self.version" }, "require-dev": { - "symfony/locale": "~2.0,>=2.0.5|~3.0.0", - "symfony/routing": "~2.2|~3.0.0", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0", - "symfony/validator": "~2.5,>=2.5.5|~3.0.0", + "symfony/locale": "~2.7|~3.0", + "symfony/routing": "~2.7|~3.0", + "symfony/translation": "~2.7|~3.0", + "symfony/validator": "~2.7|~3.0", "doctrine/common": "~2.2", "doctrine/dbal": "~2.2", "psr/log": "~1.0", - "ircmaxell/password-compat": "~1.0", - "symfony/expression-language": "~2.6|~3.0.0" + "symfony/expression-language": "~2.7|~3.0" }, "suggest": { "symfony/class-loader": "For using the ACL generateSql script", @@ -44,8 +43,7 @@ "symfony/validator": "For using the user password constraint", "symfony/routing": "For using the HttpUtils class to create sub-requests, redirect the user, and match URLs", "doctrine/dbal": "For using the built-in ACL implementation", - "symfony/expression-language": "For using the expression voter", - "ircmaxell/password-compat": "For using the BCrypt password encoder in PHP <5.5" + "symfony/expression-language": "For using the expression voter" }, "autoload": { "psr-0": { "Symfony\\Component\\Security\\": "" } diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 4fa968e449ff4..42fa336d27312 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -16,11 +16,11 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/yaml": "~2.0|~3.0.0", - "symfony/config": "~2.2|~3.0.0", + "symfony/yaml": "~2.7|~3.0", + "symfony/config": "~2.7|~3.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0" }, diff --git a/src/Symfony/Component/Stopwatch/composer.json b/src/Symfony/Component/Stopwatch/composer.json index 99821957ffbbe..de42dde154e6d 100644 --- a/src/Symfony/Component/Stopwatch/composer.json +++ b/src/Symfony/Component/Stopwatch/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\Stopwatch\\": "" } diff --git a/src/Symfony/Component/Templating/composer.json b/src/Symfony/Component/Templating/composer.json index 91defd0602213..8d33006940954 100644 --- a/src/Symfony/Component/Templating/composer.json +++ b/src/Symfony/Component/Templating/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { "psr/log": "~1.0" diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index cdbe86814a684..d81918f3d43fc 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { - "symfony/config": "~2.3,>=2.3.12|~3.0.0", - "symfony/intl": "~2.3|~3.0.0", - "symfony/yaml": "~2.2|~3.0.0", + "symfony/config": "~2.7|~3.0", + "symfony/intl": "~2.7|~3.0", + "symfony/yaml": "~2.7|~3.0", "psr/log": "~1.0" }, "suggest": { diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 6160fd0a83695..ed7a20f446eeb 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -16,16 +16,16 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0" + "php": ">=5.5.9", + "symfony/translation": "~2.7|~3.0" }, "require-dev": { - "symfony/http-foundation": "~2.1|~3.0.0", - "symfony/intl": "~2.3|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0", - "symfony/config": "~2.2|~3.0.0", - "symfony/property-access": "~2.3|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", + "symfony/http-foundation": "~2.7|~3.0", + "symfony/intl": "~2.7|~3.0", + "symfony/yaml": "~2.7|~3.0", + "symfony/config": "~2.7|~3.0", + "symfony/property-access": "~2.7|~3.0", + "symfony/expression-language": "~2.7|~3.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0", "egulias/email-validator": "~1.2,>=1.2.1" diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 58560fbcb5426..2c96748f1e64a 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "suggest": { "ext-symfony_debug": "" diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index 1ca239845b934..6f63f09a00b27 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "autoload": { "psr-0": { "Symfony\\Component\\Yaml\\": "" } From 35e0845f237df0ab065c43a7621ce2e5946a08c6 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 30 Nov 2014 21:18:40 +0000 Subject: [PATCH 018/133] [3.0] Removed some old hacks --- README.md | 21 +--- autoload.php.dist | 6 +- ...egacyUniqueEntityValidator2Dot4ApiTest.php | 26 ----- ...gacyUniqueEntityValidatorLegacyApiTest.php | 26 ----- .../Bridge/Twig/Command/LintCommand.php | 4 - .../Bridge/Twig/Extension/CodeExtension.php | 6 +- .../Bridge/Twig/Tests/Node/DumpNodeTest.php | 4 +- .../Bridge/Twig/Tests/Node/FormThemeTest.php | 6 +- .../Node/SearchAndRenderBlockNodeTest.php | 6 +- .../Bridge/Twig/Tests/Node/TransNodeTest.php | 12 +- .../FrameworkBundle/Command/ServerCommand.php | 2 +- .../Command/ServerRunCommand.php | 2 +- .../Command/YamlLintCommand.php | 4 - .../Console/Descriptor/JsonDescriptor.php | 4 - .../DependencyInjection/Configuration.php | 9 +- .../Templating/Helper/CodeHelper.php | 6 +- .../Console/Descriptor/JsonDescriptorTest.php | 7 -- .../DependencyInjection/ConfigurationTest.php | 2 +- .../FrameworkExtensionTest.php | 18 +-- .../SecurityRoutingIntegrationTest.php | 8 -- .../ClassLoader/ClassCollectionLoader.php | 5 +- .../ClassLoader/ClassMapGenerator.php | 10 +- .../ClassLoader/DebugClassLoader.php | 2 +- .../ClassLoader/DebugUniversalClassLoader.php | 2 +- .../Tests/ClassCollectionLoaderTest.php | 18 --- .../Tests/ClassMapGeneratorTest.php | 9 +- .../Console/Descriptor/TextDescriptor.php | 4 - .../Component/Debug/DebugClassLoader.php | 2 +- src/Symfony/Component/Debug/ErrorHandler.php | 43 +------ .../Component/Debug/ExceptionHandler.php | 2 +- .../ClassNotFoundFatalErrorHandler.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 10 +- .../Component/ExpressionLanguage/Parser.php | 4 - .../DateTimeToStringTransformer.php | 9 +- .../Csrf/CsrfProvider/DefaultCsrfProvider.php | 6 +- .../DateTimeToStringTransformerTest.php | 10 +- .../CsrfProvider/DefaultCsrfProviderTest.php | 4 - .../Component/HttpFoundation/JsonResponse.php | 29 +---- .../Storage/Handler/NativeSessionHandler.php | 11 +- .../Session/Storage/NativeSessionStorage.php | 38 +----- .../Storage/PhpBridgeSessionStorage.php | 4 - .../Session/Storage/Proxy/AbstractProxy.php | 32 +---- .../Handler/NativeFileSessionHandlerTest.php | 9 +- .../Handler/NativeSessionHandlerTest.php | 11 +- .../Storage/NativeSessionStorageTest.php | 36 +----- .../Storage/PhpBridgeSessionStorageTest.php | 30 +---- .../Storage/Proxy/AbstractProxyTest.php | 78 +------------ .../Storage/Proxy/SessionHandlerProxyTest.php | 8 +- .../DataCollector/DumpDataCollector.php | 7 +- .../Fragment/HIncludeFragmentRenderer.php | 6 +- .../Controller/ControllerResolverTest.php | 14 +-- .../Data/Bundle/Reader/JsonBundleReader.php | 29 +---- .../Data/Bundle/Writer/JsonBundleWriter.php | 12 +- .../Intl/DateFormatter/IntlDateFormatter.php | 31 ++--- .../Intl/NumberFormatter/NumberFormatter.php | 28 +---- .../Bundle/Writer/JsonBundleWriterTest.php | 8 -- .../AbstractIntlDateFormatterTest.php | 110 ++++-------------- .../DateFormatter/IntlDateFormatterTest.php | 7 +- .../AbstractNumberFormatterTest.php | 24 +--- .../Core/Encoder/BCryptPasswordEncoder.php | 4 - .../Core/Encoder/Pbkdf2PasswordEncoder.php | 26 +---- .../Encoder/BCryptPasswordEncoderTest.php | 11 -- .../Security/Core/Util/SecureRandom.php | 4 +- .../NativeSessionTokenStorageTest.php | 4 - .../NativeSessionTokenStorage.php | 6 +- .../Serializer/Encoder/JsonDecode.php | 6 +- .../Serializer/Encoder/JsonEncoder.php | 19 +-- .../Component/Templating/PhpEngine.php | 16 +-- .../Translation/Dumper/JsonFileDumper.php | 4 - .../Tests/Dumper/JsonFileDumperTest.php | 4 - .../AbstractComparisonValidatorTestCase.php | 4 - .../Constraints/IdenticalToValidatorTest.php | 6 +- .../NotIdenticalToValidatorTest.php | 6 +- .../Tests/Constraints/RangeValidatorTest.php | 20 ++-- .../Validator/LegacyValidator2Dot5ApiTest.php | 9 -- .../LegacyValidatorLegacyApiTest.php | 9 -- .../Validator/Tests/ValidatorBuilderTest.php | 12 +- .../Component/Validator/ValidatorBuilder.php | 13 +-- .../Component/VarDumper/Cloner/VarCloner.php | 2 +- .../VarDumper/Tests/CliDumperTest.php | 2 +- .../VarDumper/Tests/HtmlDumperTest.php | 2 +- .../Yaml/Exception/ParseException.php | 7 +- .../Yaml/Tests/ParseExceptionTest.php | 12 +- 83 files changed, 131 insertions(+), 960 deletions(-) delete mode 100644 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php delete mode 100644 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php diff --git a/README.md b/README.md index 42607fbbfa434..ebcbd8664a467 100644 --- a/README.md +++ b/README.md @@ -4,32 +4,13 @@ README What is Symfony? ----------------- -Symfony is a PHP 5.3 full-stack web framework. It is written with speed and +Symfony is a PHP full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP. Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers. -Requirements ------------- - -Symfony is only supported on PHP 5.3.3 and up. - -Be warned that PHP versions before 5.3.8 are known to be buggy and might not -work for you: - - * before PHP 5.3.4, if you get "Notice: Trying to get property of - non-object", you've hit a known PHP bug (see - https://bugs.php.net/bug.php?id=52083 and - https://bugs.php.net/bug.php?id=50027); - - * before PHP 5.3.8, if you get an error involving annotations, you've hit a - known PHP bug (see https://bugs.php.net/bug.php?id=55156). - - * PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to - run Symfony (https://bugs.php.net/bug.php?id=62715) - Installation ------------ diff --git a/autoload.php.dist b/autoload.php.dist index c179857248e6b..e2d7299b5ca6d 100644 --- a/autoload.php.dist +++ b/autoload.php.dist @@ -1,8 +1,8 @@ = 50400 && gc_enabled()) { - // Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+ - // https://bugs.php.net/bug.php?id=53976 +// Disabling Zend Garbage Collection to prevent segfaults +// https://bugs.php.net/bug.php?id=53976 +if (gc_enabled()) { gc_disable(); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php deleted file mode 100644 index 3e1151d520b46..0000000000000 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.4 - * @author Bernhard Schussek - */ -class LegacyUniqueEntityValidator2Dot4ApiTest extends UniqueEntityValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_4; - } -} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php deleted file mode 100644 index 07382d90e9d67..0000000000000 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.4 - * @author Bernhard Schussek - */ -class LegacyUniqueEntityValidatorLegacyApiTest extends UniqueEntityValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 276b6b96723d2..8f452512609aa 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -11,10 +11,6 @@ namespace Symfony\Bridge\Twig\Command; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index d7b7898a72be4..3349b4b0c03fb 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -174,11 +174,7 @@ public function formatFile($file, $line, $text = null) $text = "$text at line $line"; if (false !== $link = $this->getFileLink($file, $line)) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 1efe52d126045..e080044c8e3c7 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -56,7 +56,7 @@ public function testOneVar() } EOTXT; - $expected = preg_replace('/%(.*?)%/', version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected); + $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); $this->assertSame($expected, $compiler->compile($node)->getSource()); } @@ -82,7 +82,7 @@ public function testMultiVars() } EOTXT; - $expected = preg_replace('/%(.*?)%/', version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected); + $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); $this->assertSame($expected, $compiler->compile($node)->getSource()); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 5f8ae112118fb..34b6de2a526ff 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -66,10 +66,6 @@ public function testCompile() protected function getVariableGetter($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); - } - - return sprintf('$this->getContext($context, "%s")', $name); + return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index 60ef9edfb9751..e08572e60ca4e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -263,10 +263,6 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() protected function getVariableGetter($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); - } - - return sprintf('$this->getContext($context, "%s")', $name); + return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index df5eb559d8c21..476fc5fef1d7e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -38,19 +38,11 @@ public function testCompileStrict() } protected function getVariableGetterWithoutStrictCheck($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); - } - - return sprintf('$this->getContext($context, "%s", true)', $name); + return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } protected function getVariableGetterWithStrictCheck($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); - } - - return sprintf('$this->getContext($context, "%s")', $name); + return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php index 4a94f99fe091c..cbd5ec892f4a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php @@ -23,7 +23,7 @@ abstract class ServerCommand extends ContainerAwareCommand */ public function isEnabled() { - if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) { + if (defined('HHVM_VERSION')) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 01a1e4da7ffd4..79d4aec6b4194 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -30,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand */ public function isEnabled() { - if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) { + if (defined('HHVM_VERSION')) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php index 967c3b18a317d..83d63f802f5b4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php @@ -11,10 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Command; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 5dd2d405ee5c0..2f2f8020dd0b3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -11,10 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 9354a549805a1..d635aae8220bb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -498,14 +498,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->validate() ->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; }) ->then(function ($v) { - // This condition is duplicated in ValidatorBuilder. This - // duplication is necessary in order to know the desired - // API version already during container configuration - // (to adjust service classes etc.) - // See https://github.com/symfony/symfony/issues/11580 - $v['validation']['api'] = PHP_VERSION_ID < 50309 - ? '2.4' - : '2.5-bc'; + $v['validation']['api'] = '2.5-bc'; return $v; }) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index 5ee9fb324dea8..65a4a1a2b5882 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -166,11 +166,7 @@ public function formatFile($file, $line, $text = null) } if (false !== $link = $this->getFileLink($file, $line)) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php index 7f7a0ae15cfd7..ee03f65391f8a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php @@ -15,13 +15,6 @@ class JsonDescriptorTest extends AbstractDescriptorTest { - protected function setUp() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped on PHP 5.3 as JSON_PRETTY_PRINT does not exist.'); - } - } - protected function getDescriptor() { return new JsonDescriptor(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 9a4ad2770a442..0fdb592ca69d6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -131,7 +131,7 @@ protected static function getBundleDefaultConfig() 'static_method' => array('loadValidatorMetadata'), 'translation_domain' => 'validators', 'strict_email' => false, - 'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc', + 'api' => '2.5-bc', ), 'annotations' => array( 'cache' => 'file', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index acc3cff6ba41e..4c4f14a4fc259 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -295,11 +295,7 @@ public function testValidation() $this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]); $this->assertSame('setApiVersion', $calls[6][0]); - if (PHP_VERSION_ID < 50309) { - $this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]); - } else { - $this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]); - } + $this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]); } public function testFullyConfiguredValidationService() @@ -448,11 +444,7 @@ public function testValidationImplicitApi() $this->assertSame('setApiVersion', $calls[5][0]); // no cache, no annotations - if (PHP_VERSION_ID < 50309) { - $this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]); - } else { - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - } + $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); } /** @@ -472,11 +464,7 @@ public function testValidationAutoApi() $this->assertSame('setApiVersion', $calls[5][0]); // no cache, no annotations - if (PHP_VERSION_ID < 50309) { - $this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]); - } else { - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - } + $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); } public function testFormsCanBeEnabledWithoutCsrfProtection() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index f86ec326afa55..3593b5074314d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -30,10 +30,6 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c */ public function testRoutingErrorIsExposedWhenNotProtected($config) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); - } - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->insulate(); $client->request('GET', '/unprotected_resource'); @@ -46,10 +42,6 @@ public function testRoutingErrorIsExposedWhenNotProtected($config) */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); - } - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->insulate(); diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 6bf4ebd545ab3..8627516526d1f 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -43,10 +43,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = self::$loaded[$name] = true; - $declared = array_merge(get_declared_classes(), get_declared_interfaces()); - if (function_exists('get_declared_traits')) { - $declared = array_merge($declared, get_declared_traits()); - } + $declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits()); if ($adaptive) { // don't include already declared classes diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 4c2aeab3ac79a..0151751be05b8 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,14 +11,6 @@ namespace Symfony\Component\ClassLoader; -if (!defined('SYMFONY_TRAIT')) { - if (PHP_VERSION_ID >= 50400) { - define('SYMFONY_TRAIT', T_TRAIT); - } else { - define('SYMFONY_TRAIT', 0); - } -} - /** * ClassMapGenerator. * @@ -117,7 +109,7 @@ private static function findClasses($path) break; case T_CLASS: case T_INTERFACE: - case SYMFONY_TRAIT: + case T_TRAIT: // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { diff --git a/src/Symfony/Component/ClassLoader/DebugClassLoader.php b/src/Symfony/Component/ClassLoader/DebugClassLoader.php index 897919b20ae21..47bba2d45fe1d 100644 --- a/src/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -107,7 +107,7 @@ public function loadClass($class) if ($file = $this->classFinder->findFile($class)) { require $file; - if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (!class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false)) { if (false !== strpos($class, '/')) { throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); } diff --git a/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php b/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php index 678f4e8b2aba6..19bb79fc01a00 100644 --- a/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php @@ -55,7 +55,7 @@ public function loadClass($class) if ($file = $this->findFile($class)) { require $file; - if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (!class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false)) { throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); } } diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index e821e45063631..5e5ee06fa7d3c 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -22,12 +22,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase { public function testTraitDependencies() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Requires PHP > 5.4'); - - return; - } - require_once __DIR__.'/Fixtures/deps/traits.php'; $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); @@ -100,12 +94,6 @@ public function getDifferentOrders() */ public function testClassWithTraitsReordering(array $classes) { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Requires PHP > 5.4'); - - return; - } - require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; @@ -148,12 +136,6 @@ public function getDifferentOrdersForTraits() public function testFixClassWithTraitsOrdering() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Requires PHP > 5.4'); - - return; - } - require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/F.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/G.php'; diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 88099258eccc2..77c861d9eb889 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -102,18 +102,15 @@ public function getTestCreateMapTests() 'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php', 'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php', )), - ); - - if (PHP_VERSION_ID >= 50400) { - $data[] = array(__DIR__.'/Fixtures/php5.4', array( + array(__DIR__.'/Fixtures/php5.4', array( 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php', - )); - } + )), + ); return $data; } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index fcefcd83f68a9..1ed60e1073b4f 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -229,10 +229,6 @@ private function writeText($content, array $options = array()) */ private function formatDefaultValue($default) { - if (PHP_VERSION_ID < 50400) { - return str_replace('\/', '/', json_encode($default)); - } - return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index b70a4c4ac3d24..369e65818c11a 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -162,7 +162,7 @@ public function loadClass($class) ErrorHandler::unstackErrors(); - $exists = class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + $exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); if ('\\' === $class[0]) { $class = substr($class, 1); diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 48e4a2d69e737..65b88a2b3e458 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -357,12 +357,6 @@ public function handleError($type, $message, $file, $line, array $context) $type &= $level | $this->screamedErrors; if ($type && ($log || $throw)) { - if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && ($this->scopedErrors & $type)) { - $e = $context; // Whatever the signature of the method, - unset($e['GLOBALS'], $context); // $context is always a reference in 5.3 - $context = $e; - } - if ($throw) { if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { // Checking for class existence is a work around for https://bugs.php.net/42098 @@ -371,14 +365,6 @@ public function handleError($type, $message, $file, $line, array $context) $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line); } - if (PHP_VERSION_ID <= 50407 && (PHP_VERSION_ID >= 50400 || PHP_VERSION_ID <= 50317)) { - // Exceptions thrown from error handlers are sometimes not caught by the exception - // handler and shutdown handlers are bypassed before 5.4.8/5.3.18. - // We temporarily re-enable display_errors to prevent any blank page related to this bug. - - $throw->errorHandlerCanary = new ErrorHandlerCanary(); - } - throw $throw; } @@ -401,7 +387,7 @@ public function handleError($type, $message, $file, $line, array $context) $e['stack'] = debug_backtrace(true); // Provide object } } elseif ($trace) { - $e['stack'] = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false); + $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } } @@ -658,30 +644,3 @@ public function handleFatal() static::handleFatalError(); } } - -/** - * Private class used to work around https://bugs.php.net/54275 - * - * @author Nicolas Grekas - * - * @internal - */ -class ErrorHandlerCanary -{ - private static $displayErrors = null; - - public function __construct() - { - if (null === self::$displayErrors) { - self::$displayErrors = ini_set('display_errors', 1); - } - } - - public function __destruct() - { - if (null !== self::$displayErrors) { - ini_set('display_errors', self::$displayErrors); - self::$displayErrors = null; - } - } -} diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index cbe582eb24068..56198af0f3faa 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -441,6 +441,6 @@ protected static function utf8Htmlize($str) $str = iconv($charset, 'UTF-8', $str); } - return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8'); + return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } } diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php index 0ba0bd4483080..bc5275f3aedd6 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -191,6 +191,6 @@ private function convertFileToClass($path, $file, $prefix) */ private function classExists($class) { - return class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); } } diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 9471d54a9afce..4f52f218b6710 100755 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -581,15 +581,7 @@ public function html() $html = ''; foreach ($this->getNode(0)->childNodes as $child) { - if (PHP_VERSION_ID >= 50306) { - // node parameter was added to the saveHTML() method in PHP 5.3.6 - // @see http://php.net/manual/en/domdocument.savehtml.php - $html .= $child->ownerDocument->saveHTML($child); - } else { - $document = new \DOMDocument('1.0', 'UTF-8'); - $document->appendChild($document->importNode($child, true)); - $html .= rtrim($document->saveHTML()); - } + $html .= $child->ownerDocument->saveHTML($child); } return $html; diff --git a/src/Symfony/Component/ExpressionLanguage/Parser.php b/src/Symfony/Component/ExpressionLanguage/Parser.php index 3e769c6d4fb24..be884414a2ada 100644 --- a/src/Symfony/Component/ExpressionLanguage/Parser.php +++ b/src/Symfony/Component/ExpressionLanguage/Parser.php @@ -336,10 +336,6 @@ public function parsePostfixExpression($node) $node = new Node\GetAttrNode($node, $arg, $arguments, $type); } elseif ('[' === $token->value) { - if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && PHP_VERSION_ID < 50400) { - throw new SyntaxError('Array calls on a method call is only supported on PHP 5.4+', $token->cursor); - } - $this->stream->next(); $arg = $this->parseExpression(); $this->stream->expect(Token::PUNCTUATION_TYPE, ']'); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index f5ba9948d0951..45936d51fdb05 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -61,17 +61,12 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * * @throws UnexpectedTypeException if a timezone is not a string */ - public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = null) + public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = true) { parent::__construct($inputTimezone, $outputTimezone); $this->generateFormat = $this->parseFormat = $format; - - // The pipe in the parser pattern only works as of PHP 5.3.7 - // See http://bugs.php.net/54316 - $this->parseUsingPipe = null === $parseUsingPipe - ? PHP_VERSION_ID >= 50307 - : $parseUsingPipe; + $this->parseUsingPipe = $parseUsingPipe || null === $parseUsingPipe; // See http://php.net/manual/en/datetime.createfromformat.php // The character "|" in the format makes sure that the parts of a date diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php index fd9110d3b1527..aefc406d7be00 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php @@ -73,11 +73,7 @@ public function isCsrfTokenValid($intention, $token) */ protected function getSessionId() { - if (PHP_VERSION_ID >= 50400) { - if (PHP_SESSION_NONE === session_status()) { - session_start(); - } - } elseif (!session_id()) { + if (PHP_SESSION_NONE === session_status()) { session_start(); } 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 dbcdad0f96bdf..be0f451a90f9b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -30,6 +30,7 @@ public function dataProvider() array('H:i:00', '16:05:00', '1970-01-01 16:05:00 UTC'), array('H:i', '16:05', '1970-01-01 16:05:00 UTC'), array('H', '16', '1970-01-01 16:00:00 UTC'), + array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'), // different day representations array('Y-m-j', '2010-02-3', '2010-02-03 00:00:00 UTC'), @@ -59,11 +60,6 @@ public function dataProvider() array('U', '1265213106', '2010-02-03 16:05:06 UTC'), ); - // This test will fail < 5.3.9 - see https://bugs.php.net/51994 - if (PHP_VERSION_ID >= 50309) { - $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'); - } - return $data; } @@ -111,10 +107,6 @@ public function testTransformExpectsDateTime() */ public function testReverseTransformUsingPipe($format, $input, $output) { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); - } - $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true); $output = new \DateTime($output); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php index f201f99862c61..113fc5c6dc3ce 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php @@ -51,10 +51,6 @@ public function testGenerateCsrfTokenOnUnstartedSession() { session_id('touti'); - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires PHP >= 5.4'); - } - $this->assertSame(PHP_SESSION_NONE, session_status()); $token = $this->provider->generateCsrfToken('foo'); diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index fa80c68858260..a8769db1a58db 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -120,7 +120,7 @@ public function setData($data = array()) } if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException($this->transformJsonError()); + throw new \InvalidArgumentException(json_last_error_msg()); } return $this->update(); @@ -172,31 +172,4 @@ protected function update() return $this->setContent($this->data); } - - private function transformJsonError() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - switch (json_last_error()) { - case JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded.'; - - case JSON_ERROR_STATE_MISMATCH: - return 'Underflow or the modes mismatch.'; - - case JSON_ERROR_CTRL_CHAR: - return 'Unexpected control character found.'; - - case JSON_ERROR_SYNTAX: - return 'Syntax error, malformed JSON.'; - - case JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded.'; - - default: - return 'Unknown error.'; - } - } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 80d3ab892dc79..047c70a2d9d5c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -16,12 +16,7 @@ * * @see http://php.net/sessionhandler */ -if (PHP_VERSION_ID >= 50400) { - class NativeSessionHandler extends \SessionHandler - { - } -} else { - class NativeSessionHandler - { - } + +class NativeSessionHandler extends \SessionHandler +{ } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index a5bdbe91d8f05..fdb97dcc2c02b 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -101,11 +101,7 @@ public function __construct(array $options = array(), $handler = null, MetadataB session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used) ini_set('session.use_cookies', 1); - if (PHP_VERSION_ID >= 50400) { - session_register_shutdown(); - } else { - register_shutdown_function('session_write_close'); - } + session_register_shutdown(); $this->setMetadataBag($metaBag); $this->setOptions($options); @@ -131,15 +127,10 @@ public function start() return true; } - if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) { + if (\PHP_SESSION_ACTIVE === session_status()) { throw new \RuntimeException('Failed to start the session: already started by PHP.'); } - if (PHP_VERSION_ID < 50400 && !$this->closed && isset($_SESSION) && session_id()) { - // not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3 - throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).'); - } - if (ini_get('session.use_cookies') && headers_sent($file, $line)) { throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line)); } @@ -150,10 +141,6 @@ public function start() } $this->loadSession(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 with internal save handlers - $this->saveHandler->setActive(true); - } return true; } @@ -213,11 +200,6 @@ public function save() { session_write_close(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 with internal save handlers - $this->saveHandler->setActive(false); - } - $this->closed = true; $this->started = false; } @@ -363,24 +345,12 @@ public function setSaveHandler($saveHandler = null) if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { $saveHandler = new SessionHandlerProxy($saveHandler); } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = PHP_VERSION_ID >= 50400 ? - new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy(); + $saveHandler = new SessionHandlerProxy(new \SessionHandler()); } $this->saveHandler = $saveHandler; if ($this->saveHandler instanceof \SessionHandlerInterface) { - if (PHP_VERSION_ID >= 50400) { - session_set_save_handler($this->saveHandler, false); - } else { - session_set_save_handler( - array($this->saveHandler, 'open'), - array($this->saveHandler, 'close'), - array($this->saveHandler, 'read'), - array($this->saveHandler, 'write'), - array($this->saveHandler, 'destroy'), - array($this->saveHandler, 'gc') - ); - } + session_set_save_handler($this->saveHandler, false); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php index ced706f72c85b..6f02a7fd73d23 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php @@ -43,10 +43,6 @@ public function start() } $this->loadSession(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 + internal save handlers - $this->saveHandler->setActive(true); - } return true; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index 1036818277e1f..f3f14781149c1 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -25,11 +25,6 @@ abstract class AbstractProxy */ protected $wrapper = false; - /** - * @var bool - */ - protected $active = false; - /** * @var string */ @@ -72,32 +67,7 @@ public function isWrapper() */ public function isActive() { - if (PHP_VERSION_ID >= 50400) { - return $this->active = \PHP_SESSION_ACTIVE === session_status(); - } - - return $this->active; - } - - /** - * Sets the active flag. - * - * Has no effect under PHP 5.4+ as status is detected - * automatically in isActive() - * - * @internal - * - * @param bool $flag - * - * @throws \LogicException - */ - public function setActive($flag) - { - if (PHP_VERSION_ID >= 50400) { - throw new \LogicException('This method is disabled in PHP 5.4.0+'); - } - - $this->active = (bool) $flag; + return \PHP_SESSION_ACTIVE === session_status(); } /** 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 ab848b6b972ad..c3eeacf7b117a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -28,13 +28,8 @@ public function testConstruct() { $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - if (PHP_VERSION_ID < 50400) { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('files', ini_get('session.save_handler')); - } else { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } + $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); + $this->assertEquals('user', ini_get('session.save_handler')); $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path')); $this->assertEquals('TESTING', ini_get('session.name')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php index 3437cf08f1d8d..b2304cbc482da 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php @@ -27,14 +27,7 @@ public function testConstruct() { $handler = new NativeSessionHandler(); - // note for PHPUnit optimisers - the use of assertTrue/False - // here is deliberate since the tests do not require the classes to exist - drak - if (PHP_VERSION_ID < 50400) { - $this->assertFalse($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } else { - $this->assertTrue($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } + $this->assertTrue($handler instanceof \SessionHandler); + $this->assertTrue($handler instanceof NativeSessionHandler); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 41329e72485e1..9b836bbe99cce 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -165,34 +165,8 @@ public function testSetSaveHandlerException() $storage->setSaveHandler(new \stdClass()); } - public function testSetSaveHandler53() + public function testSetSaveHandler() { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - ini_set('session.save_handler', 'files'); - $storage = $this->getStorage(); - $storage->setSaveHandler(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(null); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeProxy()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - } - - public function testSetSaveHandler54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - ini_set('session.save_handler', 'files'); $storage = $this->getStorage(); $storage->setSaveHandler(); @@ -212,7 +186,7 @@ public function testSetSaveHandler54() /** * @expectedException \RuntimeException */ - public function testStartedOutside() + public function testStarted() { $storage = $this->getStorage(); @@ -222,10 +196,8 @@ public function testStartedOutside() session_start(); $this->assertTrue(isset($_SESSION)); - if (PHP_VERSION_ID >= 50400) { - // this only works in PHP >= 5.4 where session_status is available - $this->assertTrue($storage->getSaveHandler()->isActive()); - } + $this->assertTrue($storage->getSaveHandler()->isActive()); + // PHP session might have started, but the storage driver has not, so false is correct here $this->assertFalse($storage->isStarted()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index d9f4a30a89a68..ed989d40789af 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -59,36 +59,8 @@ protected function getStorage() return $storage; } - public function testPhpSession53() + public function testPhpSession() { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $storage = $this->getStorage(); - - $this->assertFalse(isset($_SESSION)); - $this->assertFalse($storage->getSaveHandler()->isActive()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - // in PHP 5.3 we cannot reliably tell if a session has started - $this->assertFalse($storage->getSaveHandler()->isActive()); - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); - $storage->start(); - $this->assertTrue(isset($_SESSION[$key])); - } - - public function testPhpSession54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - $storage = $this->getStorage(); $this->assertFalse(isset($_SESSION)); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index ee476a879d0af..7290e62382f9e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -85,56 +85,18 @@ public function testIsWrapper() $this->assertFalse($this->proxy->isWrapper()); } - public function testIsActivePhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->assertFalse($this->proxy->isActive()); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testIsActivePhp54() + public function testIsActive() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } $this->assertFalse($this->proxy->isActive()); session_start(); $this->assertTrue($this->proxy->isActive()); } - public function testSetActivePhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->assertTrue($this->proxy->isActive()); - $this->proxy->setActive(false); - $this->assertFalse($this->proxy->isActive()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testSetActivePhp54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - $this->proxy->setActive(true); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled @@ -147,30 +109,13 @@ public function testName() $this->assertEquals(session_name(), $this->proxy->getName()); } - /** - * @expectedException \LogicException - */ - public function testNameExceptionPhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->proxy->setName('foo'); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled * @expectedException \LogicException */ - public function testNameExceptionPhp54() + public function testNameException() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - session_start(); $this->proxy->setName('foo'); } @@ -187,30 +132,13 @@ public function testId() $this->assertEquals(session_id(), $this->proxy->getId()); } - /** - * @expectedException \LogicException - */ - public function testIdExceptionPhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->proxy->setId('foo'); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled * @expectedException \LogicException */ - public function testIdExceptionPhp54() + public function testIdException() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - session_start(); $this->proxy->setId('foo'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index d2775a80a20f1..bc810a6b209b6 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -45,7 +45,7 @@ protected function tearDown() $this->proxy = null; } - public function testOpen() + public function testOpenTrue() { $this->mock->expects($this->once()) ->method('open') @@ -53,11 +53,7 @@ public function testOpen() $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); - if (PHP_VERSION_ID < 50400) { - $this->assertTrue($this->proxy->isActive()); - } else { - $this->assertFalse($this->proxy->isActive()); - } + $this->assertFalse($this->proxy->isActive()); } public function testOpenFalse() diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index 6099097f366bd..8a836da84c5ab 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -60,12 +60,7 @@ public function dump(Data $data) $this->isCollected = false; } - $trace = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS : true; - if (PHP_VERSION_ID >= 50400) { - $trace = debug_backtrace($trace, 7); - } else { - $trace = debug_backtrace($trace); - } + $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7); $file = $trace[0]['file']; $line = $trace[0]['line']; diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 56c96b3ceda3f..304b527842445 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -107,11 +107,7 @@ public function render($uri, Request $request, array $options = array()) } $renderedAttributes = ''; if (count($attributes) > 0) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; foreach ($attributes as $attribute => $value) { $renderedAttributes .= sprintf( ' %s="%s"', diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index fe70ae5d5e844..dd1d6242eaa3a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -181,15 +181,11 @@ public function testGetArguments() $request->attributes->set('foobar', 'foobar'); $controller = array(new self(), 'controllerMethod3'); - if (PHP_VERSION_ID === 50316) { - $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system'); - } else { - try { - $resolver->getArguments($request, $controller); - $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } + try { + $resolver->getArguments($request, $controller); + $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); + } catch (\Exception $e) { + $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); } $request = Request::create('/'); diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php index 1973843481996..84b20abf77ee8 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php @@ -53,37 +53,10 @@ public function read($path, $locale) 'The resource bundle "%s/%s.json" contains invalid JSON: %s', $path, $locale, - self::getLastJsonError() + json_last_error_msg() )); } return $data; } - - /** - * @return string The last error message created by {@link json_decode()} - * - * @link http://de2.php.net/manual/en/function.json-last-error-msg.php#113243 - */ - private static function getLastJsonError() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - static $errors = array( - JSON_ERROR_NONE => null, - JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', - JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', - JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', - JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', - JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', - ); - - $error = json_last_error(); - - return array_key_exists($error, $errors) - ? $errors[$error] - : sprintf('Unknown error (%s)', $error); - } } diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php index 6a79340c695e4..f3df769e13cc6 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php @@ -35,14 +35,8 @@ public function write($path, $locale, $data) } }); - if (PHP_VERSION_ID >= 50400) { - // Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs - file_put_contents( - $path.'/'.$locale.'.json', - json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n" - ); - } else { - file_put_contents($path.'/'.$locale.'.json', json_encode($data)."\n"); - } + $contents = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n"; + + file_put_contents($path.'/'.$locale.'.json', $contents); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 7636be9a34975..37bb9cad49771 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -187,8 +187,7 @@ public static function create($locale, $datetype, $timetype, $timezone = null, $ /** * Format the date/time value (timestamp) as a string. * - * @param int|\DateTime $timestamp The timestamp to format. \DateTime objects - * are supported as of PHP 5.3.4. + * @param int|\DateTime $timestamp The timestamp to format. * * @return string|bool The formatted value or false if formatting failed. * @@ -200,20 +199,16 @@ public function format($timestamp) { // intl allows timestamps to be passed as arrays - we don't if (is_array($timestamp)) { - $message = PHP_VERSION_ID >= 50304 ? - 'Only integer Unix timestamps and DateTime objects are supported' : - 'Only integer Unix timestamps are supported'; + $message = 'Only integer Unix timestamps and DateTime objects are supported'; throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, $message); } // behave like the intl extension $argumentError = null; - if (PHP_VERSION_ID < 50304 && !is_int($timestamp)) { - $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; - } elseif (PHP_VERSION_ID >= 50304 && !is_int($timestamp) && !$timestamp instanceof \DateTime) { + if (!is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; - if (PHP_VERSION_ID >= 50500 && !is_int($timestamp)) { + if (!is_int($timestamp)) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); } } @@ -227,7 +222,7 @@ public function format($timestamp) } // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (PHP_VERSION_ID >= 50304 && $timestamp instanceof \DateTime) { + if ($timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } @@ -375,10 +370,7 @@ public function getTimeZoneId() return $this->timeZoneId; } - // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (PHP_VERSION_ID >= 50500) { - return date_default_timezone_get(); - } + return date_default_timezone_get(); } /** @@ -540,16 +532,7 @@ public function setPattern($pattern) public function setTimeZoneId($timeZoneId) { if (null === $timeZoneId) { - // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method - if (PHP_VERSION_ID >= 50500) { - $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 - // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC. - // See the first two items of the commit message for more information: - // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9 - $timeZoneId = getenv('TZ') ?: 'UTC'; - } + $timeZoneId = date_default_timezone_get(); $this->unitializedTimeZoneId = true; } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 6a66e8bb45d5a..c7f518d74c68a 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -839,9 +839,7 @@ private function getInt32Value($value) * * @param mixed $value The value to be converted * - * @return int|float The converted value - * - * @see https://bugs.php.net/bug.php?id=59597 Bug #59597 + * @return int|false The converted value */ private function getInt64Value($value) { @@ -849,30 +847,6 @@ private function getInt64Value($value) return false; } - if (PHP_INT_SIZE !== 8 && ($value > self::$int32Range['positive'] || $value <= self::$int32Range['negative'])) { - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // The negative PHP_INT_MAX was being converted to float - if ( - $value == self::$int32Range['negative'] && - ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) - ) { - return (int) $value; - } - - return (float) $value; - } - - if (PHP_INT_SIZE === 8) { - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // A 32 bit integer was being generated instead of a 64 bit integer - if ( - ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) && - (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) - ) { - $value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value)); - } - } - return (int) $value; } diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index 69575289cdd9f..f2e7b4fce46a5 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -34,10 +34,6 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires at least PHP 5.4.0.'); - } - $this->writer = new JsonBundleWriter(); $this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.rand(1000, 9999); $this->filesystem = new Filesystem(); @@ -47,10 +43,6 @@ protected function setUp() protected function tearDown() { - if (PHP_VERSION_ID < 50400) { - return; - } - $this->filesystem->remove($this->directory); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 40f5fd71c184a..cbac7ab9f836e 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -37,12 +37,7 @@ public function testConstructorDefaultTimeZone() { $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); - // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (PHP_VERSION_ID >= 50500) { - $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); - } else { - $this->assertNull($formatter->getTimeZoneId()); - } + $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } /** @@ -60,6 +55,8 @@ public function testFormat($pattern, $timestamp, $expected) public function formatProvider() { + $dateTime = new \DateTime('@0'); + $formatData = array( /* general */ array('y-M-d', 0, '1970-1-1'), @@ -236,21 +233,15 @@ public function formatProvider() array('zzz', 0, 'GMT'), array('zzzz', 0, 'GMT'), array('zzzzz', 0, 'GMT'), - ); - - // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (PHP_VERSION_ID >= 50304) { - $dateTime = new \DateTime('@0'); - - /* general, DateTime */ - $formatData[] = array('y-M-d', $dateTime, '1970-1-1'); - $formatData[] = array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"); - $formatData[] = array('h:mm a', $dateTime, '12:00 AM'); - $formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'); - $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT'); - $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT'); - } + // general, DateTime + array('y-M-d', $dateTime, '1970-1-1'), + array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"), + array('h:mm a', $dateTime, '12:00 AM'), + array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'), + array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT'), + array('K:mm a, z', $dateTime, '0:00 AM, GMT'), + ); return $formatData; } @@ -269,22 +260,8 @@ public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessa public function formatErrorProvider() { - // With PHP 5.5 IntlDateFormatter accepts empty values ('0') - if (PHP_VERSION_ID >= 50500) { - 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'), - ); - } - - $message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR'; - - if (PHP_VERSION_ID >= 50304) { - $message = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object: U_ILLEGAL_ARGUMENT_ERROR'; - } - return array( - array('y-M-d', '0', $message), - array('y-M-d', 'foobar', $message), + 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'), ); } @@ -324,16 +301,12 @@ public function formatWithTimezoneProvider() array(0, 'Europe/Dublin', '1970-01-01 01:00:00'), array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'), array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'), + array(0, 'Foo/Bar', '1970-01-01 00:00:00'), + array(0, 'Foo/Bar', '1970-01-01 00:00:00'), + array(0, 'UTC+04:30', '1970-01-01 00:00:00'), + array(0, 'UTC+04:AA', '1970-01-01 00:00:00'), ); - // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC - if (PHP_VERSION_ID < 50500) { - // 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'); - $data[] = array(0, 'UTC+04:AA', '1970-01-01 00:00:00'); - } - return $data; } @@ -341,11 +314,7 @@ public function testFormatWithGmtTimezone() { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone('GMT+03:00'); - } else { - $formatter->setTimeZoneId('GMT+03:00'); - } + $formatter->setTimeZone('GMT+03:00'); $this->assertEquals('GMT+03:00', $formatter->format(0)); } @@ -354,11 +323,7 @@ public function testFormatWithGmtTimeZoneAndMinutesOffset() { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone('GMT+00:30'); - } else { - $formatter->setTimeZoneId('GMT+00:30'); - } + $formatter->setTimeZone('GMT+00:30'); $this->assertEquals('GMT+00:30', $formatter->format(0)); } @@ -367,11 +332,7 @@ public function testFormatWithNonStandardTimezone() { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone('Pacific/Fiji'); - } else { - $formatter->setTimeZoneId('Pacific/Fiji'); - } + $formatter->setTimeZone('Pacific/Fiji'); $this->assertEquals('Fiji Standard Time', $formatter->format(0)); } @@ -387,35 +348,8 @@ public function testFormatWithConstructorTimezone() ); } - public function testFormatWithTimezoneFromEnvironmentVariable() - { - if (PHP_VERSION_ID >= 50500) { - $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); - } - - $tz = getenv('TZ'); - putenv('TZ=Europe/London'); - - $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); - $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); - - $this->assertEquals( - $this->getDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'), - $formatter->format(0) - ); - - $this->assertEquals('Europe/London', getenv('TZ')); - - // Restores TZ. - putenv('TZ='.$tz); - } - public function testFormatWithTimezoneFromPhp() { - if (PHP_VERSION_ID < 50500) { - $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); - } - $tz = date_default_timezone_get(); date_default_timezone_set('Europe/London'); @@ -843,11 +777,7 @@ public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId) { $formatter = $this->getDefaultDateFormatter(); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone($timeZoneId); - } else { - $formatter->setTimeZoneId($timeZoneId); - } + $formatter->setTimeZone($timeZoneId); $this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId()); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 2e7544b39e008..97247d47b540c 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -56,12 +56,7 @@ public function testFormatWithUnsupportedTimestampArgument() $formatter->format($localtime); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e); - - if (PHP_VERSION_ID >= 50304) { - $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); - } else { - $this->assertStringEndsWith('Only integer Unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); - } + $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); } } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 341cdc90c2ad8..531bb4c62b9fa 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -687,13 +687,7 @@ public function testParseTypeInt64With32BitIntegerInPhp32Bit() $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64); - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // The negative PHP_INT_MAX was being converted to float - if ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) { - $this->assertInternalType('int', $parsedValue); - } else { - $this->assertInternalType('float', $parsedValue); - } + $this->assertInternalType('int', $parsedValue); $this->assertEquals(-2147483648, $parsedValue); } @@ -744,24 +738,12 @@ public function testParseTypeInt64With64BitIntegerInPhp64Bit() $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64); $this->assertInternalType('integer', $parsedValue); - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // A 32 bit integer was being generated instead of a 64 bit integer - if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { - $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); - } else { - $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); - } + $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64); $this->assertInternalType('integer', $parsedValue); - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // A 32 bit integer was being generated instead of a 64 bit integer - if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { - $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); - } else { - $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); - } + $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); } /** diff --git a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php index d2b031999cbde..c0c8fe0993200 100644 --- a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php @@ -34,10 +34,6 @@ class BCryptPasswordEncoder extends BasePasswordEncoder */ public function __construct($cost) { - if (!function_exists('password_hash')) { - throw new \RuntimeException('To use the BCrypt encoder, you need to upgrade to PHP 5.5 or install the "ircmaxell/password-compat" via Composer.'); - } - $cost = (int) $cost; if ($cost < 4 || $cost > 31) { throw new \InvalidArgumentException('Cost must be in the range of 4-31.'); diff --git a/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php index dac1cad6000ef..8422a4baaea02 100644 --- a/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php @@ -64,11 +64,7 @@ public function encodePassword($raw, $salt) throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm)); } - if (function_exists('hash_pbkdf2')) { - $digest = hash_pbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length, true); - } else { - $digest = $this->hashPbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length); - } + $digest = hash_pbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length, true); return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest); } @@ -80,24 +76,4 @@ public function isPasswordValid($encoded, $raw, $salt) { return !$this->isPasswordTooLong($raw) && $this->comparePasswords($encoded, $this->encodePassword($raw, $salt)); } - - private function hashPbkdf2($algorithm, $password, $salt, $iterations, $length = 0) - { - // Number of blocks needed to create the derived key - $blocks = ceil($length / strlen(hash($algorithm, null, true))); - $digest = ''; - - for ($i = 1; $i <= $blocks; $i++) { - $ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true); - - // Iterations - for ($j = 1; $j < $iterations; $j++) { - $ib ^= ($block = hash_hmac($algorithm, $block, $password, true)); - } - - $digest .= $ib; - } - - return substr($digest, 0, $this->length); - } } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php index 2f7b845acd158..4d9ca6d48e614 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php @@ -47,8 +47,6 @@ public function testCostInRange() public function testResultLength() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); @@ -56,21 +54,12 @@ public function testResultLength() public function testValidation() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } - private function skipIfPhpVersionIsNotSupported() - { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Requires PHP >= 5.3.7'); - } - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ diff --git a/src/Symfony/Component/Security/Core/Util/SecureRandom.php b/src/Symfony/Component/Security/Core/Util/SecureRandom.php index aefc88854a648..f4167e4d2f41b 100644 --- a/src/Symfony/Component/Security/Core/Util/SecureRandom.php +++ b/src/Symfony/Component/Security/Core/Util/SecureRandom.php @@ -43,9 +43,7 @@ public function __construct($seedFile = null, LoggerInterface $logger = null) $this->logger = $logger; // determine whether to use OpenSSL - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) { - $this->useOpenSsl = false; - } elseif (!function_exists('openssl_random_pseudo_bytes')) { + if (!function_exists('openssl_random_pseudo_bytes')) { if (null !== $this->logger) { $this->logger->notice('It is recommended that you enable the "openssl" extension for random number generation.'); } diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php index 0039deb1a857b..ef49f2f884441 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php @@ -52,10 +52,6 @@ public function testStoreTokenInClosedSession() public function testStoreTokenInClosedSessionWithExistingSessionId() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires PHP 5.4 or later.'); - } - session_id('foobar'); $this->assertSame(PHP_SESSION_NONE, session_status()); diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php index 60145c65a05f1..4229bb637bcd2 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php @@ -108,11 +108,7 @@ public function removeToken($tokenId) private function startSession() { - if (PHP_VERSION_ID >= 50400) { - if (PHP_SESSION_NONE === session_status()) { - session_start(); - } - } elseif (!session_id()) { + if (PHP_SESSION_NONE === session_status()) { session_start(); } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 4bb5b43dd0945..a35849a5c65d4 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -99,11 +99,7 @@ public function decode($data, $format, array $context = array()) $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; - if (PHP_VERSION_ID >= 50400) { - $decodedData = json_decode($data, $associative, $recursionDepth, $options); - } else { - $decodedData = json_decode($data, $associative, $recursionDepth); - } + $decodedData = json_decode($data, $associative, $recursionDepth, $options); if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) { throw new UnexpectedValueException(JsonEncoder::getLastErrorMessage()); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php index 2231dd624add9..28d619f1f2f23 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php @@ -99,23 +99,6 @@ public function supportsDecoding($format) */ public static function getLastErrorMessage() { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - switch (json_last_error()) { - case JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded'; - case JSON_ERROR_STATE_MISMATCH: - return 'Underflow or the modes mismatch'; - case JSON_ERROR_CTRL_CHAR: - return 'Unexpected control character found'; - case JSON_ERROR_SYNTAX: - return 'Syntax error, malformed JSON'; - case JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded'; - default: - return 'Unknown error'; - } + return json_last_error_msg(); } } diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index fd236d2cffd88..491d17c2e0c55 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -457,11 +457,7 @@ public function getGlobals() */ protected function initializeEscapers() { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; $this->escapers = array( 'html' => @@ -488,11 +484,11 @@ function ($value) use ($flags) { * @return string the escaped value */ function ($value) { - if ('UTF-8' != $that->getCharset()) { - $value = $that->convertEncoding($value, 'UTF-8', $that->getCharset()); + if ('UTF-8' != $this->getCharset()) { + $value = $this->convertEncoding($value, 'UTF-8', $this->getCharset()); } - $callback = function ($matches) use ($that) { + $callback = function ($matches) { $char = $matches[0]; // \xHH @@ -501,7 +497,7 @@ function ($value) { } // \uHHHH - $char = $that->convertEncoding($char, 'UTF-16BE', 'UTF-8'); + $char = $this->convertEncoding($char, 'UTF-16BE', 'UTF-8'); return '\\u'.substr('0000'.bin2hex($char), -4); }; @@ -511,7 +507,7 @@ function ($value) { } if ('UTF-8' != $this->getCharset()) { - $value = $this->convertEncoding($value, $that->getCharset(), 'UTF-8'); + $value = $this->convertEncoding($value, $this->getCharset(), 'UTF-8'); } return $value; diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index fea7827498f00..f54321f00ef82 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -13,10 +13,6 @@ use Symfony\Component\Translation\MessageCatalogue; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - /** * JsonFileDumper generates an json formatted string representation of a message catalogue. * diff --git a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php index 697cd939f607a..86594ef8bbdda 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php @@ -18,10 +18,6 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase { public function testDump() { - if (PHP_VERSION_ID < 50400) { - $this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing'); - } - $catalogue = new MessageCatalogue('en'); $catalogue->add(array('foo' => 'bar')); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 4013fd48fe0fc..37ce4805f42c5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -36,10 +36,6 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal { protected static function addPhp5Dot5Comparisons(array $comparisons) { - if (version_compare(PHP_VERSION, '5.5.0-dev', '<')) { - return $comparisons; - } - $result = $comparisons; // Duplicate all tests involving DateTime objects to be tested with diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index 4b71062f05935..8550e1159fc67 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -64,10 +64,8 @@ public function provideValidComparisons() array(null, 1), ); - if (version_compare(PHP_VERSION, '>=', '5.5')) { - $immutableDate = new \DateTimeImmutable('2000-01-01'); - $comparisons[] = array($immutableDate, $immutableDate); - } + $immutableDate = new \DateTimeImmutable('2000-01-01'); + $comparisons[] = array($immutableDate, $immutableDate); return $comparisons; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 1fbd80663fadd..e59c0945c46cf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -82,10 +82,8 @@ public function provideInvalidComparisons() array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'), ); - if (version_compare(PHP_VERSION, '>=', '5.5')) { - $immutableDate = new \DateTimeImmutable('2000-01-01'); - $comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime'); - } + $immutableDate = new \DateTimeImmutable('2000-01-01'); + $comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime'); return $comparisons; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index 9b7056b548735..6e6990c39f875 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -194,11 +194,9 @@ public function getTenthToTwentiethMarch2014() array(new \DateTime('March 20, 2014')), ); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $tests[] = array(new \DateTimeImmutable('March 10, 2014')); - $tests[] = array(new \DateTimeImmutable('March 15, 2014')); - $tests[] = array(new \DateTimeImmutable('March 20, 2014')); - } + $tests[] = array(new \DateTimeImmutable('March 10, 2014')); + $tests[] = array(new \DateTimeImmutable('March 15, 2014')); + $tests[] = array(new \DateTimeImmutable('March 20, 2014')); $this->restoreDefaultTimezone(); @@ -216,10 +214,8 @@ public function getSoonerThanTenthMarch2014() array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'), ); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'); - $tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'); - } + $tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'); + $tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'); $this->restoreDefaultTimezone(); @@ -237,10 +233,8 @@ public function getLaterThanTwentiethMarch2014() array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'), ); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'); - $tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'); - } + $tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'); + $tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'); $this->restoreDefaultTimezone(); diff --git a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php index 3e1e442f75225..4509e22ee191c 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php @@ -19,15 +19,6 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest { - protected function setUp() - { - if (PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Not supported prior to PHP 5.3.9'); - } - - parent::setUp(); - } - protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) { $contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator()); diff --git a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php index 3f02a5af71c80..3f7bf1e5bb574 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php @@ -19,15 +19,6 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest { - protected function setUp() - { - if (PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Not supported prior to PHP 5.3.9'); - } - - parent::setUp(); - } - protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) { $contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator()); diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index ba184f7c784db..69689d639080f 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -112,13 +112,7 @@ public function testSetTranslationDomain() public function testDefaultApiVersion() { - if (PHP_VERSION_ID < 50309) { - // Old implementation on PHP < 5.3.9 - $this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator()); - } else { - // Legacy compatible implementation on PHP >= 5.3.9 - $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); - } + $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); } public function testSetApiVersion24() @@ -135,10 +129,6 @@ public function testSetApiVersion25() public function testSetApiVersion24And25() { - if (PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Not supported prior to PHP 5.3.9'); - } - $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC)); $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); } diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php index f5cab110cd6ec..8151a444f7938 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilder.php +++ b/src/Symfony/Component/Validator/ValidatorBuilder.php @@ -329,15 +329,6 @@ public function setApiVersion($apiVersion) )); } - if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) { - throw new InvalidArgumentException(sprintf( - 'The Validator API that is compatible with both Symfony 2.4 '. - 'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '. - 'Your current PHP version is %s.', - PHP_VERSION - )); - } - $this->apiVersion = $apiVersion; return $this; @@ -389,9 +380,7 @@ public function getValidator() $apiVersion = $this->apiVersion; if (null === $apiVersion) { - $apiVersion = PHP_VERSION_ID < 50309 - ? Validation::API_VERSION_2_4 - : Validation::API_VERSION_2_5_BC; + $apiVersion = Validation::API_VERSION_2_5_BC; } if (Validation::API_VERSION_2_4 === $apiVersion) { diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 605977be80891..0827bba547ae8 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -266,7 +266,7 @@ private static function initHashMask() } else { // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below $obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush'); - foreach (debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) { + foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], $obFuncs)) { $frame['line'] = 0; break; diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php index 49710aaa88eae..ed77ccb597ce1 100644 --- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php @@ -38,7 +38,7 @@ public function testGet() ob_start(); $dumper->dump($data); $out = ob_get_clean(); - $closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function'; + $closureLabel = 'public method'; $out = preg_replace('/[ \t]+$/m', '', $out); $intMax = PHP_INT_MAX; $res1 = (int) $var['res']; diff --git a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php index fc8a15f09fa61..87198d6d269d5 100644 --- a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php @@ -40,7 +40,7 @@ public function testGet() ob_start(); $dumper->dump($data); $out = ob_get_clean(); - $closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function'; + $closureLabel = 'public method'; $out = preg_replace('/[ \t]+$/m', '', $out); $var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8'); $intMax = PHP_INT_MAX; diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index 0447dff137345..180e712e90f80 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -125,12 +125,7 @@ private function updateRepr() } if (null !== $this->parsedFile) { - if (PHP_VERSION_ID >= 50400) { - $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; - } else { - $jsonOptions = 0; - } - $this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions)); + $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } if ($this->parsedLine >= 0) { diff --git a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php index e4eb9c98a15d1..7286d45a0939b 100644 --- a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -18,11 +18,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase public function testGetMessage() { $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml'); - if (PHP_VERSION_ID >= 50400) { - $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; - } else { - $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")'; - } + $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; $this->assertEquals($message, $exception->getMessage()); } @@ -30,11 +26,7 @@ public function testGetMessage() public function testGetMessageWithUnicodeInFilename() { $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml'); - if (PHP_VERSION_ID >= 50400) { - $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; - } else { - $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")'; - } + $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; $this->assertEquals($message, $exception->getMessage()); } From 2221a150feef7e6dee295004d0bf30498423cc15 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Tue, 30 Dec 2014 16:16:25 +0100 Subject: [PATCH 019/133] [3.0] [Twig Bridge] Fixed Tests --- .../Extension/FormExtensionDivLayoutTest.php | 19 ++++++++++------- .../FormExtensionTableLayoutTest.php | 12 ++++++++++- .../Templating/Helper/FormHelper.php | 21 ------------------- .../Helper/FormHelperDivLayoutTest.php | 18 ++++++++++++---- .../Helper/FormHelperTableLayoutTest.php | 18 ++++++++++++---- .../Form/Tests/AbstractLayoutTest.php | 20 ------------------ 6 files changed, 50 insertions(+), 58 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 4b347fe2efe0e..f621db6e83bd7 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -106,17 +106,10 @@ public function testThemeBlockInheritanceUsingDynamicExtend() public function isSelectedChoiceProvider() { - // The commented cases should not be necessary anymore, because the - // choice lists should assure that both values passed here are always - // strings return array( -// array(true, 0, 0), array(true, '0', '0'), array(true, '1', '1'), -// array(true, false, 0), -// array(true, true, 1), array(true, '', ''), -// array(true, null, ''), array(true, '1.23', '1.23'), array(true, 'foo', 'foo'), array(true, 'foo10', 'foo10'), @@ -144,7 +137,7 @@ protected function renderForm(FormView $view, array $vars = array()) protected function renderEnctype(FormView $view) { - return (string) $this->extension->renderer->searchAndRenderBlock($view, 'enctype'); + // Kept empty for 2.7 compatibility } protected function renderLabel(FormView $view, $label = null, array $vars = array()) @@ -204,4 +197,14 @@ public static function themeInheritanceProvider() array(array('parent_label.html.twig'), array('child_label.html.twig')), ); } + + public function testEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } + + public function testNoEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index b5a08e47a57dd..90d26cbc5146b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -66,7 +66,7 @@ protected function renderForm(FormView $view, array $vars = array()) protected function renderEnctype(FormView $view) { - return (string) $this->extension->renderer->searchAndRenderBlock($view, 'enctype'); + // Kept empty for 2.7 compatibility } protected function renderLabel(FormView $view, $label = null, array $vars = array()) @@ -112,4 +112,14 @@ protected function setTheme(FormView $view, array $themes) { $this->extension->renderer->setTheme($view, $themes); } + + public function testEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } + + public function testNoEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php index 0915a068b6303..2bd2336ee5919 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php @@ -120,27 +120,6 @@ public function end(FormView $view, array $variables = array()) return $this->renderer->renderBlock($view, 'form_end', $variables); } - /** - * Renders the HTML enctype in the form tag, if necessary. - * - * Example usage templates: - * - *
    enctype($form) ?>> - * - * @param FormView $view The view for which to render the encoding type - * - * @return string The HTML markup - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link start} instead. - */ - public function enctype(FormView $view) - { - trigger_error('The form helper $view[\'form\']->enctype() is deprecated since version 2.3 and will be removed in 3.0. Use $view[\'form\']->start() instead.', E_USER_DEPRECATED); - - return $this->renderer->searchAndRenderBlock($view, 'enctype'); - } - /** * Renders the HTML for a given view. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index 2fbff686fc07c..cbade328d268d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -57,14 +57,14 @@ protected function tearDown() parent::tearDown(); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderEnctype(FormView $view) { - return (string) $this->engine->get('form')->form($view, $vars); + // Kept empty for 2.7 compatibility } - protected function renderEnctype(FormView $view) + protected function renderForm(FormView $view, array $vars = array()) { - return (string) $this->engine->get('form')->enctype($view); + return (string) $this->engine->get('form')->form($view, $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) @@ -120,4 +120,14 @@ public static function themeInheritanceProvider() array(array('TestBundle:Parent'), array('TestBundle:Child')), ); } + + public function testEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } + + public function testNoEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php index c95442bed61f8..c7a7168985c44 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php @@ -58,14 +58,14 @@ protected function tearDown() parent::tearDown(); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderEnctype(FormView $view) { - return (string) $this->engine->get('form')->form($view, $vars); + // Kept empty for 2.7 compatibility } - protected function renderEnctype(FormView $view) + protected function renderForm(FormView $view, array $vars = array()) { - return (string) $this->engine->get('form')->enctype($view); + return (string) $this->engine->get('form')->form($view, $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = array()) @@ -107,4 +107,14 @@ protected function setTheme(FormView $view, array $themes) { $this->engine->get('form')->setTheme($view, $themes); } + + public function testEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } + + public function testNoEnctype() + { + $this->markTestSkipped('This test is skipped to keep 2.7 compatibility.'); + } } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 33177e1fbd2fc..c234d537bd654 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -101,8 +101,6 @@ protected function assertWidgetMatchesXpath(FormView $view, array $vars, $xpath) abstract protected function renderForm(FormView $view, array $vars = array()); - abstract protected function renderEnctype(FormView $view); - abstract protected function renderLabel(FormView $view, $label = null, array $vars = array()); abstract protected function renderErrors(FormView $view); @@ -119,24 +117,6 @@ abstract protected function renderEnd(FormView $view, array $vars = array()); abstract protected function setTheme(FormView $view, array $themes); - public function testEnctype() - { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('file', 'file') - ->getForm(); - - $this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView())); - } - - public function testNoEnctype() - { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('text', 'text') - ->getForm(); - - $this->assertEquals('', $this->renderEnctype($form->createView())); - } - public function testLabel() { $form = $this->factory->createNamed('name', 'text'); From 2120554141e2b6e8d6af4699b620ce7eb70d89e5 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Wed, 12 Nov 2014 00:39:57 +0100 Subject: [PATCH 020/133] Removed request service occurrences. --- .../FrameworkBundle/Controller/Controller.php | 16 ---------------- .../Resources/config/services.xml | 13 +------------ .../Resources/config/templating_php.xml | 7 +++---- .../Form/UserLoginFormType.php | 19 ++++++++----------- .../Functional/app/CsrfFormLogin/config.yml | 4 +--- 5 files changed, 13 insertions(+), 46 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index f42d134e295eb..beb25698b967d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -261,22 +261,6 @@ public function createFormBuilder($data = null, array $options = array()) return $this->container->get('form.factory')->createBuilder('form', $data, $options); } - /** - * Shortcut to return the request service. - * - * @return Request - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. Ask - * Symfony to inject the Request object into your controller - * method instead by type hinting it in the method's signature. - */ - public function getRequest() - { - trigger_error('The "getRequest" method of the base "Controller" class has been deprecated since Symfony 2.4 and will be removed in 3.0. The only reliable way to get the "Request" object is to inject it in the action method.', E_USER_DEPRECATED); - - return $this->container->get('request_stack')->getCurrentRequest(); - } - /** * Shortcut to return the Doctrine Registry service. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index 4457dbb27669c..2c3c6ea312a62 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -37,22 +37,11 @@ - - - - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml index 6e482f8573e51..7cfcc0986324b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml @@ -44,7 +44,7 @@ - + service('request_stack').getMasterRequest() @@ -55,9 +55,8 @@ - - - + + service('request_stack').getMasterRequest() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php index 6928e6868b09c..c615ef5fd6106 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; -use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Symfony\Component\Security\Core\Security; @@ -29,18 +29,15 @@ */ class UserLoginFormType extends AbstractType { - private $request; + private $requestStack; - /** - * @param Request $request A request instance - */ - public function __construct(Request $request) + public function __construct(RequestStack $requestStack) { - $this->request = $request; + $this->requestStack = $requestStack; } /** - * @see Symfony\Component\Form\AbstractType::buildForm() + * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { @@ -50,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('_target_path', 'hidden') ; - $request = $this->request; + $request = $this->requestStack->getCurrentRequest(); /* Note: since the Security component's form login listener intercepts * the POST request, this form will never really be bound to the @@ -75,7 +72,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) } /** - * @see Symfony\Component\Form\AbstractType::setDefaultOptions() + * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { @@ -89,7 +86,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) } /** - * @see Symfony\Component\Form\FormTypeInterface::getName() + * {@inheritdoc} */ public function getName() { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml index e1e2b0e883933..8b0920df37202 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml @@ -4,9 +4,7 @@ imports: services: csrf_form_login.form.type: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType - scope: request - arguments: - - @request + arguments: [ @request_stack ] tags: - { name: form.type, alias: user_login } From 4391219d33f0aae8437d8fd58d39d903eb24181a Mon Sep 17 00:00:00 2001 From: Saro0h Date: Sat, 3 Jan 2015 14:15:49 +0100 Subject: [PATCH 021/133] Fixed tests --- .../Tests/Controller/ControllerTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index 6ff09c348ceb0..13751bc711684 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -37,10 +37,18 @@ public function testForward() $container->expects($this->at(0))->method('get')->will($this->returnValue($requestStack)); $container->expects($this->at(1))->method('get')->will($this->returnValue($kernel)); - $controller = new Controller(); + $controller = new TestController(); $controller->setContainer($container); $response = $controller->forward('a_controller'); $this->assertEquals('xml--fr', $response->getContent()); } } + +class TestController extends Controller +{ + public function forward($controller, array $path = array(), array $query = array()) + { + return parent::forward($controller, $path, $query); + } +} From a333811d041bacdf7b603f6f6a525c67c78157c7 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Sat, 3 Jan 2015 12:33:20 +0100 Subject: [PATCH 022/133] [Config] removed deprecated ReferenceDumper class. --- src/Symfony/Component/Config/CHANGELOG.md | 11 +++++++--- .../Config/Definition/ReferenceDumper.php | 21 ------------------- 2 files changed, 8 insertions(+), 24 deletions(-) delete mode 100644 src/Symfony/Component/Config/Definition/ReferenceDumper.php diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index 59b30a3a7a6d8..1ca1c492e2d50 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -1,15 +1,20 @@ CHANGELOG ========= +3.0.0 +----- + + * removed `ReferenceDumper` class + 2.2.0 ----- - * added ArrayNodeDefinition::canBeEnabled() and ArrayNodeDefinition::canBeDisabled() + * added `ArrayNodeDefinition::canBeEnabled()` and `ArrayNodeDefinition::canBeDisabled()` to ease configuration when some sections are respectively disabled / enabled by default. * added a `normalizeKeys()` method for array nodes (to avoid key normalization) * added numerical type handling for config definitions - * added convenience methods for optional configuration sections to ArrayNodeDefinition + * added convenience methods for optional configuration sections to `ArrayNodeDefinition` * added a utils class for XML manipulations 2.1.0 @@ -17,5 +22,5 @@ CHANGELOG * added a way to add documentation on configuration * implemented `Serializable` on resources - * LoaderResolverInterface is now used instead of LoaderResolver for type + * `LoaderResolverInterface` is now used instead of `LoaderResolver` for type hinting diff --git a/src/Symfony/Component/Config/Definition/ReferenceDumper.php b/src/Symfony/Component/Config/Definition/ReferenceDumper.php deleted file mode 100644 index 7fe336d8fbf11..0000000000000 --- a/src/Symfony/Component/Config/Definition/ReferenceDumper.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Config\Definition; - -use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; - -/** - * @deprecated Deprecated since version 2.4, to be removed in 3.0. Use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper instead. - */ -class ReferenceDumper extends YamlReferenceDumper -{ -} From 1cdb655b115748975b802bc57973d080a40a67b4 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Fri, 26 Dec 2014 01:42:48 +0100 Subject: [PATCH 023/133] [Form] Removed depracted events PRE_BIND, BIND and POST_BIND --- .../Component/Form/Deprecated/FormEvents.php | 28 -- .../EventListener/BindRequestListener.php | 84 ------ .../Type/FormTypeHttpFoundationExtension.php | 8 - src/Symfony/Component/Form/FormEvents.php | 26 -- .../LegacyBindRequestListenerTest.php | 255 ------------------ .../Component/Form/Tests/SimpleFormTest.php | 8 +- 6 files changed, 4 insertions(+), 405 deletions(-) delete mode 100644 src/Symfony/Component/Form/Deprecated/FormEvents.php delete mode 100644 src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php delete mode 100644 src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php diff --git a/src/Symfony/Component/Form/Deprecated/FormEvents.php b/src/Symfony/Component/Form/Deprecated/FormEvents.php deleted file mode 100644 index 862879e75a610..0000000000000 --- a/src/Symfony/Component/Form/Deprecated/FormEvents.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Deprecated; - -trigger_error('Constants PRE_BIND, BIND and POST_BIND on class Symfony\Component\Form\FormEvents were deprecated in Symfony 2.3 and will be removed in 3.0. Use PRE_SUBMIT, SUBMIT and POST_SUBMIT instead.', E_USER_DEPRECATED); - -/** - * @deprecated since 2.7, to be removed in 3.0. - * @internal - */ -final class FormEvents -{ - const PRE_BIND = 'form.pre_bind'; - const BIND = 'form.bind'; - const POST_BIND = 'form.post_bind'; - - private function __construct() - { - } -} diff --git a/src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php b/src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php deleted file mode 100644 index bb144ed65ad6e..0000000000000 --- a/src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\HttpFoundation\EventListener; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Pass the - * Request instance to {@link Form::handleRequest()} instead. - */ -class BindRequestListener implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - // High priority in order to supersede other listeners - return array(FormEvents::PRE_SUBMIT => array('preBind', 128)); - } - - public function preBind(FormEvent $event) - { - $form = $event->getForm(); - - /* @var Request $request */ - $request = $event->getData(); - - // Only proceed if we actually deal with a Request - if (!$request instanceof Request) { - return; - } - - // Uncomment this as soon as the deprecation note should be shown - // trigger_error('Passing a Request instance to Form::submit() is deprecated since version 2.3 and will be disabled in 3.0. Call Form::process($request) instead.', E_USER_DEPRECATED); - - $name = $form->getConfig()->getName(); - $default = $form->getConfig()->getCompound() ? array() : null; - - // For request methods that must not have a request body we fetch data - // from the query string. Otherwise we look for data in the request body. - switch ($request->getMethod()) { - case 'GET': - case 'HEAD': - case 'TRACE': - $data = '' === $name - ? $request->query->all() - : $request->query->get($name, $default); - - break; - - default: - if ('' === $name) { - // Form bound without name - $params = $request->request->all(); - $files = $request->files->all(); - } else { - $params = $request->request->get($name, $default); - $files = $request->files->get($name, $default); - } - - if (is_array($params) && is_array($files)) { - $data = array_replace_recursive($params, $files); - } else { - $data = $params ?: $files; - } - - break; - } - - $event->setData($data); - } -} diff --git a/src/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php b/src/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php index 9cb0dc4476c59..a3bd84372880b 100644 --- a/src/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php +++ b/src/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\HttpFoundation\Type; use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener; use Symfony\Component\Form\RequestHandlerInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; @@ -22,11 +21,6 @@ */ class FormTypeHttpFoundationExtension extends AbstractTypeExtension { - /** - * @var BindRequestListener - */ - private $listener; - /** * @var RequestHandlerInterface */ @@ -37,7 +31,6 @@ class FormTypeHttpFoundationExtension extends AbstractTypeExtension */ public function __construct(RequestHandlerInterface $requestHandler = null) { - $this->listener = new BindRequestListener(); $this->requestHandler = $requestHandler ?: new HttpFoundationRequestHandler(); } @@ -46,7 +39,6 @@ public function __construct(RequestHandlerInterface $requestHandler = null) */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->addEventSubscriber($this->listener); $builder->setRequestHandler($this->requestHandler); } diff --git a/src/Symfony/Component/Form/FormEvents.php b/src/Symfony/Component/Form/FormEvents.php index 317472c8a00a4..33597525f7b8a 100644 --- a/src/Symfony/Component/Form/FormEvents.php +++ b/src/Symfony/Component/Form/FormEvents.php @@ -10,8 +10,6 @@ namespace Symfony\Component\Form; -use Symfony\Component\Form\Deprecated\FormEvents as Deprecated; - /** * @author Bernhard Schussek */ @@ -73,30 +71,6 @@ final class FormEvents */ const POST_SET_DATA = 'form.post_set_data'; - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link PRE_SUBMIT} instead. - * - * @Event - */ - const PRE_BIND = Deprecated::PRE_BIND; - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link SUBMIT} instead. - * - * @Event - */ - const BIND = Deprecated::BIND; - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link POST_SUBMIT} instead. - * - * @Event - */ - const POST_BIND = Deprecated::POST_BIND; - private function __construct() { } diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php deleted file mode 100644 index 183d3a7a3a975..0000000000000 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php +++ /dev/null @@ -1,255 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\HttpFoundation\EventListener; - -use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * @author Bernhard Schussek - */ -class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase -{ - private $values; - - private $filesPlain; - - private $filesNested; - - /** - * @var UploadedFile - */ - private $uploadedFile; - - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $path = tempnam(sys_get_temp_dir(), 'sf2'); - touch($path); - - $this->values = array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ); - - $this->filesPlain = array( - 'image' => array( - 'error' => UPLOAD_ERR_OK, - 'name' => 'upload.png', - 'size' => 123, - 'tmp_name' => $path, - 'type' => 'image/png', - ), - ); - - $this->filesNested = array( - 'error' => array('image' => UPLOAD_ERR_OK), - 'name' => array('image' => 'upload.png'), - 'size' => array('image' => 123), - 'tmp_name' => array('image' => $path), - 'type' => array('image' => 'image/png'), - ); - - $this->uploadedFile = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); - } - - protected function tearDown() - { - unlink($this->uploadedFile->getRealPath()); - } - - public function requestMethodProvider() - { - return array( - array('POST'), - array('PUT'), - array('DELETE'), - array('PATCH'), - ); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitRequest($method) - { - $values = array('author' => $this->values); - $files = array('author' => $this->filesNested); - $request = new Request(array(), $values, array(), array(), $files, array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => $this->uploadedFile, - ), $event->getData()); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitRequestWithEmptyName($method) - { - $request = new Request(array(), $this->values, array(), array(), $this->filesPlain, array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => $this->uploadedFile, - ), $event->getData()); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitEmptyRequestToCompoundForm($method) - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(true); - $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - // Default to empty array - $this->assertEquals(array(), $event->getData()); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitEmptyRequestToSimpleForm($method) - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(false); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - // Default to null - $this->assertNull($event->getData()); - } - - public function testSubmitGetRequest() - { - $values = array('author' => $this->values); - $request = new Request($values, array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ), $event->getData()); - } - - public function testSubmitGetRequestWithEmptyName() - { - $request = new Request($this->values, array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ), $event->getData()); - } - - public function testSubmitEmptyGetRequestToCompoundForm() - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(true); - $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array(), $event->getData()); - } - - public function testSubmitEmptyGetRequestToSimpleForm() - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(false); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertNull($event->getData()); - } -} diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 69e75c94ca263..367f115304e62 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -122,19 +122,19 @@ public function testDataIsInitializedFromSubmit() public function testFalseIsConvertedToNull() { $mock = $this->getMockBuilder('\stdClass') - ->setMethods(array('preBind')) + ->setMethods(array('preSubmit')) ->getMock(); $mock->expects($this->once()) - ->method('preBind') + ->method('preSubmit') ->with($this->callback(function ($event) { return null === $event->getData(); })); $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preBind')); + $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit')); $form = new Form($config); - $form->submit(false); + $form->bind(false); $this->assertTrue($form->isValid()); $this->assertNull($form->getData()); From 1b2501820842c11416c672fc386a1fcff9ace808 Mon Sep 17 00:00:00 2001 From: Saro0h Date: Tue, 6 Jan 2015 09:39:50 +0100 Subject: [PATCH 024/133] [FrameworkBundle] Fixed TextDescriptor::describeEventDispatcherListeners() --- .../FrameworkBundle/Console/Descriptor/TextDescriptor.php | 5 +++-- .../Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 88ad0ea3bc96f..fea7962550684 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -310,6 +310,8 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev foreach ($registeredListeners as $order => $listener) { $table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($listener))); } + + $table->render(); } else { ksort($registeredListeners); foreach ($registeredListeners as $eventListened => $eventListeners) { @@ -320,10 +322,9 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev foreach ($eventListeners as $order => $eventListener) { $table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($eventListener))); } + $table->render(); } } - - $table->render(); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt index 4cd880b0ef9f4..a07176b593a43 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt @@ -1,6 +1,12 @@ [event_dispatcher] Registered listeners by event [Event] event1 ++-------+-------------------+ +| Order | Callable | ++-------+-------------------+ +| #1 | global_function() | +| #2 | \Closure() | ++-------+-------------------+ [Event] event2 +-------+-----------------------------------------------------------------------------------+ From 8691321e2671e464bfa7f223a658eb36502b17aa Mon Sep 17 00:00:00 2001 From: prepECN Date: Sun, 4 Jan 2015 19:47:55 +0100 Subject: [PATCH 025/133] [Console] - Remove deprecated methods from Command class --- .../Component/Console/Command/Command.php | 44 +------------------ .../Console/Tests/Command/CommandTest.php | 22 ---------- 2 files changed, 1 insertion(+), 65 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 0302cb1753b51..b834d984f83ba 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -11,13 +11,10 @@ namespace Symfony\Component\Console\Command; -use Symfony\Component\Console\Descriptor\TextDescriptor; -use Symfony\Component\Console\Descriptor\XmlDescriptor; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Helper\HelperSet; @@ -345,7 +342,7 @@ public function getDefinition() } /** - * Gets the InputDefinition to be used to create XML and Text representations of this Command. + * Gets the InputDefinition to be used to create representations of this Command. * * Can be overridden to provide the original command representation when it would otherwise * be changed by merging with the application InputDefinition. @@ -600,45 +597,6 @@ public function getHelper($name) return $this->helperSet->get($name); } - /** - * Returns a text representation of the command. - * - * @return string A string representing the command - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. - */ - public function asText() - { - $descriptor = new TextDescriptor(); - $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); - $descriptor->describe($output, $this, array('raw_output' => true)); - - return $output->fetch(); - } - - /** - * Returns an XML representation of the command. - * - * @param bool $asDom Whether to return a DOM or an XML string - * - * @return string|\DOMDocument An XML string representing the command - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. - */ - public function asXml($asDom = false) - { - $descriptor = new XmlDescriptor(); - - if ($asDom) { - return $descriptor->getCommandDocument($this); - } - - $output = new BufferedOutput(); - $descriptor->describe($output, $this); - - return $output->fetch(); - } - /** * Validates a command name. * diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 36c14ddec54fb..8eede0563b437 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -317,26 +317,4 @@ public function callableMethodCommand(InputInterface $input, OutputInterface $ou { $output->writeln('from the code...'); } - - public function testLegacyAsText() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $command = new \TestCommand(); - $command->setApplication(new Application()); - $tester = new CommandTester($command); - $tester->execute(array('command' => $command->getName())); - $this->assertStringEqualsFile(self::$fixturesPath.'/command_astext.txt', $command->asText(), '->asText() returns a text representation of the command'); - } - - public function testLegacyAsXml() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $command = new \TestCommand(); - $command->setApplication(new Application()); - $tester = new CommandTester($command); - $tester->execute(array('command' => $command->getName())); - $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command'); - } } From d0672a8f03a2f8948d8e5e8f4cb19da4d58bcd29 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 7 Jan 2015 08:38:21 +0100 Subject: [PATCH 026/133] removed CHANGELOGs and UPGRADEs for 2.x versions --- CHANGELOG-2.2.md | 352 ----------- CHANGELOG-2.3.md | 637 -------------------- CHANGELOG-2.4.md | 401 ------------- CHANGELOG-2.5.md | 301 ---------- CHANGELOG-2.6.md | 48 -- UPGRADE-2.1.md | 1478 ---------------------------------------------- UPGRADE-2.2.md | 668 --------------------- UPGRADE-2.3.md | 305 ---------- UPGRADE-2.4.md | 9 - UPGRADE-2.5.md | 263 --------- UPGRADE-2.6.md | 428 -------------- 11 files changed, 4890 deletions(-) delete mode 100644 CHANGELOG-2.2.md delete mode 100644 CHANGELOG-2.3.md delete mode 100644 CHANGELOG-2.4.md delete mode 100644 CHANGELOG-2.5.md delete mode 100644 CHANGELOG-2.6.md delete mode 100644 UPGRADE-2.1.md delete mode 100644 UPGRADE-2.2.md delete mode 100644 UPGRADE-2.3.md delete mode 100644 UPGRADE-2.4.md delete mode 100644 UPGRADE-2.5.md delete mode 100644 UPGRADE-2.6.md diff --git a/CHANGELOG-2.2.md b/CHANGELOG-2.2.md deleted file mode 100644 index 274ab05e9216e..0000000000000 --- a/CHANGELOG-2.2.md +++ /dev/null @@ -1,352 +0,0 @@ -CHANGELOG for 2.2.x -=================== - -This changelog references the relevant changes (bug and security fixes) done -in 2.2 minor versions. - -To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash -To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.2.0...v2.2.1 - -* 2.2.11 (2013-12-02) - - * bug #9656 [DoctrineBridge] normalized class names in the ORM type guesser (fabpot) - * bug #9647 use the correct class name to retrieve mapped class' metadata and reposi... (xabbuh) - * bug #9643 [WebProfilerBundle] Fixed js escaping in time.html.twig (hason) - * bug #9639 Modified guessDefaultEscapingStrategy to not escape txt templates (fabpot) - * bug #9314 [Form] Fix DateType for 32bits computers. (WedgeSama) - * bug #9443 [FrameworkBundle] Fixed the registration of validation.xml file when the form is disabled (hason) - * bug #9625 [HttpFoundation] Do not return an empty session id if the session was closed (Taluu) - * bug #9447 [BrowserKit] fixed protocol-relative url redirection (jong99) - * bug #9535 No Entity Manager defined exception (armetiz) - * bug #9485 [Acl] Fix for issue #9433 (guilro) - * bug #9516 [AclProvider] Fix incorrect behavior when partial results returned from cache (superdav42) - * bug #9537 [FrameworkBundle] Fix mistake in translation's service definition. (phpmike) - * bug #9367 [Process] Check if the pipe array is empty before calling stream_select() (jfposton) - * bug #9469 [Propel1] re-factor Propel1 ModelChoiceList (havvg) - -* 2.2.10 (2013-11-13) - - * bug #9499 Request::overrideGlobals() may call invalid ini value (denkiryokuhatsuden) - * bug #9212 [Validator] Force Luhn Validator to only work with strings (Richtermeister) - * bug #9431 [DependencyInjection] fixed YamlDumper did not make services private. (realityking) - * bug #9412 [HttpFoundation] added content length header to BinaryFileResponse (kbond) - * bug #9388 [Form] Fixed: The "data" option is taken into account even if it is NULL (bschussek) - * bug #9391 [Serializer] Fixed the error handling when decoding invalid XML to avoid a Warning (stof) - * bug #9378 [DomCrawler] [HttpFoundation] Make `Content-Type` attributes identification case-insensitive (matthieuprat) - * bug #9354 [Process] Fix #9343 : revert file handle usage on Windows platform (romainneutron) - * bug #9333 [Form] Improved FormTypeCsrfExtension to use the type class as default intention if the form name is empty (bschussek) - * bug #9338 [DoctrineBridge] Added type check to prevent calling clear() on arrays (bschussek) - * bug #9327 [Form] Changed FormTypeCsrfExtension to use the form's name as default intention (bschussek) - * bug #9308 [DoctrineBridge] Loosened CollectionToArrayTransformer::transform() to accept arrays (bschussek) - * bug #9274 [Yaml] Fixed the escaping of strings starting with a dash when dumping (stof) - * bug #9270 [Templating] Fix in ChainLoader.php (janschoenherr) - * bug #9246 [Session] fixed wrong started state (tecbot) - -* 2.2.9 (2013-10-10) - - * [Security] limited the password length passed to encoders - * bug #9237 [FrameworkBundle] assets:install command should mirror .dotfiles (.htaccess) (FineWolf) - * bug #9223 [Translator] PoFileDumper - PO headers (Padam87) - * bug #9257 [Process] Fix 9182 : random failure on pipes tests (romainneutron) - * bug #9222 [Bridge] [Propel1] Fixed guessed relations (ClementGautier) - * bug #9214 [FramworkBundle] Check event listener services are not abstract (lyrixx) - * bug #9207 [HttpKernel] Check for lock existence before unlinking (ollietb) - * bug #9184 Fixed cache warmup of paths which contain back-slashes (fabpot) - * bug #9192 [Form] remove MinCount and MaxCount constraints in ValidatorTypeGuesser (franek) - * bug #9190 Fix: duplicate usage of Symfony\Component\HttpFoundation\Response (realsim) - * bug #9188 [Form] add support for Length and Range constraint in ValidatorTypeGuesser (franek) - * bug #8809 [Form] enforce correct timezone (Burgov) - * bug #9169 Fixed client insulation when using the terminable event (fabpot) - * bug #9154 Fix problem with Windows file links (backslash in JavaScript string) (fabpot) - * bug #9103 [HttpFoundation] Header `HTTP_X_FORWARDED_PROTO` can contain various values (stloyd) - -* 2.2.8 (2013-09-25) - - * same as 2.2.7 - -* 2.2.7 (2013-09-25) - - * 8980954: bugix: CookieJar returns cookies with domain "domain.com" for domain "foodomain.com" - * 3108c71: [Locale] added support for the position argument to NumberFormatter::parse() - * 0774c79: [Locale] added some more stubs for the number formatter - * e5282e8: [DomCrawler]Crawler guess charset from html - * 0e80d88: fixes RequestDataCollector bug, visible when used on Drupal8 - * c8d0342: [Console] fixed exception rendering when nested styles - * a47d663: [Console] fixed the formatter for single-char tags - * c6c35b3: [Console] Escape exception message during the rendering of an exception - * 0e437c5: [BrowserKit] Fixed the handling of parameters when redirecting - * 958ec09: NativeSessionStorage regenerate - * 0d6af5c: Use setTimeZone if this method exists. - * 773e716: [HttpFoundation] Fixed the way path to directory is trimmed. - * 42019f6: [Console] Fixed argument parsing when a single dash is passed. - * b591419: [HttpFoundation] removed double-slashes (closes #8388) - * 4f5b8f0: [HttpFoundation] tried to keep the original Request URI as much as possible to avoid different behavior between ::createFromGlobals() and ::create() - * 4c1dbc7: [TwigBridge] fixed form rendering when used in a template with dynamic inheritance - * 8444339: [HttpKernel] added a check for private event listeners/subscribers - * ce7de37: [DependencyInjection] fixed a non-detected circular reference in PhpDumper (closes #8425) - * 37102dc: [Process] Close unix pipes before calling `proc_close` to avoid a deadlock - * 8c2a733: [HttpFoundation] fixed format duplication in Request - * 1e75cf9: [Process] Fix #8970 : read output once the process is finished, enable pipe tests on Windows - * ed83752: [Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted - * 30aa1de: [Form] Fixed ChoiceList::get*By*() methods to preserve order and array keys - * 49f5027: [HttpKernel] fixer HInclude src (closes #8951) - * c567262: Fixed escaping of service identifiers in configuration - * 4a76c76: [Process][2.2] Fix Process component on windows - * 65814ba: Request->getPort() should prefer HTTP_HOST over SERVER_PORT - * e75d284: Fixing broken http auth digest in some circumstances (php-fpm + apache). - * 899f176: [Security] fixed a leak in ExceptionListener - * 2fd8a7a: [Security] fixed a leak in the ContextListener - * 4e9d990: Ignore posix_istatty warnings - * 2d34e78: [BrowserKit] fixed method/files/content when redirecting a request - * 64e1655: [BrowserKit] removed some headers when redirecting a request - * 96a4b00: [BrowserKit] fixed headers when redirecting if history is set to false (refs #8697) - * c931eb7: [HttpKernel] fixed route parameters storage in the Request data collector (closes #8867) - * 96bb731: optimized circular reference checker - * 91234cd: [HttpKernel] changed fragment URLs to be relative by default (closes #8458) - * 4922a80: [FrameworkBundle] added support for double-quoted strings in the extractor (closes #8797) - * 0d07af8: [BrowserKit] Pass headers when `followRedirect()` is called - * d400b5a: Return BC compatibility for `@Route` parameters and default values - -* 2.2.6 (2013-08-26) - - * f936b41: clearToken exception is thrown at wrong place. - * d0faf55: [Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed - * 566d79c: [Yaml] fixed embedded folded string parsing - * 0951b8d: [Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used - * 4563f1b: [Yaml] Fix comment containing a colon on a scalar line being parsed as a hash. - * 7e87eb1: fixed request format when forwarding a request - * ccaaedf: [Form] PropertyPathMapper::mapDataToForms() *always* calls setData() on every child to ensure that all *_DATA events were fired when the initialization phase is over (except for virtual forms) - * 00bc270: [Form] Fixed: submit() reacts to dynamic modifications of the form children - * 05fdb12: Fixed issue #6932 - Inconsistent locale handling in subrequests - * b3c3159: fixed locale of sub-requests when explicitely set by the developer (refs #8821) - * b72bc0b: [Locale] fixed build-data exit code in case of an error - * 9bb7a3d: fixed request format of sub-requests when explicitely set by the developer (closes #8787) - * fa35597: Sets _format attribute only if it wasn't set previously by the user. - * f946108: fixed the format of the request used to render an exception - * 51022c3: Fix typo in the check_path validator - * 5f7219e: added a missing use statement (closes #8808) - * 262879d: fix for Process:isSuccessful() - * 0723c10: [Process] Use a consistent way to reset data of the process latest run - * 85a9c9d: [HttpFoundation] Fixed removing a nonexisting namespaced attribute. - * 191d320: [Validation] Fixed IdentityTranslator to pass correct Locale to MessageSelector - * c6ecd83: SwiftMailerHandler in Monolog bridge now able to react to kernel.terminate event - * 99adcf1: {HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage - * ab9a96b: Fixes for hasParameterOption and getParameterOption methods of ArgvInput - * dbd0855: Added sleep() workaround for windows php rename bug - * fa769a2: [Process] Add more precision to Process::stop timeout - * 3ef517b: [Process] Fix #8739 - * 18896d5a: [Validator] fixed the wrong isAbstract() check against the class (fixed #8589) - * e8e76ec: [TwigBridge] Prevent code extension to display warning - * 1a73b44: added missing support for the new output API in PHP 5.4+ - * e0c7d3d: Fixed bug introduced in #8675 - * 0b965fb: made the filesystem loader compatible with Twig 2.0 - * 322f880: replaced deprecated Twig features - -* 2.2.5 (2013-08-07) - - * c35cc5b: added trusted hosts check - * 6d555bc: Fixed metadata serialization - * cd51d82: [Form] fixed wrong call to setTimeZone() (closes #8644) - * 5c359a8: Fix issue with \DateTimeZone::UTC / 'UTC' for PHP 5.4 - * 97cbb19: [Form] Removed the "disabled" attribute from the placeholder option in select fields due to problems with the BlackBerry 10 browser - * c138304: [routing] added ability for apache matcher to handle array values - * b41cf82: [Validator] fixed StaticMethodLoader trying to invoke methods of abstract classes (closes #8589) - * 3553c71: return 0 if there is no valid data - * ae7fa11: [Twig] fixed TwigEngine::exists() method when a template contains a syntax error (closes #8546) - * 28e0709: [Validator] fixed ConstraintViolation:: incorrect when nested - * 890934d: handle Optional and Required constraints from XML or YAML sources correctly - * a2eca45: Fixed #8455: PhpExecutableFinder::find() does not always return the correct binary - * 485d53a: [DependencyInjection] Fix Container::camelize to convert beginning and ending chars - * 2317443: [Security] fixed issue where authentication listeners clear unrelated tokens - * 2ebb783: fix issue #8499 modelChoiceList call getPrimaryKey on a non object - * d3eb9b7: [Validator] Fixed groups argument misplace for validateValue method from validator class - -* 2.2.4 (2013-07-15) - - * 52e530d: Fixed NativeSessionStorage:regenerate when does not exists - * bb59f40: Reverts JSON_NUMERIC_CHECK - * 9c5f8c6: [Yaml] removed wrong comment removal inside a string block - * 2dc1ee0: [HtppKernel] fixed inline fragment renderer - * 06b69b8: fixed inline fragment renderer - * 91bb757: ProgressHelper shows percentage complete. - * 9d1004b: fix handling of a default 'template' as a string - * 82dbaee: [HttpKernel] fixed the inline renderer when passing objects as attributes (closes #7124) - * 6dbd1e1: [WebProfiler] fix content-type parameter - * a830001: Passed the config when building the Configuration in ConfigurableExtension - * c875d0a: [Form] fixed INF usage which does not work on Solaris (closes #8246) - -* 2.2.3 (2013-06-19) - - * c0da3ae: [Process] Disable exception on stream_select timeout - * 77f2aa8: [HttpFoundation] fixed issue with session_regenerate_id (closes #7380) - * bcbbb28: Throw exception if value is passed to VALUE_NONE input, long syntax - * 6b71513: fixed date type format pattern regex - * 842f3fa: do not re-register commands each time a Console\Application is run - * 0991cd0: [Process] moved env check to the Process class (refs #8227) - * 8764944: fix issue where $_ENV contains array vals - * 4139936: [DomCrawler] Fix handling file:// without a host - * de289d2: [Form] corrected interface bind() method defined against in deprecation notice - * 0c0a3e9: [Console] fixed regression when calling a command foo:bar if there is another one like foo:bar:baz (closes #8245) - * 849f3ed: [Finder] Fix SplFileInfo::getContents isn't working with ssh2 protocol - * 25e3abd: fix many-to-many Propel1 ModelChoiceList - * bce6bd2: [DomCrawler] Fixed a fatal error when setting a value in a malformed field name. - * 445b2e3: [Console] fix status code when Exception::getCode returns something like 0.1 - * bbfde62: Fixed exit code for exceptions with error code 0 - * afad9c7: instantiate valid commands only - * 6d2135b: force the Content-Type to html in the web profiler controllers - -* 2.2.2 (2013-06-02) - - * 2038329: [Form] [Validator] Fixed post_max_size = 0 bug (Issue #8065) - * 169c0b9: [Finder] Fix iteration fails with non-rewindable streams - * 45b68e0: [Finder] Fix unexpected duplicate sub path related AppendIterator issue - * 5321600: Fixed two bugs in HttpCache - * 5c317b7: [Console] fix and refactor exit code handling - * 1469953: [CssSelector] Fix :nth-last-child() translation - * 91b8490: Fix Crawler::children() to not trigger a notice for childless node - * 0a4837d: Fixed XML syntax. - * a5441b2: Fixed parsing of leading blank lines in folded scalars. Closes #7989. - * ef87ba7: [Form] Fixed a method name. - * e8d5d16: Fixed Loader import - * 60edc58: Fixed fatal error in normalize/denormalizeObject. - * 05b987f: [Process] Cleanup tests & prevent assertion that kills randomly Travis-CI - * e4913f8: [Filesystem] Fix regression introduced in 10dea948 - * 5b7e1e6: added a missing check for the provider key - * b0e3ea5: [Validator] fixed wrong URL for XSD - * 59b78c7: [Validator] Fixed: $traverse and $deep is passed to the visitor from Validator::validate() - * bcb5400: [Form] Fixed transform()/reverseTransform() to always throw TransformationFailedExceptions - * 7b2ebbf: [Form] Fixed: String validation groups are never interpreted as callbacks - * 0610750: if the repository method returns an array ensure that it's internal poin... - * dcced01: [Form] Improved multi-byte handling of NumberToLocalizedStringTransformer - * 2b554d7: remove validation related headers when needed - * 2a531d7: Fix getPort() returning 80 instead of 443 when X-FORWARDED-PROTO is set to https - * 10dea94: [Filesystem] copy() is not working when open_basedir is set - * 8757ad4: [Process] Fix #5594 : `termsig` must be used instead of `stopsig` in exceptions when a process is signaled - * be34917: [Console] find command even if its name is a namespace too (closes #7860) - * 3c97004: Reset all catalogues when adding resource to fallback locale (#7715, #7819) - * 0fb35a4: Added reloading of fallback catalogues when calling addResource() (#7715) - * 9e49bc8: Re-added context information to log list - * 06e21ff: Filesystem::touch() not working with different owners (utime/atime issue) - * d98118a: [Config] #7644 add tests for passing number looking attributes as strings - * 36d057b: [HttpFoundation][BrowserKit] fixed path when converting a cookie to a string - * 495d0e3: [HttpFoundation] fixed empty domain= in Cookie::__toString() - * c2bc707: fixed detection of secure cookies received over https - * af819a7: [2.2] Pass ESI header to subrequests - * 54bcf5c: [Translator] added additional conversion for encodings other than utf-8 - * 67b5797: fixed source messages to accept pluralized messages [Validator][translation][japanese] add messages for new validator - * 8a434ed: fix a DI circular reference recognition bug - * 22bf965: [DependencyInjection] fixed wrong exception class - * 5abf887: Fix default value handling for multi-value options - * da156d3: fix overwriting of request's locale if attribute _locale is missing - * 1adbe3c: [HttpKernel] truncate profiler token to 6 chars (see #7665) - * d552e4c: [HttpFoundation] do not use server variable PATH_INFO because it is already decoded and thus symfony is fragile to double encoding of the path - * 4c51ec7: Fix download over SSL using IE < 8 and binary file response - * 46909fa: [Console] Fix merging of application definition, fixes #7068, replaces #7158 - * 972bde7: [HttpKernel] fixed the Kernel when the ClassLoader component is not available (closes #7406) - * f163226: fixed output of bag values - * 047212a: [Yaml] fixed handling an empty value - * 94a9cdc: [Routing][XML Loader] Add a possibility to set a default value to null - * 302d44f: [Console] fixed handling of "0" input on ask - * 383a84b: fixed handling of "0" input on ask - * 0f0c29c: [HttpFoundation] Fixed bug in key searching for NamespacedAttributeBag - * 7fc429f: [Form] DateTimeToRfc3339Transformer use proper transformation exteption in reverse transformation - * 9fcd2f6: [HttpFoundation] fixed the creation of sub-requests under some circumstances for IIS - * 8a9e898: Fix finding ACLs from ObjectIdentity's with different types - * a3826ab: #7531: [HttpKernel][Config] FileLocator adds NULL as global resource path - * 9d71ebe: Fix autocompletion of command names when namespaces conflict - * bec8ff1: Fix timeout in Process::stop method - * 3780fdb: Fix Process timeout - * 99256e4: [HttpKernel] Remove args from 5.3 stack traces to avoid filling log files, fixes #7259 - * e8cae94: fix overwriting of request's locale if attribute _locale is missing - * c4da2d9: [HttpFoundation] getClientIp is fixed. - -* 2.2.1 (2013-04-06) - - * 751abe1: Doctrine cannot handle bare random non-utf8 strings - * 673fd9b: idAsIndex should be true with a smallint or bigint id field. - * 64a1d39: Fixed long multibyte parameter logging in DbalLogger:startQuery - * 4cf06c1: Keep the file extension in the temporary copy and test that it exists (closes #7482) - * 64ac34d: [Security] fixed wrong interface - * 9875c4b: Added '@@' escaping strategy for YamlFileLoader and YamlDumper - * bbcdfe2: [Yaml] fixed bugs with folded scalar parsing - * 5afea04: [Form] made DefaultCsrfProvider using session_status() when available - * c928ddc: [HttpFoudantion] fixed Request::getPreferredLanguage() - * e6b7515: [DomCrawler] added support for query string with slash - * 633c051: Fixed invalid file path for hiddeninput.exe on Windows. - * 7ef90d2: fix xsd definition for strict-requirements - * 39445c5: [WebProfilerBundle] Fixed the toolbar styles to apply them in IE8 - * 601da45: [ClassLoader] fixed heredocs handling - * 17dc2ff: [HttpRequest] fixes Request::getLanguages() bug - * 67fbbac: [DoctrineBridge] Fixed non-utf-8 recognition - * e51432a: sub-requests are now created with the same class as their parent - * cc3a40e: [FrameworkBundle] changed temp kernel name in cache:clear - * d7a7434: [Routing] fix url generation for optional parameter having a null value - * ef53456: [DoctrineBridge] Avoids blob values to be logged by doctrine - * 6575df6: [Security] use current request attributes to generate redirect url? - * 7216cb0: [Validator] fix showing wrong max file size for upload errors - * c423f16: [2.1][TwigBridge] Fixes Issue #7342 in TwigBridge - * 7d87ecd: [FrameworkBundle] fixed cache:clear command's warmup - * 5ad4bd1: [TwigBridge] now enter/leave scope on Twig_Node_Module - * fe4cc24: [TwigBridge] fixed fixed scope & trans_default_domain node visitor - * fc47589: [BrowserKit] added ability to ignored malformed set-cookie header - * 602cdee: replace INF to PHP_INT_MAX inside Finder component. - * 5bc30bb: [Translation] added xliff loader/dumper with resname support - * 663c796: Property accessor custom array object fix - * 4f3771d: [2.2][HttpKernel] fixed wrong option name in FragmentHandler::fixOptions - * a735cbd: fix xargs pipe to work with spaces in dir names - * 15bf033: [FrameworkBundle] fix router debug command - * d16d193: [FramworkBundle] removed unused property of trans update command - * 523ef29: Fix warning for buildXml method - * 7241be9: [Finder] fixed a potential issue on Solaris where INF value is wrong (refs #7269) - * 1d3da29: [FrameworkBundle] avoids cache:clear to break if new/old folders already exist - * b9cdb9a: [HttpKernel] Fixed possible profiler token collision (closes #7272, closes #7171) - * d1f5d25: [FrameworkBundle] Fixes invalid serialized objects in cache - * c82c754: RedisProfilerStorage wrong db-number/index-number selected - * e86fefa: Unset loading[$id] in ContainerBuilder on exception - * 709518b: Default validation message translation fix. - * c0687cd: remove() should not use deprecated getParent() so it does not trigger deprecation internally - * 708c0d3: adjust routing tests to not use prefix in addCollection - * acff735: [Routing] trigger deprecation warning for deprecated features that will be removed in 2.3 - * 41ad9d8: [Routing] make xml loader more tolerant - * 73bead7: [ClassLoader] made DebugClassLoader idempotent - * a4ec677: [DomCrawler] Fix relative path handling in links - * 6681df0: [Console] fixed StringInput binding - * 5bf2f71: [Console] added deprecation annotation - * 8d9cd42: Routing issue with installation in a sub-directory ref: https://github.com/symfony/symfony/issues/7129 - * c97ee8d: [Translator] mention that the message id may also be an object that can be cast to string in TranslatorInterface and fix the IdentityTranslator that did not respect this - * 5a36b2d: [Translator] fix MessageCatalogueInterface::getFallbackCatalogue that can return null - -* 2.2.0 (2013-03-01) - - * 5b19c89: [Console] fixed unparsed StringInput tokens - * e92b76c: Mask PHP_AUTH_PW header in profiler - * bae83c7: [TwigBridge] fixed trans twig extractor - * f40adbc: [Finder] adds adapter selection/unselection capabilities - * 8f8ba38: [DomCrawler] fix handling of schemes by Link::getUri() - * 83382bc: [TwigBridge] fixed the translator extractor that were not trimming the text in trans tags (closes #7056) - * b1ea8e5: Fixed handling absent href attribute in base tag - * 83a61cf: fixed paths/notPaths regex for shell adapters - * 32c5bf7: fix issue 4911 - * 13b8ce0: Adds expandable globs support to shell adapters - * 850bd5a: [HttpFoundation] Fixed messed up headers - * 4ecc246: Fixes AppCache + ESI + Stopwatch problem - * 0690709: added a DebuClassLoader::findFile() method to make the wrapping less invasive - * da22926: [Validator] gracefully handle transChoice errors - * 635b1fc: StringInput resets the given options - -* 2.2.0-RC3 (2013-02-24) - - * b2080c4: [HttpFoundation] Remove Cache-Control when using https download via IE<9 (fixes #6750) - * b7bd630: [Form] Fixed TimeType not to render a "size" attribute in select tags - * 368f62f: Expanded fault-tolerance for unusual cookie dates - * 171cff0: [FrameworkBundle] Fix a BC for Hinclude global template - * 3e40c17: [HttpKernel] fixed locale management when exiting sub-requests - * 3933912: fixed HInclude renderer (closes #7113) - * 189fba6: Removed some leaking deprecation warning in the Form component - * d0e4b76: [HttpFoundation] fixed, overwritten CONTENT_TYPE - * 609636e: [Config] tweaked dumper to indent multi-line info - * 0eff68f: Fix REMOTE_ADDR for cached subrequests - * 54d7d25: [HttpKernel] hinclude fragment renderer must escape URIs properly to return valid html - * f842ae6: [FrameworkBundle] CSRF should be on by default - * cb319ac: [HttpKernel] added error display suppression when using the ErrorHandler (if not, errors are displayed twice, refs #6254) - * de0f7b7: [HttpFoundation] Added getter for httpMethodParameterOverride state diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md deleted file mode 100644 index 1fa2df288dac1..0000000000000 --- a/CHANGELOG-2.3.md +++ /dev/null @@ -1,637 +0,0 @@ -CHANGELOG for 2.3.x -=================== - -This changelog references the relevant changes (bug and security fixes) done -in 2.3 minor versions. - -To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash -To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 - -* 2.3.23 (2014-12-03) - - * bug #12811 Configure firewall's kernel exception listener with configured entry point or a default entry point (rjkip) - * bug #12784 [DependencyInjection] make paths relative to __DIR__ in the generated container (nicolas-grekas) - * bug #12716 [ClassLoader] define constant only if it wasn't defined before (xabbuh) - * bug #12553 [Debug] fix error message on double exception (nicolas-grekas) - * bug #12550 [FrameworkBundle] backport #12489 (xabbuh) - * bug #12570 Fix initialized() with aliased services (Daniel Wehner) - * bug #12137 [FrameworkBundle] cache:clear command fills *.php.meta files with wrong data (Strate) - -* 2.3.22 (2014-11-20) - - * bug #12525 [Bundle][FrameworkBundle] be smarter when guessing the document root (xabbuh) - * bug #12296 [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners (rjkip) - * bug #12393 [DependencyInjection] inlined factory not referenced (boekkooi) - * bug #12436 [Filesystem] Fixed case for empty folder (yosmanyga) - * bug #12370 [Yaml] improve error message for multiple documents (xabbuh) - * bug #12170 [Form] fix form handling with OPTIONS request method (Tobion) - * bug #12235 [Validator] Fixed Regex::getHtmlPattern() to work with complex and negated patterns (webmozart) - * bug #12326 [Session] remove invalid hack in session regenerate (Tobion) - * bug #12341 [Kernel] ensure session is saved before sending response (Tobion) - * bug #12329 [Routing] serialize the compiled route to speed things up (Tobion) - * bug #12316 Break infinite loop while resolving aliases (chx) - * bug #12313 [Security][listener] change priority of switchuser (aitboudad) - -* 2.3.21 (2014-10-24) - - * bug #11696 [Form] Fix #11694 - Enforce options value type check in some form types (kix) - * bug #12209 [FrameworkBundle] Fixed ide links (hason) - * bug #12208 Add missing argument (WouterJ) - * bug #12197 [TwigBundle] do not pass a template reference to twig (Tobion) - * bug #12196 [TwigBundle] show correct fallback exception template in debug mode (Tobion) - * bug #12187 [CssSelector] don't raise warnings when exception is thrown (xabbuh) - * bug #11998 [Intl] Integrated ICU data into Intl component #2 (webmozart) - * bug #11920 [Intl] Integrated ICU data into Intl component #1 (webmozart) - -* 2.3.20 (2014-09-28) - - * bug #9453 [Form][DateTime] Propagate invalid_message & invalid_message_parameters to date & time (egeloen) - * bug #11058 [Security] bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider (glutamatt) - * bug #12004 [Form] Fixed ValidatorTypeGuesser to guess properties without constraints not to be required (webmozart) - * bug #11904 Make twig ExceptionController conformed with ExceptionListener (megazoll) - * bug #11924 [Form] Moved POST_MAX_SIZE validation from FormValidator to request handler (rpg600, webmozart) - * bug #11079 Response::isNotModified returns true when If-Modified-Since is later than Last-Modified (skolodyazhnyy) - * bug #11989 [Finder][Urgent] Remove asterisk and question mark from folder name in test to prevent windows file system issues. (Adam) - * bug #11908 [Translation] [Config] Clear libxml errors after parsing xliff file (pulzarraider) - * bug #11937 [HttpKernel] Make sure HttpCache is a trusted proxy (thewilkybarkid) - * bug #11970 [Finder] Escape location for regex searches (ymc-dabe) - * bug #11837 Use getPathname() instead of string casting to get BinaryFileReponse file path (nervo) - * bug #11513 [Translation] made XliffFileDumper support CDATA sections. (hhamon) - * bug #11907 [Intl] Improved bundle reader implementations (webmozart) - * bug #11874 [Console] guarded against non-traversable aliases (thierrymarianne) - * bug #11799 [YAML] fix handling of empty sequence items (xabbuh) - * bug #11906 [Intl] Fixed a few bugs in TextBundleWriter (webmozart) - * bug #11459 [Form][Validator] All index items after children are to be considered grand-children when resolving ViolationPath (Andrew Moore) - * bug #11715 [Form] FormBuilder::getIterator() now deals with resolved children (issei-m) - * bug #11892 [SwiftmailerBridge] Bump allowed versions of swiftmailer (ymc-dabe) - * bug #11918 [DependencyInjection] remove `service` parameter type from XSD (xabbuh) - * bug #11905 [Intl] Removed non-working $fallback argument from ArrayAccessibleResourceBundle (webmozart) - * bug #11497 Use separated function to resolve command and related arguments (JJK801) - * bug #11374 [DI] Added safeguards against invalid config in the YamlFileLoader (stof) - * bug #11897 [FrameworkBundle] Remove invalid markup (flack) - * bug #11860 [Security] Fix usage of unexistent method in DoctrineAclCache. (mauchede) - * bug #11850 [YAML] properly mask escape sequences in quoted strings (xabbuh) - * bug #11856 [FrameworkBundle] backport more error information from 2.6 to 2.3 (xabbuh) - * bug #11843 [Yaml] improve error message when detecting unquoted asterisks (xabbuh) - -* 2.3.19 (2014-09-03) - - * security #11832 CVE-2014-6072 (fabpot) - * security #11831 CVE-2014-5245 (stof) - * security #11830 CVE-2014-4931 (aitboudad, Jérémy Derussé) - * security #11829 CVE-2014-6061 (damz, fabpot) - * security #11828 CVE-2014-5244 (nicolas-grekas, larowlan) - * bug #10197 [FrameworkBundle] PhpExtractor bugfix and improvements (mtibben) - * bug #11772 [Filesystem] Add FTP stream wrapper context option to enable overwrite (Damian Sromek) - * bug #11788 [Yaml] fixed mapping keys containing a quoted # (hvt, fabpot) - * bug #11160 [DoctrineBridge] Abstract Doctrine Subscribers with tags (merk) - * bug #11768 [ClassLoader] Add a __call() method to XcacheClassLoader (tstoeckler) - * bug #11726 [Filesystem Component] mkdir race condition fix #11626 (kcassam) - * bug #11677 [YAML] resolve variables in inlined YAML (xabbuh) - * bug #11639 [DependencyInjection] Fixed factory service not within the ServiceReferenceGraph. (boekkooi) - * bug #11778 [Validator] Fixed wrong translations for Collection constraints (samicemalone) - * bug #11756 [DependencyInjection] fix @return anno created by PhpDumper (jakubkulhan) - * bug #11711 [DoctrineBridge] Fix empty parameter logging in the dbal logger (jakzal) - * bug #11692 [DomCrawler] check for the correct field type (xabbuh) - * bug #11672 [Routing] fix handling of nullable XML attributes (xabbuh) - * bug #11624 [DomCrawler] fix the axes handling in a bc way (xabbuh) - * bug #11676 [Form] Fixed #11675 ValueToDuplicatesTransformer accept "0" value (Nek-) - * bug #11695 [Validators] Fixed failing tests requiring ICU 52.1 which are skipped otherwise (webmozart) - * bug #11529 [WebProfilerBundle] Fixed double height of canvas (hason) - * bug #11641 [WebProfilerBundle ] Fix toolbar vertical alignment (blaugueux) - * bug #11559 [Validator] Convert objects to string in comparison validators (webmozart) - * feature #11510 [HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field (catchamonkey) - * bug #11408 [HttpFoundation] Update QUERY_STRING when overrideGlobals (yguedidi) - * bug #11633 [FrameworkBundle] add missing attribute to XSD (xabbuh) - * bug #11601 [Validator] Allow basic auth in url when using UrlValidator. (blaugueux) - * bug #11609 [Console] fixed style creation when providing an unknown tag option (fabpot) - * bug #10914 [HttpKernel] added an analyze of environment parameters for built-in server (mauchede) - * bug #11598 [Finder] Shell escape and windows support (Gordon Franke, gimler) - * bug #11499 [BrowserKit] Fixed relative redirects for ambiguous paths (pkruithof) - * bug #11516 [BrowserKit] Fix browser kit redirect with ports (dakota) - * bug #11545 [Bundle][FrameworkBundle] built-in server: exit when docroot does not exist (xabbuh) - * bug #11560 Plural fix (1emming) - * bug #11558 [DependencyInjection] Fixed missing 'factory-class' attribute in XmlDumper output (kerdany) - * bug #11548 [Component][DomCrawler] fix axes handling in Crawler::filterXPath() (xabbuh) - * bug #11422 [DependencyInjection] Self-referenced 'service_container' service breaks garbage collection (sun) - * bug #11428 [Serializer] properly handle null data when denormalizing (xabbuh) - * bug #10687 [Validator] Fixed string conversion in constraint violations (eagleoneraptor, webmozart) - * bug #11475 [EventDispatcher] don't count empty listeners (xabbuh) - * bug #11436 fix signal handling in wait() on calls to stop() (xabbuh, romainneutron) - * bug #11469 [BrowserKit] Fixed server HTTP_HOST port uri conversion (bcremer, fabpot) - * bug #11425 Fix issue described in #11421 (Ben, ben-rosio) - * bug #11423 Pass a Scope instance instead of a scope name when cloning a container in the GrahpvizDumper (jakzal) - * bug #11120 [Process] Reduce I/O load on Windows platform (romainneutron) - * bug #11342 [Form] Check if IntlDateFormatter constructor returned a valid object before using it (romainneutron) - * bug #11411 [Validator] Backported #11410 to 2.3: Object initializers are called only once per object (webmozart) - * bug #11403 [Translator][FrameworkBundle] Added @ to the list of allowed chars in Translator (takeit) - * bug #11381 [Process] Use correct test for empty string in UnixPipes (whs, romainneutron) - -* 2.3.18 (2014-07-15) - - * [Security] Forced validate of locales passed to the translator - * feature #11367 [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses... (CVE-2014-4671) (Andrew Moore) - * bug #11386 Remove Spaceless Blocks from Twig Form Templates (chrisguitarguy) - * bug #9719 [TwigBundle] fix configuration tree for paths (mdavis1982, cordoval) - * bug #11244 [HttpFoundation] Remove body-related headers when sending the response, if body is empty (SimonSimCity) - -* 2.3.17 (2014-07-07) - - * bug #11238 [Translation] Added unescaping of ids in PoFileLoader (JustBlackBird) - * bug #11194 [DomCrawler] Remove the query string and the anchor of the uri of a link (benja-M-1) - * bug #11272 [Console] Make sure formatter is the same. (akimsko) - * bug #11259 [Config] Fixed failed config schema loads due to libxml_disable_entity_loader usage (ccorliss) - * bug #11234 [ClassLoader] fixed PHP warning on PHP 5.3 (fabpot) - * bug #11179 [Process] Fix ExecutableFinder with open basedir (cs278) - * bug #11242 [CssSelector] Refactored the CssSelector to remove the circular object graph (stof) - * bug #11219 [DomCrawler] properly handle buttons with single and double quotes insid... (xabbuh) - * bug #11220 [Components][Serializer] optional constructor arguments can be omitted during the denormalization process (xabbuh) - * bug #11186 Added missing `break` statement (apfelbox) - * bug #11169 [Console] Fixed notice in DialogHelper (florianv) - * bug #11144 [HttpFoundation] Fixed Request::getPort returns incorrect value under IPv6 (kicken) - * bug #10966 PHP Fatal error when getContainer method of ContainerAwareCommand has be... (kevinvergauwen) - * bug #10981 [HttpFoundation] Fixed isSecure() check to be compliant with the docs (Jannik Zschiesche) - * bug #11092 [HttpFoundation] Fix basic authentication in url with PHP-FPM (Kdecherf) - * bug #10808 [DomCrawler] Empty select with attribute name="foo[]" bug fix (darles) - * bug #11063 [HttpFoundation] fix switch statement (Tobion) - * bug #11009 [HttpFoundation] smaller fixes for PdoSessionHandler (Tobion) - * bug #11041 Remove undefined variable $e (skydiablo) - -* 2.3.16 (2014-05-31) - - * bug #11014 [Validator] Remove property and method targets from the optional and required constraints (jakzal) - * bug #10983 [DomCrawler] Fixed charset detection in html5 meta charset tag (77web) - * bug #10979 Make rootPath part of regex greedy (artursvonda) - * bug #10995 [TwigBridge][Trans]set %count% only on transChoice from the current context. (aitboudad) - * bug #10987 [DomCrawler] Fixed a forgotten case of complex XPath queries (stof) - -* 2.3.15 (2014-05-22) - - * reverted #10908 - -* 2.3.14 (2014-05-22) - - * bug #10849 [WIP][Finder] Fix wrong implementation on sortable callback comparator (ProPheT777) - * bug #10929 [Process] Add validation on Process input (romainneutron) - * bug #10958 [DomCrawler] Fixed filterXPath() chaining loosing the parent DOM nodes (stof, robbertkl) - * bug #10953 [HttpKernel] fixed file uploads in functional tests without file selected (realmfoo) - * bug #10937 [HttpKernel] Fix "absolute path" when we look to the cache directory (BenoitLeveque) - * bug #10908 [HttpFoundation] implement session locking for PDO (Tobion) - * bug #10894 [HttpKernel] removed absolute paths from the generated container (fabpot) - * bug #10926 [DomCrawler] Fixed the initial state for options without value attribute (stof) - * bug #10925 [DomCrawler] Fixed the handling of boolean attributes in ChoiceFormField (stof) - * bug #10777 [Form] Automatically add step attribute to HTML5 time widgets to display seconds if needed (tucksaun) - * bug #10909 [PropertyAccess] Fixed plurals for -ves words (csarrazi) - * bug #10899 Explicitly define the encoding. (jakzal) - * bug #10897 [Console] Fix a console test (jakzal) - * bug #10896 [HttpKernel] Fixed cache behavior when TTL has expired and a default "global" TTL is defined (alquerci, fabpot) - * bug #10841 [DomCrawler] Fixed image input case sensitive (geoffrey-brier) - * bug #10714 [Console]Improve formatter for double-width character (denkiryokuhatsuden) - * bug #10872 [Form] Fixed TrimListenerTest as of PHP 5.5 (webmozart) - * bug #10762 [BrowserKit] Allow URLs that don't contain a path when creating a cookie from a string (thewilkybarkid) - * bug #10863 [Security] Add check for supported attributes in AclVoter (artursvonda) - * bug #10833 [TwigBridge][Transchoice] set %count% from the current context. (aitboudad) - * bug #10820 [WebProfilerBundle] Fixed profiler seach/homepage with empty token (tucksaun) - * bug #10815 Fixed issue #5427 (umpirsky) - * bug #10817 [Debug] fix #10313: FlattenException not found (nicolas-grekas) - * bug #10803 [Debug] fix ErrorHandlerTest when context is not an array (nicolas-grekas) - * bug #10801 [Debug] ErrorHandler: remove $GLOBALS from context in PHP5.3 fix #10292 (nicolas-grekas) - * bug #10797 [HttpFoundation] Allow File instance to be passed to BinaryFileResponse (anlutro) - * bug #10643 [TwigBridge] Removed strict check when found variables inside a translation (goetas) - -* 2.3.13 (2014-04-27) - - * bug #10789 [Console] Fixed the rendering of exceptions on HHVM with a terminal width (stof) - * bug #10773 [WebProfilerBundle ] Fixed an edge case on WDT loading (tucksaun) - * bug #10763 [Process] Disable TTY mode on Windows platform (romainneutron) - * bug #10772 [Finder] Fix ignoring of unreadable dirs in the RecursiveDirectoryIterator (jakzal) - * bug #10757 [Process] Setting STDIN while running should not be possible (romainneutron) - * bug #10749 Fixed incompatibility of x509 auth with nginx (alcaeus) - * bug #10735 [Translation] [PluralizationRules] Little correction for case 'ar' (klyk50) - * bug #10720 [HttpFoundation] Fix DbalSessionHandler (Tobion) - * bug #10721 [HttpFoundation] status 201 is allowed to have a body (Tobion) - * bug #10728 [Process] Fix #10681, process are failing on Windows Server 2003 (romainneutron) - * bug #10733 [DomCrawler] Textarea value should default to empty string instead of null. (Berdir) - * bug #10723 [Security] fix DBAL connection typehint (Tobion) - * bug #10700 Fixes various inconsistencies in the code (fabpot) - * bug #10697 [Translation] Make IcuDatFileLoader/IcuResFileLoader::load invalid resource compatible with HHVM. (idn2104) - * bug #10652 [HttpFoundation] fix PDO session handler under high concurrency (Tobion) - * bug #10669 [Profiler] Prevent throwing fatal errors when searching timestamps or invalid dates (stloyd) - * bug #10670 [Templating] PhpEngine should propagate charset to its helpers (stloyd) - * bug #10665 [DependencyInjection] Fix ticket #10663 - Added setCharset method call to PHP templating engine (koku) - * bug #10654 Changed the typehint of the EsiFragmentRenderer to the interface (stof) - * bug #10649 [BrowserKit] Fix #10641 : BrowserKit is broken when using ip as host (romainneutron) - -* 2.3.12 (2014-04-03) - - * bug #10586 Fixes URL validator to accept single part urls (merk) - * bug #10591 [Form] Buttons are now disabled if their containing form is disabled (webmozart) - * bug #10579 HHVM fixes (fabpot) - * bug #10564 fixed the profiler when an uncalled listener throws an exception when instantiated (fabpot) - * bug #10568 [Form] Fixed hashing of choice lists containing non-UTF-8 characters (webmozart) - * bug #10536 Avoid levenshtein comparison when using ContainerBuilder. (catch56) - * bug #10549 Fixed server values in BrowserKit (fabpot) - * bug #10540 [HttpKernel] made parsing controllers more robust (fabpot) - * bug #10545 [DependencyInjection] Fixed YamlFileLoader imports path (jrnickell) - * bug #10523 [Debug] Check headers sent before sending PHP response (GromNaN) - * bug #10275 [Validator] Fixed ACE domain checks on UrlValidator (#10031) (aeoris) - * bug #10123 handle array root element (greg0ire) - * bug #10532 Fixed regression when using Symfony on filesystems without chmod support (fabpot) - * bug #10502 [HttpKernel] Fix #10437: Catch exceptions when reloading a no-cache request (romainneutron) - * bug #10493 Fix libxml_use_internal_errors and libxml_disable_entity_loader usage (romainneutron) - * bug #9784 [HttpFoundation] Removed ini check to make Uploadedfile work on Google App Engine (micheleorselli) - * bug #10416 [Form] Allow options to be grouped by objects (felds) - * bug #10410 [Form] Fix "Array was modified outside object" in ResizeFormListener. (Chekote) - * bug #10494 [Validator] Minor fix in IBAN validator (sprain) - * bug #10491 Fixed bug that incorrectly causes the "required" attribute to be omitted from select even though it contains the "multiple" attribute (fabpot) - * bug #10479 [Process] Fix escaping on Windows (romainneutron) - * bug #10480 [Process] Fixed fatal errors in getOutput and getErrorOutput when process was not started (romainneutron) - * bug #10420 [Process] Make Process::start non-blocking on Windows platform (romainneutron) - * bug #10455 [Process] Fix random failures in test suite on TravisCI (romainneutron) - * bug #10448 [Process] Fix quoted arguments escaping (romainneutron) - * bug #10444 [DomCrawler] Fixed incorrect value name conversion in getPhpValues() and getPhpFiles() (romainneutron) - * bug #10423 [Config] XmlUtils::convertDomElementToArray does not handle '0' (bendavies) - * bug #10153 [Process] Fixed data in pipe being truncated if not read before process termination (astephens25) - * bug #10429 [Process] Fix #9160 : escaping an argument with a trailing backslash on windows fails (romainneutron) - * bug #10412 [Process] Fix process status in TTY mode (romainneutron) - * bug #10382 10158 get vary multiple (bbinkovitz) - * bug #10251 [Form] Fixes empty file-inputs getting treated as extra field. (jenkoian) - * bug #10351 [HttpKernel] fix stripComments() normalizing new-lines (sstok) - * bug #10348 Update FileLoader to fix issue #10339 (msumme) - -* 2.3.11 (2014-02-27) - - * bug #10146 [WebProfilerBundle] fixed parsing Mongo DSN and added Test for it (malarzm) - * bug #10299 [Finder] () is also a valid delimiter (WouterJ) - * bug #10255 [FrameworkBundle] Fixed wrong redirect url if path contains some query parameters (pulzarraider) - * bug #10285 Bypass sigchild detection if phpinfo is not available (Seldaek) - * bug #10269 [Form] Revert "Fix "Array was modified outside object" in ResizeFormListener." (norzechowicz) - -* 2.3.10 (2014-02-12) - - * bug #10231 [Console] removed problematic regex (fabpot) - * bug #10245 [DomCrawler] Added support for tags to be treated as links (shamess) - * bug #10232 [Form] Fix "Array was modified outside object" in ResizeFormListener. (Chekote) - * bug #10215 [Routing] reduced recursion in dumper (arnaud-lb) - * bug #10207 [DomCrawler] Fixed filterXPath() chaining (robbertkl) - * bug #10205 [DomCrawler] Fixed incorrect handling of image inputs (robbertkl) - * bug #10191 [HttpKernel] fixed wrong reference in TraceableEventDispatcher (fabpot) - * bug #10195 [Debug] Fixed recursion level incrementing in FlattenException::flattenArgs(). (sun) - * bug #10151 [Form] Update DateTime objects only if the actual value has changed (peterrehm) - * bug #10140 allow the TextAreaFormField to be used with valid/invalid HTML (dawehner) - * bug #10131 added lines to exceptions for the trans and transchoice tags (fabpot) - * bug #10119 [Validator] Minor fix in XmlFileLoader (florianv) - * bug #10078 [BrowserKit] add non-standard port to HTTP_HOST server param (kbond) - * bug #10091 [Translation] Update PluralizationRules.php (guilhermeblanco) - * bug #10053 [Form] fixed allow render 0 numeric input value (dczech) - * bug #10033 [HttpKernel] Bugfix - Logger Deprecation Notice (Rican7) - * bug #10023 [FrameworkBundle] Thrown an HttpException instead returning a Response in RedirectController::redirectAction() (jakzal) - * bug #9985 Prevent WDT from creating a session (mvrhov) - * bug #10000 [Console] Fixed the compatibility with HHVM (stof) - * bug #9979 [Doctrine Bridge][Validator] Fix for null values in assosiated properties when using UniqueEntityValidator (vpetrovych) - * bug #9983 [TwigBridge] Update min. version of Twig (stloyd) - * bug #9970 [CssSelector] fixed numeric attribute issue (jfsimon) - * bug #9747 [DoctrineBridge] Fix: Add type detection. Needed by pdo_dblib (iamluc) - * bug #9962 [Process] Fix #9861 : Revert TTY mode (romainneutron) - * bug #9960 [Form] Update minimal requirement in composer.json (stloyd) - * bug #9952 [Translator] Fix Empty translations with Qt files (vlefort) - * bug #9948 [WebProfilerBundle] Fixed profiler toolbar icons for XHTML. (rafalwrzeszcz) - * bug #9933 Propel1 exception message (jaugustin) - * bug #9949 [BrowserKit] Throw exception on invalid cookie expiration timestamp (anlutro) - -* 2.3.9 (2014-01-05) - - * bug #9938 [Process] Add support SAPI cli-server (peter-gribanov) - * bug #9940 [EventDispatcher] Fix hardcoded listenerTag name in error message (lemoinem) - * bug #9908 [HttpFoundation] Throw proper exception when invalid data is passed to JsonResponse class (stloyd) - * bug #9902 [Security] fixed pre/post authentication checks (fabpot) - * bug #9899 [Filesystem | WCM] 9339 fix stat on url for filesystem copy (cordoval) - * bug #9589 [DependencyInjection] Fixed #9020 - Added support for collections in service#parameters (lavoiesl) - * bug #9889 [Console] fixed column width when using the Table helper with some decoration in cells (fabpot) - * bug #9323 [DomCrawler]fix #9321 Crawler::addHtmlContent add gbk encoding support (bronze1man) - * bug #8997 [Security] Fixed problem with losing ROLE_PREVIOUS_ADMIN role. (pawaclawczyk) - * bug #9557 [DoctrineBridge] Fix for cache-key conflict when having a \Traversable as choices (DRvanR) - * bug #9879 [Security] Fix ExceptionListener to catch correctly AccessDeniedException if is not first exception (fabpot) - * bug #9885 [Dependencyinjection] Fixed handling of inlined references in the AnalyzeServiceReferencesPass (fabpot) - * bug #9884 [DomCrawler] Fixed creating form objects from named form nodes (jakzal) - * bug #9882 Add support for HHVM in the getting of the PHP executable (fabpot) - * bug #9850 [Validator] Fixed IBAN validator with 0750447346 value (stewe) - * bug #9865 [Validator] Fixes message value for objects (jongotlin) - * bug #9441 [Form][DateTimeToArrayTransformer] Check for hour, minute & second validity (egeloen) - * bug #9867 #9866 [Filesystem] Fixed mirror for symlinks (COil) - * bug #9806 [Security] Fix parent serialization of user object (ddeboer) - * bug #9834 [DependencyInjection] Fixed support for backslashes in service ids. (jakzal) - * bug #9826 fix #9356 [Security] Logger should manipulate the user reloaded from provider (matthieuauger) - * bug #9769 [BrowserKit] fixes #8311 CookieJar is totally ignorant of RFC 6265 edge cases (jzawadzki) - * bug #9697 [Config] fix 5528 let ArrayNode::normalizeValue respect order of value array provided (cordoval) - * bug #9701 [Config] fix #7243 allow 0 as arraynode name (cordoval) - * bug #9795 [Form] Fixed issue in BaseDateTimeTransformer when invalid timezone cause Trans... (tyomo4ka) - * bug #9714 [HttpFoundation] BinaryFileResponse should also return 416 or 200 on some range-requets (SimonSimCity) - * bug #9601 [Routing] Remove usage of deprecated _scheme requirement (Danez) - * bug #9489 [DependencyInjection] Add normalization to tag options (WouterJ) - * bug #9135 [Form] [Validator] fix maxLength guesser (franek) - * bug #9790 [Filesystem] Changed the mode for a target file in copy() to be write only (jakzal) - -* 2.3.8 (2013-12-16) - - * bug #9758 [Console] fixed TableHelper when cell value has new line (k-przybyszewski) - * bug #9760 [Routing] Fix router matching pattern against multiple hosts (karolsojko) - * bug #9674 [Form] rename validators.ua.xlf to validators.uk.xlf (craue) - * bug #9722 [Validator]Fixed getting wrong msg when value is an object in Exception (aitboudad) - * bug #9750 allow TraceableEventDispatcher to reuse event instance in nested events (evillemez) - * bug #9718 [validator] throw an exception if isn't an instance of ConstraintValidatorInterface. (aitboudad) - * bug #9716 Reset the box model to content-box in the web debug toolbar (stof) - * bug #9711 [FrameworkBundle] Allowed "0" as a checkbox value in php templates (jakzal) - * bug #9665 [Bridge/Doctrine] ORMQueryBuilderLoader - handled the scenario when no entity manager is passed with closure query builder (jakzal) - * bug #9656 [DoctrineBridge] normalized class names in the ORM type guesser (fabpot) - * bug #9647 use the correct class name to retrieve mapped class' metadata and reposi... (xabbuh) - * bug #9648 [Debug] ensured that a fatal PHP error is actually fatal after being handled by our error handler (fabpot) - * bug #9643 [WebProfilerBundle] Fixed js escaping in time.html.twig (hason) - * bug #9641 [Debug] Avoid notice from being "eaten" by fatal error. (fabpot) - * bug #9639 Modified guessDefaultEscapingStrategy to not escape txt templates (fabpot) - * bug #9314 [Form] Fix DateType for 32bits computers. (WedgeSama) - * bug #9443 [FrameworkBundle] Fixed the registration of validation.xml file when the form is disabled (hason) - * bug #9625 [HttpFoundation] Do not return an empty session id if the session was closed (Taluu) - * bug #9637 [Validator] Replaced inexistent interface (jakzal) - * bug #9605 Adjusting CacheClear Warmup method to namespaced kernels (rdohms) - * bug #9610 Container::camelize also takes backslashes into consideration (ondrejmirtes) - * bug #9447 [BrowserKit] fixed protocol-relative url redirection (jong99) - * bug #9535 No Entity Manager defined exception (armetiz) - * bug #9485 [Acl] Fix for issue #9433 (guilro) - * bug #9516 [AclProvider] Fix incorrect behavior when partial results returned from cache (superdav42) - * bug #9352 [Intl] make currency bundle merge fallback locales when accessing data, ... (shieldo) - * bug #9537 [FrameworkBundle] Fix mistake in translation's service definition. (phpmike) - * bug #9367 [Process] Check if the pipe array is empty before calling stream_select() (jfposton) - * bug #9211 [Form] Fixed memory leak in FormValidator (bschussek) - * bug #9469 [Propel1] re-factor Propel1 ModelChoiceList (havvg) - -* 2.3.7 (2013-11-14) - - * bug #9499 Request::overrideGlobals() may call invalid ini value (denkiryokuhatsuden) - * bug #9420 [Console][ProgressHelper] Fix ProgressHelper redraw when redrawFreq is greater than 1 (giosh94mhz) - * bug #9212 [Validator] Force Luhn Validator to only work with strings (Richtermeister) - * bug #9476 Fixed bug with lazy services (peterrehm) - * bug #9431 [DependencyInjection] fixed YamlDumper did not make services private. (realityking) - * bug #9416 fixed issue with clone now the children of the original form are preserved and the clone form is given new children (yjv) - * bug #9412 [HttpFoundation] added content length header to BinaryFileResponse (kbond) - * bug #9395 [HttpKernel] fixed memory limit display in MemoryDataCollector (hhamon) - * bug #9388 [Form] Fixed: The "data" option is taken into account even if it is NULL (bschussek) - * bug #9391 [Serializer] Fixed the error handling when decoding invalid XML to avoid a Warning (stof) - * bug #9378 [DomCrawler] [HttpFoundation] Make `Content-Type` attributes identification case-insensitive (matthieuprat) - * bug #9354 [Process] Fix #9343 : revert file handle usage on Windows platform (romainneutron) - * bug #9334 [Form] Improved FormTypeCsrfExtension to use the type class as default intention if the form name is empty (bschussek) - * bug #9333 [Form] Improved FormTypeCsrfExtension to use the type class as default intention if the form name is empty (bschussek) - * bug #9338 [DoctrineBridge] Added type check to prevent calling clear() on arrays (bschussek) - * bug #9328 [Form] Changed FormTypeCsrfExtension to use the form's name as default intention (bschussek) - * bug #9327 [Form] Changed FormTypeCsrfExtension to use the form's name as default intention (bschussek) - * bug #9308 [DoctrineBridge] Loosened CollectionToArrayTransformer::transform() to accept arrays (bschussek) - * bug #9274 [Yaml] Fixed the escaping of strings starting with a dash when dumping (stof) - * bug #9270 [Templating] Fix in ChainLoader.php (janschoenherr) - * bug #9246 [Session] fixed wrong started state (tecbot) - -* 2.3.6 (2013-10-10) - - * [Security] limited the password length passed to encoders - * bug #9259 [Process] Fix latest merge from 2.2 in 2.3 (romainneutron) - * bug #9237 [FrameworkBundle] assets:install command should mirror .dotfiles (.htaccess) (FineWolf) - * bug #9223 [Translator] PoFileDumper - PO headers (Padam87) - * bug #9257 [Process] Fix 9182 : random failure on pipes tests (romainneutron) - * bug #9222 [Bridge] [Propel1] Fixed guessed relations (ClementGautier) - * bug #9214 [FramworkBundle] Check event listener services are not abstract (lyrixx) - * bug #9207 [HttpKernel] Check for lock existence before unlinking (ollietb) - * bug #9184 Fixed cache warmup of paths which contain back-slashes (fabpot) - * bug #9192 [Form] remove MinCount and MaxCount constraints in ValidatorTypeGuesser (franek) - * bug #9190 Fix: duplicate usage of Symfony\Component\HttpFoundation\Response (realsim) - * bug #9188 [Form] add support for Length and Range constraint in ValidatorTypeGuesser (franek) - * bug #8809 [Form] enforce correct timezone (Burgov) - * bug #9169 Fixed client insulation when using the terminable event (fabpot) - * bug #9154 Fix problem with Windows file links (backslash in JavaScript string) (fabpot) - * bug #9153 [DependencyInjection] Prevented inlining of lazy loaded private service definitions (jakzal) - * bug #9103 [HttpFoundation] Header `HTTP_X_FORWARDED_PROTO` can contain various values (stloyd) - -* 2.3.5 (2013-09-27) - - * 8980954: bugix: CookieJar returns cookies with domain "domain.com" for domain "foodomain.com" - * bb59ac2: fixed HTML5 form attribute handling XPath query - * 3108c71: [Locale] added support for the position argument to NumberFormatter::parse() - * 0774c79: [Locale] added some more stubs for the number formatter - * e5282e8: [DomCrawler]Crawler guess charset from html - * 0e80d88: fixes RequestDataCollector bug, visible when used on Drupal8 - * c8d0342: [Console] fixed exception rendering when nested styles - * a47d663: [Console] fixed the formatter for single-char tags - * c6c35b3: [Console] Escape exception message during the rendering of an exception - * 04e730e: [DomCrawler] fixed HTML5 form attribute handling - * 0e437c5: [BrowserKit] Fixed the handling of parameters when redirecting - * d84df4c: [Process] Properly close pipes after a Process::stop call - * b3ae29d: fixed bytes conversion when used on 32-bits systems - * a273e79: [Form] Fixed: "required" attribute is not added to
@@ -26,5 +24,6 @@
{% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': false } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }} {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 485cb57c9bff6..7379beaae8621 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -1,115 +1,106 @@ {% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} - {# Symfony Logo #} + {% if 'unknown' == collector.symfonyState %} + {% set block_status = '' %} + {% set symfony_version_status = 'Unable to retrieve information about the Symfony version.' %} + {% elseif 'eol' == collector.symfonyState %} + {% set block_status = 'red' %} + {% set symfony_version_status = 'This Symfony version will no longer receive security fixes.' %} + {% elseif 'eom' == collector.symfonyState %} + {% set block_status = 'yellow' %} + {% set symfony_version_status = 'This Symfony version will only receive security fixes.' %} + {% elseif 'dev' == collector.symfonyState %} + {% set block_status = 'yellow' %} + {% set symfony_version_status = 'This Symfony version is still in the development phase.' %} + {% else %} + {% set block_status = '' %} + {% set symfony_version_status = '' %} + {% endif %} + {% set icon %} - - - - {% if collector.applicationname %} - {{ collector.applicationname }} {{ collector.applicationversion }} - {% elseif collector.symfonyState is defined %} - {% if 'unknown' == collector.symfonyState -%} - - {%- elseif 'eol' == collector.symfonyState -%} - - {%- elseif 'eom' == collector.symfonyState -%} - - {%- elseif 'dev' == collector.symfonyState -%} - - {%- else -%} - - {%- endif -%} - {{ collector.symfonyversion }} - {% endif %} + {% if collector.symfonyState is defined %} + + {{ include('@WebProfiler/Icon/symfony.svg') }} - + {{ collector.symfonyversion }} + {% elseif collector.applicationname %} + {{ collector.applicationname }} + {{ collector.applicationversion }} + {% endif %} {% endset %} + {% set text %} {% if collector.applicationname %}
{{ collector.applicationname }} {{ collector.applicationversion }}
{% endif %} +
- Symfony {{ collector.symfonyversion }} -
-
- Symfony Documentation + Profiler token + + {% if profiler_url %} + {{ collector.token }} + {% else %} + {{ collector.token }} + {% endif %} +
- {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': false } %} - {# PHP Information #} - {% set icon %} - - - - {% endset %} - {% set text %} - {% spaceless %} -
- PHP - {{ collector.phpversion }} + {% if 'n/a' != collector.appname %} +
+ Kernel name + {{ collector.appname }}
-
- PHP Extensions - xdebug - accel + {% endif %} + + {% if 'n/a' != collector.env %} +
+ Environment + {{ collector.env }}
+ {% endif %} + + {% if 'n/a' != collector.debug %}
- PHP SAPI - {{ collector.sapiName }} + Debug + {{ collector.debug ? 'enabled' : 'disabled' }}
- {% endspaceless %} - {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': false } %} + {% endif %} - {# Environment #} - {% set debug_status_class %}sf-toolbar-status sf-toolbar-status-{{ collector.debug ? 'green' : 'red' }}{% endset %} - {% set icon %} - - {{ token }} - {% if 'n/a' != collector.appname or 'n/a' != collector.env %} - - {{ collector.appname }} - {{ collector.env }} +
+ PHP version + + {{ collector.phpversion }} +   View phpinfo() - {% endif %} - {% endset %} - {% set text %} - {% spaceless %} - {% if 'n/a' != collector.appname %} -
- Name - {{ collector.appname }} -
- {% endif %} - {% if 'n/a' != collector.env %} -
- Environment - {{ collector.env }} -
- {% endif %} - {% if 'n/a' != collector.debug %} -
- Debug - {{ collector.debug ? 'en' : 'dis' }}abled -
- {% endif %} +
+ +
+ PHP Extensions + xdebug + accel +
+ +
+ PHP SAPI + {{ collector.sapiName }} +
+ + {% if collector.symfonyversion is defined %}
- Token + Resources - {% if profiler_url %} - {{ collector.token }} - {% else %} - {{ collector.token }} - {% endif %} + + Read Symfony {{ collector.symfonyversion }} Docs +
- {% endspaceless %} + {% endif %} {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false, status: block_status }) }} {% endblock %} {% block menu %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig index f4342df72b1c9..d7b286647044e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig @@ -3,13 +3,31 @@ {% from _self import form_tree_entry, form_tree_details %} {% block toolbar %} - {% if collector.data|length %} + {% if collector.data.nb_errors > 0 or collector.data.forms|length %} + {% set status_color = collector.data.nb_errors ? 'red' : '' %} {% set icon %} - - {% if collector.data.nb_errors %}{{ collector.data.nb_errors }}{% else %}{{ collector.data.forms|length }}{% endif %} + {{ include('@WebProfiler/Icon/form.svg') }} + + {% if collector.data.nb_errors %} + {{ collector.data.nb_errors }} + {% else %} + {{ collector.data.forms|length }} + {% endif %} + {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + {% set text %} +
+ Number of forms + {{ collector.data.forms|length }} +
+
+ Number of errors + {{ collector.data.nb_errors }} +
+ {% endset %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} @@ -418,6 +436,7 @@ {% endblock %} {% macro form_tree_entry(name, data, expanded) %} + {% import _self as tree %}
  • {% if data.children is not empty %} @@ -434,7 +453,7 @@ {% if data.children is not empty %} {% endif %} @@ -442,6 +461,7 @@ {% endmacro %} {% macro form_tree_details(name, data, forms_by_hash) %} + {% import _self as tree %}

    {{ name|default('(no name)') }} @@ -608,7 +628,7 @@ {{ option }}
    {{ value }}
    - {% if data.resolved_options[option] is sameas(value) %} + {% if data.resolved_options[option] is same as(value) %} same as passed value {% else %}
    {{ data.resolved_options[option] }}
    @@ -673,6 +693,6 @@

    {% for childName, childData in data.children %} - {{ _self.form_tree_details(childName, childData, forms_by_hash) }} + {{ tree.form_tree_details(childName, childData, forms_by_hash) }} {% endfor %} {% endmacro %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig index a6707da12d77e..33ec18e58ce7d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig @@ -5,36 +5,30 @@ {% block toolbar %} {% if collector.counterrors or collector.countdeprecations or collector.countscreams %} {% set icon %} - - {% if collector.counterrors %} - {% set status_color = "red" %} - {% elseif collector.countdeprecations %} - {% set status_color = "yellow" %} - {% endif %} + {% set status_color = collector.counterrors ? 'red' : collector.countdeprecations ? 'yellow' : '' %} {% set error_count = collector.counterrors + collector.countdeprecations + collector.countscreams %} - {{ error_count }} + {{ include('@WebProfiler/Icon/logger.svg') }} + {{ error_count }} {% endset %} + {% set text %} - {% if collector.counterrors %} -
    - Errors - {{ collector.counterrors }} -
    - {% endif %} - {% if collector.countdeprecations %} -
    - Deprecated Calls - {{ collector.countdeprecations }} -
    - {% endif %} - {% if collector.countscreams %} -
    - Silenced Errors - {{ collector.countscreams }} -
    - {% endif %} +
    + Errors + {{ collector.counterrors|default(0) }} +
    + +
    + Deprecated Calls + {{ collector.countdeprecations|default(0) }} +
    + +
    + Silenced Errors + {{ collector.countscreams|default(0) }} +
    {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} @@ -126,8 +120,6 @@ {% set stack = log.context.stack|default([]) %} {% set id = 'sf-call-stack-' ~ log_index %} - {{ log.message }} - {% if stack %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig index 397b5e8305927..702b4df3658fe 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig @@ -2,16 +2,23 @@ {% block toolbar %} {% set icon %} - - - {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB - + {% set status_color = (collector.memory / 1024 / 1024) > 50 ? 'yellow' : '' %} + {{ include('@WebProfiler/Icon/memory.svg') }} + {{ '%.1f'|format(collector.memory / 1024 / 1024) }} + MB {% endset %} + {% set text %}
    - Memory usage - {{ '%.1f'|format(collector.memory / 1024 / 1024) }} / {{ collector.memoryLimit == -1 ? '∞' : '%.1f'|format(collector.memoryLimit / 1024 / 1024)|escape }} MB + Peak memory usage + {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB +
    + +
    + PHP memory limit + {{ collector.memoryLimit == -1 ? '∞' : '%.0f'|format(collector.memoryLimit / 1024 / 1024)|escape }} MB
    {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': false } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false, status: status_color }) }} {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig index 4d00a07d5fd8a..ad799c6b23e49 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig @@ -1,41 +1,54 @@ {% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} + + {% set request_handler %} {% if collector.controller.class is defined %} {% set link = collector.controller.file|file_link(collector.controller.line) %} - {% if collector.controller.method %} - {{ collector.controller.class|abbr_class }} - - {{ collector.controller.method }} - - {% else %} - {{ collector.controller.class|abbr_class }} - {% endif %} + {% if link %}
    {% else %}{% endif %} + + {{ collector.controller.class|abbr_class|striptags }} + + {%- if collector.controller.method -%} +  :: {{ collector.controller.method }} + {%- endif -%} + + {% if link %}{% else %}{% endif %} {% else %} - {{ collector.controller }} + {{ collector.controller }} {% endif %} {% endset %} - {% set request_status_code_color = (400 > collector.statuscode) ? ((200 == collector.statuscode) ? 'green' : 'yellow') : 'red'%} - {% set request_route = collector.route ? collector.route : 'NONE' %} + + {% set request_status_code_color = (400 > collector.statuscode) ? ((200 == collector.statuscode) ? 'green' : 'yellow') : 'red' %} + {% set icon %} - - {{ collector.statuscode }} - {{ request_handler }} + {{ collector.statuscode }} + {% if collector.route %} + @ + {{ collector.route }} + {% endif %} {% endset %} + {% set text %} {% spaceless %}
    - Status - {{ collector.statuscode }} {{ collector.statustext }} + HTTP status + {{ collector.statuscode }} {{ collector.statustext }}
    Controller - {{ request_handler }} + {{ request_handler }}
    + {% if collector.controller.class is defined %} +
    + Controller class + {{ collector.controller.class }} +
    + {% endif %}
    Route name - {{ request_route }} + {{ collector.route|default('NONE') }}
    Has session @@ -43,7 +56,8 @@
    {% endspaceless %} {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }} {% endblock %} {% block menu %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index db807a721168e..39f8f62abd3a1 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -16,18 +16,28 @@ {% endif %} {% block toolbar %} - {% set duration = collector.events|length ? '%.0f ms'|format(collector.duration) : 'n/a' %} + {% set total_time = collector.events|length ? '%.0f'|format(collector.duration) : 'n/a' %} + {% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %} + {% set status_color = collector.events|length and collector.duration > 1000 ? 'yellow' : '' %} + {% set icon %} - - {{ duration }} + {{ include('@WebProfiler/Icon/time.svg') }} + {{ total_time }} + ms {% endset %} + {% set text %}
    Total time - {{ duration }} + {{ total_time }} ms +
    +
    + Initialization time + {{ initialization_time }} ms
    {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endblock %} {% block menu %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig index 840e7cd1acc80..3d75c46768969 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig @@ -5,36 +5,34 @@ {% block toolbar %} {% if collector.messages|length %} {% set icon %} - - {% if collector.countMissings %} - {% set status_color = "red" %} - {% elseif collector.countFallbacks %} - {% set status_color = "yellow" %} - {% endif %} + {{ include('@WebProfiler/Icon/translation.svg') }} + {% set status_color = collector.countMissings ? 'red' : collector.countFallbacks ? 'yellow' : '' %} {% set error_count = collector.countMissings + collector.countFallbacks %} - {{ error_count ?: collector.countdefines }} + {{ error_count ?: collector.countdefines }} {% endset %} + {% set text %} - {% if collector.countMissings %} -
    - Missing messages - {{ collector.countMissings }} -
    - {% endif %} - {% if collector.countFallbacks %} -
    - Fallback messages - {{ collector.countFallbacks }} -
    - {% endif %} - {% if collector.countdefines %} -
    - Defined messages - {{ collector.countdefines }} -
    - {% endif %} +
    + Missing messages + + {{ collector.countMissings }} + +
    + +
    + Fallback messages + + {{ collector.countFallbacks }} + +
    + +
    + Defined messages + {{ collector.countdefines }} +
    {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }} {% endif %} {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig index 0ecd469bd0732..95713b93db249 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig @@ -1,30 +1,33 @@ {% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} - {% set time = collector.templatecount ? '%0.0f ms'|format(collector.time) : 'n/a' %} + {% set time = collector.templatecount ? '%0.0f'|format(collector.time) : 'n/a' %} {% set icon %} - Twig - {{ time }} + {{ include('@WebProfiler/Icon/twig.svg') }} + {{ time }} + ms {% endset %} + {% set text %}
    Render Time - {{ time }} + {{ time }} ms
    Template Calls - {{ collector.templatecount }} + {{ collector.templatecount }}
    Block Calls - {{ collector.blockcount }} + {{ collector.blockcount }}
    Macro Calls - {{ collector.macrocount }} + {{ collector.macrocount }}
    {% endset %} - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} + + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }} {% endblock %} {% block menu %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg new file mode 100644 index 0000000000000..d8cad847d4710 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg @@ -0,0 +1,6 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/close.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/close.svg new file mode 100644 index 0000000000000..49a75fc165143 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/close.svg @@ -0,0 +1,5 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/form.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/form.svg new file mode 100644 index 0000000000000..18bdb6e793d5d --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/form.svg @@ -0,0 +1,6 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/logger.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/logger.svg new file mode 100644 index 0000000000000..3270a33618d5e --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/logger.svg @@ -0,0 +1,7 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/memory.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/memory.svg new file mode 100644 index 0000000000000..5cd2fc4d84f27 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/memory.svg @@ -0,0 +1,5 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/symfony.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/symfony.svg new file mode 100644 index 0000000000000..8d0ab1417f898 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/symfony.svg @@ -0,0 +1,12 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/time.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/time.svg new file mode 100644 index 0000000000000..ec280a59a6bc3 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/time.svg @@ -0,0 +1,5 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg new file mode 100644 index 0000000000000..93d42327ed859 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg @@ -0,0 +1,13 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/twig.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/twig.svg new file mode 100644 index 0000000000000..21d81ea2161c8 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/twig.svg @@ -0,0 +1,5 @@ + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index e313380e51095..2b1eeff3c00e9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -86,6 +86,7 @@ return; } + var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax'); var tbodies = document.querySelectorAll('.sf-toolbar-ajax-request-list'); var state = 'ok'; if (tbodies.length) { @@ -165,31 +166,24 @@ tbody.appendChild(rows); if (infoSpan) { - var text = requestStack.length + ' call' + (requestStack.length > 1 ? 's' : ''); + var text = requestStack.length + ' AJAX request' + (requestStack.length > 1 ? 's' : ''); infoSpan.textContent = text; } } else { - var cell = document.createElement('td'); - cell.setAttribute('colspan', '4'); - cell.textContent = "No AJAX requests yet."; - var row = document.createElement('tr'); - row.appendChild(cell); - tbody.appendChild(row); + ajaxToolbarPanel.style.display = 'none'; } } requestCounter[0].textContent = requestStack.length; - var className = 'sf-toolbar-ajax-requests sf-toolbar-status'; - if (state == 'ok') { - className += ' sf-toolbar-status-green'; - } else if (state == 'error') { - className += ' sf-toolbar-status-red'; + var className = 'sf-toolbar-ajax-requests sf-toolbar-value'; + requestCounter[0].className = className; + + if (state == 'error') { + Sfjs.addClass(ajaxToolbarPanel, 'sf-toolbar-status-red'); } else { - className += ' sf-ajax-request-loading'; + Sfjs.addClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); } - - requestCounter[0].className = className; }; var addEventListener; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig index fd32565347953..3e453b0a212c9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig @@ -179,7 +179,7 @@ pre, code { width: 250px; margin-left: -100%; } -table td { +#collector-content table td { background-color: white; } h1 { @@ -273,15 +273,15 @@ ul.alt li { ul.alt li.even { background: #f1f7e2; } -ul.alt li.error, tr.error td { +ul.alt li.error { background-color: #f66; margin-bottom: 1px; } -ul.alt li.warning, tr.warning td { +ul.alt li.warning { background-color: #ffcc00; margin-bottom: 1px; } -ul.alt li.scream, ul.alt li.scream strong, tr.scream td, tr.scream strong { +ul.alt li.scream, ul.alt li.scream strong { color: gray; } ul.sf-call-stack li { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 8d736a716dd36..6d07bc4e0babb 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -1,21 +1,12 @@ .sf-minitoolbar { + background-color: #222; + bottom: 0; display: none; - + height: 36px; + padding: 5px 6px 0; position: fixed; - bottom: 0; right: 0; - - padding: 5px 5px 0; - - background-color: #f7f7f7; - background-image: -moz-linear-gradient(top, #e4e4e4, #ffffff); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e4e4e4), to(#ffffff)); - background-image: -o-linear-gradient(top, #e4e4e4, #ffffff); - background: linear-gradient(top, #e4e4e4, #ffffff); - - border-radius: 16px 0 0 0; - - z-index: 6000000; + z-index: 99999; } .sf-toolbarreset * { @@ -26,127 +17,135 @@ } .sf-toolbarreset { - position: fixed; - background-color: #f7f7f7; + background-color: #222; + bottom: 0; + box-shadow: 0 -1px 0px rgba(0, 0, 0, 0.2); + color: #EEE; + font: 11px Arial, sans-serif; left: 0; - right: 0; margin: 0; - padding: 0 40px 0 0; - z-index: 6000000; - font: 11px Verdana, Arial, sans-serif; + padding: 0 36px 0 0; + position: fixed; + right: 0; text-align: left; - color: #2f2f2f; - - background-image: -moz-linear-gradient(top, #e4e4e4, #ffffff); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e4e4e4), to(#ffffff)); - background-image: -o-linear-gradient(top, #e4e4e4, #ffffff); - background: linear-gradient(top, #e4e4e4, #ffffff); - - bottom: 0; - border-top: 1px solid #bbb; + z-index: 99999; } .sf-toolbarreset abbr { - border-bottom: 1px dotted #000000; - cursor: help; -} -.sf-toolbarreset span, -.sf-toolbarreset div, -.sf-toolbarreset td, -.sf-toolbarreset th { - font-size: 11px; + border: dashed #777; + border-width: 0 0 1px; } +.sf-toolbarreset svg, .sf-toolbarreset img { - width: auto; - display: inline; -} -.sf-toolbarreset table { - border-collapse: collapse; - border-spacing: 0; - background-color: #000; - margin: 0; - padding: 0; - border: 0; - width: 100%; - table-layout: auto; + max-height: 20px; } + .sf-toolbarreset .hide-button { + background: #444; + cursor: pointer; display: block; position: absolute; top: 0; right: 0; - width: 40px; - height: 40px; + width: 36px; + height: 36px; cursor: pointer; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAAAllBMVEXDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PExMTPz8/Q0NDR0dHT09Pb29vc3Nzf39/h4eHi4uLj4+P6+vr7+/v8/Pz9/f3///+Nh2QuAAAAIXRSTlMABgwPGBswMzk8QktRV4SKjZOWmaKlq7TAxszb3urt+fy1vNEpAAAAiklEQVQIHUXBBxKCQBREwRFzDqjoGh+C2YV//8u5Sll2S0E/dof1tKdKM6GyqCto7PjZRJIS/mbSELgXOSd/BzpKIH1ZefVWpDDTHsi8mZVnwImPi5ndCLbaAZk3M58Bay0h9VbeSvMpjDUAHj4jL55AW1rxN5fU2PLjIgVRzNdxVFOlGzvnJi0Fb1XNGBHA9uQOAAAAAElFTkSuQmCC'); - background-repeat: no-repeat; - background-position: 13px 11px; + text-align: center; +} +.sf-toolbarreset .hide-button svg { + max-height: 18px; + padding-top: 10px; } .sf-toolbar-block { - white-space: nowrap; - color: #2f2f2f; + cursor: default; display: block; - min-height: 28px; - border-bottom: 1px solid #e4e4e4; - border-right: 1px solid #e4e4e4; - padding: 0; float: left; - cursor: default; + height: 36px; + margin-right: 0; + white-space: nowrap; +} +.sf-toolbar-block > a, +.sf-toolbar-block > a:hover { + display: block; + text-decoration: none; } .sf-toolbar-block span { display: inline-block; } +.sf-toolbar-block .sf-toolbar-value { + color: #F5F5F5; + font-size: 13px; + line-height: 36px; + padding: 0; +} +.sf-toolbar-block .sf-toolbar-label, +.sf-toolbar-block .sf-toolbar-class-separator { + color: #AAA; + font-size: 12px; +} +.sf-toolbar-block .sf-toolbar-info { + border-collapse: collapse; + display: table; + z-index: 100000; +} +.sf-toolbar-block hr { + border-top: 1px solid #777; + margin: 4px 0; + padding-top: 4px; +} .sf-toolbar-block .sf-toolbar-info-piece { - line-height: 19px; - margin-bottom: 5px; + /* this 'border-bottom' trick is needed because 'margin-bottom' doesn't work for table rows */ + border-bottom: solid transparent 3px; + display: table-row; +} +.sf-toolbar-block .sf-toolbar-info-piece-additional, +.sf-toolbar-block .sf-toolbar-info-piece-additional-detail { + display: none; } .sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status { - padding: 0px 5px; - border-radius: 5px; + padding: 2px 5px; margin-bottom: 0px; - vertical-align: top; +} +.sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status + .sf-toolbar-status { + margin-left: 4px; } .sf-toolbar-block .sf-toolbar-info-piece:last-child { margin-bottom: 0; } -.sf-toolbar-block .sf-toolbar-info-piece a, -.sf-toolbar-block .sf-toolbar-info-piece abbr { - color: #2f2f2f; +.sf-toolbar-block .sf-toolbar-info-piece a { + color: #99CDD8; + text-decoration: underline; +} +.sf-toolbar-block .sf-toolbar-info-piece a:hover { + text-decoration: none; } .sf-toolbar-block .sf-toolbar-info-piece b { - display: inline-block; - min-width: 110px; - vertical-align: top; + color: #AAA; + display: table-cell; + font-size: 11px; + padding: 4px 8px 4px 0; } +.sf-toolbar-block .sf-toolbar-info-piece span { -.sf-toolbar-block .sf-toolbar-info-with-next-pointer:after { - content: ' :: '; - color: #999; } - -.sf-toolbar-block .sf-toolbar-info-with-delimiter { - border-right: 1px solid #999; - padding-right: 5px; +.sf-toolbar-block .sf-toolbar-info-piece span { + color: #F5F5F5; + font-size: 12px; } .sf-toolbar-block .sf-toolbar-info { + background-color: #444; + bottom: 36px; + color: #F5F5F5; display: none; - position: absolute; - background-color: #fff; - border: 1px solid #bbb; padding: 9px 0; - margin-left: -1px; - - bottom: 38px; - border-bottom-width: 0; - border-bottom: 1px solid #bbb; - border-radius: 4px 4px 0 0; + position: absolute; } .sf-toolbar-block .sf-toolbar-info:empty { @@ -155,154 +154,131 @@ .sf-toolbar-block .sf-toolbar-status { display: inline-block; - color: #fff; + color: #FFF; background-color: #666; padding: 3px 6px; - border-radius: 3px; margin-bottom: 2px; vertical-align: middle; min-width: 6px; min-height: 13px; } -.sf-toolbar-block .sf-toolbar-status abbr { - color: #fff; - border-bottom: 1px dotted black; -} - .sf-toolbar-block .sf-toolbar-status-green { - background-color: #759e1a; + background-color: rgba(117, 158, 43, 0.8); } - .sf-toolbar-block .sf-toolbar-status-red { - background-color: #a33; + background-color: rgba(200, 43, 43, 0.8); } - .sf-toolbar-block .sf-toolbar-status-yellow { - background-color: #ffcc00; - color: #000; -} - -.sf-toolbar-block .sf-toolbar-status-black { - background-color: #000; + background-color: rgb(189, 132, 0); } -.sf-toolbar-block .sf-toolbar-icon { - display: block; +.sf-toolbar-block.sf-toolbar-status-green { + background-color: rgba(117, 158, 43, 0.8); + color: #FFF; } - -.sf-toolbar-block .sf-toolbar-icon > a, -.sf-toolbar-block .sf-toolbar-icon > span { - display: block; - font-weight: normal; - text-decoration: none; - margin: 0; - padding: 5px 8px; - min-width: 20px; - text-align: center; - vertical-align: middle; +.sf-toolbar-block.sf-toolbar-status-red { + background-color: rgba(200, 43, 43, 0.8); + color: #FFF; } - -.sf-toolbar-block .sf-toolbar-icon > a, -.sf-toolbar-block .sf-toolbar-icon > a:link -.sf-toolbar-block .sf-toolbar-icon > a:hover { - color: black !important; +.sf-toolbar-block.sf-toolbar-status-yellow { + background-color: rgb(189, 132, 0); + color: #FFF; } -.sf-toolbar-block .sf-toolbar-icon > a[href]:after { - content: ""; +.sf-toolbar-block-request .sf-toolbar-status { + color: #FFF; + display: inline-block; + font-size: 14px; + height: 36px; + line-height: 36px; + padding: 0 10px; } - -.sf-toolbar-block .sf-toolbar-icon img, .sf-toolbar-block .sf-toolbar-icon svg { - border-width: 0; - vertical-align: middle; +.sf-toolbar-block-request .sf-toolbar-info-piece a { + text-decoration: none; } - -.sf-toolbar-block .sf-toolbar-icon img + span, .sf-toolbar-block .sf-toolbar-icon svg + span { - margin-left: 5px; - margin-top: 2px; +.sf-toolbar-block-request .sf-toolbar-info-piece a:hover { + text-decoration: underline; } -.sf-toolbar-block .sf-toolbar-icon .sf-toolbar-status { - border-radius: 12px; - border-bottom-left-radius: 0; - margin-top: 0; +.sf-toolbar-status-green .sf-toolbar-label, +.sf-toolbar-status-yellow .sf-toolbar-label, +.sf-toolbar-status-red .sf-toolbar-label { + color: #FFF; } - -.sf-toolbar-block .sf-toolbar-info-method { - border-bottom: 1px dashed #ccc; - cursor: help; +.sf-toolbar-status-green svg path, +.sf-toolbar-status-red svg path, +.sf-toolbar-status-yellow svg path { + fill: #FFF; } - -.sf-toolbar-block .sf-toolbar-info-method[onclick=""] { - border-bottom: none; - cursor: inherit; +.sf-toolbar-block-config svg path { + fill: #FFF; } -.sf-toolbar-info-php {} -.sf-toolbar-info-php-ext {} - -.sf-toolbar-info-php-ext .sf-toolbar-status { - margin-left: 2px; +.sf-toolbar-block .sf-toolbar-icon { + display: block; + height: 36px; + padding: 0 7px; } - -.sf-toolbar-info-php-ext .sf-toolbar-status:first-child { - margin-left: 0; +.sf-toolbar-block-request .sf-toolbar-icon { + padding-left: 0; + padding-right: 0; } -.sf-toolbar-block a .sf-toolbar-info-piece-additional, -.sf-toolbar-block a .sf-toolbar-info-piece-additional-detail { - display: inline-block; +.sf-toolbar-block .sf-toolbar-icon img, +.sf-toolbar-block .sf-toolbar-icon svg { + border-width: 0; + position: relative; + top: 8px; } -.sf-toolbar-block a .sf-toolbar-info-piece-additional:empty, -.sf-toolbar-block a .sf-toolbar-info-piece-additional-detail:empty { - display: none; +.sf-toolbar-block .sf-toolbar-icon img + span, +.sf-toolbar-block .sf-toolbar-icon svg + span { + margin-left: 4px; } - -.sf-toolbarreset:hover { - box-shadow: rgba(0, 0, 0, 0.3) 0 0 50px; +.sf-toolbar-block-config .sf-toolbar-icon .sf-toolbar-value { + margin-left: 4px; } .sf-toolbar-block:hover { - box-shadow: rgba(0, 0, 0, 0.35) 0 0 5px; - border-right: none; - margin-right: 1px; position: relative; } - .sf-toolbar-block:hover .sf-toolbar-icon { - background-color: #fff; - border-top: 1px dotted #DDD; + background-color: #444; position: relative; - margin-top: -1px; z-index: 10002; } - .sf-toolbar-block:hover .sf-toolbar-info { display: block; - min-width: -webkit-calc(100% + 2px); - min-width: calc(100% + 2px); - z-index: 10001; - box-sizing: border-box; - padding: 9px; - line-height: 19px; - + padding: 10px; max-width: 480px; max-height: 480px; word-wrap: break-word; overflow: hidden; overflow-y: auto; } - -.sf-toolbar-ajax-requests th, .sf-toolbar-ajax-requests td { - border-bottom: 1px solid #ddd; - padding: 0 4px; - color: #2f2f2f; - background-color: #fff; +.sf-toolbar-info-piece b.sf-toolbar-ajax-info { + color: #F5F5F5; +} +.sf-toolbar-ajax-requests { + width: 100%; +} +.sf-toolbar-ajax-requests td { + background-color: #444; + border-bottom: 1px solid #777; + color: #F5F5F5; + font-size: 12px; + padding: 4px; +} +.sf-toolbar-ajax-requests tr:last-child td { + border-bottom: 0; } .sf-toolbar-ajax-requests th { - background-color: #eee; + background-color: #222; + border-bottom: 0; + color: #AAA; + font-size: 11px; + padding: 4px; } .sf-ajax-request-url { max-width: 300px; @@ -310,12 +286,15 @@ overflow: hidden; text-overflow: ellipsis; } +.sf-toolbar-ajax-requests .sf-ajax-request-url a { + text-decoration: none; +} +.sf-toolbar-ajax-requests .sf-ajax-request-url a:hover { + text-decoration: underline; +} .sf-ajax-request-duration { text-align: right; } -.sf-ajax-request-error { - color: #a33 !important; -} .sf-ajax-request-loading { -webkit-animation: sf-blink .5s ease-in-out infinite; -o-animation: sf-blink .5s ease-in-out infinite; @@ -323,121 +302,155 @@ animation: sf-blink .5s ease-in-out infinite; } @-webkit-keyframes sf-blink { - 0% { color: black; } - 50% { color: #bbb; } - 100% { color: black; } + 0% { background: #222; } + 50% { background: #444; } + 100% { background: #222; } } @-moz-keyframes sf-blink { - 0% { color: black; } - 50% { color: #bbb; } - 100% { color: black; } -} -@-o-keyframes sf-blink { - 0% { color: black; } - 50% { color: #bbb; } - 100% { color: black; } + 0% { background: #222; } + 50% { background: #444; } + 100% { background: #222; } } @keyframes sf-blink { - 0% { color: black; } - 50% { color: #bbb; } - 100% { color: black; } + 0% { background: #222; } + 50% { background: #444; } + 100% { background: #222; } +} + +.sf-toolbar-block-dump pre.sf-dump { + background-color: #222; + border-color: #777; + border-radius: 0; + margin: 6px 0 12px 0; + width: 200px; +} +.sf-toolbar-block-dump pre.sf-dump:last-child { + margin-bottom: 0; +} +.sf-toolbar-block-dump .sf-toolbar-info-piece .sf-toolbar-file-line { + color: #AAA; + margin-left: 4px; +} +.sf-toolbar-block-dump .sf-toolbar-info img { + display: none; } -/***** Override the setting when the toolbar is on the top *****/ +/* Override the setting when the toolbar is on the top */ {% if position == 'top' %} .sf-minitoolbar { - top: 0; bottom: auto; right: 0; - - background-color: #f7f7f7; - - background-image: -moz-linear-gradient(225deg, #e4e4e4, #ffffff); - background-image: -webkit-gradient(linear, 100% 0%, 0% 0%, from(#e4e4e4), to(#ffffff)); - background-image: -o-linear-gradient(135deg, #e4e4e4, #ffffff); - background: linear-gradient(225deg, #e4e4e4, #ffffff); - - border-radius: 0 0 0 16px; + top: 0; } .sf-toolbarreset { - background-image: -moz-linear-gradient(225deg, #e4e4e4, #ffffff); - background-image: -webkit-gradient(linear, 100% 0%, 0% 0%, from(#e4e4e4), to(#ffffff)); - background-image: -o-linear-gradient(135deg, #e4e4e4, #ffffff); - background: linear-gradient(225deg, #e4e4e4, #ffffff); - - top: 0; bottom: auto; - border-bottom: 1px solid #bbb; + box-shadow: 0 1px 0px rgba(0, 0, 0, 0.2); + top: 0; } .sf-toolbar-block .sf-toolbar-info { - top: 39px; bottom: auto; - border-top-width: 0; - border-radius: 0 0 4px 4px; - } - - .sf-toolbar-block:hover .sf-toolbar-icon { - border-top: none; - border-bottom: 1px dotted #DDD; - margin-top: 0; - margin-bottom: -1px; + top: 36px; } {% endif %} {% if not floatable %} .sf-toolbarreset { position: static; - background: #cbcbcb; - - background-image: -moz-linear-gradient(90deg, #cbcbcb, #e8e8e8) !important; - background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, from(#cbcbcb), to(#e8e8e8)) !important; - background-image: -o-linear-gradient(180deg, #cbcbcb, #e8e8e8) !important; - background: linear-gradient(90deg, #cbcbcb, #e8e8e8) !important; } {% endif %} -/***** Media query *****/ -@media screen and (max-width: 779px) { - .sf-toolbar-block .sf-toolbar-icon > * > :first-child ~ * { +/* Responsive Design */ +.sf-toolbar-icon .sf-toolbar-label, +.sf-toolbar-icon .sf-toolbar-value { + display: none; +} +.sf-toolbar-block-config .sf-toolbar-icon .sf-toolbar-label { + display: inline-block; +} + +/* Legacy Design - these styles are maintained to make old panels look + a bit better on the new toolbar */ +.sf-toolbar-block .sf-toolbar-info-piece-additional-detail { + color: #AAA; + font-size: 12px; +} +.sf-toolbar-status-green .sf-toolbar-info-piece-additional-detail, +.sf-toolbar-status-yellow .sf-toolbar-info-piece-additional-detail, +.sf-toolbar-status-red .sf-toolbar-info-piece-additional-detail { + color: #FFF; +} + +@media (min-width: 768px) { + + .sf-toolbar-icon .sf-toolbar-label, + .sf-toolbar-icon .sf-toolbar-value { + display: inline; + } + + .sf-toolbar-block .sf-toolbar-icon img, + .sf-toolbar-block .sf-toolbar-icon svg { + top: 6px; + } + .sf-toolbar-block-config:hover .sf-toolbar-info { + right: 0; + } + .sf-toolbar-block-time .sf-toolbar-icon svg, + .sf-toolbar-block-memory .sf-toolbar-icon svg { display: none; } + .sf-toolbar-block-time .sf-toolbar-icon svg + span, + .sf-toolbar-block-memory .sf-toolbar-icon svg + span { + margin-left: 0; + } - .sf-toolbar-block .sf-toolbar-icon > * > .sf-toolbar-info-piece-additional, - .sf-toolbar-block .sf-toolbar-icon > * > .sf-toolbar-info-piece-additional-detail { - display: none !important; + .sf-toolbar-block .sf-toolbar-icon { + padding: 0 10px; + } + .sf-toolbar-block-time .sf-toolbar-icon { + padding-right: 5px; + } + .sf-toolbar-block-memory .sf-toolbar-icon { + padding-left: 5px; + } + .sf-toolbar-block-request .sf-toolbar-icon { + padding-left: 0; + padding-right: 0; + } + .sf-toolbar-block-request .sf-toolbar-status + .sf-toolbar-label { + margin-left: 4px; + } + .sf-toolbar-block-request .sf-toolbar-label + .sf-toolbar-value { + margin-right: 10px; } -} -@media screen and (min-width: 880px) { - .sf-toolbar-block .sf-toolbar-icon a[href$="config"] .sf-toolbar-info-piece-additional { - display: inline-block; + .sf-toolbar-block-request:hover .sf-toolbar-info { + max-width: none; } -} -@media screen and (min-width: 980px) { - .sf-toolbar-block .sf-toolbar-icon a[href$="security"] .sf-toolbar-info-piece-additional { - display: inline-block; + .sf-toolbar-block .sf-toolbar-info-piece b { + font-size: 12px; + } + .sf-toolbar-block .sf-toolbar-info-piece span { + font-size: 13px; } -} -@media screen and (max-width: 1179px) { - .sf-toolbar-block .sf-toolbar-icon > * > .sf-toolbar-info-piece-additional { - display: none; + .sf-toolbar-block-config { + float: right; + margin-left: 0; + margin-right: 0; } } -@media screen and (max-width: 1439px) { - .sf-toolbar-block .sf-toolbar-icon > * > .sf-toolbar-info-piece-additional-detail { - display: none; +@media (min-width: 1024px) { + .sf-toolbar-block .sf-toolbar-info-piece-additional, + .sf-toolbar-block .sf-toolbar-info-piece-additional-detail { + display: inline-block; } -} -/***** Media query print: Do not print the Toolbar. *****/ -@media print { - .sf-toolbar { + .sf-toolbar-block .sf-toolbar-info-piece-additional:empty, + .sf-toolbar-block .sf-toolbar-info-piece-additional-detail:empty { display: none; - visibility: hidden; } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig index dbe3d0cdbf7b8..e4fea4b00b1a0 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig @@ -15,11 +15,11 @@ Sfjs.setPreference('toolbar/displayState', 'block'); "> - + {{ include('@WebProfiler/Icon/symfony.svg') }}
    {% endif %} @@ -30,7 +30,8 @@ 'collector': profile.getcollector(name), 'profiler_url': profiler_url, 'token': profile.token, - 'name': name + 'name': name, + 'profiler_markup_version': profiler_markup_version }) }} {% endfor %} @@ -42,7 +43,9 @@ (p.previousElementSibling || p.previousSibling).style.display = 'none'; document.getElementById('sfMiniToolbar-{{ token }}').style.display = 'block'; Sfjs.setPreference('toolbar/displayState', 'none'); - "> + "> + {{ include('@WebProfiler/Icon/close.svg') }} + {% endif %}
  • diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig index 42bbfea5769b7..2f30e05c9a6b3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig @@ -1,9 +1,6 @@ -{% if link %} - {% set icon %} - {{ icon }} - {% endset %} -{% endif %} -
    -
    {{ icon|default('') }}
    -
    {{ text|default('') }}
    +
    + {% if link %}{% endif %} +
    {{ icon|default('') }}
    + {% if link %}
    {% endif %} +
    {{ text|default('') }}
    diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig index 91ad9ad10ecf1..1eadef3e9611a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig @@ -46,12 +46,15 @@ toolbarInfo.style.right = ''; toolbarInfo.style.left = ''; - if (leftValue > 0 && rightValue > 0) { + if (elementWidth > pageWidth) { + toolbarInfo.style.left = 0; + } + else if (leftValue > 0 && rightValue > 0) { toolbarInfo.style.right = (rightValue * -1) + 'px'; } else if (leftValue < 0) { toolbarInfo.style.left = 0; } else { - toolbarInfo.style.right = '-1px'; + toolbarInfo.style.right = '0px'; } }; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 1ed32ca676ea5..4a290ad51449e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -23,7 +23,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase public function testEmptyToken($token) { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); - $twig = $this->getMock('Twig_Environment'); + $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() @@ -47,7 +47,7 @@ public function getEmptyTokenCases() public function testReturns404onTokenNotFound() { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); - $twig = $this->getMock('Twig_Environment'); + $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() @@ -77,7 +77,7 @@ public function testReturns404onTokenNotFound() public function testSearchResult() { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); - $twig = $this->getMock('Twig_Environment'); + $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 00d17cee42acd..a3732fde425b1 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -50,6 +50,8 @@ protected function setUp() $this->container = new ContainerBuilder(); $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')); $this->container->register('twig', 'Twig_Environment'); + $this->container->register('twig_loader', 'Twig_Loader_Array')->addArgument(array()); + $this->container->register('twig', 'Twig_Environment')->addArgument(new Reference('twig_loader')); $this->container->setParameter('kernel.bundles', array()); $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 4638ee36e924e..5c8a3becb8326 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -138,7 +138,7 @@ protected function mockProfile() protected function mockTwigEnvironment() { - $this->twigEnvironment = $this->getMockBuilder('Twig_Environment')->getMock(); + $this->twigEnvironment = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $this->twigEnvironment->expects($this->any()) ->method('loadTemplate') diff --git a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php index a6cb0bb6a3276..13df2f443e9f0 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php @@ -14,7 +14,7 @@ use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; /** - * Twig extension for the profiler + * Twig extension for the profiler. * * @author Fabien Potencier */ diff --git a/src/Symfony/Component/Asset/Context/NullContext.php b/src/Symfony/Component/Asset/Context/NullContext.php index 47d29d7d2e33c..0743d8ccbd615 100644 --- a/src/Symfony/Component/Asset/Context/NullContext.php +++ b/src/Symfony/Component/Asset/Context/NullContext.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Asset\Context; -use Symfony\Component\HttpFoundation\RequestStack; - /** * A context that does nothing. * diff --git a/src/Symfony/Component/Asset/Packages.php b/src/Symfony/Component/Asset/Packages.php index e980b7608e860..0a8c96354967c 100644 --- a/src/Symfony/Component/Asset/Packages.php +++ b/src/Symfony/Component/Asset/Packages.php @@ -67,7 +67,7 @@ public function addPackage($name, PackageInterface $package) * @return PackageInterface An asset package * * @throws InvalidArgumentException If there is no package by that name - * @throws LogicException If no default package is defined + * @throws LogicException If no default package is defined */ public function getPackage($name = null) { diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 112bee87bddce..d242acdc1b46d 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -118,6 +118,25 @@ private static function findClasses($path) case T_CLASS: case T_INTERFACE: case SYMFONY_TRAIT: + // Skip usage of ::class constant + $isClassConstant = false; + for ($j = $i - 1; $j > 0; --$j) { + if (is_string($tokens[$j])) { + break; + } + + if (T_DOUBLE_COLON === $tokens[$j][0]) { + $isClassConstant = true; + break; + } elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) { + break; + } + } + + if ($isClassConstant) { + continue; + } + // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 29c3288347dcc..e6756f1898d84 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -47,7 +47,7 @@ private function clean($file) /** * @dataProvider getTestCreateMapTests */ - public function testDump($directory, $expected) + public function testDump($directory) { $this->prepare_workspace(); @@ -115,6 +115,12 @@ public function getTestCreateMapTests() )); } + if (PHP_VERSION_ID >= 50500) { + $data[] = array(__DIR__.'/Fixtures/php5.5', array( + 'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php', + )); + } + return $data; } diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/php5.5/class_cons.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/php5.5/class_cons.php new file mode 100644 index 0000000000000..0ed8d77fcafd6 --- /dev/null +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/php5.5/class_cons.php @@ -0,0 +1,11 @@ + */ diff --git a/src/Symfony/Component/Config/Definition/BooleanNode.php b/src/Symfony/Component/Config/Definition/BooleanNode.php index df06b307aea42..08e1a7730713a 100644 --- a/src/Symfony/Component/Config/Definition/BooleanNode.php +++ b/src/Symfony/Component/Config/Definition/BooleanNode.php @@ -39,4 +39,13 @@ protected function validateType($value) throw $ex; } } + + /** + * {@inheritdoc} + */ + protected function isValueEmpty($value) + { + // a boolean value cannot be empty + return false; + } } diff --git a/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php index db7ebc24117a1..7f8eb2681d9e9 100644 --- a/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php @@ -30,6 +30,18 @@ public function __construct($name, NodeParentInterface $parent = null) $this->nullEquivalent = true; } + /** + * {@inheritdoc} + * + * @deprecated Deprecated since version 2.8, to be removed in 3.0. + */ + public function cannotBeEmpty() + { + @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); + + return parent::cannotBeEmpty(); + } + /** * Instantiate a Node. * diff --git a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php index ddd716d06a7b5..a1cd49b73cab4 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php @@ -58,4 +58,16 @@ public function min($min) return $this; } + + /** + * {@inheritdoc} + * + * @deprecated Deprecated since version 2.8, to be removed in 3.0. + */ + public function cannotBeEmpty() + { + @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); + + return parent::cannotBeEmpty(); + } } diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index ab56a928382b1..0c891ca20a544 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -247,7 +247,7 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name } /** - * Outputs a single config reference line + * Outputs a single config reference line. * * @param string $text * @param int $indent diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index a7cd4486f2c47..83587fb49c81a 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -125,7 +125,7 @@ private function writeNode(NodeInterface $node, $depth = 0) if ($info = $node->getInfo()) { $this->writeLine(''); // indenting multi-line info - $info = str_replace("\n", sprintf("\n%".($depth * 4)."s# ", ' '), $info); + $info = str_replace("\n", sprintf("\n%".($depth * 4).'s# ', ' '), $info); $this->writeLine('# '.$info, $depth * 4); } @@ -160,7 +160,7 @@ private function writeNode(NodeInterface $node, $depth = 0) } /** - * Outputs a single config reference line + * Outputs a single config reference line. * * @param string $text * @param int $indent diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index 224871ab6fe02..9b4c4156e311e 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -25,8 +25,8 @@ class EnumNode extends ScalarNode public function __construct($name, NodeInterface $parent = null, array $values = array()) { $values = array_unique($values); - if (count($values) <= 1) { - throw new \InvalidArgumentException('$values must contain at least two distinct elements.'); + if (empty($values)) { + throw new \InvalidArgumentException('$values must contain at least one element.'); } parent::__construct($name, $parent); diff --git a/src/Symfony/Component/Config/Definition/NumericNode.php b/src/Symfony/Component/Config/Definition/NumericNode.php index 2304ad9987120..439935e4559f8 100644 --- a/src/Symfony/Component/Config/Definition/NumericNode.php +++ b/src/Symfony/Component/Config/Definition/NumericNode.php @@ -52,4 +52,13 @@ protected function finalizeValue($value) return $value; } + + /** + * {@inheritdoc} + */ + protected function isValueEmpty($value) + { + // a numeric value cannot be empty + return false; + } } diff --git a/src/Symfony/Component/Config/Definition/ScalarNode.php b/src/Symfony/Component/Config/Definition/ScalarNode.php index 854c265763a70..6b3fd0b68fd22 100644 --- a/src/Symfony/Component/Config/Definition/ScalarNode.php +++ b/src/Symfony/Component/Config/Definition/ScalarNode.php @@ -46,4 +46,12 @@ protected function validateType($value) throw $ex; } } + + /** + * {@inheritdoc} + */ + protected function isValueEmpty($value) + { + return null === $value || '' === $value; + } } diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index 2ab7a45b6bc76..e2c0677475933 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -84,7 +84,7 @@ protected function validateType($value) */ protected function finalizeValue($value) { - if (!$this->allowEmptyValue && empty($value)) { + if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { $ex = new InvalidConfigurationException(sprintf( 'The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), @@ -116,4 +116,20 @@ protected function mergeValues($leftSide, $rightSide) { return $rightSide; } + + /** + * Evaluates if the given value is to be treated as empty. + * + * By default, PHP's empty() function is used to test for emptiness. This + * method may be overridden by subtypes to better match their understanding + * of empty data. + * + * @param mixed $value + * + * @return bool + */ + protected function isValueEmpty($value) + { + return empty($value); + } } diff --git a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php index 0753d64b4fecc..b0cb079e96fbc 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php @@ -24,6 +24,19 @@ public function testNormalize($value) $this->assertSame($value, $node->normalize($value)); } + /** + * @dataProvider getValidValues + * + * @param bool $value + */ + public function testValidNonEmptyValues($value) + { + $node = new BooleanNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + public function getValidValues() { return array( diff --git a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php index 2b84de6b098f7..654d5050dd9c9 100644 --- a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php @@ -23,10 +23,23 @@ public function testFinalizeValue() /** * @expectedException \InvalidArgumentException + * @expectedExceptionMessage $values must contain at least one element. */ + public function testConstructionWithNoValues() + { + new EnumNode('foo', null, array()); + } + public function testConstructionWithOneValue() { - new EnumNode('foo', null, array('foo', 'foo')); + $node = new EnumNode('foo', null, array('foo')); + $this->assertSame('foo', $node->finalize('foo')); + } + + public function testConstructionWithOneDistinctValue() + { + $node = new EnumNode('foo', null, array('foo', 'foo')); + $this->assertSame('foo', $node->finalize('foo')); } /** diff --git a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php index 4f308ca76b77c..84afd6c104223 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php @@ -24,6 +24,19 @@ public function testNormalize($value) $this->assertSame($value, $node->normalize($value)); } + /** + * @dataProvider getValidValues + * + * @param int $value + */ + public function testValidNonEmptyValues($value) + { + $node = new FloatNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + public function getValidValues() { return array( diff --git a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php index 1527db7a70206..58d21485993f1 100644 --- a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php @@ -24,6 +24,19 @@ public function testNormalize($value) $this->assertSame($value, $node->normalize($value)); } + /** + * @dataProvider getValidValues + * + * @param int $value + */ + public function testValidNonEmptyValues($value) + { + $node = new IntegerNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + public function getValidValues() { return array( diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index a79841071ca89..86c1803018a67 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -76,4 +76,51 @@ public function testNormalizeThrowsExceptionWithErrorMessage() $node->normalize(array()); } + + /** + * @dataProvider getValidNonEmptyValues + * + * @param mixed $value + */ + public function testValidNonEmptyValues($value) + { + $node = new ScalarNode('test'); + $node->setAllowEmptyValue(false); + + $this->assertSame($value, $node->finalize($value)); + } + + public function getValidNonEmptyValues() + { + return array( + array(false), + array(true), + array('foo'), + array(0), + array(1), + array(0.0), + array(0.1), + ); + } + + /** + * @dataProvider getEmptyValues + * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException + * + * @param mixed $value + */ + public function testNotAllowedEmptyValuesThrowException($value) + { + $node = new ScalarNode('test'); + $node->setAllowEmptyValue(false); + $node->finalize($value); + } + + public function getEmptyValues() + { + return array( + array(null), + array(''), + ); + } } diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index 07254c67201a6..4e29d2ed4517d 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +2.8.0 +----- + + * use readline for user input in the question helper when available to allow + the use of arrow keys + 2.6.0 ----- diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 5c3fea9a2caf2..212796a3edcc8 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -249,12 +249,16 @@ private function formatDefaultValue($default) */ private function getColumnWidth(array $commands) { - $width = 0; + $widths = array(); + foreach ($commands as $command) { - $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; + $widths[] = strlen($command->getName()); + foreach ($command->getAliases() as $alias) { + $widths[] = strlen($alias); + } } - return $width + 2; + return max($widths) + 2; } /** diff --git a/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php b/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php index 56f5526428f8e..92adf1ef96ceb 100644 --- a/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php +++ b/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php @@ -19,19 +19,19 @@ class ConsoleCommandEvent extends ConsoleEvent { /** - * The return code for skipped commands, this will also be passed into the terminate event + * The return code for skipped commands, this will also be passed into the terminate event. */ const RETURN_CODE_DISABLED = 113; /** - * Indicates if the command should be run or skipped + * Indicates if the command should be run or skipped. * * @var bool */ private $commandShouldRun = true; /** - * Disables the command, so it won't be run + * Disables the command, so it won't be run. * * @return bool */ @@ -41,7 +41,7 @@ public function disableCommand() } /** - * Enables the command + * Enables the command. * * @return bool */ @@ -51,7 +51,7 @@ public function enableCommand() } /** - * Returns true if the command is runnable, false otherwise + * Returns true if the command is runnable, false otherwise. * * @return bool */ diff --git a/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php b/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php index 0b4b9379020d9..1119b795c8b83 100644 --- a/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php +++ b/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php @@ -25,7 +25,7 @@ class DebugFormatterHelper extends Helper private $count = -1; /** - * Starts a debug formatting session + * Starts a debug formatting session. * * @param string $id The id of the formatting session * @param string $message The message to display @@ -41,7 +41,7 @@ public function start($id, $message, $prefix = 'RUN') } /** - * Adds progress to a formatting session + * Adds progress to a formatting session. * * @param string $id The id of the formatting session * @param string $buffer The message to display @@ -61,7 +61,7 @@ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPr unset($this->started[$id]['out']); } if (!isset($this->started[$id]['err'])) { - $message .= sprintf("%s %s ", $this->getBorder($id), $errorPrefix); + $message .= sprintf('%s %s ', $this->getBorder($id), $errorPrefix); $this->started[$id]['err'] = true; } @@ -72,7 +72,7 @@ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPr unset($this->started[$id]['err']); } if (!isset($this->started[$id]['out'])) { - $message .= sprintf("%s %s ", $this->getBorder($id), $prefix); + $message .= sprintf('%s %s ', $this->getBorder($id), $prefix); $this->started[$id]['out'] = true; } @@ -83,7 +83,7 @@ public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPr } /** - * Stops a formatting session + * Stops a formatting session. * * @param string $id The id of the formatting session * @param string $message The message to display diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 9e4fa02f2c615..53a684a81bd6c 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -77,7 +77,7 @@ public function setInputStream($stream) } /** - * Returns the helper's input stream + * Returns the helper's input stream. * * @return resource */ @@ -127,11 +127,7 @@ public function doAsk(OutputInterface $output, Question $question) } if (false === $ret) { - $ret = fgets($inputStream, 4096); - if (false === $ret) { - throw new \RuntimeException('Aborted'); - } - $ret = trim($ret); + $ret = $this->readFromInput($inputStream); } } else { $ret = trim($this->autocomplete($output, $question, $inputStream)); @@ -150,7 +146,7 @@ public function doAsk(OutputInterface $output, Question $question) * Outputs the question prompt. * * @param OutputInterface $output - * @param Question $question + * @param Question $question */ protected function writePrompt(OutputInterface $output, Question $question) { @@ -222,7 +218,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu // Backspace Character if ("\177" === $c) { if (0 === $numMatches && 0 !== $i) { - $i--; + --$i; // Move cursor backwards $output->write("\033[1D"); } @@ -275,7 +271,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu } else { $output->write($c); $ret .= $c; - $i++; + ++$i; $numMatches = 0; $ofs = 0; @@ -423,6 +419,30 @@ private function getShell() return self::$shell; } + /** + * Reads user input. + * + * @param resource $stream The input stream + * + * @return string User input + * + * @throws \RuntimeException + */ + private function readFromInput($stream) + { + if (STDIN === $stream && function_exists('readline')) { + $ret = readline(); + } else { + $ret = fgets($stream, 4096); + } + + if (false === $ret) { + throw new \RuntimeException('Aborted'); + } + + return trim($ret); + } + /** * Returns whether Stty is available or not. * diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 275e23b87c864..4d247f543ca3f 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -247,7 +247,7 @@ private function renderRowSeparator() } $markup = $this->style->getCrossingChar(); - for ($column = 0; $column < $count; $column++) { + for ($column = 0; $column < $count; ++$column) { $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar(); } @@ -340,7 +340,7 @@ private function calculateNumberOfColumns() private function buildTableRows($rows) { $unmergedRows = array(); - for ($rowKey = 0; $rowKey < count($rows); $rowKey++) { + for ($rowKey = 0; $rowKey < count($rows); ++$rowKey) { $rows = $this->fillNextRows($rows, $rowKey); // Remove any new line breaks and replace it with a new line @@ -513,7 +513,7 @@ private function getRowColumns($row) */ private function calculateColumnsWidth($rows) { - for ($column = 0; $column < $this->numberOfColumns; $column++) { + for ($column = 0; $column < $this->numberOfColumns; ++$column) { $lengths = array(); foreach ($rows as $row) { if ($row instanceof TableSeparator) { diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 43cbe725fb26e..a6c2132797086 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -215,8 +215,8 @@ private function addLongOption($name, $value) $option = $this->definition->getOption($name); - // Convert false values (from a previous call to substr()) to null - if (false === $value) { + // Convert empty values to null + if (!isset($value[0])) { $value = null; } diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index cf5d49c4c624c..1f7417ea5aa66 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -18,9 +18,10 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface; /** - * PSR-3 compliant console logger + * PSR-3 compliant console logger. * * @author Kévin Dunglas + * * @link http://www.php-fig.org/psr/psr-3/ */ class ConsoleLogger extends AbstractLogger @@ -93,7 +94,7 @@ public function log($level, $message, array $context = array()) } /** - * Interpolates context values into the message placeholders + * Interpolates context values into the message placeholders. * * @author PHP Framework Interoperability Group * diff --git a/src/Symfony/Component/Console/Question/ConfirmationQuestion.php b/src/Symfony/Component/Console/Question/ConfirmationQuestion.php index 9e55859053f8e..29d98879f0c56 100644 --- a/src/Symfony/Component/Console/Question/ConfirmationQuestion.php +++ b/src/Symfony/Component/Console/Question/ConfirmationQuestion.php @@ -23,8 +23,8 @@ class ConfirmationQuestion extends Question /** * Constructor. * - * @param string $question The question to ask to the user - * @param bool $default The default answer to return, true or false + * @param string $question The question to ask to the user + * @param bool $default The default answer to return, true or false * @param string $trueAnswerRegex A regex to match the "yes" answer */ public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') diff --git a/src/Symfony/Component/Console/Style/OutputStyle.php b/src/Symfony/Component/Console/Style/OutputStyle.php index 13ed05b13dc4a..8371bb533551e 100644 --- a/src/Symfony/Component/Console/Style/OutputStyle.php +++ b/src/Symfony/Component/Console/Style/OutputStyle.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Decorates output to add console style guide helpers + * Decorates output to add console style guide helpers. * * @author Kevin Bond */ diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index b3113a41e2d46..0d366c7e894bd 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -379,7 +379,7 @@ private function autoPrependBlock() { $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); - if (false === $chars) { + if (!isset($chars[0])) { return $this->newLine(); //empty history, so we should start with a new line. } //Prepend new line for each non LF chars (This means no blank line was output before) diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 4b465f8aaaecd..d1d65186e1932 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -365,8 +365,7 @@ public function testLegacyAsXml() // scope. function createClosure() { - return function(InputInterface $input, OutputInterface $output) - { + return function (InputInterface $input, OutputInterface $output) { $output->writeln($this instanceof Command ? 'bound to the command' : 'not bound to the command'); }; } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php b/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php index aef6d2246cb34..0070c0a48676c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php @@ -14,7 +14,7 @@ use Symfony\Component\Console\Output\BufferedOutput; /** - * Dummy output + * Dummy output. * * @author Kévin Dunglas */ diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php index 97b99efe7472c..8f33e3bf374a5 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php @@ -315,7 +315,7 @@ public function testNonDecoratedOutput() $bar = new ProgressBar($output = $this->getOutputStream(false), 200); $bar->start(); - for ($i = 0; $i < 200; $i++) { + for ($i = 0; $i < 200; ++$i) { $bar->advance(); } @@ -384,7 +384,7 @@ public function testParallelBars() $output->write("\n"); $bar3->start(); - for ($i = 1; $i <= 3; $i++) { + for ($i = 1; $i <= 3; ++$i) { // up two lines $output->write("\033[2A"); if ($i <= 2) { diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index 1abc363240167..c5eca2cafdc07 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Console logger test + * Console logger test. * * @author Kévin Dunglas */ diff --git a/src/Symfony/Component/CssSelector/Node/Specificity.php b/src/Symfony/Component/CssSelector/Node/Specificity.php index 0dfec3b95568f..0ce0c3f3049dd 100644 --- a/src/Symfony/Component/CssSelector/Node/Specificity.php +++ b/src/Symfony/Component/CssSelector/Node/Specificity.php @@ -78,7 +78,7 @@ public function getValue() /** * Returns -1 if the object specificity is lower than the argument, - * 0 if they are equal, and 1 if the argument is lower + * 0 if they are equal, and 1 if the argument is lower. * * @param Specificity $specificity * diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index a2532d3038d64..c8e5d1a83ff4d 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -32,6 +32,7 @@ class DebugClassLoader private static $caseCheck; private static $deprecated = array(); private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null'); + private static $darwinCache = array('/' => array('/', array())); /** * Constructor. @@ -220,33 +221,73 @@ public function loadClass($class) throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); } - if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*)+\.(php|hh)$#D', $file, $tail)) { + if (self::$caseCheck && preg_match('#(?:[/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*+)++\.(?:php|hh)$#D', $file, $tail)) { $tail = $tail[0]; + $tailLen = strlen($tail); $real = $refl->getFileName(); if (2 === self::$caseCheck) { // realpath() on MacOSX doesn't normalize the case of characters - $cwd = getcwd(); - $basename = strrpos($real, '/'); - chdir(substr($real, 0, $basename)); - $basename = substr($real, $basename + 1); - // glob() patterns are case-sensitive even if the underlying fs is not - if (!in_array($basename, glob($basename.'*', GLOB_NOSORT), true)) { - $real = getcwd().'/'; - $h = opendir('.'); - while (false !== $f = readdir($h)) { - if (0 === strcasecmp($f, $basename)) { - $real .= $f; - break; + + $i = 1 + strrpos($real, '/'); + $file = substr($real, $i); + $real = substr($real, 0, $i); + + if (isset(self::$darwinCache[$real])) { + $kDir = $real; + } else { + $kDir = strtolower($real); + + if (isset(self::$darwinCache[$kDir])) { + $real = self::$darwinCache[$kDir][0]; + } else { + $dir = getcwd(); + chdir($real); + $real = getcwd().'/'; + chdir($dir); + + $dir = $real; + $k = $kDir; + $i = strlen($dir) - 1; + while (!isset(self::$darwinCache[$k])) { + self::$darwinCache[$k] = array($dir, array()); + self::$darwinCache[$dir] = &self::$darwinCache[$k]; + + while ('/' !== $dir[--$i]) { + } + $k = substr($k, 0, ++$i); + $dir = substr($dir, 0, $i--); + } + } + } + + $dirFiles = self::$darwinCache[$kDir][1]; + + if (isset($dirFiles[$file])) { + $kFile = $file; + } else { + $kFile = strtolower($file); + + if (!isset($dirFiles[$kFile])) { + foreach (scandir($real, 2) as $f) { + if ('.' !== $f[0]) { + $dirFiles[$f] = $f; + if ($f === $file) { + $kFile = $k = $file; + } elseif ($f !== $k = strtolower($f)) { + $dirFiles[$k] = $f; + } + } } + self::$darwinCache[$kDir][1] = $dirFiles; } - closedir($h); } - chdir($cwd); + + $real .= $dirFiles[$kFile]; } - if (0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true) - && 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false) + if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true) + && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false) ) { throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real)); } diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 5af132ddc3260..e2ab0d6af921f 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -252,7 +252,7 @@ public function setExceptionHandler($handler) public function throwAt($levels, $replace = false) { $prev = $this->thrownErrors; - $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; + $this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; if (!$replace) { $this->thrownErrors |= $prev; } @@ -490,7 +490,7 @@ public function handleError($type, $message, $file, $line, array $context, array } /** - * Handles an exception by logging then forwarding it to an other handler. + * Handles an exception by logging then forwarding it to another handler. * * @param \Exception|\Throwable $exception An exception to handle * @param array $error An array as returned by error_get_last() diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index c883f15469e0b..257ad4460cd4a 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -38,7 +38,7 @@ class ExceptionHandler public function __construct($debug = true, $charset = null, $fileLinkFormat = null) { - if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) { + if (false !== strpos($charset, '%')) { // Swap $charset and $fileLinkFormat for BC reasons $pivot = $fileLinkFormat; $fileLinkFormat = $charset; @@ -153,19 +153,23 @@ public function handle(\Exception $exception) * it will fallback to plain PHP functions. * * @param \Exception $exception An \Exception instance - * - * @see sendPhpResponse() - * @see createResponse() */ private function failSafeHandle(\Exception $exception) { - if (class_exists('Symfony\Component\HttpFoundation\Response', false)) { + if (class_exists('Symfony\Component\HttpFoundation\Response', false) + && __CLASS__ !== get_class($this) + && ($reflector = new \ReflectionMethod($this, 'createResponse')) + && __CLASS__ !== $reflector->class + ) { $response = $this->createResponse($exception); $response->sendHeaders(); $response->sendContent(); - } else { - $this->sendPhpResponse($exception); + @trigger_error(sprintf("The %s::createResponse method is deprecated since 2.8 and won't be called anymore when handling an exception in 3.0.", $reflector->class), E_USER_DEPRECATED); + + return; } + + $this->sendPhpResponse($exception); } /** @@ -199,9 +203,13 @@ public function sendPhpResponse($exception) * @param \Exception|FlattenException $exception An \Exception instance * * @return Response A Response instance + * + * @deprecated since 2.8, to be removed in 3.0. */ public function createResponse($exception) { + @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); + if (!$exception instanceof FlattenException) { $exception = FlattenException::create($exception); } diff --git a/src/Symfony/Component/Debug/Resources/ext/tests/003.phpt b/src/Symfony/Component/Debug/Resources/ext/tests/003.phpt index 1d464720b7e31..a36333392eec3 100644 --- a/src/Symfony/Component/Debug/Resources/ext/tests/003.phpt +++ b/src/Symfony/Component/Debug/Resources/ext/tests/003.phpt @@ -56,7 +56,7 @@ Symfony\Component\Debug\Exception\UndefinedFunctionException Object [message:protected] => Attempted to call function "notexist" from namespace "Symfony\Component\Debug". [string:Exception:private] => [code:protected] => 0 - [file:protected] => - + [file:protected] => %s [line:protected] => %d [trace:Exception:private] => Array ( diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index 26f889288ff93..d4b93c0838922 100644 --- a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -13,71 +13,97 @@ use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\Debug\Exception\OutOfMemoryException; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; +require_once __DIR__.'/HeaderMock.php'; + class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase { + protected function setUp() + { + testHeader(); + } + + protected function tearDown() + { + testHeader(); + } + public function testDebug() { $handler = new ExceptionHandler(false); - $response = $handler->createResponse(new \RuntimeException('Foo')); - $this->assertContains('

    Whoops, looks like something went wrong.

    ', $response->getContent()); - $this->assertNotContains('

    ', $response->getContent()); + ob_start(); + $handler->sendPhpResponse(new \RuntimeException('Foo')); + $response = ob_get_clean(); + + $this->assertContains('

    Whoops, looks like something went wrong.

    ', $response); + $this->assertNotContains('

    ', $response); $handler = new ExceptionHandler(true); - $response = $handler->createResponse(new \RuntimeException('Foo')); - $this->assertContains('

    Whoops, looks like something went wrong.

    ', $response->getContent()); - $this->assertContains('

    ', $response->getContent()); + ob_start(); + $handler->sendPhpResponse(new \RuntimeException('Foo')); + $response = ob_get_clean(); + + $this->assertContains('

    Whoops, looks like something went wrong.

    ', $response); + $this->assertContains('

    ', $response); } public function testStatusCode() { - $handler = new ExceptionHandler(false); + $handler = new ExceptionHandler(false, 'iso8859-1'); + + ob_start(); + $handler->sendPhpResponse(new NotFoundHttpException('Foo')); + $response = ob_get_clean(); + + $this->assertContains('Sorry, the page you are looking for could not be found.', $response); - $response = $handler->createResponse(new \RuntimeException('Foo')); - $this->assertEquals('500', $response->getStatusCode()); - $this->assertContains('Whoops, looks like something went wrong.', $response->getContent()); + $expectedHeaders = array( + array('HTTP/1.0 404', true, null), + array('Content-Type: text/html; charset=iso8859-1', true, null), + ); - $response = $handler->createResponse(new NotFoundHttpException('Foo')); - $this->assertEquals('404', $response->getStatusCode()); - $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent()); + $this->assertSame($expectedHeaders, testHeader()); } public function testHeaders() { - $handler = new ExceptionHandler(false); + $handler = new ExceptionHandler(false, 'iso8859-1'); + + ob_start(); + $handler->sendPhpResponse(new MethodNotAllowedHttpException(array('POST'))); + $response = ob_get_clean(); - $response = $handler->createResponse(new MethodNotAllowedHttpException(array('POST'))); - $this->assertEquals('405', $response->getStatusCode()); - $this->assertEquals('POST', $response->headers->get('Allow')); + $expectedHeaders = array( + array('HTTP/1.0 405', true, null), + array('Allow: POST', false, null), + array('Content-Type: text/html; charset=iso8859-1', true, null), + ); + + $this->assertSame($expectedHeaders, testHeader()); } public function testNestedExceptions() { $handler = new ExceptionHandler(true); - $response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar'))); + ob_start(); + $handler->sendPhpResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar'))); + $response = ob_get_clean(); + + $this->assertStringMatchesFormat('%AFoo%ABar%A', $response); } public function testHandle() { $exception = new \Exception('foo'); - if (class_exists('Symfony\Component\HttpFoundation\Response')) { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse')); - $handler - ->expects($this->exactly(2)) - ->method('createResponse') - ->will($this->returnValue(new Response())); - } else { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); - $handler - ->expects($this->exactly(2)) - ->method('sendPhpResponse'); - } + $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); + $handler + ->expects($this->exactly(2)) + ->method('sendPhpResponse'); $handler->handle($exception); @@ -93,18 +119,10 @@ public function testHandleOutOfMemoryException() { $exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__); - if (class_exists('Symfony\Component\HttpFoundation\Response')) { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse')); - $handler - ->expects($this->once()) - ->method('createResponse') - ->will($this->returnValue(new Response())); - } else { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); - $handler - ->expects($this->once()) - ->method('sendPhpResponse'); - } + $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); + $handler + ->expects($this->once()) + ->method('sendPhpResponse'); $that = $this; $handler->setHandler(function ($e) use ($that) { diff --git a/src/Symfony/Component/Debug/Tests/HeaderMock.php b/src/Symfony/Component/Debug/Tests/HeaderMock.php new file mode 100644 index 0000000000000..65d0b588558b5 --- /dev/null +++ b/src/Symfony/Component/Debug/Tests/HeaderMock.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +function headers_sent() +{ + return false; +} + +function header($str, $replace = true, $status = null) +{ + Tests\testHeader($str, $replace, $status); +} + +namespace Symfony\Component\Debug\Tests; + +function testHeader() +{ + static $headers = array(); + + if (!$h = func_get_args()) { + $h = $headers; + $headers = array(); + + return $h; + } + + $headers[] = func_get_args(); +} diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index 17c56460cb703..6e89d6d48acb9 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -25,12 +25,7 @@ "require-dev": { "symfony/phpunit-bridge": "~2.7|~3.0.0", "symfony/class-loader": "~2.2|~3.0.0", - "symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0", - "symfony/http-foundation": "~2.1|~3.0.0" - }, - "suggest": { - "symfony/http-foundation": "", - "symfony/http-kernel": "" + "symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Debug\\": "" } diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index c13da0b280b3b..02cb2d50ec59b 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG * deprecated the concept of scopes * added `Definition::setShared()` and `Definition::isShared()` * added ResettableContainerInterface to be able to reset the container to release memory on shutdown + * added a way to define the priority of service decoration 2.7.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php index ef0a19c6a725c..f80d705a9bede 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php @@ -19,18 +19,28 @@ * * @author Christophe Coevoet * @author Fabien Potencier + * @author Diego Saint Esteben */ class DecoratorServicePass implements CompilerPassInterface { public function process(ContainerBuilder $container) { + $definitions = new \SplPriorityQueue(); + $order = PHP_INT_MAX; + foreach ($container->getDefinitions() as $id => $definition) { if (!$decorated = $definition->getDecoratedService()) { continue; } + $definitions->insert(array($id, $definition), array($decorated[2], --$order)); + } + + foreach ($definitions as $arr) { + list($id, $definition) = $arr; + list($inner, $renamedId) = $definition->getDecoratedService(); + $definition->setDecoratedService(null); - list($inner, $renamedId) = $decorated; if (!$renamedId) { $renamedId = $id.'.inner'; } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 4e99cca77ac08..49d705cf7d670 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -150,12 +150,13 @@ public function setFactoryMethod($factoryMethod) * * @param null|string $id The decorated service id, use null to remove decoration * @param null|string $renamedId The new decorated service id + * @param int $priority The priority of decoration * * @return Definition The current instance * * @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals. */ - public function setDecoratedService($id, $renamedId = null) + public function setDecoratedService($id, $renamedId = null, $priority = 0) { if ($renamedId && $id == $renamedId) { throw new \InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); @@ -164,7 +165,7 @@ public function setDecoratedService($id, $renamedId = null) if (null === $id) { $this->decoratedService = null; } else { - $this->decoratedService = array($id, $renamedId); + $this->decoratedService = array($id, $renamedId, (int) $priority); } return $this; @@ -173,7 +174,7 @@ public function setDecoratedService($id, $renamedId = null) /** * Gets the service that decorates this service. * - * @return null|array An array composed of the decorated service id and the new id for it, null if no service is decorated + * @return null|array An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated */ public function getDecoratedService() { diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index f5a1485a5f33a..7764079d5109a 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -173,11 +173,11 @@ public function setLazy($boolean) /** * {@inheritdoc} */ - public function setDecoratedService($id, $renamedId = null) + public function setDecoratedService($id, $renamedId = null, $priority = 0) { $this->changes['decorated_service'] = true; - return parent::setDecoratedService($id, $renamedId); + return parent::setDecoratedService($id, $renamedId, $priority); } /** diff --git a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index 70e19af52f55f..9710e8b0d2c74 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -166,14 +166,18 @@ private function findNodes() $container = $this->cloneContainer(); foreach ($container->getDefinitions() as $id => $definition) { - $className = $definition->getClass(); + $class = $definition->getClass(); + + if ('\\' === substr($class, 0, 1)) { + $class = substr($class, 1); + } try { - $className = $this->container->getParameterBag()->resolveValue($className); + $class = $this->container->getParameterBag()->resolveValue($class); } catch (ParameterNotFoundException $e) { } - $nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted'))); + $nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted'))); $container->setDefinition($id, new Definition('stdClass')); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 40d4c31ea7c74..c1c6f80f70b77 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -372,7 +372,13 @@ private function addServiceReturn($id, $definition) */ private function addServiceInstance($id, $definition) { - $class = $this->dumpValue($definition->getClass()); + $class = $definition->getClass(); + + if ('\\' === substr($class, 0, 1)) { + $class = substr($class, 1); + } + + $class = $this->dumpValue($class); if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); @@ -560,7 +566,7 @@ private function addService($id, $definition) if ($definition->isSynthetic()) { $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically'; } elseif ($class = $definition->getClass()) { - $return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.$class, $class); + $return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\')); } elseif ($definition->getFactory()) { $factory = $definition->getFactory(); if (is_string($factory)) { @@ -862,8 +868,8 @@ public function __construct() if (count($scopes = $this->container->getScopes(false)) > 0) { $code .= "\n"; - $code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n"; - $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren(false)).";\n"; + $code .= ' $this->scopes = '.$this->dumpValue($scopes).";\n"; + $code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren(false)).";\n"; } $code .= $this->addMethodMap(); @@ -908,8 +914,8 @@ public function __construct() $code .= "\n"; if (count($scopes = $this->container->getScopes(false)) > 0) { - $code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n"; - $code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren(false)).";\n"; + $code .= ' $this->scopes = '.$this->dumpValue($scopes).";\n"; + $code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren(false)).";\n"; } else { $code .= " \$this->scopes = array();\n"; $code .= " \$this->scopeChildren = array();\n"; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 1f9183f418de8..c405c4ce902c3 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -114,8 +114,12 @@ private function addService($definition, $id, \DOMElement $parent) if (null !== $id) { $service->setAttribute('id', $id); } - if ($definition->getClass()) { - $service->setAttribute('class', $definition->getClass()); + if ($class = $definition->getClass()) { + if ('\\' === substr($class, 0, 1)) { + $class = substr($class, 1); + } + + $service->setAttribute('class', $class); } if ($definition->getFactoryMethod(false)) { $service->setAttribute('factory-method', $definition->getFactoryMethod(false)); @@ -145,11 +149,14 @@ private function addService($definition, $id, \DOMElement $parent) $service->setAttribute('lazy', 'true'); } if (null !== $decorated = $definition->getDecoratedService()) { - list($decorated, $renamedId) = $decorated; + list($decorated, $renamedId, $priority) = $decorated; $service->setAttribute('decorates', $decorated); if (null !== $renamedId) { $service->setAttribute('decoration-inner-name', $renamedId); } + if (0 !== $priority) { + $service->setAttribute('decoration-priority', $priority); + } } foreach ($definition->getTags() as $name => $tags) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index e1a5709dd32e2..3fac53e01c330 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -64,8 +64,12 @@ public function dump(array $options = array()) private function addService($id, $definition) { $code = " $id:\n"; - if ($definition->getClass()) { - $code .= sprintf(" class: %s\n", $definition->getClass()); + if ($class = $definition->getClass()) { + if ('\\' === substr($class, 0, 1)) { + $class = substr($class, 1); + } + + $code .= sprintf(" class: %s\n", $class); } if (!$definition->isPublic()) { @@ -137,11 +141,14 @@ private function addService($id, $definition) } if (null !== $decorated = $definition->getDecoratedService()) { - list($decorated, $renamedId) = $decorated; + list($decorated, $renamedId, $priority) = $decorated; $code .= sprintf(" decorates: %s\n", $decorated); if (null !== $renamedId) { $code .= sprintf(" decoration_inner_name: %s\n", $renamedId); } + if (0 !== $priority) { + $code .= sprintf(" decoration_priority: %s\n", $priority); + } } if ($callable = $definition->getFactory()) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 15b6e60366ea2..de2ea9852a5f4 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -245,7 +245,8 @@ private function parseDefinition(\DOMElement $service, $file) if ($value = $service->getAttribute('decorates')) { $renameId = $service->hasAttribute('decoration-inner-name') ? $service->getAttribute('decoration-inner-name') : null; - $definition->setDecoratedService($value, $renameId); + $priority = $service->hasAttribute('decoration-priority') ? $service->getAttribute('decoration-priority') : 0; + $definition->setDecoratedService($value, $renameId, $priority); } return $definition; diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 3b4c5cda80768..ce04d10afabbe 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -290,7 +290,8 @@ private function parseDefinition($id, $service, $file) if (isset($service['decorates'])) { $renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null; - $definition->setDecoratedService($service['decorates'], $renameId); + $priority = isset($service['decoration_priority']) ? $service['decoration_priority'] : 0; + $definition->setDecoratedService($service['decorates'], $renameId, $priority); } $this->container->setDefinition($id, $definition); diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd index 11f869c04ac22..15bdd791dcf27 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd @@ -101,6 +101,7 @@ + diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index 96003547b69fb..ead76d738d320 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\ParameterBag; +use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; /** @@ -25,6 +26,8 @@ interface ParameterBagInterface /** * Clears all parameters. * + * @throws LogicException if the ParameterBagInterface can not be cleared + * * @api */ public function clear(); @@ -34,6 +37,8 @@ public function clear(); * * @param array $parameters An array of parameters * + * @throws LogicException if the parameter can not be added + * * @api */ public function add(array $parameters); @@ -66,6 +71,8 @@ public function get($name); * @param string $name The parameter name * @param mixed $value The parameter value * + * @throws LogicException if the parameter can not be set + * * @api */ public function set($name, $value); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php index 368ec3c5cd46a..e3aba6d7074cd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\DependencyInjection\Tests\Compiler; use Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php index e17961ac99db1..952f7a0bd847c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php @@ -73,6 +73,48 @@ public function testProcessWithAlias() $this->assertNull($fooExtendedDefinition->getDecoratedService()); } + public function testProcessWithPriority() + { + $container = new ContainerBuilder(); + $fooDefinition = $container + ->register('foo') + ->setPublic(false) + ; + $barDefinition = $container + ->register('bar') + ->setPublic(true) + ->setDecoratedService('foo') + ; + $bazDefinition = $container + ->register('baz') + ->setPublic(true) + ->setDecoratedService('foo', null, 5) + ; + $quxDefinition = $container + ->register('qux') + ->setPublic(true) + ->setDecoratedService('foo', null, 3) + ; + + $this->process($container); + + $this->assertEquals('bar', $container->getAlias('foo')); + $this->assertFalse($container->getAlias('foo')->isPublic()); + + $this->assertSame($fooDefinition, $container->getDefinition('baz.inner')); + $this->assertFalse($container->getDefinition('baz.inner')->isPublic()); + + $this->assertEquals('qux', $container->getAlias('bar.inner')); + $this->assertFalse($container->getAlias('bar.inner')->isPublic()); + + $this->assertEquals('baz', $container->getAlias('qux.inner')); + $this->assertFalse($container->getAlias('qux.inner')->isPublic()); + + $this->assertNull($barDefinition->getDecoratedService()); + $this->assertNull($bazDefinition->getDecoratedService()); + $this->assertNull($quxDefinition->getDecoratedService()); + } + protected function process(ContainerBuilder $container) { $repeatedPass = new DecoratorServicePass(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index 1f91b37821b75..6e112bb7ff126 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\DependencyInjection\Tests\Compiler; use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass; @@ -35,7 +44,7 @@ public function testExpressionLanguageProviderForwarding() $provider = $this->getMock('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface'); $container = new ContainerBuilder(new ParameterBag()); $container->registerExtension($extension); - $container->prependExtensionConfig('foo', array('bar' => true )); + $container->prependExtensionConfig('foo', array('bar' => true)); $container->addExpressionLanguageProvider($provider); $pass = new MergeExtensionConfigurationPass(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php index 9f1cc87b1db1c..2180483e2be90 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php @@ -241,7 +241,7 @@ public function testSetDecoratedServiceOnServiceHasParent() ->setDecoratedService('foo', 'foo_inner') ; - $this->assertEquals(array('foo', 'foo_inner'), $container->getDefinition('child1')->getDecoratedService()); + $this->assertEquals(array('foo', 'foo_inner', 0), $container->getDefinition('child1')->getDecoratedService()); } protected function process(ContainerBuilder $container) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index cffef3900802f..24ea6d6e91356 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -710,7 +710,7 @@ public function testThatCloningIsNotSupported() { $class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container'); $clone = $class->getMethod('__clone'); - if (PHP_VERSION_ID >= 540000) { + if (PHP_VERSION_ID >= 50400) { $this->assertFalse($class->isCloneable()); } $this->assertTrue($clone->isPrivate()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index d67f1d7224a20..e8df12295348f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -56,16 +56,23 @@ public function testSetGetClass() public function testSetGetDecoratedService() { + $def = new Definition('stdClass'); + $this->assertNull($def->getDecoratedService()); + $def->setDecoratedService('foo', 'foo.renamed', 5); + $this->assertEquals(array('foo', 'foo.renamed', 5), $def->getDecoratedService()); + $def->setDecoratedService(null); + $this->assertNull($def->getDecoratedService()); + $def = new Definition('stdClass'); $this->assertNull($def->getDecoratedService()); $def->setDecoratedService('foo', 'foo.renamed'); - $this->assertEquals(array('foo', 'foo.renamed'), $def->getDecoratedService()); + $this->assertEquals(array('foo', 'foo.renamed', 0), $def->getDecoratedService()); $def->setDecoratedService(null); $this->assertNull($def->getDecoratedService()); $def = new Definition('stdClass'); $def->setDecoratedService('foo'); - $this->assertEquals(array('foo', null), $def->getDecoratedService()); + $this->assertEquals(array('foo', null, 0), $def->getDecoratedService()); $def->setDecoratedService(null); $this->assertNull($def->getDecoratedService()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php index d9b65a43fe261..5d63e348e5de2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php @@ -10,7 +10,7 @@ $container = new ContainerBuilder(); $container - ->register('foo', 'Bar\FooClass') + ->register('foo', '\Bar\FooClass') ->addTag('foo', array('foo' => 'foo')) ->addTag('foo', array('bar' => 'bar', 'baz' => 'baz')) ->setFactory(array('Bar\\FooClass', 'getInstance')) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml index a1a320bd826d4..4595c668c73df 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml @@ -47,6 +47,7 @@ + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index 2186620045cc9..6a377c91d3fb8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -26,6 +26,10 @@ services: decorator_service_with_name: decorates: decorated decoration_inner_name: decorated.pif-pouf + decorator_service_with_name_and_priority: + decorates: decorated + decoration_inner_name: decorated.pif-pouf + decoration_priority: 5 new_factory1: { class: FooBarClass, factory: factory} new_factory2: { class: FooBarClass, factory: [@baz, getClass]} new_factory3: { class: FooBarClass, factory: [BazClass, getInstance]} diff --git a/src/Symfony/Component/DependencyInjection/Tests/LegacyDefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/LegacyDefinitionTest.php index b85d81f48153d..07891fff6dc5c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/LegacyDefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/LegacyDefinitionTest.php @@ -22,8 +22,8 @@ public function testSetGetFactoryClass() { $def = new Definition('stdClass'); $this->assertNull($def->getFactoryClass()); - $this->assertSame($def, $def->setFactoryClass('stdClass2'), "->setFactoryClass() implements a fluent interface."); - $this->assertEquals('stdClass2', $def->getFactoryClass(), "->getFactoryClass() returns current class to construct this service."); + $this->assertSame($def, $def->setFactoryClass('stdClass2'), '->setFactoryClass() implements a fluent interface.'); + $this->assertEquals('stdClass2', $def->getFactoryClass(), '->getFactoryClass() returns current class to construct this service.'); } public function testSetGetFactoryMethod() @@ -38,7 +38,7 @@ public function testSetGetFactoryService() { $def = new Definition('stdClass'); $this->assertNull($def->getFactoryService()); - $this->assertSame($def, $def->setFactoryService('foo.bar'), "->setFactoryService() implements a fluent interface."); - $this->assertEquals('foo.bar', $def->getFactoryService(), "->getFactoryService() returns current service to construct this service."); + $this->assertSame($def, $def->setFactoryService('foo.bar'), '->setFactoryService() implements a fluent interface.'); + $this->assertEquals('foo.bar', $def->getFactoryService(), '->getFactoryService() returns current service to construct this service.'); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 581dc675fb3fd..b717113bb436a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -242,8 +242,9 @@ public function testLoadServices() $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); - $this->assertEquals(array('decorated', null), $services['decorator_service']->getDecoratedService()); - $this->assertEquals(array('decorated', 'decorated.pif-pouf'), $services['decorator_service_with_name']->getDecoratedService()); + $this->assertEquals(array('decorated', null, 0), $services['decorator_service']->getDecoratedService()); + $this->assertEquals(array('decorated', 'decorated.pif-pouf', 0), $services['decorator_service_with_name']->getDecoratedService()); + $this->assertEquals(array('decorated', 'decorated.pif-pouf', 5), $services['decorator_service_with_name_and_priority']->getDecoratedService()); } public function testParsesTags() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 058f5b66dffd1..45f1cb496d08b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -171,8 +171,9 @@ public function testLoadServices() $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); - $this->assertEquals(array('decorated', null), $services['decorator_service']->getDecoratedService()); - $this->assertEquals(array('decorated', 'decorated.pif-pouf'), $services['decorator_service_with_name']->getDecoratedService()); + $this->assertEquals(array('decorated', null, 0), $services['decorator_service']->getDecoratedService()); + $this->assertEquals(array('decorated', 'decorated.pif-pouf', 0), $services['decorator_service_with_name']->getDecoratedService()); + $this->assertEquals(array('decorated', 'decorated.pif-pouf', 5), $services['decorator_service_with_name_and_priority']->getDecoratedService()); } public function testLoadFactoryShortSyntax() diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php index e6e7fea2f17a9..6d963dc054566 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php @@ -57,4 +57,13 @@ public function testAdd() $bag = new FrozenParameterBag(array()); $bag->add(array()); } + + /** + * @expectedException \LogicException + */ + public function testRemove() + { + $bag = new FrozenParameterBag(array('foo' => 'bar')); + $bag->remove('foo'); + } } diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index acf62e638faba..bf7ce5d55463d 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -355,7 +355,7 @@ public function offsetUnset($name) } /** - * Disables validation + * Disables validation. * * @return self */ diff --git a/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php index f9c7e0e8bef3f..199d2c00715b3 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php @@ -135,7 +135,7 @@ public function testDispatchForClosure() { $invoked = 0; $listener = function () use (&$invoked) { - $invoked++; + ++$invoked; }; $this->dispatcher->addListener('pre.foo', $listener); $this->dispatcher->addListener('post.foo', $listener); diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index 24e60024ff041..4aa6226e49297 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -110,8 +110,8 @@ public function testLogger() $tdispatcher->addListener('foo', $listener1 = function () {; }); $tdispatcher->addListener('foo', $listener2 = function () {; }); - $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); - $logger->expects($this->at(1))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); + $logger->expects($this->at(0))->method('debug')->with('Notified event "foo" to listener "closure".'); + $logger->expects($this->at(1))->method('debug')->with('Notified event "foo" to listener "closure".'); $tdispatcher->dispatch('foo'); } @@ -125,9 +125,9 @@ public function testLoggerWithStoppedEvent() $tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); }); $tdispatcher->addListener('foo', $listener2 = function () {; }); - $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); - $logger->expects($this->at(1))->method('debug')->with("Listener \"closure\" stopped propagation of the event \"foo\"."); - $logger->expects($this->at(2))->method('debug')->with("Listener \"closure\" was not called for event \"foo\"."); + $logger->expects($this->at(0))->method('debug')->with('Notified event "foo" to listener "closure".'); + $logger->expects($this->at(1))->method('debug')->with('Listener "closure" stopped propagation of the event "foo".'); + $logger->expects($this->at(2))->method('debug')->with('Listener "closure" was not called for event "foo".'); $tdispatcher->dispatch('foo'); } diff --git a/src/Symfony/Component/ExpressionLanguage/Parser.php b/src/Symfony/Component/ExpressionLanguage/Parser.php index 8d06c225859bb..e761898423da3 100644 --- a/src/Symfony/Component/ExpressionLanguage/Parser.php +++ b/src/Symfony/Component/ExpressionLanguage/Parser.php @@ -43,32 +43,32 @@ public function __construct(array $functions) '+' => array('precedence' => 500), ); $this->binaryOperators = array( - 'or' => array('precedence' => 10, 'associativity' => Parser::OPERATOR_LEFT), - '||' => array('precedence' => 10, 'associativity' => Parser::OPERATOR_LEFT), - 'and' => array('precedence' => 15, 'associativity' => Parser::OPERATOR_LEFT), - '&&' => array('precedence' => 15, 'associativity' => Parser::OPERATOR_LEFT), - '|' => array('precedence' => 16, 'associativity' => Parser::OPERATOR_LEFT), - '^' => array('precedence' => 17, 'associativity' => Parser::OPERATOR_LEFT), - '&' => array('precedence' => 18, 'associativity' => Parser::OPERATOR_LEFT), - '==' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '===' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '!=' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '!==' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '<' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '>' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '>=' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '<=' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - 'not in' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - 'in' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - 'matches' => array('precedence' => 20, 'associativity' => Parser::OPERATOR_LEFT), - '..' => array('precedence' => 25, 'associativity' => Parser::OPERATOR_LEFT), - '+' => array('precedence' => 30, 'associativity' => Parser::OPERATOR_LEFT), - '-' => array('precedence' => 30, 'associativity' => Parser::OPERATOR_LEFT), - '~' => array('precedence' => 40, 'associativity' => Parser::OPERATOR_LEFT), - '*' => array('precedence' => 60, 'associativity' => Parser::OPERATOR_LEFT), - '/' => array('precedence' => 60, 'associativity' => Parser::OPERATOR_LEFT), - '%' => array('precedence' => 60, 'associativity' => Parser::OPERATOR_LEFT), - '**' => array('precedence' => 200, 'associativity' => Parser::OPERATOR_RIGHT), + 'or' => array('precedence' => 10, 'associativity' => self::OPERATOR_LEFT), + '||' => array('precedence' => 10, 'associativity' => self::OPERATOR_LEFT), + 'and' => array('precedence' => 15, 'associativity' => self::OPERATOR_LEFT), + '&&' => array('precedence' => 15, 'associativity' => self::OPERATOR_LEFT), + '|' => array('precedence' => 16, 'associativity' => self::OPERATOR_LEFT), + '^' => array('precedence' => 17, 'associativity' => self::OPERATOR_LEFT), + '&' => array('precedence' => 18, 'associativity' => self::OPERATOR_LEFT), + '==' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '===' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '!=' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '!==' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '<' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '>' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '>=' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '<=' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + 'not in' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + 'in' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + 'matches' => array('precedence' => 20, 'associativity' => self::OPERATOR_LEFT), + '..' => array('precedence' => 25, 'associativity' => self::OPERATOR_LEFT), + '+' => array('precedence' => 30, 'associativity' => self::OPERATOR_LEFT), + '-' => array('precedence' => 30, 'associativity' => self::OPERATOR_LEFT), + '~' => array('precedence' => 40, 'associativity' => self::OPERATOR_LEFT), + '*' => array('precedence' => 60, 'associativity' => self::OPERATOR_LEFT), + '/' => array('precedence' => 60, 'associativity' => self::OPERATOR_LEFT), + '%' => array('precedence' => 60, 'associativity' => self::OPERATOR_LEFT), + '**' => array('precedence' => 200, 'associativity' => self::OPERATOR_RIGHT), ); } diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index 8516273a661d1..ac9599769fa9c 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/src/Symfony/Component/ExpressionLanguage/TokenStream.php @@ -71,7 +71,7 @@ public function expect($type, $value = null, $message = null) } /** - * Checks if end of stream was reached + * Checks if end of stream was reached. * * @return bool */ diff --git a/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php b/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php index 15533db408966..bcc8fe81fcef4 100644 --- a/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php +++ b/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Filesystem\Exception; /** - * Exception class thrown when a file couldn't be found + * Exception class thrown when a file couldn't be found. * * @author Fabien Potencier * @author Christian Gärtner diff --git a/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php b/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php index c88c763173c4a..35350587633d0 100644 --- a/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php +++ b/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php @@ -19,7 +19,7 @@ interface IOExceptionInterface extends ExceptionInterface { /** - * Returns the associated path for the exception + * Returns the associated path for the exception. * * @return string The path. */ diff --git a/src/Symfony/Component/Filesystem/LockHandler.php b/src/Symfony/Component/Filesystem/LockHandler.php index 59d35ec92883e..fa2575f9110d7 100644 --- a/src/Symfony/Component/Filesystem/LockHandler.php +++ b/src/Symfony/Component/Filesystem/LockHandler.php @@ -32,8 +32,9 @@ class LockHandler private $handle; /** - * @param string $name The lock name - * @param string|null $lockPath The directory to store the lock. Default values will use temporary directory + * @param string $name The lock name + * @param string|null $lockPath The directory to store the lock. Default values will use temporary directory + * * @throws IOException If the lock directory could not be created or is not writable */ public function __construct($name, $lockPath = null) @@ -53,10 +54,12 @@ public function __construct($name, $lockPath = null) } /** - * Lock the resource + * Lock the resource. + * + * @param bool $blocking wait until the lock is released + * + * @return bool Returns true if the lock was acquired, false otherwise * - * @param bool $blocking wait until the lock is released - * @return bool Returns true if the lock was acquired, false otherwise * @throws IOException If the lock file could not be created or opened */ public function lock($blocking = false) @@ -98,7 +101,7 @@ public function lock($blocking = false) } /** - * Release the resource + * Release the resource. */ public function release() { diff --git a/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php b/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php index 8c6c0064cda92..f967cdaa54aed 100644 --- a/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php +++ b/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php @@ -133,7 +133,7 @@ public function testGetMissingLabelException() public function testErrorHandler() { $cmd = Command::create(); - $handler = function() { return 'error-handler'; }; + $handler = function () { return 'error-handler'; }; $cmd->setErrorHandler($handler); $this->assertSame($handler, $cmd->getErrorHandler()); diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php index a2eef508f315a..2233a83a416bd 100644 --- a/src/Symfony/Component/Form/AbstractExtension.php +++ b/src/Symfony/Component/Form/AbstractExtension.php @@ -156,7 +156,15 @@ private function initTypes() throw new UnexpectedTypeException($type, 'Symfony\Component\Form\FormTypeInterface'); } - $this->types[$type->getName()] = $type; + // Since Symfony 3.0 types are identified by their FQCN + $fqcn = get_class($type); + $legacyName = $type->getName(); + + $this->types[$fqcn] = $type; + + if ($legacyName) { + $this->types[$legacyName] = $type; + } } } diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component/Form/AbstractType.php index 1e74d99e4937e..1c56677c05c15 100644 --- a/src/Symfony/Component/Form/AbstractType.php +++ b/src/Symfony/Component/Form/AbstractType.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Form; +use Symfony\Component\Form\Util\StringUtil; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; @@ -61,11 +62,37 @@ public function configureOptions(OptionsResolver $resolver) { } + /** + * {@inheritdoc} + */ + public function getName() + { + // As of Symfony 2.8, the name defaults to the fully-qualified class name + return get_class($this); + } + + /** + * Returns the prefix of the template block name for this type. + * + * The block prefixes default to the underscored short class name with + * the "Type" suffix removed (e.g. "UserProfileType" => "user_profile"). + * + * @return string The prefix of the template block name + */ + public function getBlockPrefix() + { + $fqcn = get_class($this); + $name = $this->getName(); + + // For BC: Use the name as block prefix if one is set + return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn); + } + /** * {@inheritdoc} */ public function getParent() { - return 'form'; + return 'Symfony\Component\Form\Extension\Core\Type\FormType'; } } diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index 00f5611d938e9..1fa5ec25a7925 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -336,8 +336,6 @@ public function isSynchronized() /** * Unsupported method. - * - * @return null Always returns null */ public function getTransformationFailure() { diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php index 0251d01ac88e8..072ce59d3a0d0 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php @@ -84,7 +84,7 @@ public function getDecoratedFactory() */ public function createListFromChoices($choices, $value = null) { - if (is_string($value)) { + if (is_string($value) && !is_callable($value)) { $value = new PropertyPath($value); } @@ -134,7 +134,7 @@ public function createListFromFlippedChoices($choices, $value = null) */ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null) { - if (is_string($value)) { + if (is_string($value) && !is_callable($value)) { $value = new PropertyPath($value); } @@ -151,12 +151,12 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul /** * {@inheritdoc} * - * @param ChoiceListInterface $list The choice list - * @param null|array|callable|string|PropertyPath $preferredChoices The preferred choices - * @param null|callable|string|PropertyPath $label The callable or path generating the choice labels - * @param null|callable|string|PropertyPath $index The callable or path generating the view indices - * @param null|array|\Traversable|callable|string|PropertyPath $groupBy The callable or path generating the group names - * @param null|array|callable|string|PropertyPath $attr The callable or path generating the HTML attributes + * @param ChoiceListInterface $list The choice list + * @param null|array|callable|string|PropertyPath $preferredChoices The preferred choices + * @param null|callable|string|PropertyPath $label The callable or path generating the choice labels + * @param null|callable|string|PropertyPath $index The callable or path generating the view indices + * @param null|callable|string|PropertyPath $groupBy The callable or path generating the group names + * @param null|array|callable|string|PropertyPath $attr The callable or path generating the HTML attributes * * @return ChoiceListView The choice list view */ @@ -164,7 +164,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, { $accessor = $this->propertyAccessor; - if (is_string($label)) { + if (is_string($label) && !is_callable($label)) { $label = new PropertyPath($label); } @@ -174,7 +174,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, }; } - if (is_string($preferredChoices)) { + if (is_string($preferredChoices) && !is_callable($preferredChoices)) { $preferredChoices = new PropertyPath($preferredChoices); } @@ -189,7 +189,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, }; } - if (is_string($index)) { + if (is_string($index) && !is_callable($index)) { $index = new PropertyPath($index); } @@ -199,7 +199,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, }; } - if (is_string($groupBy)) { + if (is_string($groupBy) && !is_callable($groupBy)) { $groupBy = new PropertyPath($groupBy); } @@ -213,7 +213,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, }; } - if (is_string($attr)) { + if (is_string($attr) && !is_callable($attr)) { $attr = new PropertyPath($attr); } diff --git a/src/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.php b/src/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.php index 9171fe3f1653c..573cc2d6e3c07 100644 --- a/src/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.php +++ b/src/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.php @@ -48,9 +48,9 @@ public function loadChoiceList($value = null); * The callable receives the choice as first and the array key as the second * argument. * - * @param string[] $values An array of choice values. Non-existing - * values in this array are ignored - * @param null|callable $value The callable generating the choice values + * @param string[] $values An array of choice values. Non-existing + * values in this array are ignored + * @param null|callable $value The callable generating the choice values * * @return array An array of choices */ @@ -66,9 +66,9 @@ public function loadChoicesForValues(array $values, $value = null); * The callable receives the choice as first and the array key as the second * argument. * - * @param array $choices An array of choices. Non-existing choices in - * this array are ignored - * @param null|callable $value The callable generating the choice values + * @param array $choices An array of choices. Non-existing choices in + * this array are ignored + * @param null|callable $value The callable generating the choice values * * @return string[] An array of choice values */ diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php index 8e59620369692..05d753330626f 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceGroupView.php @@ -19,14 +19,14 @@ class ChoiceGroupView implements \IteratorAggregate { /** - * The label of the group + * The label of the group. * * @var string */ public $label; /** - * The choice views in the group + * The choice views in the group. * * @var ChoiceGroupView[]|ChoiceView[] */ @@ -35,7 +35,7 @@ class ChoiceGroupView implements \IteratorAggregate /** * Creates a new choice group view. * - * @param string $label The label of the group. + * @param string $label The label of the group. * @param ChoiceGroupView[]|ChoiceView[] $choices The choice views in the * group. */ diff --git a/src/Symfony/Component/Form/Deprecated/FormEvents.php b/src/Symfony/Component/Form/Deprecated/FormEvents.php index 2d891ed32e3ed..e20edfa52174b 100644 --- a/src/Symfony/Component/Form/Deprecated/FormEvents.php +++ b/src/Symfony/Component/Form/Deprecated/FormEvents.php @@ -15,6 +15,7 @@ /** * @deprecated since version 2.7, to be removed in 3.0. + * * @internal */ final class FormEvents diff --git a/src/Symfony/Component/Form/Extension/Core/DataMapper/CheckboxListMapper.php b/src/Symfony/Component/Form/Extension/Core/DataMapper/CheckboxListMapper.php index d87196475fec2..b1169ceafa8c3 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataMapper/CheckboxListMapper.php +++ b/src/Symfony/Component/Form/Extension/Core/DataMapper/CheckboxListMapper.php @@ -13,7 +13,6 @@ use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\DataMapperInterface; -use Symfony\Component\Form\Exception; use Symfony\Component\Form\Exception\TransformationFailedException; /** diff --git a/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php b/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php index c0e30f303452a..b36a67f36b0f7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php @@ -15,6 +15,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; +use Symfony\Component\Form\Util\StringUtil; use Symfony\Component\OptionsResolver\OptionsResolver; /** @@ -77,7 +78,17 @@ public function buildView(FormView $view, FormInterface $form, array $options) $blockPrefixes = array(); for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) { - array_unshift($blockPrefixes, $type->getName()); + if (method_exists($type, 'getBlockPrefix')) { + array_unshift($blockPrefixes, $type->getBlockPrefix()); + } else { + @trigger_error(get_class($type).': The ResolvedFormTypeInterface::getBlockPrefix() method will be added in version 3.0. You should add it to your implementation.', E_USER_DEPRECATED); + + $fqcn = get_class($type->getInnerType()); + $name = $type->getName(); + $hasCustomName = $name !== $fqcn; + + array_unshift($blockPrefixes, $hasCustomName ? $name : StringUtil::fqcnToBlockPrefix($fqcn)); + } } $blockPrefixes[] = $uniqueBlockPrefix; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php index 057ec54d8c6ca..3548a609fea46 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php @@ -31,13 +31,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'date'; + return __NAMESPACE__.'\DateType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'birthday'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php b/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php index 7456adc93dd97..9e58b80245615 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php @@ -32,6 +32,14 @@ public function getParent() * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'button'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php b/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php index 53a5e05275735..ddf7a5e5fcdbd 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php @@ -66,6 +66,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'checkbox'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 5015edbed4a29..a1207839bb924 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -363,6 +363,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'choice'; } @@ -427,12 +435,12 @@ private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $ch ); if ($options['multiple']) { - $choiceType = 'checkbox'; + $choiceType = __NAMESPACE__.'\CheckboxType'; // The user can check 0 or more checkboxes. If required // is true, he is required to check all of them. $choiceOpts['required'] = false; } else { - $choiceType = 'radio'; + $choiceType = __NAMESPACE__.'\RadioType'; } $builder->add($name, $choiceType, $choiceOpts); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php index 32001e81bdc6a..508013b312ed3 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php @@ -88,7 +88,7 @@ public function configureOptions(OptionsResolver $resolver) 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', - 'type' => 'text', + 'type' => __NAMESPACE__.'\TextType', 'options' => array(), 'delete_empty' => false, )); @@ -100,6 +100,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'collection'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php index 30ee0a0f9e89c..45da8d509a56a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php @@ -33,13 +33,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'choice'; + return __NAMESPACE__.'\ChoiceType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'country'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php index b473d139e6566..7a26316e01a47 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php @@ -33,13 +33,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'choice'; + return __NAMESPACE__.'\ChoiceType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'currency'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 24fa3e5424615..cddeac9b4dc28 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -161,8 +161,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'time' => $timeParts, )), ))) - ->add('date', 'date', $dateOptions) - ->add('time', 'time', $timeOptions) + ->add('date', __NAMESPACE__.'\DateType', $dateOptions) + ->add('time', __NAMESPACE__.'\TimeType', $timeOptions) ; } @@ -284,6 +284,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'datetime'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 9c567d76e2c01..59500c89155c8 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -37,6 +37,11 @@ class DateType extends AbstractType \IntlDateFormatter::SHORT, ); + private static $widgets = array( + 'text' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'choice' => 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', + ); + /** * {@inheritdoc} */ @@ -101,9 +106,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) } $builder - ->add('year', $options['widget'], $yearOptions) - ->add('month', $options['widget'], $monthOptions) - ->add('day', $options['widget'], $dayOptions) + ->add('year', self::$widgets[$options['widget']], $yearOptions) + ->add('month', self::$widgets[$options['widget']], $monthOptions) + ->add('day', self::$widgets[$options['widget']], $dayOptions) ->addViewTransformer(new DateTimeToArrayTransformer( $options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day') )) @@ -253,6 +258,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'date'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php b/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php index 26652ef6603b2..019a09e0e1c3e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php @@ -20,13 +20,21 @@ class EmailType extends AbstractType */ public function getParent() { - return 'text'; + return __NAMESPACE__.'\TextType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'email'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index bc24899de5cb0..6c67b8dc4b595 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -61,6 +61,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'file'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index 9d5be03bf6e59..734c56b0eb1d8 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -244,6 +244,14 @@ public function getParent() * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'form'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php b/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php index 37b25435e1842..5287bb7c1db0f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php @@ -34,6 +34,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'hidden'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php b/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php index 512844f43a037..8e790793b96ed 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php @@ -73,6 +73,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'integer'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php index 9d071eb8b03ee..6fc6031af11c2 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php @@ -33,13 +33,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'choice'; + return __NAMESPACE__.'\ChoiceType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'language'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php index f09f5a62f1e29..a6d42f8c917ee 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php @@ -33,13 +33,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'choice'; + return __NAMESPACE__.'\ChoiceType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'locale'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php b/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php index 267fe9eaf636c..788f9460f5c36 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php @@ -78,6 +78,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'money'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php b/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php index b53961a81a404..7794349ae2adb 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php @@ -71,6 +71,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'number'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php b/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php index 611eb4d4a3004..2aa1808972b5a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php @@ -44,13 +44,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'text'; + return __NAMESPACE__.'\TextType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'password'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php b/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php index ff8beff72bc26..1fbad1aaa0d35 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php @@ -62,6 +62,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'percent'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php b/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php index dfa7c7d53bd5f..43110d99697e0 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php @@ -20,13 +20,21 @@ class RadioType extends AbstractType */ public function getParent() { - return 'checkbox'; + return __NAMESPACE__.'\CheckboxType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'radio'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php b/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php index 78909e643f5a7..b70926f354edc 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php @@ -20,13 +20,21 @@ class RangeType extends AbstractType */ public function getParent() { - return 'text'; + return __NAMESPACE__.'\TextType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'range'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php b/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php index 950dc740056b0..f46dba7f7af32 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php @@ -47,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'type' => 'text', + 'type' => __NAMESPACE__.'\TextType', 'options' => array(), 'first_options' => array(), 'second_options' => array(), @@ -65,6 +65,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'repeated'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php b/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php index cf55f7c5910a1..6d8421355d52f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php @@ -26,13 +26,21 @@ class ResetType extends AbstractType implements ButtonTypeInterface */ public function getParent() { - return 'button'; + return __NAMESPACE__.'\ButtonType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'reset'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php b/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php index bf82972d56bc2..a5148740ce84f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php @@ -20,13 +20,21 @@ class SearchType extends AbstractType */ public function getParent() { - return 'text'; + return __NAMESPACE__.'\TextType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'search'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php b/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php index 6d160b969214b..d102fc9579114 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php @@ -33,13 +33,21 @@ public function buildView(FormView $view, FormInterface $form, array $options) */ public function getParent() { - return 'button'; + return __NAMESPACE__.'\ButtonType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'submit'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextType.php index 4aef1cd6e6218..86df235385435 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TextType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TextType.php @@ -30,6 +30,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'text'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php index 0e749b155433a..9bbd9b5671c39 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php @@ -30,13 +30,21 @@ public function buildView(FormView $view, FormInterface $form, array $options) */ public function getParent() { - return 'text'; + return __NAMESPACE__.'\TextType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'textarea'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index 49f77c5bd1d66..d4803d03e7699 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -25,6 +25,11 @@ class TimeType extends AbstractType { + private static $widgets = array( + 'text' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + 'choice' => 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', + ); + /** * {@inheritdoc} */ @@ -99,14 +104,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) } } - $builder->add('hour', $options['widget'], $hourOptions); + $builder->add('hour', self::$widgets[$options['widget']], $hourOptions); if ($options['with_minutes']) { - $builder->add('minute', $options['widget'], $minuteOptions); + $builder->add('minute', self::$widgets[$options['widget']], $minuteOptions); } if ($options['with_seconds']) { - $builder->add('second', $options['widget'], $secondOptions); + $builder->add('second', self::$widgets[$options['widget']], $secondOptions); } $builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget'])); @@ -238,6 +243,14 @@ public function configureOptions(OptionsResolver $resolver) * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'time'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index 82c07e2f121ba..3277a1838636c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -39,13 +39,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'choice'; + return __NAMESPACE__.'\ChoiceType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'timezone'; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php b/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php index 3b087e1865c17..a723a90a27b67 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php @@ -43,13 +43,21 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'text'; + return __NAMESPACE__.'\TextType'; } /** * {@inheritdoc} */ public function getName() + { + return $this->getBlockPrefix(); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() { return 'url'; } diff --git a/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php b/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php index 5e6ff5823bb2d..576d9eba2cbce 100644 --- a/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php +++ b/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php @@ -13,7 +13,7 @@ @trigger_error('The '.__NAMESPACE__.'\ChoiceView class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED); -/** +/* * Represents a choice in templates. * * @author Bernhard Schussek diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php index 4f3d985529af4..2a55069692f8a 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php @@ -22,6 +22,7 @@ * is expected. * * @since 2.4 + * * @author Bernhard Schussek * * @deprecated since version 2.4, to be removed in 3.0. diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php index cf744ac014f4b..b246a616b03ed 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php @@ -18,6 +18,7 @@ * Adapter for using the new token generator with the old interface. * * @since 2.4 + * * @author Bernhard Schussek * * @deprecated since version 2.4, to be removed in 3.0. diff --git a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php index 35d8648215855..cf5038ae1f6cd 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php +++ b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php @@ -108,7 +108,7 @@ public function finishView(FormView $view, FormInterface $form, array $options) $tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: get_class($form->getConfig()->getType()->getInnerType())); $data = (string) $options['csrf_token_manager']->getToken($tokenId); - $csrfForm = $factory->createNamed($options['csrf_field_name'], 'hidden', $data, array( + $csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, array( 'mapped' => false, )); @@ -153,6 +153,6 @@ public function configureOptions(OptionsResolver $resolver) */ public function getExtendedType() { - return 'form'; + return 'Symfony\Component\Form\Extension\Core\Type\FormType'; } } diff --git a/src/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php b/src/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php index fbdef26ed62cb..70b347fa9af3a 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php @@ -18,6 +18,7 @@ * Extension for collecting data of the forms on a page. * * @since 2.4 + * * @author Robert Schönthal * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php b/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php index 6419af477844d..8fd70f09b1796 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php @@ -21,6 +21,7 @@ * and {@link FormEvents::POST_SUBMIT} events. * * @since 2.4 + * * @author Bernhard Schussek */ class DataCollectorListener implements EventSubscriberInterface diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php index ddfb3400cbdfc..4fb08772d7de4 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php @@ -21,6 +21,7 @@ * Data collector for {@link FormInterface} instances. * * @since 2.4 + * * @author Robert Schönthal * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php index db7c0f0803706..a57693a995241 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php @@ -19,6 +19,7 @@ * Collects and structures information about forms. * * @since 2.4 + * * @author Bernhard Schussek */ interface FormDataCollectorInterface extends DataCollectorInterface diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php index 0ae5560afeab1..1c678ac665d09 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php @@ -20,6 +20,7 @@ * Default implementation of {@link FormDataExtractorInterface}. * * @since 2.4 + * * @author Bernhard Schussek */ class FormDataExtractor implements FormDataExtractorInterface diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php index d47496552d0d0..a5bb7d0ef30a1 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php @@ -18,6 +18,7 @@ * Extracts arrays of information out of forms. * * @since 2.4 + * * @author Bernhard Schussek */ interface FormDataExtractorInterface diff --git a/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php b/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php index 960048a0c2ee6..65430f1d222b0 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php @@ -22,6 +22,7 @@ * Proxy that invokes a data collector when creating a form and its view. * * @since 2.4 + * * @author Bernhard Schussek */ class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface @@ -50,6 +51,14 @@ public function getName() return $this->proxiedType->getName(); } + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return method_exists($this->proxiedType, 'getBlockPrefix') ? $this->proxiedType->getBlockPrefix() : $this->getName(); + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php b/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php index c2cb3a03469fe..f5f4ed2e2095c 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php @@ -21,6 +21,7 @@ * instances. * * @since 2.4 + * * @author Bernhard Schussek */ class ResolvedTypeFactoryDataCollectorProxy implements ResolvedFormTypeFactoryInterface diff --git a/src/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php b/src/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php index 2c6ddfe3e5b59..55918d7c1e2f6 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php @@ -20,6 +20,7 @@ * Type extension for collecting data of a form with this type. * * @since 2.4 + * * @author Robert Schönthal * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index 685e8cf2996d5..2c3730c46d8ec 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -22,17 +22,19 @@ class DependencyInjectionExtension implements FormExtensionInterface private $typeServiceIds; private $typeExtensionServiceIds; private $guesserServiceIds; + private $legacyNames; private $guesser; private $guesserLoaded = false; public function __construct(ContainerInterface $container, array $typeServiceIds, array $typeExtensionServiceIds, - array $guesserServiceIds) + array $guesserServiceIds, array $legacyNames = array()) { $this->container = $container; $this->typeServiceIds = $typeServiceIds; $this->typeExtensionServiceIds = $typeExtensionServiceIds; $this->guesserServiceIds = $guesserServiceIds; + $this->legacyNames = $legacyNames; } public function getType($name) @@ -41,15 +43,21 @@ public function getType($name) throw new InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name)); } + if (isset($this->legacyNames[$name])) { + @trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); + } + $type = $this->container->get($this->typeServiceIds[$name]); - if ($type->getName() !== $name) { + // BC: validate result of getName() for legacy names (non-FQCN) + if (isset($this->legacyNames[$name]) && $type->getName() !== $name) { throw new InvalidArgumentException( sprintf('The type name specified for the service "%s" does not match the actual name. Expected "%s", given "%s"', $this->typeServiceIds[$name], $name, $type->getName() - )); + ) + ); } return $type; @@ -57,11 +65,23 @@ public function getType($name) public function hasType($name) { - return isset($this->typeServiceIds[$name]); + if (isset($this->typeServiceIds[$name])) { + if (isset($this->legacyNames[$name])) { + @trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); + } + + return true; + } + + return false; } public function getTypeExtensions($name) { + if (isset($this->legacyNames[$name])) { + @trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); + } + $extensions = array(); if (isset($this->typeExtensionServiceIds[$name])) { @@ -75,6 +95,10 @@ public function getTypeExtensions($name) public function hasTypeExtensions($name) { + if (isset($this->legacyNames[$name])) { + @trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); + } + return isset($this->typeExtensionServiceIds[$name]); } diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php index 97c0d67997ece..066a3d9eec3f7 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php @@ -94,6 +94,6 @@ public function configureOptions(OptionsResolver $resolver) */ public function getExtendedType() { - return 'form'; + return 'Symfony\Component\Form\Extension\Core\Type\FormType'; } } diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php index 3eacceae63224..ff27fbdb474fe 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php @@ -40,6 +40,6 @@ public function configureOptions(OptionsResolver $resolver) */ public function getExtendedType() { - return 'repeated'; + return 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'; } } diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php index ff1c762ef072d..fa844eb1331ad 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php @@ -21,6 +21,6 @@ class SubmitTypeValidatorExtension extends BaseValidatorExtension */ public function getExtendedType() { - return 'submit'; + return 'Symfony\Component\Form\Extension\Core\Type\SubmitType'; } } diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php index 8a9a75074feda..e7ed95c459d03 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php @@ -50,7 +50,7 @@ public function __construct($validator) // the DIC, where the XML file is loaded automatically. Thus the following // code must be kept synchronized with validation.xml - /** @var $metadata ClassMetadata */ + /* @var $metadata ClassMetadata */ $metadata->addConstraint(new Form()); $metadata->addPropertyConstraint('children', new Valid()); diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 81c9ad5f6d680..b4dd78c105be3 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -99,7 +99,7 @@ public function create($name, $type = null, array $options = array()) } if (null === $type && null === $this->getDataClass()) { - $type = 'text'; + $type = 'Symfony\Component\Form\Extension\Core\Type\TextType'; } if (null !== $type) { diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php index 76e2938904df9..7ee2df26b4bf7 100644 --- a/src/Symfony/Component/Form/FormErrorIterator.php +++ b/src/Symfony/Component/Form/FormErrorIterator.php @@ -87,7 +87,7 @@ public function __toString() if ($error instanceof FormError) { $string .= 'ERROR: '.$error->getMessage()."\n"; } else { - /** @var $error FormErrorIterator */ + /* @var $error FormErrorIterator */ $string .= $error->form->getName().":\n"; $string .= self::indent((string) $error); } diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index cfca4588bd8b1..a88fd0d176502 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form; use Symfony\Component\Form\Exception\UnexpectedTypeException; +use Symfony\Component\Form\Util\StringUtil; class FormFactory implements FormFactoryInterface { @@ -34,7 +35,7 @@ public function __construct(FormRegistryInterface $registry, ResolvedFormTypeFac /** * {@inheritdoc} */ - public function create($type = 'form', $data = null, array $options = array()) + public function create($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()) { return $this->createBuilder($type, $data, $options)->getForm(); } @@ -42,7 +43,7 @@ public function create($type = 'form', $data = null, array $options = array()) /** * {@inheritdoc} */ - public function createNamed($name, $type = 'form', $data = null, array $options = array()) + public function createNamed($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()) { return $this->createNamedBuilder($name, $type, $data, $options)->getForm(); } @@ -58,11 +59,37 @@ public function createForProperty($class, $property, $data = null, array $option /** * {@inheritdoc} */ - public function createBuilder($type = 'form', $data = null, array $options = array()) + public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()) { - $name = $type instanceof FormTypeInterface || $type instanceof ResolvedFormTypeInterface - ? $type->getName() - : $type; + $name = null; + $typeName = null; + + if ($type instanceof ResolvedFormTypeInterface) { + if (method_exists($type, 'getBlockPrefix')) { + // As of Symfony 3.0, the block prefix of the type is used as + // default name + $name = $type->getBlockPrefix(); + } else { + // BC + $typeName = $type->getName(); + } + } elseif ($type instanceof FormTypeInterface) { + // BC + $typeName = $type->getName(); + } else { + // BC + $typeName = $type; + } + + if (null === $name) { + if (false === strpos($typeName, '\\')) { + // No FQCN - leave unchanged for BC + $name = $typeName; + } else { + // FQCN + $name = StringUtil::fqcnToBlockPrefix($typeName); + } + } return $this->createNamedBuilder($name, $type, $data, $options); } @@ -70,17 +97,20 @@ public function createBuilder($type = 'form', $data = null, array $options = arr /** * {@inheritdoc} */ - public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array()) + public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()) { if (null !== $data && !array_key_exists('data', $options)) { $options['data'] = $data; } if ($type instanceof FormTypeInterface) { + @trigger_error('Passing type instances to FormBuilder::add(), Form::add() or the FormFactory is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); $type = $this->resolveType($type); } elseif (is_string($type)) { $type = $this->registry->getType($type); - } elseif (!$type instanceof ResolvedFormTypeInterface) { + } elseif ($type instanceof ResolvedFormTypeInterface) { + @trigger_error('Passing type instances to FormBuilder::add(), Form::add() or the FormFactory is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); + } else { throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface'); } @@ -99,7 +129,7 @@ public function createNamedBuilder($name, $type = 'form', $data = null, array $o public function createBuilderForProperty($class, $property, $data = null, array $options = array()) { if (null === $guesser = $this->registry->getTypeGuesser()) { - return $this->createNamedBuilder($property, 'text', $data, $options); + return $this->createNamedBuilder($property, 'Symfony\Component\Form\Extension\Core\Type\TextType', $data, $options); } $typeGuess = $guesser->guessType($class, $property); @@ -107,7 +137,7 @@ public function createBuilderForProperty($class, $property, $data = null, array $requiredGuess = $guesser->guessRequired($class, $property); $patternGuess = $guesser->guessPattern($class, $property); - $type = $typeGuess ? $typeGuess->getType() : 'text'; + $type = $typeGuess ? $typeGuess->getType() : 'Symfony\Component\Form\Extension\Core\Type\TextType'; $maxLength = $maxLengthGuess ? $maxLengthGuess->getValue() : null; $pattern = $patternGuess ? $patternGuess->getValue() : null; diff --git a/src/Symfony/Component/Form/FormFactoryBuilder.php b/src/Symfony/Component/Form/FormFactoryBuilder.php index a5bf5b38fdbce..64021eac7a573 100644 --- a/src/Symfony/Component/Form/FormFactoryBuilder.php +++ b/src/Symfony/Component/Form/FormFactoryBuilder.php @@ -78,7 +78,7 @@ public function addExtensions(array $extensions) */ public function addType(FormTypeInterface $type) { - $this->types[$type->getName()] = $type; + $this->types[] = $type; return $this; } @@ -89,7 +89,7 @@ public function addType(FormTypeInterface $type) public function addTypes(array $types) { foreach ($types as $type) { - $this->types[$type->getName()] = $type; + $this->types[] = $type; } return $this; diff --git a/src/Symfony/Component/Form/FormFactoryInterface.php b/src/Symfony/Component/Form/FormFactoryInterface.php index 220b470496551..b7e95cb01eb4d 100644 --- a/src/Symfony/Component/Form/FormFactoryInterface.php +++ b/src/Symfony/Component/Form/FormFactoryInterface.php @@ -29,7 +29,7 @@ interface FormFactoryInterface * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type */ - public function create($type = 'form', $data = null, array $options = array()); + public function create($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()); /** * Returns a form. @@ -45,7 +45,7 @@ public function create($type = 'form', $data = null, array $options = array()); * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type */ - public function createNamed($name, $type = 'form', $data = null, array $options = array()); + public function createNamed($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()); /** * Returns a form for a property of a class. @@ -74,7 +74,7 @@ public function createForProperty($class, $property, $data = null, array $option * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type */ - public function createBuilder($type = 'form', $data = null, array $options = array()); + public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()); /** * Returns a form builder. @@ -88,7 +88,7 @@ public function createBuilder($type = 'form', $data = null, array $options = arr * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type */ - public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array()); + public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array()); /** * Returns a form builder for a property of a class. diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index 0dc21df2bcaa0..e9809edcdc2ca 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -34,6 +34,11 @@ class FormRegistry implements FormRegistryInterface */ private $types = array(); + /** + * @var string[] + */ + private $legacyNames = array(); + /** * @var FormTypeGuesserInterface|false|null */ @@ -84,12 +89,21 @@ public function getType($name) } if (!$type) { - throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name)); + // Support fully-qualified class names + if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) { + $type = new $name(); + } else { + throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name)); + } } $this->resolveAndAddType($type); } + if (isset($this->legacyNames[$name])) { + @trigger_error(sprintf('Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "%s" instead.', $name, get_class($this->types[$name]->getInnerType())), E_USER_DEPRECATED); + } + return $this->types[$name]; } @@ -103,27 +117,52 @@ public function getType($name) */ private function resolveAndAddType(FormTypeInterface $type) { + $typeExtensions = array(); $parentType = $type->getParent(); + $fqcn = get_class($type); + $name = $type->getName(); + $hasCustomName = $name !== $fqcn; if ($parentType instanceof FormTypeInterface) { + @trigger_error('Returning a FormTypeInterface from FormTypeInterface::getParent() is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); + $this->resolveAndAddType($parentType); $parentType = $parentType->getName(); } - $typeExtensions = array(); + if ($hasCustomName) { + foreach ($this->extensions as $extension) { + $typeExtensions = array_merge( + $typeExtensions, + $extension->getTypeExtensions($name) + ); + } + + if ($typeExtensions) { + @trigger_error('Returning a type name from FormTypeExtensionInterface::getExtendedType() is deprecated since version 2.8 and will be removed in 3.0. Return the fully-qualified type class name instead.', E_USER_DEPRECATED); + } + } foreach ($this->extensions as $extension) { $typeExtensions = array_merge( $typeExtensions, - $extension->getTypeExtensions($type->getName()) + $extension->getTypeExtensions($fqcn) ); } - $this->types[$type->getName()] = $this->resolvedTypeFactory->createResolvedType( + $resolvedType = $this->resolvedTypeFactory->createResolvedType( $type, $typeExtensions, $parentType ? $this->getType($parentType) : null ); + + $this->types[$fqcn] = $resolvedType; + + if ($hasCustomName) { + // Enable access by the explicit type name until Symfony 3.0 + $this->types[$name] = $resolvedType; + $this->legacyNames[$name] = true; + } } /** @@ -131,6 +170,10 @@ private function resolveAndAddType(FormTypeInterface $type) */ public function hasType($name) { + if (isset($this->legacyNames[$name])) { + @trigger_error(sprintf('Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "%s" instead.', $name, get_class($this->types[$name]->getInnerType())), E_USER_DEPRECATED); + } + if (isset($this->types[$name])) { return true; } diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php index 11c48db26de5f..83d2181b925a8 100644 --- a/src/Symfony/Component/Form/FormTypeInterface.php +++ b/src/Symfony/Component/Form/FormTypeInterface.php @@ -86,7 +86,12 @@ public function setDefaultOptions(OptionsResolverInterface $resolver); * is discouraged because it leads to a performance penalty. The support * for returning type instances may be dropped from future releases. * - * @return string|null|FormTypeInterface The name of the parent type if any, null otherwise. + * Returning a {@link FormTypeInterface} instance is deprecated since + * Symfony 2.8 and will be unsupported as of Symfony 3.0. Return the + * fully-qualified class name of the parent type instead. + * + * @return string|null|FormTypeInterface The name of the parent type if any, + * null otherwise. */ public function getParent(); @@ -94,6 +99,9 @@ public function getParent(); * Returns the name of this type. * * @return string The name of this type + * + * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. + * Use the fully-qualified class name of the type instead. */ public function getName(); } diff --git a/src/Symfony/Component/Form/PreloadedExtension.php b/src/Symfony/Component/Form/PreloadedExtension.php index 6b4f9ef6a170b..a8fd9d0097e35 100644 --- a/src/Symfony/Component/Form/PreloadedExtension.php +++ b/src/Symfony/Component/Form/PreloadedExtension.php @@ -38,15 +38,22 @@ class PreloadedExtension implements FormExtensionInterface /** * Creates a new preloaded extension. * - * @param FormTypeInterface[] $types The types that the extension should support. - * @param array[FormTypeExtensionInterface[]] $typeExtensions The type extensions that the extension should support. - * @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support. + * @param FormTypeInterface[] $types The types that the extension should support + * @param FormTypeExtensionInterface[][] $typeExtensions The type extensions that the extension should support + * @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support */ public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null) { - $this->types = $types; $this->typeExtensions = $typeExtensions; $this->typeGuesser = $typeGuesser; + + foreach ($types as $type) { + // Up to Symfony 2.8, types were identified by their names + $this->types[$type->getName()] = $type; + + // Since Symfony 2.8, types are identified by their FQCN + $this->types[get_class($type)] = $type; + } } /** diff --git a/src/Symfony/Component/Form/ResolvedFormType.php b/src/Symfony/Component/Form/ResolvedFormType.php index 765cb7bf6cbdc..b334acff3c655 100644 --- a/src/Symfony/Component/Form/ResolvedFormType.php +++ b/src/Symfony/Component/Form/ResolvedFormType.php @@ -14,6 +14,7 @@ use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\Form\Util\StringUtil; use Symfony\Component\OptionsResolver\OptionsResolver; /** @@ -23,6 +24,16 @@ */ class ResolvedFormType implements ResolvedFormTypeInterface { + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $blockPrefix; + /** * @var FormTypeInterface */ @@ -45,11 +56,40 @@ class ResolvedFormType implements ResolvedFormTypeInterface public function __construct(FormTypeInterface $innerType, array $typeExtensions = array(), ResolvedFormTypeInterface $parent = null) { - if (!preg_match('/^[a-z0-9_]*$/i', $innerType->getName())) { + $fqcn = get_class($innerType); + $name = $innerType->getName(); + $hasCustomName = $name !== $fqcn; + + if (method_exists($innerType, 'getBlockPrefix')) { + $reflector = new \ReflectionMethod($innerType, 'getName'); + $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; + + $reflector = new \ReflectionMethod($innerType, 'getBlockPrefix'); + $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; + + // Bundles compatible with both 2.3 and 2.8 should implement both methods + // Anyone else should only override getBlockPrefix() if they actually + // want to have a different block prefix than the default one + if ($isOldOverwritten && !$isNewOverwritten) { + @trigger_error(get_class($this->innerType).': The FormTypeInterface::getName() method is deprecated since version 2.8 and will be removed in 3.0. Remove it from your classes. Use getBlockPrefix() if you want to customize the template block prefix. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED); + } + + $blockPrefix = $innerType->getBlockPrefix(); + } else { + @trigger_error(get_class($this->innerType).': The FormTypeInterface::getBlockPrefix() method will be added in version 3.0. You should extend AbstractType or add it to your implementation.', E_USER_DEPRECATED); + + // Deal with classes that don't extend AbstractType + // Calculate block prefix from the FQCN by default + $blockPrefix = $hasCustomName ? $name : StringUtil::fqcnToBlockPrefix($fqcn); + } + + // As of Symfony 2.8, getName() returns the FQCN by default + // Otherwise check that the name matches the old naming restrictions + if ($hasCustomName && !preg_match('/^[a-z0-9_]*$/i', $name)) { throw new InvalidArgumentException(sprintf( 'The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".', get_class($innerType), - $innerType->getName() + $name )); } @@ -59,6 +99,8 @@ public function __construct(FormTypeInterface $innerType, array $typeExtensions } } + $this->name = $name; + $this->blockPrefix = $blockPrefix; $this->innerType = $innerType; $this->typeExtensions = $typeExtensions; $this->parent = $parent; @@ -69,7 +111,17 @@ public function __construct(FormTypeInterface $innerType, array $typeExtensions */ public function getName() { - return $this->innerType->getName(); + return $this->name; + } + + /** + * Returns the prefix of the template block name for this type. + * + * @return string The prefix of the template block name + */ + public function getBlockPrefix() + { + return $this->blockPrefix; } /** diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php index af01a8ea1dfb8..432c62623be3f 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php @@ -17,7 +17,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { public function testLabelOnForm() { - $form = $this->factory->createNamed('name', 'date'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); $view = $form->createView(); $this->renderWidget($view, array('label' => 'foo')); $html = $this->renderLabel($view); @@ -32,7 +32,7 @@ public function testLabelOnForm() public function testLabelDoesNotRenderFieldAttributes() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), null, array( 'attr' => array( 'class' => 'my&class', @@ -49,7 +49,7 @@ public function testLabelDoesNotRenderFieldAttributes() public function testLabelWithCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), null, array( 'label_attr' => array( 'class' => 'my&class', @@ -66,7 +66,7 @@ public function testLabelWithCustomAttributesPassedDirectly() public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), 'Custom label', array( 'label_attr' => array( 'class' => 'my&class', @@ -84,7 +84,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'label' => 'Custom label', )); $html = $this->renderLabel($form->createView(), null, array( @@ -104,7 +104,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly public function testErrors() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form->addError(new FormError('[trans]Error 1[/trans]')); $form->addError(new FormError('[trans]Error 2[/trans]')); $view = $form->createView(); @@ -137,7 +137,7 @@ public function testErrors() public function testOverrideWidgetBlock() { // see custom_widgets.html.twig - $form = $this->factory->createNamed('text_id', 'text'); + $form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderWidget($form->createView()); $this->assertMatchesXpath($html, @@ -155,7 +155,7 @@ public function testOverrideWidgetBlock() public function testCheckedCheckbox() { - $form = $this->factory->createNamed('name', 'checkbox', true); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true); $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), '/div @@ -173,7 +173,7 @@ public function testCheckedCheckbox() public function testUncheckedCheckbox() { - $form = $this->factory->createNamed('name', 'checkbox', false); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false); $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), '/div @@ -191,7 +191,7 @@ public function testUncheckedCheckbox() public function testCheckboxWithValue() { - $form = $this->factory->createNamed('name', 'checkbox', false, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, array( 'value' => 'foo&bar', )); @@ -211,7 +211,7 @@ public function testCheckboxWithValue() public function testSingleChoice() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -233,7 +233,7 @@ public function testSingleChoice() public function testSingleChoiceWithoutTranslation() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -256,7 +256,7 @@ public function testSingleChoiceWithoutTranslation() public function testSingleChoiceAttributes() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'multiple' => false, @@ -281,7 +281,7 @@ public function testSingleChoiceAttributes() public function testSingleChoiceWithPreferred() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -305,7 +305,7 @@ public function testSingleChoiceWithPreferred() public function testSingleChoiceWithPreferredAndNoSeparator() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -328,7 +328,7 @@ public function testSingleChoiceWithPreferredAndNoSeparator() public function testSingleChoiceWithPreferredAndBlankSeparator() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -352,7 +352,7 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() public function testChoiceWithOnlyPreferred() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&a', '&b'), 'multiple' => false, @@ -369,7 +369,7 @@ public function testChoiceWithOnlyPreferred() public function testSingleChoiceNonRequired() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => false, @@ -393,7 +393,7 @@ public function testSingleChoiceNonRequired() public function testSingleChoiceNonRequiredNoneSelected() { - $form = $this->factory->createNamed('name', 'choice', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => false, @@ -417,7 +417,7 @@ public function testSingleChoiceNonRequiredNoneSelected() public function testSingleChoiceNonRequiredWithPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -442,7 +442,7 @@ public function testSingleChoiceNonRequiredWithPlaceholder() public function testSingleChoiceRequiredWithPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => false, @@ -467,7 +467,7 @@ public function testSingleChoiceRequiredWithPlaceholder() public function testSingleChoiceRequiredWithPlaceholderViaView() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => false, @@ -491,7 +491,7 @@ public function testSingleChoiceRequiredWithPlaceholderViaView() public function testSingleChoiceGrouped() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array( 'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'Group&2' => array('&c' => 'Choice&C'), @@ -522,7 +522,7 @@ public function testSingleChoiceGrouped() public function testMultipleChoice() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => true, @@ -546,7 +546,7 @@ public function testMultipleChoice() public function testMultipleChoiceAttributes() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'required' => true, @@ -573,7 +573,7 @@ public function testMultipleChoiceAttributes() public function testMultipleChoiceSkipsPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => true, 'expanded' => false, @@ -596,7 +596,7 @@ public function testMultipleChoiceSkipsPlaceholder() public function testMultipleChoiceNonRequired() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => true, @@ -619,7 +619,7 @@ public function testMultipleChoiceNonRequired() public function testSingleChoiceExpanded() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -654,7 +654,7 @@ public function testSingleChoiceExpanded() public function testSingleChoiceExpandedWithoutTranslation() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -690,7 +690,7 @@ public function testSingleChoiceExpandedWithoutTranslation() public function testSingleChoiceExpandedAttributes() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'multiple' => false, @@ -728,7 +728,7 @@ public function testSingleChoiceExpandedAttributes() public function testSingleChoiceExpandedWithPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -773,7 +773,7 @@ public function testSingleChoiceExpandedWithPlaceholder() public function testSingleChoiceExpandedWithBooleanValue() { - $form = $this->factory->createNamed('name', 'choice', true, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array( 'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -808,7 +808,7 @@ public function testSingleChoiceExpandedWithBooleanValue() public function testMultipleChoiceExpanded() { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'multiple' => true, 'expanded' => true, @@ -853,7 +853,7 @@ public function testMultipleChoiceExpanded() public function testMultipleChoiceExpandedWithoutTranslation() { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'multiple' => true, 'expanded' => true, @@ -899,7 +899,7 @@ public function testMultipleChoiceExpandedWithoutTranslation() public function testMultipleChoiceExpandedAttributes() { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'multiple' => true, @@ -947,7 +947,7 @@ public function testMultipleChoiceExpandedAttributes() public function testCountry() { - $form = $this->factory->createNamed('name', 'country', 'AT'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/select @@ -961,7 +961,7 @@ public function testCountry() public function testCountryWithPlaceholder() { - $form = $this->factory->createNamed('name', 'country', 'AT', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT', array( 'placeholder' => 'Select&Country', 'required' => false, )); @@ -979,7 +979,7 @@ public function testCountryWithPlaceholder() public function testDateTime() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1015,7 +1015,7 @@ public function testDateTime() public function testDateTimeWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'datetime', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'input' => 'string', 'placeholder' => 'Change&Me', 'required' => false, @@ -1055,7 +1055,7 @@ public function testDateTimeWithHourAndMinute() { $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); - $form = $this->factory->createNamed('name', 'datetime', $data, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array( 'input' => 'array', 'required' => false, )); @@ -1092,7 +1092,7 @@ public function testDateTimeWithHourAndMinute() public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1133,7 +1133,7 @@ public function testDateTimeWithSeconds() public function testDateTimeSingleText() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'date_widget' => 'single_text', 'time_widget' => 'single_text', @@ -1162,7 +1162,7 @@ public function testDateTimeSingleText() public function testDateTimeWithWidgetSingleText() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'widget' => 'single_text', 'model_timezone' => 'UTC', @@ -1181,7 +1181,7 @@ public function testDateTimeWithWidgetSingleText() public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'date_widget' => 'choice', 'time_widget' => 'choice', @@ -1202,7 +1202,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() public function testDateChoice() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1231,7 +1231,7 @@ public function testDateChoice() public function testDateChoiceWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'date', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'input' => 'string', 'widget' => 'choice', 'placeholder' => 'Change&Me', @@ -1262,7 +1262,7 @@ public function testDateChoiceWithPlaceholderGlobal() public function testDateChoiceWithPlaceholderOnYear() { - $form = $this->factory->createNamed('name', 'date', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'input' => 'string', 'widget' => 'choice', 'required' => false, @@ -1293,7 +1293,7 @@ public function testDateChoiceWithPlaceholderOnYear() public function testDateText() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( 'input' => 'string', 'widget' => 'text', )); @@ -1325,7 +1325,7 @@ public function testDateText() public function testDateSingleText() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -1342,7 +1342,7 @@ public function testDateSingleText() public function testBirthDay() { - $form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '2000-02-03', array( 'input' => 'string', )); @@ -1370,7 +1370,7 @@ public function testBirthDay() public function testBirthDayWithPlaceholder() { - $form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '1950-01-01', array( 'input' => 'string', 'placeholder' => '', 'required' => false, @@ -1403,7 +1403,7 @@ public function testBirthDayWithPlaceholder() public function testEmail() { - $form = $this->factory->createNamed('name', 'email', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1418,7 +1418,7 @@ public function testEmail() public function testEmailWithMaxLength() { - $form = $this->factory->createNamed('name', 'email', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', array( 'attr' => array('maxlength' => 123), )); @@ -1435,7 +1435,7 @@ public function testEmailWithMaxLength() public function testHidden() { - $form = $this->factory->createNamed('name', 'hidden', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1452,7 +1452,7 @@ public function testHidden() */ public function testLegacyReadOnly() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'read_only' => true, )); @@ -1468,7 +1468,7 @@ public function testLegacyReadOnly() public function testDisabled() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'disabled' => true, )); @@ -1484,7 +1484,7 @@ public function testDisabled() public function testInteger() { - $form = $this->factory->createNamed('name', 'integer', 123); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1498,7 +1498,7 @@ public function testInteger() public function testLanguage() { - $form = $this->factory->createNamed('name', 'language', 'de'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/select @@ -1512,7 +1512,7 @@ public function testLanguage() public function testLocale() { - $form = $this->factory->createNamed('name', 'locale', 'de_AT'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/select @@ -1526,7 +1526,7 @@ public function testLocale() public function testMoney() { - $form = $this->factory->createNamed('name', 'money', 1234.56, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array( 'currency' => 'EUR', )); @@ -1550,7 +1550,7 @@ public function testMoney() public function testNumber() { - $form = $this->factory->createNamed('name', 'number', 1234.56); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1564,7 +1564,7 @@ public function testNumber() public function testPassword() { - $form = $this->factory->createNamed('name', 'password', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1577,7 +1577,7 @@ public function testPassword() public function testPasswordSubmittedWithNotAlwaysEmpty() { - $form = $this->factory->createNamed('name', 'password', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array( 'always_empty' => false, )); $form->submit('foo&bar'); @@ -1594,7 +1594,7 @@ public function testPasswordSubmittedWithNotAlwaysEmpty() public function testPasswordWithMaxLength() { - $form = $this->factory->createNamed('name', 'password', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', array( 'attr' => array('maxlength' => 123), )); @@ -1610,7 +1610,7 @@ public function testPasswordWithMaxLength() public function testPercent() { - $form = $this->factory->createNamed('name', 'percent', 0.1); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1); $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), '/div @@ -1632,7 +1632,7 @@ public function testPercent() public function testCheckedRadio() { - $form = $this->factory->createNamed('name', 'radio', true); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true); $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), '/div @@ -1656,7 +1656,7 @@ public function testCheckedRadio() public function testUncheckedRadio() { - $form = $this->factory->createNamed('name', 'radio', false); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false); $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), '/div @@ -1679,7 +1679,7 @@ public function testUncheckedRadio() public function testRadioWithValue() { - $form = $this->factory->createNamed('name', 'radio', false, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, array( 'value' => 'foo&bar', )); @@ -1704,7 +1704,7 @@ public function testRadioWithValue() public function testRange() { - $form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5))); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5))); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1719,7 +1719,7 @@ public function testRange() public function testRangeWithMinMaxValues() { - $form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5, 'max' => 57))); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5, 'max' => 57))); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1735,7 +1735,7 @@ public function testRangeWithMinMaxValues() public function testTextarea() { - $form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', array( 'attr' => array('pattern' => 'foo'), )); @@ -1751,7 +1751,7 @@ public function testTextarea() public function testText() { - $form = $this->factory->createNamed('name', 'text', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1766,7 +1766,7 @@ public function testText() public function testTextWithMaxLength() { - $form = $this->factory->createNamed('name', 'text', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', array( 'attr' => array('maxlength' => 123), )); @@ -1783,7 +1783,7 @@ public function testTextWithMaxLength() public function testSearch() { - $form = $this->factory->createNamed('name', 'search', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -1798,7 +1798,7 @@ public function testSearch() public function testTime() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1825,7 +1825,7 @@ public function testTime() public function testTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1860,7 +1860,7 @@ public function testTimeWithSeconds() public function testTimeText() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'widget' => 'text', )); @@ -1893,7 +1893,7 @@ public function testTimeText() public function testTimeSingleText() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -1911,7 +1911,7 @@ public function testTimeSingleText() public function testTimeWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'time', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'input' => 'string', 'placeholder' => 'Change&Me', 'required' => false, @@ -1938,7 +1938,7 @@ public function testTimeWithPlaceholderGlobal() public function testTimeWithPlaceholderOnYear() { - $form = $this->factory->createNamed('name', 'time', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'input' => 'string', 'required' => false, 'placeholder' => array('hour' => 'Change&Me'), @@ -1965,7 +1965,7 @@ public function testTimeWithPlaceholderOnYear() public function testTimezone() { - $form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/select @@ -1984,7 +1984,7 @@ public function testTimezone() public function testTimezoneWithPlaceholder() { - $form = $this->factory->createNamed('name', 'timezone', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', null, array( 'placeholder' => 'Select&Timezone', 'required' => false, )); @@ -2002,7 +2002,7 @@ public function testTimezoneWithPlaceholder() public function testUrl() { $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; - $form = $this->factory->createNamed('name', 'url', $url); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input @@ -2016,7 +2016,7 @@ public function testUrl() public function testButton() { - $form = $this->factory->createNamed('name', 'button'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/button[@type="button"][@name="name"][.="[trans]Name[/trans]"][@class="my&class btn"]' @@ -2025,7 +2025,7 @@ public function testButton() public function testSubmit() { - $form = $this->factory->createNamed('name', 'submit'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SubmitType'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/button[@type="submit"][@name="name"][@class="my&class btn"]' @@ -2034,7 +2034,7 @@ public function testSubmit() public function testReset() { - $form = $this->factory->createNamed('name', 'reset'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ResetType'); $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/button[@type="reset"][@name="name"][@class="my&class btn"]' @@ -2043,7 +2043,7 @@ public function testReset() public function testWidgetAttributes() { - $form = $this->factory->createNamed('text', 'text', 'value', array( + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( 'required' => true, 'disabled' => true, 'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), @@ -2057,7 +2057,7 @@ public function testWidgetAttributes() public function testWidgetAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('text', 'text', 'value', array( + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( 'attr' => array('foo' => true), )); @@ -2069,7 +2069,7 @@ public function testWidgetAttributeNameRepeatedIfTrue() public function testButtonAttributes() { - $form = $this->factory->createNamed('button', 'button', null, array( + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( 'disabled' => true, 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), )); @@ -2082,7 +2082,7 @@ public function testButtonAttributes() public function testButtonAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('button', 'button', null, array( + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( 'attr' => array('foo' => true), )); diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index 45b2f311c2942..fb7be87eadfe0 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -12,14 +12,13 @@ namespace Symfony\Component\Form\Tests; use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Tests\Fixtures\AlternatingRowType; use Symfony\Component\Security\Csrf\CsrfToken; abstract class AbstractDivLayoutTest extends AbstractLayoutTest { public function testRow() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); $html = $this->renderRow($view); @@ -39,7 +38,7 @@ public function testRow() public function testRowOverrideVariables() { - $view = $this->factory->createNamed('name', 'text')->createView(); + $view = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType')->createView(); $html = $this->renderRow($view, array( 'attr' => array('class' => 'my&class'), 'label' => 'foo&bar', @@ -58,7 +57,7 @@ public function testRowOverrideVariables() public function testRepeatedRow() { - $form = $this->factory->createNamed('name', 'repeated'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'); $form->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); $html = $this->renderRow($view); @@ -85,7 +84,7 @@ public function testRepeatedRow() public function testButtonRow() { - $form = $this->factory->createNamed('name', 'button'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType'); $view = $form->createView(); $html = $this->renderRow($view); @@ -101,11 +100,11 @@ public function testButtonRow() public function testRest() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'repeated') - ->add('field3', 'text') - ->add('field4', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType') + ->add('field3', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field4', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -142,15 +141,15 @@ public function testRest() public function testRestWithChildrenForms() { - $child1 = $this->factory->createNamedBuilder('child1', 'form') - ->add('field1', 'text') - ->add('field2', 'text'); + $child1 = $this->factory->createNamedBuilder('child1', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $child2 = $this->factory->createNamedBuilder('child2', 'form') - ->add('field1', 'text') - ->add('field2', 'text'); + $child2 = $this->factory->createNamedBuilder('child2', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $view = $this->factory->createNamedBuilder('parent', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($child1) ->add($child2) ->getForm() @@ -200,9 +199,9 @@ public function testRestWithChildrenForms() public function testRestAndRepeatedWithRow() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('first', 'text') - ->add('password', 'repeated') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('first', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('password', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType') ->getForm() ->createView(); @@ -226,9 +225,9 @@ public function testRestAndRepeatedWithRow() public function testRestAndRepeatedWithRowPerChild() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('first', 'text') - ->add('password', 'repeated') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('first', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('password', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType') ->getForm() ->createView(); @@ -254,9 +253,9 @@ public function testRestAndRepeatedWithRowPerChild() public function testRestAndRepeatedWithWidgetPerChild() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('first', 'text') - ->add('password', 'repeated') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('first', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('password', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType') ->getForm() ->createView(); @@ -284,8 +283,8 @@ public function testRestAndRepeatedWithWidgetPerChild() public function testCollection() { - $form = $this->factory->createNamed('names', 'collection', array('a', 'b'), array( - 'type' => 'text', + $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -306,8 +305,8 @@ public function testCollectionWithAlternatingRowTypes() array('title' => 'a'), array('title' => 'b'), ); - $form = $this->factory->createNamed('names', 'collection', $data, array( - 'type' => new AlternatingRowType(), + $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $data, array( + 'type' => 'Symfony\Component\Form\Tests\Fixtures\AlternatingRowType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -324,8 +323,8 @@ public function testCollectionWithAlternatingRowTypes() public function testEmptyCollection() { - $form = $this->factory->createNamed('names', 'collection', array(), array( - 'type' => 'text', + $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -340,12 +339,12 @@ public function testCollectionRow() { $collection = $this->factory->createNamedBuilder( 'collection', - 'collection', + 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), - array('type' => 'text') + array('type' => 'Symfony\Component\Form\Extension\Core\Type\TextType') ); - $form = $this->factory->createNamedBuilder('form', 'form') + $form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($collection) ->getForm(); @@ -378,11 +377,11 @@ public function testCollectionRow() public function testForm() { - $form = $this->factory->createNamedBuilder('name', 'form') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->setMethod('PUT') ->setAction('http://example.com') - ->add('firstName', 'text') - ->add('lastName', 'text') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); // include ampersands everywhere to validate escaping @@ -422,9 +421,9 @@ public function testForm() public function testFormWidget() { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('firstName', 'text') - ->add('lastName', 'text') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -450,10 +449,10 @@ public function testFormWidget() // https://github.com/symfony/symfony/issues/2308 public function testNestedFormError() { - $form = $this->factory->createNamedBuilder('name', 'form') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory - ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) - ->add('grandChild', 'form') + ->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('error_bubbling' => false)) + ->add('grandChild', 'Symfony\Component\Form\Extension\Core\Type\FormType') ) ->getForm(); @@ -476,11 +475,11 @@ public function testCsrf() ->method('getToken') ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); - $form = $this->factory->createNamedBuilder('name', 'form') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory // No CSRF protection on nested forms - ->createNamedBuilder('child', 'form') - ->add($this->factory->createNamedBuilder('grandchild', 'text')) + ->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add($this->factory->createNamedBuilder('grandchild', 'Symfony\Component\Form\Extension\Core\Type\TextType')) ) ->getForm(); @@ -497,8 +496,8 @@ public function testCsrf() public function testRepeated() { - $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( - 'type' => 'text', + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', 'foobar', array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -523,7 +522,7 @@ public function testRepeated() public function testRepeatedWithCustomOptions() { - $form = $this->factory->createNamed('name', 'repeated', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( // the global required value cannot be overridden 'first_options' => array('label' => 'Test', 'required' => false), 'second_options' => array('label' => 'Test2'), @@ -551,8 +550,8 @@ public function testRepeatedWithCustomOptions() public function testSearchInputName() { - $form = $this->factory->createNamedBuilder('full', 'form') - ->add('name', 'search') + $form = $this->factory->createNamedBuilder('full', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType') ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -572,7 +571,7 @@ public function testSearchInputName() public function testLabelHasNoId() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, @@ -587,7 +586,7 @@ public function testLabelHasNoId() public function testLabelIsNotRenderedWhenSetToFalse() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'label' => false, )); $html = $this->renderRow($form->createView()); @@ -608,7 +607,7 @@ public function testLabelIsNotRenderedWhenSetToFalse() public function testThemeBlockInheritance($theme) { $view = $this->factory - ->createNamed('name', 'email') + ->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType') ->createView() ; @@ -625,11 +624,11 @@ public function testThemeBlockInheritance($theme) */ public function testThemeInheritance($parentTheme, $childTheme) { - $child = $this->factory->createNamedBuilder('child', 'form') - ->add('field', 'text'); + $child = $this->factory->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('field', 'text') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->add($child) ->getForm() ->createView() @@ -671,7 +670,7 @@ public function testThemeInheritance($parentTheme, $childTheme) public function testCollectionRowWithCustomBlock() { $collection = array('one', 'two', 'three'); - $form = $this->factory->createNamedBuilder('names', 'collection', $collection) + $form = $this->factory->createNamedBuilder('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $collection) ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -691,7 +690,7 @@ public function testCollectionRowWithCustomBlock() */ public function testChoiceRowWithCustomBlock() { - $form = $this->factory->createNamedBuilder('name_c', 'choice', 'a', array( + $form = $this->factory->createNamedBuilder('name_c', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', 'a', array( 'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'), 'expanded' => true, )) @@ -709,9 +708,9 @@ public function testChoiceRowWithCustomBlock() public function testFormEndWithRest() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -739,9 +738,9 @@ public function testFormEndWithRest() public function testFormEndWithoutRest() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -755,11 +754,11 @@ public function testFormEndWithoutRest() public function testWidgetContainerAttributes() { - $form = $this->factory->createNamed('form', 'form', null, array( + $form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), )); - $form->add('text', 'text'); + $form->add('text', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderWidget($form->createView()); @@ -769,7 +768,7 @@ public function testWidgetContainerAttributes() public function testWidgetContainerAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('form', 'form', null, array( + $form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'attr' => array('foo' => true), )); diff --git a/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php b/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php index b1534db3abc88..74a70399fd0ce 100644 --- a/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php @@ -19,14 +19,14 @@ class AbstractExtensionTest extends \PHPUnit_Framework_TestCase public function testHasType() { $loader = new ConcreteExtension(); - $this->assertTrue($loader->hasType('foo')); - $this->assertFalse($loader->hasType('bar')); + $this->assertTrue($loader->hasType('Symfony\Component\Form\Tests\Fixtures\FooType')); + $this->assertFalse($loader->hasType('foo')); } public function testGetType() { $loader = new ConcreteExtension(); - $this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('foo')); + $this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType')); } /** @@ -35,7 +35,7 @@ public function testGetType() */ public function testCustomOptionsResolver() { - $extension = new Fixtures\FooTypeBarExtension(); + $extension = new Fixtures\LegacyFooTypeBarExtension(); $resolver = new Fixtures\CustomOptionsResolver(); $extension->setDefaultOptions($resolver); } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 67e381562a1a5..eac19c0d69fef 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -134,8 +134,8 @@ abstract protected function setTheme(FormView $view, array $themes); */ public function testEnctype() { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('file', 'file') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType') ->getForm(); $this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView())); @@ -146,8 +146,8 @@ public function testEnctype() */ public function testNoEnctype() { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('text', 'text') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('text', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $this->assertEquals('', $this->renderEnctype($form->createView())); @@ -155,7 +155,7 @@ public function testNoEnctype() public function testLabel() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $view = $form->createView(); $this->renderWidget($view, array('label' => 'foo')); $html = $this->renderLabel($view); @@ -170,7 +170,7 @@ public function testLabel() public function testLabelWithoutTranslation() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'translation_domain' => false, )); @@ -184,7 +184,7 @@ public function testLabelWithoutTranslation() public function testLabelOnForm() { - $form = $this->factory->createNamed('name', 'date'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); $view = $form->createView(); $this->renderWidget($view, array('label' => 'foo')); $html = $this->renderLabel($view); @@ -199,7 +199,7 @@ public function testLabelOnForm() public function testLabelWithCustomTextPassedAsOption() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'label' => 'Custom label', )); $html = $this->renderLabel($form->createView()); @@ -214,7 +214,7 @@ public function testLabelWithCustomTextPassedAsOption() public function testLabelWithCustomTextPassedDirectly() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), 'Custom label'); $this->assertMatchesXpath($html, @@ -227,7 +227,7 @@ public function testLabelWithCustomTextPassedDirectly() public function testLabelWithCustomTextPassedAsOptionAndDirectly() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'label' => 'Custom label', )); $html = $this->renderLabel($form->createView(), 'Overridden label'); @@ -242,7 +242,7 @@ public function testLabelWithCustomTextPassedAsOptionAndDirectly() public function testLabelDoesNotRenderFieldAttributes() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), null, array( 'attr' => array( 'class' => 'my&class', @@ -259,7 +259,7 @@ public function testLabelDoesNotRenderFieldAttributes() public function testLabelWithCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), null, array( 'label_attr' => array( 'class' => 'my&class', @@ -276,7 +276,7 @@ public function testLabelWithCustomAttributesPassedDirectly() public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderLabel($form->createView(), 'Custom label', array( 'label_attr' => array( 'class' => 'my&class', @@ -295,7 +295,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() // https://github.com/symfony/symfony/issues/5029 public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'label' => 'Custom label', )); $html = $this->renderLabel($form->createView(), null, array( @@ -316,7 +316,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly public function testLabelFormatName() { $form = $this->factory->createNamedBuilder('myform') - ->add('myfield', 'text') + ->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $view = $form->get('myfield')->createView(); $html = $this->renderLabel($view, null, array('label_format' => 'form.%name%')); @@ -332,7 +332,7 @@ public function testLabelFormatName() public function testLabelFormatId() { $form = $this->factory->createNamedBuilder('myform') - ->add('myfield', 'text') + ->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $view = $form->get('myfield')->createView(); $html = $this->renderLabel($view, null, array('label_format' => 'form.%id%')); @@ -349,8 +349,8 @@ public function testLabelFormatAsFormOption() { $options = array('label_format' => 'form.%name%'); - $form = $this->factory->createNamedBuilder('myform', 'form', null, $options) - ->add('myfield', 'text') + $form = $this->factory->createNamedBuilder('myform', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, $options) + ->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $view = $form->get('myfield')->createView(); $html = $this->renderLabel($view); @@ -367,8 +367,8 @@ public function testLabelFormatOverriddenOption() { $options = array('label_format' => 'form.%name%'); - $form = $this->factory->createNamedBuilder('myform', 'form', null, $options) - ->add('myfield', 'text', array('label_format' => 'field.%name%')) + $form = $this->factory->createNamedBuilder('myform', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, $options) + ->add('myfield', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('label_format' => 'field.%name%')) ->getForm(); $view = $form->get('myfield')->createView(); $html = $this->renderLabel($view); @@ -384,7 +384,7 @@ public function testLabelFormatOverriddenOption() public function testLabelFormatOnButton() { $form = $this->factory->createNamedBuilder('myform') - ->add('mybutton', 'button') + ->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType') ->getForm(); $view = $form->get('mybutton')->createView(); $html = $this->renderWidget($view, array('label_format' => 'form.%name%')); @@ -401,7 +401,7 @@ public function testLabelFormatOnButton() public function testLabelFormatOnButtonId() { $form = $this->factory->createNamedBuilder('myform') - ->add('mybutton', 'button') + ->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType') ->getForm(); $view = $form->get('mybutton')->createView(); $html = $this->renderWidget($view, array('label_format' => 'form.%id%')); @@ -417,7 +417,7 @@ public function testLabelFormatOnButtonId() public function testErrors() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form->addError(new FormError('[trans]Error 1[/trans]')); $form->addError(new FormError('[trans]Error 2[/trans]')); $view = $form->createView(); @@ -437,7 +437,7 @@ public function testErrors() public function testOverrideWidgetBlock() { // see custom_widgets.html.twig - $form = $this->factory->createNamed('text_id', 'text'); + $form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderWidget($form->createView()); $this->assertMatchesXpath($html, @@ -454,7 +454,7 @@ public function testOverrideWidgetBlock() public function testCheckedCheckbox() { - $form = $this->factory->createNamed('name', 'checkbox', true); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -468,7 +468,7 @@ public function testCheckedCheckbox() public function testUncheckedCheckbox() { - $form = $this->factory->createNamed('name', 'checkbox', false); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -481,7 +481,7 @@ public function testUncheckedCheckbox() public function testCheckboxWithValue() { - $form = $this->factory->createNamed('name', 'checkbox', false, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, array( 'value' => 'foo&bar', )); @@ -496,7 +496,7 @@ public function testCheckboxWithValue() public function testSingleChoice() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -529,7 +529,7 @@ public function testSingleChoice() public function testSingleChoiceWithoutTranslation() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -551,7 +551,7 @@ public function testSingleChoiceWithoutTranslation() public function testSingleChoiceAttributes() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'multiple' => false, @@ -575,7 +575,7 @@ public function testSingleChoiceAttributes() public function testSingleChoiceWithPreferred() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -598,7 +598,7 @@ public function testSingleChoiceWithPreferred() public function testSingleChoiceWithPreferredAndNoSeparator() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -620,7 +620,7 @@ public function testSingleChoiceWithPreferredAndNoSeparator() public function testSingleChoiceWithPreferredAndBlankSeparator() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -643,7 +643,7 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() public function testChoiceWithOnlyPreferred() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&a', '&b'), 'multiple' => false, @@ -659,7 +659,7 @@ public function testChoiceWithOnlyPreferred() public function testSingleChoiceNonRequired() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => false, @@ -682,7 +682,7 @@ public function testSingleChoiceNonRequired() public function testSingleChoiceNonRequiredNoneSelected() { - $form = $this->factory->createNamed('name', 'choice', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => false, @@ -705,7 +705,7 @@ public function testSingleChoiceNonRequiredNoneSelected() public function testSingleChoiceNonRequiredWithPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -729,7 +729,7 @@ public function testSingleChoiceNonRequiredWithPlaceholder() public function testSingleChoiceRequiredWithPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => false, @@ -756,7 +756,7 @@ public function testSingleChoiceRequiredWithPlaceholder() public function testSingleChoiceRequiredWithPlaceholderViaView() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => false, @@ -782,7 +782,7 @@ public function testSingleChoiceRequiredWithPlaceholderViaView() public function testSingleChoiceGrouped() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array( 'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'Group&2' => array('&c' => 'Choice&C'), @@ -812,7 +812,7 @@ public function testSingleChoiceGrouped() public function testMultipleChoice() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => true, @@ -835,7 +835,7 @@ public function testMultipleChoice() public function testMultipleChoiceAttributes() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'required' => true, @@ -861,7 +861,7 @@ public function testMultipleChoiceAttributes() public function testMultipleChoiceSkipsPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => true, 'expanded' => false, @@ -883,7 +883,7 @@ public function testMultipleChoiceSkipsPlaceholder() public function testMultipleChoiceNonRequired() { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => true, @@ -905,7 +905,7 @@ public function testMultipleChoiceNonRequired() public function testSingleChoiceExpanded() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -927,7 +927,7 @@ public function testSingleChoiceExpanded() public function testSingleChoiceExpandedWithoutTranslation() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -950,7 +950,7 @@ public function testSingleChoiceExpandedWithoutTranslation() public function testSingleChoiceExpandedAttributes() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'multiple' => false, @@ -975,7 +975,7 @@ public function testSingleChoiceExpandedAttributes() public function testSingleChoiceExpandedWithPlaceholder() { - $form = $this->factory->createNamed('name', 'choice', '&a', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -1000,7 +1000,7 @@ public function testSingleChoiceExpandedWithPlaceholder() public function testSingleChoiceExpandedWithBooleanValue() { - $form = $this->factory->createNamed('name', 'choice', true, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array( 'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -1022,7 +1022,7 @@ public function testSingleChoiceExpandedWithBooleanValue() public function testMultipleChoiceExpanded() { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'multiple' => true, 'expanded' => true, @@ -1047,7 +1047,7 @@ public function testMultipleChoiceExpanded() public function testMultipleChoiceExpandedWithoutTranslation() { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'multiple' => true, 'expanded' => true, @@ -1073,7 +1073,7 @@ public function testMultipleChoiceExpandedWithoutTranslation() public function testMultipleChoiceExpandedAttributes() { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'multiple' => true, @@ -1101,7 +1101,7 @@ public function testMultipleChoiceExpandedAttributes() public function testCountry() { - $form = $this->factory->createNamed('name', 'country', 'AT'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -1114,7 +1114,7 @@ public function testCountry() public function testCountryWithPlaceholder() { - $form = $this->factory->createNamed('name', 'country', 'AT', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT', array( 'placeholder' => 'Select&Country', 'required' => false, )); @@ -1131,7 +1131,7 @@ public function testCountryWithPlaceholder() public function testDateTime() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1170,7 +1170,7 @@ public function testDateTime() public function testDateTimeWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'datetime', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'input' => 'string', 'placeholder' => 'Change&Me', 'required' => false, @@ -1212,7 +1212,7 @@ public function testDateTimeWithHourAndMinute() { $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); - $form = $this->factory->createNamed('name', 'datetime', $data, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array( 'input' => 'array', 'required' => false, )); @@ -1251,7 +1251,7 @@ public function testDateTimeWithHourAndMinute() public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1293,7 +1293,7 @@ public function testDateTimeWithSeconds() public function testDateTimeSingleText() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'date_widget' => 'single_text', 'time_widget' => 'single_text', @@ -1319,7 +1319,7 @@ public function testDateTimeSingleText() public function testDateTimeWithWidgetSingleText() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'widget' => 'single_text', 'model_timezone' => 'UTC', @@ -1337,7 +1337,7 @@ public function testDateTimeWithWidgetSingleText() public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( 'input' => 'string', 'date_widget' => 'choice', 'time_widget' => 'choice', @@ -1357,7 +1357,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() public function testDateChoice() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1382,7 +1382,7 @@ public function testDateChoice() public function testDateChoiceWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'date', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'input' => 'string', 'widget' => 'choice', 'placeholder' => 'Change&Me', @@ -1409,7 +1409,7 @@ public function testDateChoiceWithPlaceholderGlobal() public function testDateChoiceWithPlaceholderOnYear() { - $form = $this->factory->createNamed('name', 'date', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'input' => 'string', 'widget' => 'choice', 'required' => false, @@ -1436,7 +1436,7 @@ public function testDateChoiceWithPlaceholderOnYear() public function testDateText() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( 'input' => 'string', 'widget' => 'text', )); @@ -1464,7 +1464,7 @@ public function testDateText() public function testDateSingleText() { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -1480,8 +1480,8 @@ public function testDateSingleText() public function testDateErrorBubbling() { - $form = $this->factory->createNamedBuilder('form', 'form') - ->add('date', 'date') + $form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('date', 'Symfony\Component\Form\Extension\Core\Type\DateType') ->getForm(); $form->get('date')->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); @@ -1492,7 +1492,7 @@ public function testDateErrorBubbling() public function testBirthDay() { - $form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '2000-02-03', array( 'input' => 'string', )); @@ -1516,7 +1516,7 @@ public function testBirthDay() public function testBirthDayWithPlaceholder() { - $form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '1950-01-01', array( 'input' => 'string', 'placeholder' => '', 'required' => false, @@ -1545,7 +1545,7 @@ public function testBirthDayWithPlaceholder() public function testEmail() { - $form = $this->factory->createNamed('name', 'email', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1559,7 +1559,7 @@ public function testEmail() public function testEmailWithMaxLength() { - $form = $this->factory->createNamed('name', 'email', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', array( 'attr' => array('maxlength' => 123), )); @@ -1575,7 +1575,7 @@ public function testEmailWithMaxLength() public function testFile() { - $form = $this->factory->createNamed('name', 'file'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\FileType'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1586,7 +1586,7 @@ public function testFile() public function testHidden() { - $form = $this->factory->createNamed('name', 'hidden', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1602,7 +1602,7 @@ public function testHidden() */ public function testLegacyReadOnly() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'read_only' => true, )); @@ -1617,7 +1617,7 @@ public function testLegacyReadOnly() public function testDisabled() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'disabled' => true, )); @@ -1632,7 +1632,7 @@ public function testDisabled() public function testInteger() { - $form = $this->factory->createNamed('name', 'integer', 123); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1645,7 +1645,7 @@ public function testInteger() public function testLanguage() { - $form = $this->factory->createNamed('name', 'language', 'de'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -1658,7 +1658,7 @@ public function testLanguage() public function testLocale() { - $form = $this->factory->createNamed('name', 'locale', 'de_AT'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -1671,7 +1671,7 @@ public function testLocale() public function testMoney() { - $form = $this->factory->createNamed('name', 'money', 1234.56, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array( 'currency' => 'EUR', )); @@ -1687,7 +1687,7 @@ public function testMoney() public function testNumber() { - $form = $this->factory->createNamed('name', 'number', 1234.56); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1700,7 +1700,7 @@ public function testNumber() public function testPassword() { - $form = $this->factory->createNamed('name', 'password', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1712,7 +1712,7 @@ public function testPassword() public function testPasswordSubmittedWithNotAlwaysEmpty() { - $form = $this->factory->createNamed('name', 'password', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array( 'always_empty' => false, )); $form->submit('foo&bar'); @@ -1728,7 +1728,7 @@ public function testPasswordSubmittedWithNotAlwaysEmpty() public function testPasswordWithMaxLength() { - $form = $this->factory->createNamed('name', 'password', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', array( 'attr' => array('maxlength' => 123), )); @@ -1743,7 +1743,7 @@ public function testPasswordWithMaxLength() public function testPercent() { - $form = $this->factory->createNamed('name', 'percent', 0.1); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1757,7 +1757,7 @@ public function testPercent() public function testCheckedRadio() { - $form = $this->factory->createNamed('name', 'radio', true); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1771,7 +1771,7 @@ public function testCheckedRadio() public function testUncheckedRadio() { - $form = $this->factory->createNamed('name', 'radio', false); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1784,7 +1784,7 @@ public function testUncheckedRadio() public function testRadioWithValue() { - $form = $this->factory->createNamed('name', 'radio', false, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, array( 'value' => 'foo&bar', )); @@ -1799,7 +1799,7 @@ public function testRadioWithValue() public function testRange() { - $form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5))); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5))); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1813,7 +1813,7 @@ public function testRange() public function testRangeWithMinMaxValues() { - $form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5, 'max' => 57))); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5, 'max' => 57))); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1828,7 +1828,7 @@ public function testRangeWithMinMaxValues() public function testTextarea() { - $form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', array( 'attr' => array('pattern' => 'foo'), )); @@ -1843,7 +1843,7 @@ public function testTextarea() public function testText() { - $form = $this->factory->createNamed('name', 'text', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1857,7 +1857,7 @@ public function testText() public function testTextWithMaxLength() { - $form = $this->factory->createNamed('name', 'text', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', array( 'attr' => array('maxlength' => 123), )); @@ -1873,7 +1873,7 @@ public function testTextWithMaxLength() public function testSearch() { - $form = $this->factory->createNamed('name', 'search', 'foo&bar'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1887,7 +1887,7 @@ public function testSearch() public function testTime() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1911,7 +1911,7 @@ public function testTime() public function testTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1942,7 +1942,7 @@ public function testTimeWithSeconds() public function testTimeText() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'widget' => 'text', )); @@ -1972,7 +1972,7 @@ public function testTimeText() public function testTimeSingleText() { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -1989,7 +1989,7 @@ public function testTimeSingleText() public function testTimeWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'time', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'input' => 'string', 'placeholder' => 'Change&Me', 'required' => false, @@ -2014,7 +2014,7 @@ public function testTimeWithPlaceholderGlobal() public function testTimeWithPlaceholderOnYear() { - $form = $this->factory->createNamed('name', 'time', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'input' => 'string', 'required' => false, 'placeholder' => array('hour' => 'Change&Me'), @@ -2039,8 +2039,8 @@ public function testTimeWithPlaceholderOnYear() public function testTimeErrorBubbling() { - $form = $this->factory->createNamedBuilder('form', 'form') - ->add('time', 'time') + $form = $this->factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('time', 'Symfony\Component\Form\Extension\Core\Type\TimeType') ->getForm(); $form->get('time')->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); @@ -2051,7 +2051,7 @@ public function testTimeErrorBubbling() public function testTimezone() { - $form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -2069,7 +2069,7 @@ public function testTimezone() public function testTimezoneWithPlaceholder() { - $form = $this->factory->createNamed('name', 'timezone', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', null, array( 'placeholder' => 'Select&Timezone', 'required' => false, )); @@ -2086,7 +2086,7 @@ public function testTimezoneWithPlaceholder() public function testUrl() { $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; - $form = $this->factory->createNamed('name', 'url', $url); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -2099,8 +2099,8 @@ public function testUrl() public function testCollectionPrototype() { - $form = $this->factory->createNamedBuilder('name', 'form', array('items' => array('one', 'two', 'three'))) - ->add('items', 'collection', array('allow_add' => true)) + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType', array('items' => array('one', 'two', 'three'))) + ->add('items', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('allow_add' => true)) ->getForm() ->createView(); @@ -2115,8 +2115,8 @@ public function testCollectionPrototype() public function testEmptyRootFormName() { - $form = $this->factory->createNamedBuilder('', 'form') - ->add('child', 'text') + $form = $this->factory->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $this->assertMatchesXpath($this->renderWidget($form->createView()), @@ -2127,7 +2127,7 @@ public function testEmptyRootFormName() public function testButton() { - $form = $this->factory->createNamed('name', 'button'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/button[@type="button"][@name="name"][.="[trans]Name[/trans]"]' @@ -2136,14 +2136,14 @@ public function testButton() public function testButtonLabelIsEmpty() { - $form = $this->factory->createNamed('name', 'button'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType'); $this->assertSame('', $this->renderLabel($form->createView())); } public function testSubmit() { - $form = $this->factory->createNamed('name', 'submit'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SubmitType'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/button[@type="submit"][@name="name"]' @@ -2152,7 +2152,7 @@ public function testSubmit() public function testReset() { - $form = $this->factory->createNamed('name', 'reset'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ResetType'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/button[@type="reset"][@name="name"]' @@ -2161,7 +2161,7 @@ public function testReset() public function testStartTag() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => 'http://example.com/directory', )); @@ -2173,7 +2173,7 @@ public function testStartTag() public function testStartTagForPutRequest() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'put', 'action' => 'http://example.com/directory', )); @@ -2190,7 +2190,7 @@ public function testStartTagForPutRequest() public function testStartTagWithOverriddenVars() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'put', 'action' => 'http://example.com/directory', )); @@ -2205,11 +2205,11 @@ public function testStartTagWithOverriddenVars() public function testStartTagForMultipartForm() { - $form = $this->factory->createBuilder('form', null, array( + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => 'http://example.com/directory', )) - ->add('file', 'file') + ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType') ->getForm(); $html = $this->renderStart($form->createView()); @@ -2219,7 +2219,7 @@ public function testStartTagForMultipartForm() public function testStartTagWithExtraAttributes() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'method' => 'get', 'action' => 'http://example.com/directory', )); @@ -2233,7 +2233,7 @@ public function testStartTagWithExtraAttributes() public function testWidgetAttributes() { - $form = $this->factory->createNamed('text', 'text', 'value', array( + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( 'required' => true, 'disabled' => true, 'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), @@ -2247,7 +2247,7 @@ public function testWidgetAttributes() public function testWidgetAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('text', 'text', 'value', array( + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( 'attr' => array('foo' => true), )); @@ -2259,7 +2259,7 @@ public function testWidgetAttributeNameRepeatedIfTrue() public function testWidgetAttributeHiddenIfFalse() { - $form = $this->factory->createNamed('text', 'text', 'value', array( + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( 'attr' => array('foo' => false), )); @@ -2270,7 +2270,7 @@ public function testWidgetAttributeHiddenIfFalse() public function testButtonAttributes() { - $form = $this->factory->createNamed('button', 'button', null, array( + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( 'disabled' => true, 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), )); @@ -2283,7 +2283,7 @@ public function testButtonAttributes() public function testButtonAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('button', 'button', null, array( + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( 'attr' => array('foo' => true), )); @@ -2295,7 +2295,7 @@ public function testButtonAttributeNameRepeatedIfTrue() public function testButtonAttributeHiddenIfFalse() { - $form = $this->factory->createNamed('button', 'button', null, array( + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( 'attr' => array('foo' => false), )); @@ -2306,7 +2306,7 @@ public function testButtonAttributeHiddenIfFalse() public function testTextareaWithWhitespaceOnlyContentRetainsValue() { - $form = $this->factory->createNamed('textarea', 'textarea', ' '); + $form = $this->factory->createNamed('textarea', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', ' '); $html = $this->renderWidget($form->createView()); @@ -2315,8 +2315,8 @@ public function testTextareaWithWhitespaceOnlyContentRetainsValue() public function testTextareaWithWhitespaceOnlyContentRetainsValueWhenRenderingForm() { - $form = $this->factory->createBuilder('form', array('textarea' => ' ')) - ->add('textarea', 'textarea') + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array('textarea' => ' ')) + ->add('textarea', 'Symfony\Component\Form\Extension\Core\Type\TextareaType') ->getForm(); $html = $this->renderForm($form->createView()); @@ -2326,7 +2326,7 @@ public function testTextareaWithWhitespaceOnlyContentRetainsValueWhenRenderingFo public function testWidgetContainerAttributeHiddenIfFalse() { - $form = $this->factory->createNamed('form', 'form', null, array( + $form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'attr' => array('foo' => false), )); @@ -2338,9 +2338,9 @@ public function testWidgetContainerAttributeHiddenIfFalse() public function testTranslatedAttributes() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('firstName', 'text', array('attr' => array('title' => 'Foo'))) - ->add('lastName', 'text', array('attr' => array('placeholder' => 'Bar'))) + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('attr' => array('title' => 'Foo'))) + ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('attr' => array('placeholder' => 'Bar'))) ->getForm() ->createView(); diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index d6e0b4f67194b..022b5148e9e51 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -323,7 +323,7 @@ public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $ ->will($this->returnValue($iniMax)); $options = array('post_max_size_message' => 'Max {{ max }}!'); - $form = $this->factory->createNamed('name', 'text', null, $options); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options); $this->setRequestData('POST', array(), array()); $this->requestHandler->handleRequest($form, $this->request); diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index f655d17cd65a0..7cb44ade6b192 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -18,7 +18,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest { public function testRow() { - $form = $this->factory->createNamed('name', 'text'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); $html = $this->renderRow($view); @@ -42,7 +42,7 @@ public function testRow() public function testLabelIsNotRenderedWhenSetToFalse() { - $form = $this->factory->createNamed('name', 'text', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( 'label' => false, )); $html = $this->renderRow($form->createView()); @@ -61,7 +61,7 @@ public function testLabelIsNotRenderedWhenSetToFalse() public function testRepeatedRow() { - $form = $this->factory->createNamed('name', 'repeated'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'); $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, @@ -91,7 +91,7 @@ public function testRepeatedRow() public function testRepeatedRowWithErrors() { - $form = $this->factory->createNamed('name', 'repeated'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'); $form->addError(new FormError('[trans]Error![/trans]')); $view = $form->createView(); $html = $this->renderRow($view); @@ -128,7 +128,7 @@ public function testRepeatedRowWithErrors() public function testButtonRow() { - $form = $this->factory->createNamed('name', 'button'); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType'); $view = $form->createView(); $html = $this->renderRow($view); @@ -147,11 +147,11 @@ public function testButtonRow() public function testRest() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'repeated') - ->add('field3', 'text') - ->add('field4', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType') + ->add('field3', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field4', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -194,8 +194,8 @@ public function testRest() public function testCollection() { - $form = $this->factory->createNamed('names', 'collection', array('a', 'b'), array( - 'type' => 'text', + $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array('a', 'b'), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -212,8 +212,8 @@ public function testCollection() public function testEmptyCollection() { - $form = $this->factory->createNamed('names', 'collection', array(), array( - 'type' => 'text', + $form = $this->factory->createNamed('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -226,11 +226,11 @@ public function testEmptyCollection() public function testForm() { - $view = $this->factory->createNamedBuilder('name', 'form') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->setMethod('PUT') ->setAction('http://example.com') - ->add('firstName', 'text') - ->add('lastName', 'text') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -278,9 +278,9 @@ public function testForm() public function testFormWidget() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('firstName', 'text') - ->add('lastName', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -315,10 +315,10 @@ public function testFormWidget() // https://github.com/symfony/symfony/issues/2308 public function testNestedFormError() { - $form = $this->factory->createNamedBuilder('name', 'form') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory - ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) - ->add('grandChild', 'form') + ->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('error_bubbling' => false)) + ->add('grandChild', 'Symfony\Component\Form\Extension\Core\Type\FormType') ) ->getForm(); @@ -341,11 +341,11 @@ public function testCsrf() ->method('getToken') ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); - $form = $this->factory->createNamedBuilder('name', 'form') + $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory // No CSRF protection on nested forms - ->createNamedBuilder('child', 'form') - ->add($this->factory->createNamedBuilder('grandchild', 'text')) + ->createNamedBuilder('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add($this->factory->createNamedBuilder('grandchild', 'Symfony\Component\Form\Extension\Core\Type\TextType')) ) ->getForm(); @@ -365,8 +365,8 @@ public function testCsrf() public function testRepeated() { - $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( - 'type' => 'text', + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', 'foobar', array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -399,8 +399,8 @@ public function testRepeated() public function testRepeatedWithCustomOptions() { - $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( - 'type' => 'password', + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RepeatedType', 'foobar', array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'first_options' => array('label' => 'Test', 'required' => false), 'second_options' => array('label' => 'Test2'), )); @@ -440,7 +440,7 @@ public function testRepeatedWithCustomOptions() public function testCollectionRowWithCustomBlock() { $collection = array('one', 'two', 'three'); - $form = $this->factory->createNamedBuilder('names', 'collection', $collection) + $form = $this->factory->createNamedBuilder('names', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', $collection) ->getForm(); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -456,9 +456,9 @@ public function testCollectionRowWithCustomBlock() public function testFormEndWithRest() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -494,9 +494,9 @@ public function testFormEndWithRest() public function testFormEndWithoutRest() { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') + $view = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('field1', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('field2', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm() ->createView(); @@ -510,11 +510,11 @@ public function testFormEndWithoutRest() public function testWidgetContainerAttributes() { - $form = $this->factory->createNamed('form', 'form', null, array( + $form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), )); - $form->add('text', 'text'); + $form->add('text', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $html = $this->renderWidget($form->createView()); @@ -524,7 +524,7 @@ public function testWidgetContainerAttributes() public function testWidgetContainerAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('form', 'form', null, array( + $form = $this->factory->createNamed('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'attr' => array('foo' => true), )); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index bdd64b0f4bfd7..48278819e0e26 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -888,7 +888,7 @@ function ($object, $key, $value) { /** * @group legacy */ - public function testCreateViewForLegacyChoiceList() + public function testCreateViewForFlatLegacyChoiceList() { // legacy ChoiceList instances provide legacy ChoiceView objects $preferred = array(new LegacyChoiceView('x', 'x', 'Preferred')); @@ -909,6 +909,36 @@ public function testCreateViewForLegacyChoiceList() $this->assertEquals(array(new ChoiceView('x', 'x', 'Preferred')), $view->preferredChoices); } + /** + * @group legacy + */ + public function testCreateViewForNestedLegacyChoiceList() + { + // legacy ChoiceList instances provide legacy ChoiceView objects + $preferred = array('Section 1' => array(new LegacyChoiceView('x', 'x', 'Preferred'))); + $other = array( + 'Section 2' => array(new LegacyChoiceView('y', 'y', 'Other')), + new LegacyChoiceView('z', 'z', 'Other one'), + ); + + $list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'); + + $list->expects($this->once()) + ->method('getPreferredViews') + ->will($this->returnValue($preferred)); + $list->expects($this->once()) + ->method('getRemainingViews') + ->will($this->returnValue($other)); + + $view = $this->factory->createView(new LegacyChoiceListAdapter($list)); + + $this->assertEquals(array( + 'Section 2' => array(new ChoiceView('y', 'y', 'Other')), + new ChoiceView('z', 'z', 'Other one'), + ), $view->choices); + $this->assertEquals(array('Section 1' => array(new ChoiceView('x', 'x', 'Preferred'))), $view->preferredChoices); + } + private function assertScalarListWithChoiceValues(ChoiceListInterface $list) { $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $list->getValues()); diff --git a/src/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php b/src/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php index 77873a71f9561..f85568f097cf2 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php @@ -26,16 +26,16 @@ public function testArrayBasedForm() $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->createBuilder('form') - ->add('firstName', 'text') - ->add('lastName', 'text') - ->add('gender', 'choice', array( + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'choices' => array('male' => 'Male', 'female' => 'Female'), 'required' => false, )) - ->add('age', 'number') - ->add('birthDate', 'birthday') - ->add('city', 'choice', array( + ->add('age', 'Symfony\Component\Form\Extension\Core\Type\NumberType') + ->add('birthDate', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType') + ->add('city', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( // simulate 300 different cities 'choices' => range(1, 300), )) diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index fdf83896d55a6..a306647234dd9 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -110,7 +110,7 @@ public function testSubmitDoesNotAddExtraFieldForNullValues() $factory = Forms::createFormFactoryBuilder() ->getFormFactory(); - $child = $factory->create('file', null, array('auto_initialize' => false)); + $child = $factory->createNamed('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', null, array('auto_initialize' => false)); $this->form->add($child); $this->form->submit(array('file' => null), false); 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 d6964d395ab14..3816b66c6b7d3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -170,9 +170,11 @@ public function testTransformWrapsIntlErrors() { $transformer = new DateTimeToLocalizedStringTransformer(); + $this->markTestIncomplete('Checking for intl errors needs to be reimplemented'); + // HOW TO REPRODUCE? - //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\Transdate_formationFailedException'); + //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException'); //$transformer->transform(1.5); } 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 840134da950df..c51132518ba67 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -20,10 +20,7 @@ protected function setUp() { parent::setUp(); - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); + \Locale::setDefault('en'); } public function transformWithRoundingProvider() @@ -89,6 +86,11 @@ public function testTransformWithRounding($input, $output, $roundingMode) public function testReverseTransform() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new IntegerToLocalizedStringTransformer(); $this->assertEquals(1, $transformer->reverseTransform('1')); @@ -106,6 +108,11 @@ public function testReverseTransformEmpty() public function testReverseTransformWithGrouping() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new IntegerToLocalizedStringTransformer(null, true); $this->assertEquals(1234, $transformer->reverseTransform('1.234,5')); 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 8b91fe10a2dff..99e4c8a574cf2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -16,18 +16,13 @@ class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() + public function testTransform() { - parent::setUp(); - // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); - } - public function testTransform() - { $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); $this->assertEquals('1,23', $transformer->transform(123)); @@ -51,6 +46,11 @@ public function testTransformEmpty() public function testReverseTransform() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); $this->assertEquals(123, $transformer->reverseTransform('1,23')); 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 47a0cd9574eb2..21a74ab486614 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -20,10 +20,7 @@ protected function setUp() { parent::setUp(); - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); + \Locale::setDefault('en'); } public function provideTransformations() @@ -44,6 +41,9 @@ public function provideTransformations() */ public function testTransform($from, $to, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(); @@ -67,6 +67,9 @@ public function provideTransformationsWithGrouping() */ public function testTransformWithGrouping($from, $to, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -76,6 +79,11 @@ public function testTransformWithGrouping($from, $to, $locale) public function testTransformWithScale() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(2); $this->assertEquals('1234,50', $transformer->transform(1234.5)); @@ -84,6 +92,11 @@ public function testTransformWithScale() public function transformWithRoundingProvider() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + return array( // towards positive infinity (1.6 -> 2, -1.6 -> -1) array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_CEILING), @@ -183,6 +196,11 @@ public function testTransformWithRounding($scale, $input, $output, $roundingMode public function testTransformDoesNotRoundIfNoScale() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, null, NumberToLocalizedStringTransformer::ROUND_DOWN); $this->assertEquals('1234,547', $transformer->transform(1234.547)); @@ -193,6 +211,9 @@ public function testTransformDoesNotRoundIfNoScale() */ public function testReverseTransform($to, $from, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(); @@ -205,6 +226,9 @@ public function testReverseTransform($to, $from, $locale) */ public function testReverseTransformWithGrouping($to, $from, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -219,6 +243,9 @@ public function testReverseTransformWithGroupingAndFixedSpaces() $this->markTestSkipped('The "mbstring" extension is required for this test.'); } + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('ru'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -228,6 +255,11 @@ public function testReverseTransformWithGroupingAndFixedSpaces() public function testReverseTransformWithGroupingButWithoutGroupSeparator() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, true); // omit group separator @@ -343,6 +375,9 @@ public function testReverseTransformDoesNotRoundIfNoScale() public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('fr'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -360,6 +395,11 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1.234.5'); @@ -370,6 +410,11 @@ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1234.5'); @@ -377,6 +422,9 @@ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGro public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed() { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('fr'); $transformer = new NumberToLocalizedStringTransformer(); @@ -386,6 +434,9 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupin public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('bg'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -403,7 +454,6 @@ public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() */ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() { - \Locale::setDefault('en'); $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1,234,5'); @@ -414,7 +464,6 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() */ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() { - \Locale::setDefault('en'); $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1234,5'); @@ -422,7 +471,6 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithN public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed() { - \Locale::setDefault('en'); $transformer = new NumberToLocalizedStringTransformer(); $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); @@ -542,6 +590,9 @@ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() $this->markTestSkipped('The "mbstring" extension is required for this test.'); } + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('ru'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -559,6 +610,9 @@ public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() $this->markTestSkipped('The "mbstring" extension is required for this test.'); } + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('ru'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -587,6 +641,9 @@ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() $this->markTestSkipped('The "mbstring" extension is required for this test.'); } + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('ru'); $transformer = new NumberToLocalizedStringTransformer(null, true); 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 6c9ef6186caec..99f06741b90d7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -20,10 +20,7 @@ protected function setUp() { parent::setUp(); - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); + \Locale::setDefault('en'); } public function testTransform() @@ -55,6 +52,11 @@ public function testTransformWithInteger() public function testTransformWithScale() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new PercentToLocalizedStringTransformer(2); $this->assertEquals('12,34', $transformer->transform(0.1234)); @@ -89,6 +91,11 @@ public function testReverseTransformWithInteger() public function testReverseTransformWithScale() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new PercentToLocalizedStringTransformer(2); $this->assertEquals(0.1234, $transformer->reverseTransform('12,34')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php index 0048cf41c5bfd..801ffd8833205 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php @@ -45,7 +45,7 @@ public function testStripLeadingUnderscoresAndDigitsFromId() public function testPassIdAndNameToViewWithParent() { - $view = $this->factory->createNamedBuilder('parent', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add('child', $this->getTestedType()) ->getForm() ->createView(); @@ -57,8 +57,8 @@ public function testPassIdAndNameToViewWithParent() public function testPassIdAndNameToViewWithGrandParent() { - $builder = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form'); + $builder = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType'); $builder->get('child')->add('grand_child', $this->getTestedType()); $view = $builder->getForm()->createView(); @@ -80,7 +80,7 @@ public function testPassTranslationDomainToView() public function testInheritTranslationDomainFromParent() { $view = $this->factory - ->createNamedBuilder('parent', 'form', null, array( + ->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'translation_domain' => 'domain', )) ->add('child', $this->getTestedType()) @@ -93,7 +93,7 @@ public function testInheritTranslationDomainFromParent() public function testPreferOwnTranslationDomain() { $view = $this->factory - ->createNamedBuilder('parent', 'form', null, array( + ->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'translation_domain' => 'parent_domain', )) ->add('child', $this->getTestedType(), array( @@ -107,7 +107,7 @@ public function testPreferOwnTranslationDomain() public function testDefaultTranslationDomain() { - $view = $this->factory->createNamedBuilder('parent', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add('child', $this->getTestedType()) ->getForm() ->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php index 755eac9035e07..5ef6f0479316b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php @@ -16,18 +16,28 @@ */ class BirthdayTypeTest extends BaseTypeTest { + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('birthday'); + + $this->assertSame('birthday', $form->getConfig()->getType()->getName()); + } + /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testSetInvalidYearsOption() { - $this->factory->create('birthday', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\BirthdayType', null, array( 'years' => 'bad value', )); } protected function getTestedType() { - return 'birthday'; + return 'Symfony\Component\Form\Extension\Core\Type\BirthdayType'; } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php index 55835e77feb73..c94903980e474 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php @@ -16,13 +16,23 @@ */ class ButtonTypeTest extends BaseTypeTest { + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('button'); + + $this->assertSame('button', $form->getConfig()->getType()->getName()); + } + public function testCreateButtonInstances() { - $this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create('button')); + $this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ButtonType')); } protected function getTestedType() { - return 'button'; + return 'Symfony\Component\Form\Extension\Core\Type\ButtonType'; } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php index 9437bd7eea655..e6e3c7088f1da 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php @@ -15,10 +15,20 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { - public function testDataIsFalseByDefault() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('checkbox'); + $this->assertSame('checkbox', $form->getConfig()->getType()->getName()); + } + + public function testDataIsFalseByDefault() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType'); + $this->assertFalse($form->getData()); $this->assertFalse($form->getNormData()); $this->assertNull($form->getViewData()); @@ -26,7 +36,7 @@ public function testDataIsFalseByDefault() public function testPassValueToView() { - $form = $this->factory->create('checkbox', null, array('value' => 'foobar')); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array('value' => 'foobar')); $view = $form->createView(); $this->assertEquals('foobar', $view->vars['value']); @@ -34,7 +44,7 @@ public function testPassValueToView() public function testCheckedIfDataTrue() { - $form = $this->factory->create('checkbox'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType'); $form->setData(true); $view = $form->createView(); @@ -43,7 +53,7 @@ public function testCheckedIfDataTrue() public function testCheckedIfDataTrueWithEmptyValue() { - $form = $this->factory->create('checkbox', null, array('value' => '')); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array('value' => '')); $form->setData(true); $view = $form->createView(); @@ -52,7 +62,7 @@ public function testCheckedIfDataTrueWithEmptyValue() public function testNotCheckedIfDataFalse() { - $form = $this->factory->create('checkbox'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType'); $form->setData(false); $view = $form->createView(); @@ -61,7 +71,7 @@ public function testNotCheckedIfDataFalse() public function testSubmitWithValueChecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => 'foobar', )); $form->submit('foobar'); @@ -72,7 +82,7 @@ public function testSubmitWithValueChecked() public function testSubmitWithRandomValueChecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => 'foobar', )); $form->submit('krixikraxi'); @@ -83,7 +93,7 @@ public function testSubmitWithRandomValueChecked() public function testSubmitWithValueUnchecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => 'foobar', )); $form->submit(null); @@ -94,7 +104,7 @@ public function testSubmitWithValueUnchecked() public function testSubmitWithEmptyValueChecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => '', )); $form->submit(''); @@ -105,7 +115,7 @@ public function testSubmitWithEmptyValueChecked() public function testSubmitWithEmptyValueUnchecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => '', )); $form->submit(null); @@ -116,7 +126,7 @@ public function testSubmitWithEmptyValueUnchecked() public function testSubmitWithEmptyValueAndFalseUnchecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => '', )); $form->submit(false); @@ -127,7 +137,7 @@ public function testSubmitWithEmptyValueAndFalseUnchecked() public function testSubmitWithEmptyValueAndTrueChecked() { - $form = $this->factory->create('checkbox', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CheckboxType', null, array( 'value' => '', )); $form->submit(true); @@ -151,7 +161,7 @@ function ($value) { } ); - $form = $this->factory->createBuilder('checkbox') + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\CheckboxType') ->addModelTransformer($transformer) ->getForm(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php index 83430d935c674..3e0ea22f9dbfa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php @@ -30,7 +30,7 @@ public function testSameChoiceFieldCreatedMultipleTimes() $choices = range(1, 300); for ($i = 0; $i < 100; ++$i) { - $this->factory->create('choice', mt_rand(1, 400), array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', mt_rand(1, 400), array( 'choices' => $choices, )); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 32fa8b1af7543..67241a1be921c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -67,12 +67,22 @@ protected function tearDown() $this->objectChoices = null; } + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('choice'); + + $this->assertSame('choice', $form->getConfig()->getType()->getName()); + } + /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testChoicesOptionExpectsArrayOrTraversable() { - $this->factory->create('choice', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => new \stdClass(), )); } @@ -82,7 +92,7 @@ public function testChoicesOptionExpectsArrayOrTraversable() */ public function testChoiceListOptionExpectsChoiceListInterface() { - $this->factory->create('choice', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choice_list' => array('foo' => 'foo'), )); } @@ -92,19 +102,19 @@ public function testChoiceListOptionExpectsChoiceListInterface() */ public function testChoiceLoaderOptionExpectsChoiceLoaderInterface() { - $this->factory->create('choice', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choice_loader' => new \stdClass(), )); } public function testChoiceListAndChoicesCanBeEmpty() { - $this->factory->create('choice'); + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType'); } public function testExpandedChoicesOptionsTurnIntoChildren() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => $this->choices, )); @@ -114,7 +124,7 @@ public function testExpandedChoicesOptionsTurnIntoChildren() public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -127,7 +137,7 @@ public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice() public function testPlaceholderNotPresentIfRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -140,7 +150,7 @@ public function testPlaceholderNotPresentIfRequired() public function testPlaceholderNotPresentIfMultiple() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'required' => false, @@ -153,7 +163,7 @@ public function testPlaceholderNotPresentIfMultiple() public function testPlaceholderNotPresentIfEmptyChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -169,7 +179,7 @@ public function testPlaceholderNotPresentIfEmptyChoice() public function testExpandedChoicesOptionsAreFlattened() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => $this->groupedChoices, )); @@ -194,7 +204,7 @@ public function testExpandedChoicesOptionsAreFlattenedObjectChoices() $obj4 = (object) array('id' => 4, 'name' => 'Jon'); $obj5 = (object) array('id' => 5, 'name' => 'Roman'); - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => array( 'Symfony' => array($obj1, $obj2, $obj3), @@ -214,7 +224,7 @@ public function testExpandedChoicesOptionsAreFlattenedObjectChoices() public function testExpandedCheckboxesAreNeverRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'required' => true, @@ -228,7 +238,7 @@ public function testExpandedCheckboxesAreNeverRequired() public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -242,7 +252,7 @@ public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired() public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -256,7 +266,7 @@ public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired() public function testSubmitSingleNonExpanded() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, @@ -271,7 +281,7 @@ public function testSubmitSingleNonExpanded() public function testSubmitSingleNonExpandedInvalidChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, @@ -286,7 +296,7 @@ public function testSubmitSingleNonExpandedInvalidChoice() public function testSubmitSingleNonExpandedNull() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, @@ -304,7 +314,7 @@ public function testSubmitSingleNonExpandedNull() // choices are available. public function testSubmitSingleNonExpandedNullNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => array(), @@ -319,7 +329,7 @@ public function testSubmitSingleNonExpandedNullNoChoices() public function testSubmitSingleNonExpandedEmpty() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, @@ -334,7 +344,7 @@ public function testSubmitSingleNonExpandedEmpty() public function testSubmitSingleNonExpandedEmptyExplicitEmptyChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => array( @@ -357,7 +367,7 @@ public function testSubmitSingleNonExpandedEmptyExplicitEmptyChoice() // choices are available. public function testSubmitSingleNonExpandedEmptyNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => array(), @@ -372,7 +382,7 @@ public function testSubmitSingleNonExpandedEmptyNoChoices() public function testSubmitSingleNonExpandedFalse() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->choices, @@ -390,7 +400,7 @@ public function testSubmitSingleNonExpandedFalse() // choices are available. public function testSubmitSingleNonExpandedFalseNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => array(), @@ -405,7 +415,7 @@ public function testSubmitSingleNonExpandedFalseNoChoices() public function testSubmitSingleNonExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->objectChoices, @@ -427,7 +437,7 @@ public function testSubmitSingleNonExpandedObjectChoices() */ public function testLegacySubmitSingleNonExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choice_list' => new ObjectChoiceList( @@ -451,7 +461,7 @@ public function testLegacySubmitSingleNonExpandedObjectChoices() public function testSubmitMultipleNonExpanded() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, @@ -466,7 +476,7 @@ public function testSubmitMultipleNonExpanded() public function testSubmitMultipleNonExpandedEmpty() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, @@ -484,7 +494,7 @@ public function testSubmitMultipleNonExpandedEmpty() // choices are available. public function testSubmitMultipleNonExpandedEmptyNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => array(), @@ -499,7 +509,7 @@ public function testSubmitMultipleNonExpandedEmptyNoChoices() public function testSubmitMultipleNonExpandedInvalidScalarChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, @@ -514,7 +524,7 @@ public function testSubmitMultipleNonExpandedInvalidScalarChoice() public function testSubmitMultipleNonExpandedInvalidArrayChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, @@ -529,7 +539,7 @@ public function testSubmitMultipleNonExpandedInvalidArrayChoice() public function testSubmitMultipleNonExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->objectChoices, @@ -550,7 +560,7 @@ public function testSubmitMultipleNonExpandedObjectChoices() */ public function testLegacySubmitMultipleNonExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choice_list' => new ObjectChoiceList( @@ -573,7 +583,7 @@ public function testLegacySubmitMultipleNonExpandedObjectChoices() public function testSubmitSingleExpandedRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -601,7 +611,7 @@ public function testSubmitSingleExpandedRequired() public function testSubmitSingleExpandedRequiredInvalidChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -629,7 +639,7 @@ public function testSubmitSingleExpandedRequiredInvalidChoice() public function testSubmitSingleExpandedNonRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -659,7 +669,7 @@ public function testSubmitSingleExpandedNonRequired() public function testSubmitSingleExpandedNonRequiredInvalidChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -687,7 +697,7 @@ public function testSubmitSingleExpandedNonRequiredInvalidChoice() public function testSubmitSingleExpandedRequiredNull() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -718,7 +728,7 @@ public function testSubmitSingleExpandedRequiredNull() // choices are available. public function testSubmitSingleExpandedRequiredNullNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -735,7 +745,7 @@ public function testSubmitSingleExpandedRequiredNullNoChoices() public function testSubmitSingleExpandedRequiredEmpty() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -766,7 +776,7 @@ public function testSubmitSingleExpandedRequiredEmpty() // choices are available. public function testSubmitSingleExpandedRequiredEmptyNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -783,7 +793,7 @@ public function testSubmitSingleExpandedRequiredEmptyNoChoices() public function testSubmitSingleExpandedRequiredFalse() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -814,7 +824,7 @@ public function testSubmitSingleExpandedRequiredFalse() // choices are available. public function testSubmitSingleExpandedRequiredFalseNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => true, @@ -831,7 +841,7 @@ public function testSubmitSingleExpandedRequiredFalseNoChoices() public function testSubmitSingleExpandedNonRequiredNull() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -864,7 +874,7 @@ public function testSubmitSingleExpandedNonRequiredNull() // choices are available. public function testSubmitSingleExpandedNonRequiredNullNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -881,7 +891,7 @@ public function testSubmitSingleExpandedNonRequiredNullNoChoices() public function testSubmitSingleExpandedNonRequiredEmpty() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -914,7 +924,7 @@ public function testSubmitSingleExpandedNonRequiredEmpty() // choices are available. public function testSubmitSingleExpandedNonRequiredEmptyNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -931,7 +941,7 @@ public function testSubmitSingleExpandedNonRequiredEmptyNoChoices() public function testSubmitSingleExpandedNonRequiredFalse() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -964,7 +974,7 @@ public function testSubmitSingleExpandedNonRequiredFalse() // choices are available. public function testSubmitSingleExpandedNonRequiredFalseNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'required' => false, @@ -981,7 +991,7 @@ public function testSubmitSingleExpandedNonRequiredFalseNoChoices() public function testSubmitSingleExpandedWithEmptyChild() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'choices' => array( @@ -1003,7 +1013,7 @@ public function testSubmitSingleExpandedWithEmptyChild() public function testSubmitSingleExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'choices' => $this->objectChoices, @@ -1034,7 +1044,7 @@ public function testSubmitSingleExpandedObjectChoices() */ public function testLegacySubmitSingleExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'choice_list' => new ObjectChoiceList( @@ -1067,7 +1077,7 @@ public function testLegacySubmitSingleExpandedObjectChoices() public function testSubmitSingleExpandedNumericChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => true, 'choices' => $this->numericChoices, @@ -1092,7 +1102,7 @@ public function testSubmitSingleExpandedNumericChoices() public function testSubmitMultipleExpanded() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, @@ -1119,7 +1129,7 @@ public function testSubmitMultipleExpanded() public function testSubmitMultipleExpandedInvalidScalarChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, @@ -1146,7 +1156,7 @@ public function testSubmitMultipleExpandedInvalidScalarChoice() public function testSubmitMultipleExpandedInvalidArrayChoice() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, @@ -1173,7 +1183,7 @@ public function testSubmitMultipleExpandedInvalidArrayChoice() public function testSubmitMultipleExpandedEmpty() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->choices, @@ -1201,7 +1211,7 @@ public function testSubmitMultipleExpandedEmpty() // choices are available. public function testSubmitMultipleExpandedEmptyNoChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => array(), @@ -1215,7 +1225,7 @@ public function testSubmitMultipleExpandedEmptyNoChoices() public function testSubmitMultipleExpandedWithEmptyChild() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => array( @@ -1240,7 +1250,7 @@ public function testSubmitMultipleExpandedWithEmptyChild() public function testSubmitMultipleExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->objectChoices, @@ -1271,7 +1281,7 @@ public function testSubmitMultipleExpandedObjectChoices() */ public function testLegacySubmitMultipleExpandedObjectChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choice_list' => new ObjectChoiceList( @@ -1304,7 +1314,7 @@ public function testLegacySubmitMultipleExpandedObjectChoices() public function testSubmitMultipleExpandedNumericChoices() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => true, 'choices' => $this->numericChoices, @@ -1333,7 +1343,7 @@ public function testSubmitMultipleExpandedNumericChoices() */ public function testSetDataSingleNonExpandedAcceptsBoolean() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'expanded' => false, 'choices' => $this->numericChoices, @@ -1348,7 +1358,7 @@ public function testSetDataSingleNonExpandedAcceptsBoolean() public function testSetDataMultipleNonExpandedAcceptsBoolean() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->numericChoices, @@ -1363,7 +1373,7 @@ public function testSetDataMultipleNonExpandedAcceptsBoolean() public function testPassRequiredToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, )); $view = $form->createView(); @@ -1373,7 +1383,7 @@ public function testPassRequiredToView() public function testPassNonRequiredToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'required' => false, 'choices' => $this->choices, )); @@ -1384,7 +1394,7 @@ public function testPassNonRequiredToView() public function testPassMultipleToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'choices' => $this->choices, )); @@ -1395,7 +1405,7 @@ public function testPassMultipleToView() public function testPassExpandedToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'expanded' => true, 'choices' => $this->choices, )); @@ -1406,7 +1416,7 @@ public function testPassExpandedToView() public function testPassChoiceTranslationDomainToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, )); $view = $form->createView(); @@ -1416,7 +1426,7 @@ public function testPassChoiceTranslationDomainToView() public function testChoiceTranslationDomainWithTrueValueToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, 'choice_translation_domain' => true, )); @@ -1427,7 +1437,7 @@ public function testChoiceTranslationDomainWithTrueValueToView() public function testDefaultChoiceTranslationDomainIsSameAsTranslationDomainToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->choices, 'translation_domain' => 'foo', )); @@ -1439,10 +1449,10 @@ public function testDefaultChoiceTranslationDomainIsSameAsTranslationDomainToVie public function testInheritChoiceTranslationDomainFromParent() { $view = $this->factory - ->createNamedBuilder('parent', 'form', null, array( + ->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'translation_domain' => 'domain', )) - ->add('child', 'choice') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType') ->getForm() ->createView(); @@ -1451,7 +1461,7 @@ public function testInheritChoiceTranslationDomainFromParent() public function testPlaceholderIsNullByDefaultIfRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'required' => true, 'choices' => $this->choices, @@ -1463,7 +1473,7 @@ public function testPlaceholderIsNullByDefaultIfRequired() public function testPlaceholderIsEmptyStringByDefaultIfNotRequired() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => false, 'required' => false, 'choices' => $this->choices, @@ -1478,7 +1488,7 @@ public function testPlaceholderIsEmptyStringByDefaultIfNotRequired() */ public function testPassPlaceholderToView($multiple, $expanded, $required, $placeholder, $viewValue) { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => $multiple, 'expanded' => $expanded, 'required' => $required, @@ -1496,7 +1506,7 @@ public function testPassPlaceholderToView($multiple, $expanded, $required, $plac */ public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue) { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => $multiple, 'expanded' => $expanded, 'required' => $required, @@ -1516,7 +1526,7 @@ public function testPassEmptyValueBC($multiple, $expanded, $required, $placehold */ public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded, $required, $placeholder, $viewValue) { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => $multiple, 'expanded' => $expanded, 'required' => $required, @@ -1576,7 +1586,7 @@ public function getOptionsWithPlaceholder() public function testPassChoicesToView() { $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $choices, )); $view = $form->createView(); @@ -1592,7 +1602,7 @@ public function testPassChoicesToView() public function testPassPreferredChoicesToView() { $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $choices, 'preferred_choices' => array('b', 'd'), )); @@ -1610,7 +1620,7 @@ public function testPassPreferredChoicesToView() public function testPassHierarchicalChoicesToView() { - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => $this->groupedChoices, 'preferred_choices' => array('b', 'd'), )); @@ -1641,7 +1651,7 @@ public function testPassChoiceDataToView() $obj2 = (object) array('value' => 'b', 'label' => 'B'); $obj3 = (object) array('value' => 'c', 'label' => 'C'); $obj4 = (object) array('value' => 'd', 'label' => 'D'); - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array($obj1, $obj2, $obj3, $obj4), 'choices_as_values' => true, 'choice_label' => 'label', @@ -1659,7 +1669,7 @@ public function testPassChoiceDataToView() public function testAdjustFullNameForMultipleNonExpanded() { - $form = $this->factory->createNamed('name', 'choice', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, @@ -1672,7 +1682,7 @@ public function testAdjustFullNameForMultipleNonExpanded() // https://github.com/symfony/symfony/issues/3298 public function testInitializeWithEmptyChoices() { - $this->factory->createNamed('name', 'choice', null, array( + $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array(), )); } @@ -1684,7 +1694,7 @@ public function testInitializeWithDefaultObjectChoice() $obj3 = (object) array('value' => 'c', 'label' => 'C'); $obj4 = (object) array('value' => 'd', 'label' => 'D'); - $form = $this->factory->create('choice', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( 'choices' => array($obj1, $obj2, $obj3, $obj4), 'choices_as_values' => true, 'choice_label' => 'label', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index ef00ea25bd84a..81010ae50f371 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -13,23 +13,34 @@ use Symfony\Component\Form\Form; use Symfony\Component\Form\Tests\Fixtures\Author; -use Symfony\Component\Form\Tests\Fixtures\AuthorType; class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { - public function testContainsNoChildByDefault() + /** + * @group legacy + */ + public function testLegacyName() { - $form = $this->factory->create('collection', null, array( + $form = $this->factory->create('collection', array( 'type' => 'text', )); + $this->assertSame('collection', $form->getConfig()->getType()->getName()); + } + + public function testContainsNoChildByDefault() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', + )); + $this->assertCount(0, $form); } public function testSetDataAdjustsSize() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'options' => array( 'attr' => array('maxlength' => 20), ), @@ -57,8 +68,8 @@ public function testSetDataAdjustsSize() public function testThrowsExceptionIfObjectIsNotTraversable() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); $form->setData(new \stdClass()); @@ -66,8 +77,8 @@ public function testThrowsExceptionIfObjectIsNotTraversable() public function testNotResizedIfSubmittedWithMissingData() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $form->setData(array('foo@foo.com', 'bar@bar.com')); $form->submit(array('foo@bar.com')); @@ -80,8 +91,8 @@ public function testNotResizedIfSubmittedWithMissingData() public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_delete' => true, )); $form->setData(array('foo@foo.com', 'bar@bar.com')); @@ -95,8 +106,8 @@ public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_delete' => true, 'delete_empty' => true, )); @@ -112,8 +123,8 @@ public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty() public function testDontAddEmptyDataIfDeleteEmpty() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_add' => true, 'delete_empty' => true, )); @@ -129,8 +140,8 @@ public function testDontAddEmptyDataIfDeleteEmpty() public function testNoDeleteEmptyIfDeleteNotAllowed() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_delete' => false, 'delete_empty' => true, )); @@ -144,8 +155,8 @@ public function testNoDeleteEmptyIfDeleteNotAllowed() public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty() { - $form = $this->factory->create('collection', null, array( - 'type' => new AuthorType(), + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType', // If the field is not required, no new Author will be created if the // form is completely empty 'options' => array('required' => false), @@ -167,8 +178,8 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty() public function testNotResizedIfSubmittedWithExtraData() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $form->setData(array('foo@bar.com')); $form->submit(array('foo@foo.com', 'bar@bar.com')); @@ -180,8 +191,8 @@ public function testNotResizedIfSubmittedWithExtraData() public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_add' => true, )); $form->setData(array('foo@bar.com')); @@ -196,8 +207,8 @@ public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() public function testAllowAddButNoPrototype() { - $form = $this->factory->create('collection', null, array( - 'type' => 'form', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'allow_add' => true, 'prototype' => false, )); @@ -208,8 +219,8 @@ public function testAllowAddButNoPrototype() public function testPrototypeMultipartPropagation() { $form = $this->factory - ->create('collection', null, array( - 'type' => 'file', + ->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'allow_add' => true, 'prototype' => true, )) @@ -220,8 +231,8 @@ public function testPrototypeMultipartPropagation() public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() { - $form = $this->factory->create('collection', array(), array( - 'type' => 'file', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'prototype' => true, 'allow_add' => true, )); @@ -232,8 +243,8 @@ public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() { - $form = $this->factory->create('collection', array(), array( - 'type' => 'file', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'allow_add' => true, 'prototype' => true, )); @@ -245,16 +256,16 @@ public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() public function testPrototypeNameOption() { - $form = $this->factory->create('collection', null, array( - 'type' => 'form', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'prototype' => true, 'allow_add' => true, )); $this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default'); - $form = $this->factory->create('collection', null, array( - 'type' => 'form', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FormType', 'prototype' => true, 'allow_add' => true, 'prototype_name' => '__test__', @@ -265,8 +276,8 @@ public function testPrototypeNameOption() public function testPrototypeDefaultLabel() { - $form = $this->factory->create('collection', array(), array( - 'type' => 'file', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\FileType', 'allow_add' => true, 'prototype' => true, 'prototype_name' => '__test__', @@ -277,8 +288,8 @@ public function testPrototypeDefaultLabel() public function testPrototypeData() { - $form = $this->factory->create('collection', array(), array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'allow_add' => true, 'prototype' => true, 'prototype_data' => 'foo', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php index 16af981e624ab..3580b4ee07da8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php @@ -24,9 +24,19 @@ protected function setUp() parent::setUp(); } - public function testCountriesAreSelectable() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('country'); + + $this->assertSame('country', $form->getConfig()->getType()->getName()); + } + + public function testCountriesAreSelectable() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CountryType'); $view = $form->createView(); $choices = $view->vars['choices']; @@ -40,7 +50,7 @@ public function testCountriesAreSelectable() public function testUnknownCountryIsNotIncluded() { - $form = $this->factory->create('country', 'country'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CountryType', 'Symfony\Component\Form\Extension\Core\Type\CountryType'); $view = $form->createView(); $choices = $view->vars['choices']; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php index 2d572d60b45df..e2925961df2f2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php @@ -24,9 +24,19 @@ protected function setUp() parent::setUp(); } - public function testCurrenciesAreSelectable() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('currency'); + + $this->assertSame('currency', $form->getConfig()->getType()->getName()); + } + + public function testCurrenciesAreSelectable() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CurrencyType'); $view = $form->createView(); $choices = $view->vars['choices']; 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 f31cc04bd0669..d9f5640c54d80 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -13,20 +13,29 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; class DateTimeTypeTest extends TestCase { protected function setUp() { - IntlTestHelper::requireIntl($this); + \Locale::setDefault('en'); parent::setUp(); } + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('datetime'); + + $this->assertSame('datetime', $form->getConfig()->getType()->getName()); + } + public function testSubmitDateTime() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'date_widget' => 'choice', @@ -53,7 +62,7 @@ public function testSubmitDateTime() public function testSubmitString() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'string', @@ -78,7 +87,7 @@ public function testSubmitString() public function testSubmitTimestamp() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'timestamp', @@ -105,7 +114,7 @@ public function testSubmitTimestamp() public function testSubmitWithoutMinutes() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'date_widget' => 'choice', @@ -134,7 +143,7 @@ public function testSubmitWithoutMinutes() public function testSubmitWithSeconds() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'date_widget' => 'choice', @@ -165,7 +174,7 @@ public function testSubmitWithSeconds() public function testSubmitDifferentTimezones() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'America/New_York', 'view_timezone' => 'Pacific/Tahiti', 'date_widget' => 'choice', @@ -196,7 +205,7 @@ public function testSubmitDifferentTimezones() public function testSubmitDifferentTimezonesDateTime() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'America/New_York', 'view_timezone' => 'Pacific/Tahiti', 'widget' => 'single_text', @@ -215,7 +224,7 @@ public function testSubmitDifferentTimezonesDateTime() public function testSubmitStringSingleText() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'string', @@ -230,7 +239,7 @@ public function testSubmitStringSingleText() public function testSubmitStringSingleTextWithSeconds() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'string', @@ -246,7 +255,7 @@ public function testSubmitStringSingleTextWithSeconds() public function testSubmitDifferentPattern() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'date_format' => 'MM*yyyy*dd', 'date_widget' => 'single_text', 'time_widget' => 'single_text', @@ -268,12 +277,12 @@ public function testInitializeWithDateTime() { // Throws an exception if "data_class" option is not explicitly set // to null in the type - $this->factory->create('datetime', new \DateTime()); + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', new \DateTime()); } public function testSingleTextWidgetShouldUseTheRightInputType() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'widget' => 'single_text', )); @@ -283,7 +292,7 @@ public function testSingleTextWidgetShouldUseTheRightInputType() public function testPassDefaultPlaceholderToViewIfNotRequired() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'required' => false, 'with_seconds' => true, )); @@ -299,7 +308,7 @@ public function testPassDefaultPlaceholderToViewIfNotRequired() public function testPassNoPlaceholderToViewIfRequired() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'required' => true, 'with_seconds' => true, )); @@ -315,7 +324,7 @@ public function testPassNoPlaceholderToViewIfRequired() public function testPassPlaceholderAsString() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'placeholder' => 'Empty', 'with_seconds' => true, )); @@ -331,7 +340,7 @@ public function testPassPlaceholderAsString() public function testPassEmptyValueBC() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'empty_value' => 'Empty', 'with_seconds' => true, )); @@ -353,7 +362,7 @@ public function testPassEmptyValueBC() public function testPassPlaceholderAsArray() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'placeholder' => array( 'year' => 'Empty year', 'month' => 'Empty month', @@ -376,7 +385,7 @@ public function testPassPlaceholderAsArray() public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'required' => false, 'placeholder' => array( 'year' => 'Empty year', @@ -398,7 +407,7 @@ public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() public function testPassPlaceholderAsPartialArrayAddNullIfRequired() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'required' => true, 'placeholder' => array( 'year' => 'Empty year', @@ -420,7 +429,7 @@ public function testPassPlaceholderAsPartialArrayAddNullIfRequired() public function testPassHtml5TypeIfSingleTextAndHtml5Format() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'widget' => 'single_text', )); @@ -430,7 +439,7 @@ public function testPassHtml5TypeIfSingleTextAndHtml5Format() public function testDontPassHtml5TypeIfHtml5NotAllowed() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'widget' => 'single_text', 'html5' => false, )); @@ -441,7 +450,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed() public function testDontPassHtml5TypeIfNotHtml5Format() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'widget' => 'single_text', 'format' => 'yyyy-MM-dd HH:mm', )); @@ -452,7 +461,7 @@ public function testDontPassHtml5TypeIfNotHtml5Format() public function testDontPassHtml5TypeIfNotSingleText() { - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'widget' => 'text', )); @@ -463,7 +472,7 @@ public function testDontPassHtml5TypeIfNotSingleText() public function testDateTypeChoiceErrorsBubbleUp() { $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null); $form['date']->addError($error); @@ -474,7 +483,7 @@ public function testDateTypeChoiceErrorsBubbleUp() public function testDateTypeSingleTextErrorsBubbleUp() { $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'date_widget' => 'single_text', )); @@ -487,7 +496,7 @@ public function testDateTypeSingleTextErrorsBubbleUp() public function testTimeTypeChoiceErrorsBubbleUp() { $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null); $form['time']->addError($error); @@ -498,7 +507,7 @@ public function testTimeTypeChoiceErrorsBubbleUp() public function testTimeTypeSingleTextErrorsBubbleUp() { $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( 'time_widget' => 'single_text', )); 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 f66441e43cca3..e9fe5391e85f3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -23,18 +23,23 @@ class DateTypeTest extends TestCase protected function setUp() { parent::setUp(); - - // we test against "de_AT", so we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - $this->defaultTimezone = date_default_timezone_get(); } protected function tearDown() { date_default_timezone_set($this->defaultTimezone); + \Locale::setDefault('en'); + } + + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('date'); + + $this->assertSame('date', $form->getConfig()->getType()->getName()); } /** @@ -42,7 +47,7 @@ protected function tearDown() */ public function testInvalidWidgetOption() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'fake_widget', )); } @@ -52,14 +57,14 @@ public function testInvalidWidgetOption() */ public function testInvalidInputOption() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'input' => 'fake_input', )); } public function testSubmitFromSingleTextDateTimeWithDefaultFormat() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'single_text', @@ -74,7 +79,12 @@ public function testSubmitFromSingleTextDateTimeWithDefaultFormat() public function testSubmitFromSingleTextDateTime() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', @@ -90,7 +100,12 @@ public function testSubmitFromSingleTextDateTime() public function testSubmitFromSingleTextString() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', @@ -106,7 +121,12 @@ public function testSubmitFromSingleTextString() public function testSubmitFromSingleTextTimestamp() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', @@ -124,7 +144,12 @@ public function testSubmitFromSingleTextTimestamp() public function testSubmitFromSingleTextRaw() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', @@ -146,7 +171,7 @@ public function testSubmitFromSingleTextRaw() public function testSubmitFromText() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'text', @@ -168,7 +193,7 @@ public function testSubmitFromText() public function testSubmitFromChoice() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'choice', @@ -190,7 +215,7 @@ public function testSubmitFromChoice() public function testSubmitFromChoiceEmpty() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'choice', @@ -211,7 +236,7 @@ public function testSubmitFromChoiceEmpty() public function testSubmitFromInputDateTimeDifferentPattern() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'format' => 'MM*yyyy*dd', @@ -227,7 +252,7 @@ public function testSubmitFromInputDateTimeDifferentPattern() public function testSubmitFromInputStringDifferentPattern() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'format' => 'MM*yyyy*dd', @@ -243,7 +268,7 @@ public function testSubmitFromInputStringDifferentPattern() public function testSubmitFromInputTimestampDifferentPattern() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'format' => 'MM*yyyy*dd', @@ -261,7 +286,7 @@ public function testSubmitFromInputTimestampDifferentPattern() public function testSubmitFromInputRawDifferentPattern() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'format' => 'MM*yyyy*dd', @@ -286,7 +311,7 @@ public function testSubmitFromInputRawDifferentPattern() */ public function testDatePatternWithFormatOption($format, $pattern) { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => $format, )); @@ -312,7 +337,7 @@ public function provideDateFormats() */ public function testThrowExceptionIfFormatIsNoPattern() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => '0', 'widget' => 'single_text', 'input' => 'string', @@ -324,7 +349,7 @@ public function testThrowExceptionIfFormatIsNoPattern() */ public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'months' => array(6, 7), 'format' => 'yy', )); @@ -335,7 +360,7 @@ public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay() */ public function testThrowExceptionIfFormatIsNoConstant() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => 105, )); } @@ -345,7 +370,7 @@ public function testThrowExceptionIfFormatIsNoConstant() */ public function testThrowExceptionIfFormatIsInvalid() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => array(), )); } @@ -355,7 +380,7 @@ public function testThrowExceptionIfFormatIsInvalid() */ public function testThrowExceptionIfYearsIsInvalid() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'years' => 'bad value', )); } @@ -365,7 +390,7 @@ public function testThrowExceptionIfYearsIsInvalid() */ public function testThrowExceptionIfMonthsIsInvalid() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'months' => 'bad value', )); } @@ -375,14 +400,19 @@ public function testThrowExceptionIfMonthsIsInvalid() */ public function testThrowExceptionIfDaysIsInvalid() { - $this->factory->create('date', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'days' => 'bad value', )); } public function testSetDataWithNegativeTimezoneOffsetStringInput() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', 'view_timezone' => 'America/New_York', @@ -399,7 +429,12 @@ public function testSetDataWithNegativeTimezoneOffsetStringInput() public function testSetDataWithNegativeTimezoneOffsetDateTimeInput() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', 'view_timezone' => 'America/New_York', @@ -419,7 +454,7 @@ public function testSetDataWithNegativeTimezoneOffsetDateTimeInput() public function testYearsOption() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'years' => array(2010, 2011), )); @@ -433,21 +468,27 @@ public function testYearsOption() public function testMonthsOption() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'months' => array(6, 7), + 'format' => \IntlDateFormatter::SHORT, )); $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), + new ChoiceView(6, '6', '06'), + new ChoiceView(7, '7', '07'), ), $view['month']->vars['choices']); } public function testMonthsOptionShortFormat() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'months' => array(1, 4), 'format' => 'dd.MMM.yy', )); @@ -455,14 +496,19 @@ public function testMonthsOptionShortFormat() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('1', '1', 'Jän'), - new ChoiceView('4', '4', 'Apr.'), + new ChoiceView(1, '1', 'Jän'), + new ChoiceView(4, '4', 'Apr.'), ), $view['month']->vars['choices']); } public function testMonthsOptionLongFormat() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'months' => array(1, 4), 'format' => 'dd.MMMM.yy', )); @@ -470,14 +516,19 @@ public function testMonthsOptionLongFormat() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('1', '1', 'Jänner'), - new ChoiceView('4', '4', 'April'), + new ChoiceView(1, '1', 'Jänner'), + new ChoiceView(4, '4', 'April'), ), $view['month']->vars['choices']); } public function testMonthsOptionLongFormatWithDifferentTimezone() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'months' => array(1, 4), 'format' => 'dd.MMMM.yy', )); @@ -485,22 +536,22 @@ public function testMonthsOptionLongFormatWithDifferentTimezone() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('1', '1', 'Jänner'), - new ChoiceView('4', '4', 'April'), + new ChoiceView(1, '1', 'Jänner'), + new ChoiceView(4, '4', 'April'), ), $view['month']->vars['choices']); } public function testIsDayWithinRangeReturnsTrueIfWithin() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'days' => array(6, 7), )); $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), + new ChoiceView(6, '6', '06'), + new ChoiceView(7, '7', '07'), ), $view['day']->vars['choices']); } @@ -508,7 +559,7 @@ public function testIsPartiallyFilledReturnsFalseIfSingleText() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'single_text', @@ -523,7 +574,7 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'choice', @@ -542,7 +593,7 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyFilled() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'choice', @@ -561,7 +612,7 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'widget' => 'choice', @@ -578,7 +629,12 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty() public function testPassDatePatternToView() { - $form = $this->factory->create('date'); + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType'); $view = $form->createView(); $this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); @@ -586,7 +642,12 @@ public function testPassDatePatternToView() public function testPassDatePatternToViewDifferentFormat() { - $form = $this->factory->create('date', null, array( + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => \IntlDateFormatter::LONG, )); @@ -597,7 +658,7 @@ public function testPassDatePatternToViewDifferentFormat() public function testPassDatePatternToViewDifferentPattern() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => 'MMyyyydd', )); @@ -608,7 +669,7 @@ public function testPassDatePatternToViewDifferentPattern() public function testPassDatePatternToViewDifferentPatternWithSeparators() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'format' => 'MM*yyyy*dd', )); @@ -619,7 +680,7 @@ public function testPassDatePatternToViewDifferentPatternWithSeparators() public function testDontPassDatePatternIfText() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'single_text', )); $view = $form->createView(); @@ -629,9 +690,12 @@ public function testDontPassDatePatternIfText() public function testDatePatternFormatWithQuotedStrings() { + // we test against "es_ES", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('es_ES'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( // EEEE, d 'de' MMMM 'de' y 'format' => \IntlDateFormatter::FULL, )); @@ -643,7 +707,7 @@ public function testDatePatternFormatWithQuotedStrings() public function testPassWidgetToView() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'single_text', )); $view = $form->createView(); @@ -656,12 +720,12 @@ public function testInitializeWithDateTime() { // Throws an exception if "data_class" option is not explicitly set // to null in the type - $this->factory->create('date', new \DateTime()); + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', new \DateTime()); } public function testSingleTextWidgetShouldUseTheRightInputType() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'single_text', )); @@ -671,7 +735,7 @@ public function testSingleTextWidgetShouldUseTheRightInputType() public function testPassDefaultPlaceholderToViewIfNotRequired() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'required' => false, )); @@ -683,7 +747,7 @@ public function testPassDefaultPlaceholderToViewIfNotRequired() public function testPassNoPlaceholderToViewIfRequired() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'required' => true, )); @@ -695,7 +759,7 @@ public function testPassNoPlaceholderToViewIfRequired() public function testPassPlaceholderAsString() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'placeholder' => 'Empty', )); @@ -707,7 +771,7 @@ public function testPassPlaceholderAsString() public function testPassEmptyValueBC() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'empty_value' => 'Empty', )); @@ -722,7 +786,7 @@ public function testPassEmptyValueBC() public function testPassPlaceholderAsArray() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'placeholder' => array( 'year' => 'Empty year', 'month' => 'Empty month', @@ -738,7 +802,7 @@ public function testPassPlaceholderAsArray() public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'required' => false, 'placeholder' => array( 'year' => 'Empty year', @@ -754,7 +818,7 @@ public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() public function testPassPlaceholderAsPartialArrayAddNullIfRequired() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'required' => true, 'placeholder' => array( 'year' => 'Empty year', @@ -770,7 +834,7 @@ public function testPassPlaceholderAsPartialArrayAddNullIfRequired() public function testPassHtml5TypeIfSingleTextAndHtml5Format() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'single_text', )); @@ -780,7 +844,7 @@ public function testPassHtml5TypeIfSingleTextAndHtml5Format() public function testDontPassHtml5TypeIfHtml5NotAllowed() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'single_text', 'html5' => false, )); @@ -791,7 +855,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed() public function testDontPassHtml5TypeIfNotHtml5Format() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'single_text', 'format' => \IntlDateFormatter::MEDIUM, )); @@ -802,7 +866,7 @@ public function testDontPassHtml5TypeIfNotHtml5Format() public function testDontPassHtml5TypeIfNotSingleText() { - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => 'text', )); @@ -824,7 +888,7 @@ public function provideCompoundWidgets() public function testYearErrorsBubbleUp($widget) { $error = new FormError('Invalid!'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => $widget, )); $form['year']->addError($error); @@ -839,7 +903,7 @@ public function testYearErrorsBubbleUp($widget) public function testMonthErrorsBubbleUp($widget) { $error = new FormError('Invalid!'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => $widget, )); $form['month']->addError($error); @@ -854,7 +918,7 @@ public function testMonthErrorsBubbleUp($widget) public function testDayErrorsBubbleUp($widget) { $error = new FormError('Invalid!'); - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'widget' => $widget, )); $form['day']->addError($error); @@ -870,7 +934,7 @@ public function testYearsFor32BitsMachines() 'PHP must be compiled in 32 bit mode to run this test'); } - $form = $this->factory->create('date', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( 'years' => range(1900, 2040), )); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php index 55555efecb7bf..eebb6ad5839ea 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php @@ -13,10 +13,20 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('file'); + + $this->assertSame('file', $form->getConfig()->getType()->getName()); + } + // https://github.com/symfony/symfony/pull/5028 public function testSetData() { - $form = $this->factory->createBuilder('file')->getForm(); + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType')->getForm(); $data = $this->createUploadedFileMock('abcdef', 'original.jpg', true); $form->setData($data); @@ -26,7 +36,7 @@ public function testSetData() public function testSubmit() { - $form = $this->factory->createBuilder('file')->getForm(); + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType')->getForm(); $data = $this->createUploadedFileMock('abcdef', 'original.jpg', true); $form->submit($data); @@ -37,7 +47,7 @@ public function testSubmit() // https://github.com/symfony/symfony/issues/6134 public function testSubmitEmpty() { - $form = $this->factory->createBuilder('file')->getForm(); + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType')->getForm(); $form->submit(null); @@ -46,7 +56,7 @@ public function testSubmitEmpty() public function testSubmitMultiple() { - $form = $this->factory->createBuilder('file', null, array( + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FileType', null, array( 'multiple' => true, ))->getForm(); @@ -65,9 +75,9 @@ public function testSubmitMultiple() public function testDontPassValueToView() { - $form = $this->factory->create('file'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FileType'); $form->submit(array( - 'file' => $this->createUploadedFileMock('abcdef', 'original.jpg', true), + 'Symfony\Component\Form\Extension\Core\Type\FileType' => $this->createUploadedFileMock('abcdef', 'original.jpg', true), )); $view = $form->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 0ebb554a6ac84..5df2002397354 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -51,25 +51,35 @@ public function setReferenceCopy($reference) class FormTypeTest extends BaseTypeTest { + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('form'); + + $this->assertSame('form', $form->getConfig()->getType()->getName()); + } + public function testCreateFormInstances() { - $this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create('form')); + $this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType')); } public function testPassRequiredAsOption() { - $form = $this->factory->create('form', null, array('required' => false)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('required' => false)); $this->assertFalse($form->isRequired()); - $form = $this->factory->create('form', null, array('required' => true)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('required' => true)); $this->assertTrue($form->isRequired()); } public function testSubmittedDataIsTrimmedBeforeTransforming() { - $form = $this->factory->createBuilder('form') + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') ->addViewTransformer(new FixedDataTransformer(array( null => '', 'reverse[a]' => 'a', @@ -85,7 +95,7 @@ public function testSubmittedDataIsTrimmedBeforeTransforming() public function testSubmittedDataIsNotTrimmedBeforeTransformingIfNoTrimming() { - $form = $this->factory->createBuilder('form', null, array('trim' => false)) + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('trim' => false)) ->addViewTransformer(new FixedDataTransformer(array( null => '', 'reverse[ a ]' => ' a ', @@ -104,8 +114,8 @@ public function testSubmittedDataIsNotTrimmedBeforeTransformingIfNoTrimming() */ public function testLegacyNonReadOnlyFormWithReadOnlyParentIsReadOnly() { - $view = $this->factory->createNamedBuilder('parent', 'form', null, array('read_only' => true)) - ->add('child', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('read_only' => true)) + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->getForm() ->createView(); @@ -114,8 +124,8 @@ public function testLegacyNonReadOnlyFormWithReadOnlyParentIsReadOnly() public function testNonReadOnlyFormWithReadOnlyParentIsReadOnly() { - $view = $this->factory->createNamedBuilder('parent', 'form', null, array('attr' => array('readonly' => true))) - ->add('child', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array('attr' => array('readonly' => true))) + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->getForm() ->createView(); @@ -127,8 +137,8 @@ public function testNonReadOnlyFormWithReadOnlyParentIsReadOnly() */ public function testLegacyReadOnlyFormWithNonReadOnlyParentIsReadOnly() { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form', array('read_only' => true)) + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', array('read_only' => true)) ->getForm() ->createView(); @@ -137,8 +147,8 @@ public function testLegacyReadOnlyFormWithNonReadOnlyParentIsReadOnly() public function testReadOnlyFormWithNonReadOnlyParentIsReadOnly() { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form', array('attr' => array('readonly' => true))) + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType', array('attr' => array('readonly' => true))) ->getForm() ->createView(); @@ -150,8 +160,8 @@ public function testReadOnlyFormWithNonReadOnlyParentIsReadOnly() */ public function testLegacyNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly() { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->getForm() ->createView(); @@ -160,8 +170,8 @@ public function testLegacyNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly() public function testNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly() { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form') + $view = $this->factory->createNamedBuilder('parent', 'Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->getForm() ->createView(); @@ -170,7 +180,7 @@ public function testNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly() public function testPassMaxLengthToView() { - $form = $this->factory->create('form', null, array('attr' => array('maxlength' => 10))); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('attr' => array('maxlength' => 10))); $view = $form->createView(); $this->assertSame(10, $view->vars['attr']['maxlength']); @@ -178,7 +188,7 @@ public function testPassMaxLengthToView() public function testPassMaxLengthBCToView() { - $form = $this->factory->create('form', null, array('max_length' => 10)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('max_length' => 10)); $view = $form->createView(); $this->assertSame(10, $view->vars['attr']['maxlength']); @@ -186,21 +196,21 @@ public function testPassMaxLengthBCToView() public function testDataClassMayBeNull() { - $this->factory->createBuilder('form', null, array( + $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => null, )); } public function testDataClassMayBeAbstractClass() { - $this->factory->createBuilder('form', null, array( + $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor', )); } public function testDataClassMayBeInterface() { - $this->factory->createBuilder('form', null, array( + $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface', )); } @@ -210,19 +220,19 @@ public function testDataClassMayBeInterface() */ public function testDataClassMustBeValidClassOrInterface() { - $this->factory->createBuilder('form', null, array( + $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'foobar', )); } public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable() { - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => false, )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->setData(null); @@ -238,13 +248,13 @@ public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable() public function testSubmitWithEmptyDataCreatesObjectIfInitiallySubmittedWithObject() { - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( // data class is inferred from the passed object 'data' => new Author(), 'required' => false, )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->setData(null); @@ -260,11 +270,11 @@ public function testSubmitWithEmptyDataCreatesObjectIfInitiallySubmittedWithObje public function testSubmitWithEmptyDataCreatesArrayIfDataClassIsNull() { - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => null, 'required' => false, )); - $builder->add('firstName', 'text'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->setData(null); @@ -275,12 +285,12 @@ public function testSubmitWithEmptyDataCreatesArrayIfDataClassIsNull() public function testSubmitEmptyWithEmptyDataCreatesNoObjectIfNotRequired() { - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => false, )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->setData(null); @@ -291,12 +301,12 @@ public function testSubmitEmptyWithEmptyDataCreatesNoObjectIfNotRequired() public function testSubmitEmptyWithEmptyDataCreatesObjectIfRequired() { - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => true, )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $builder->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->setData(null); @@ -310,8 +320,8 @@ public function testSubmitEmptyWithEmptyDataCreatesObjectIfRequired() */ public function testSubmitWithEmptyDataStoresArrayIfNoClassAvailable() { - $form = $this->factory->createBuilder('form') - ->add('firstName', 'text') + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $form->setData(null); @@ -322,7 +332,7 @@ public function testSubmitWithEmptyDataStoresArrayIfNoClassAvailable() public function testSubmitWithEmptyDataPassesEmptyStringToTransformerIfNotCompound() { - $form = $this->factory->createBuilder('form') + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') ->addViewTransformer(new FixedDataTransformer(array( // required for the initial, internal setData(null) null => 'null', @@ -341,11 +351,11 @@ public function testSubmitWithEmptyDataUsesEmptyDataOption() { $author = new Author(); - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'empty_data' => $author, )); - $builder->add('firstName', 'text'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->submit(array('firstName' => 'Bernhard')); @@ -370,7 +380,7 @@ public function provideZeros() */ public function testSetDataThroughParamsWithZero($data, $dataAsString) { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data' => $data, 'compound' => false, )); @@ -387,12 +397,12 @@ public function testSetDataThroughParamsWithZero($data, $dataAsString) */ public function testAttributesException() { - $this->factory->create('form', null, array('attr' => '')); + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('attr' => '')); } public function testNameCanBeEmptyString() { - $form = $this->factory->createNamed('', 'form'); + $form = $this->factory->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType'); $this->assertEquals('', $form->getName()); } @@ -401,11 +411,11 @@ public function testSubformDoesntCallSetters() { $author = new FormTest_AuthorWithoutRefSetter(new Author()); - $builder = $this->factory->createBuilder('form', $author); - $builder->add('reference', 'form', array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author); + $builder->add('reference', 'Symfony\Component\Form\Extension\Core\Type\FormType', array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', )); - $builder->get('reference')->add('firstName', 'text'); + $builder->get('reference')->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->submit(array( @@ -424,11 +434,11 @@ public function testSubformCallsSettersIfTheObjectChanged() $author = new FormTest_AuthorWithoutRefSetter(null); $newReference = new Author(); - $builder = $this->factory->createBuilder('form', $author); - $builder->add('referenceCopy', 'form', array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author); + $builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType', array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', )); - $builder->get('referenceCopy')->add('firstName', 'text'); + $builder->get('referenceCopy')->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form['referenceCopy']->setData($newReference); // new author object @@ -447,12 +457,12 @@ public function testSubformCallsSettersIfByReferenceIsFalse() { $author = new FormTest_AuthorWithoutRefSetter(new Author()); - $builder = $this->factory->createBuilder('form', $author); - $builder->add('referenceCopy', 'form', array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author); + $builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType', array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'by_reference' => false, )); - $builder->get('referenceCopy')->add('firstName', 'text'); + $builder->get('referenceCopy')->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $builder->getForm(); $form->submit(array( @@ -470,8 +480,8 @@ public function testSubformCallsSettersIfReferenceIsScalar() { $author = new FormTest_AuthorWithoutRefSetter('scalar'); - $builder = $this->factory->createBuilder('form', $author); - $builder->add('referenceCopy', 'form'); + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', $author); + $builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType'); $builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer( function () {}, function ($value) { // reverseTransform @@ -495,9 +505,9 @@ public function testSubformAlwaysInsertsIntoArrays() $ref2 = new Author(); $author = array('referenceCopy' => $ref1); - $builder = $this->factory->createBuilder('form'); + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType'); $builder->setData($author); - $builder->add('referenceCopy', 'form'); + $builder->add('referenceCopy', 'Symfony\Component\Form\Extension\Core\Type\FormType'); $builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer( function () {}, function ($value) use ($ref2) { // reverseTransform @@ -518,9 +528,9 @@ function ($value) use ($ref2) { // reverseTransform public function testPassMultipartTrueIfAnyChildIsMultipartToView() { - $view = $this->factory->createBuilder('form') - ->add('foo', 'text') - ->add('bar', 'file') + $view = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('bar', 'Symfony\Component\Form\Extension\Core\Type\FileType') ->getForm() ->createView(); @@ -529,8 +539,8 @@ public function testPassMultipartTrueIfAnyChildIsMultipartToView() public function testViewIsNotRenderedByDefault() { - $view = $this->factory->createBuilder('form') - ->add('foo', 'form') + $view = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') + ->add('foo', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->getForm() ->createView(); @@ -539,7 +549,7 @@ public function testViewIsNotRenderedByDefault() public function testErrorBubblingIfCompound() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'compound' => true, )); @@ -548,7 +558,7 @@ public function testErrorBubblingIfCompound() public function testNoErrorBubblingIfNotCompound() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'compound' => false, )); @@ -557,7 +567,7 @@ public function testNoErrorBubblingIfNotCompound() public function testOverrideErrorBubbling() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'compound' => false, 'error_bubbling' => true, )); @@ -567,7 +577,7 @@ public function testOverrideErrorBubbling() public function testPropertyPath() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'property_path' => 'foo', )); @@ -577,7 +587,7 @@ public function testPropertyPath() public function testPropertyPathNullImpliesDefault() { - $form = $this->factory->createNamed('name', 'form', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'property_path' => null, )); @@ -587,7 +597,7 @@ public function testPropertyPathNullImpliesDefault() public function testNotMapped() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'property_path' => 'foo', 'mapped' => false, )); @@ -598,14 +608,14 @@ public function testNotMapped() public function testViewValidNotSubmitted() { - $form = $this->factory->create('form'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType'); $view = $form->createView(); $this->assertTrue($view->vars['valid']); } public function testViewNotValidSubmitted() { - $form = $this->factory->create('form'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType'); $form->submit(array()); $form->addError(new FormError('An error')); $view = $form->createView(); @@ -614,14 +624,14 @@ public function testViewNotValidSubmitted() public function testViewSubmittedNotSubmitted() { - $form = $this->factory->create('form'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType'); $view = $form->createView(); $this->assertFalse($view->vars['submitted']); } public function testViewSubmittedSubmitted() { - $form = $this->factory->create('form'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType'); $form->submit(array()); $view = $form->createView(); $this->assertTrue($view->vars['submitted']); @@ -629,7 +639,7 @@ public function testViewSubmittedSubmitted() public function testDataOptionSupersedesSetDataCalls() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data' => 'default', 'compound' => false, )); @@ -641,7 +651,7 @@ public function testDataOptionSupersedesSetDataCalls() public function testDataOptionSupersedesSetDataCallsIfNull() { - $form = $this->factory->create('form', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data' => null, 'compound' => false, )); @@ -653,7 +663,7 @@ public function testDataOptionSupersedesSetDataCallsIfNull() public function testNormDataIsPassedToView() { - $view = $this->factory->createBuilder('form') + $view = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') ->addViewTransformer(new FixedDataTransformer(array( 'foo' => 'bar', ))) @@ -668,7 +678,7 @@ public function testNormDataIsPassedToView() // https://github.com/symfony/symfony/issues/6862 public function testPassZeroLabelToView() { - $view = $this->factory->create('form', null, array( + $view = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'label' => '0', )) ->createView(); @@ -681,12 +691,12 @@ public function testPassZeroLabelToView() */ public function testCanGetErrorsWhenButtonInForm() { - $builder = $this->factory->createBuilder('form', null, array( + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => false, )); - $builder->add('foo', 'text'); - $builder->add('submit', 'submit'); + $builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); + $builder->add('submit', 'Symfony\Component\Form\Extension\Core\Type\SubmitType'); $form = $builder->getForm(); //This method should not throw a Fatal Error Exception. @@ -695,6 +705,6 @@ public function testCanGetErrorsWhenButtonInForm() protected function getTestedType() { - return 'form'; + return 'Symfony\Component\Form\Extension\Core\Type\FormType'; } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php index 85f91ff18126d..c268d2a167ffa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php @@ -23,10 +23,20 @@ protected function setUp() parent::setUp(); } - public function testSubmitCastsToInteger() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('integer'); + $this->assertSame('integer', $form->getConfig()->getType()->getName()); + } + + public function testSubmitCastsToInteger() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\IntegerType'); + $form->submit('1.678'); $this->assertSame(1, $form->getData()); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php index ea6255d034b6b..ca20bba3482c8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php @@ -24,9 +24,19 @@ protected function setUp() parent::setUp(); } - public function testCountriesAreSelectable() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('language'); + + $this->assertSame('language', $form->getConfig()->getType()->getName()); + } + + public function testCountriesAreSelectable() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\LanguageType'); $view = $form->createView(); $choices = $view->vars['choices']; @@ -39,7 +49,7 @@ public function testCountriesAreSelectable() public function testMultipleLanguagesIsNotIncluded() { - $form = $this->factory->create('language', 'language'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\LanguageType', 'Symfony\Component\Form\Extension\Core\Type\LanguageType'); $view = $form->createView(); $choices = $view->vars['choices']; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php index 7f6d922ec9867..924613d8b664c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php @@ -24,9 +24,19 @@ protected function setUp() parent::setUp(); } - public function testLocalesAreSelectable() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('locale'); + + $this->assertSame('locale', $form->getConfig()->getType()->getName()); + } + + public function testLocalesAreSelectable() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\LocaleType'); $view = $form->createView(); $choices = $view->vars['choices']; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php index c499908d7713c..d4d53eb759db6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php @@ -25,11 +25,21 @@ protected function setUp() parent::setUp(); } + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('money'); + + $this->assertSame('money', $form->getConfig()->getType()->getName()); + } + public function testPassMoneyPatternToView() { \Locale::setDefault('de_DE'); - $form = $this->factory->create('money'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType'); $view = $form->createView(); $this->assertSame('{{ widget }} €', $view->vars['money_pattern']); @@ -39,7 +49,7 @@ public function testMoneyPatternWorksForYen() { \Locale::setDefault('en_US'); - $form = $this->factory->create('money', null, array('currency' => 'JPY')); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType', null, array('currency' => 'JPY')); $view = $form->createView(); $this->assertTrue((bool) strstr($view->vars['money_pattern'], '¥')); } @@ -49,8 +59,8 @@ public function testPassDifferentPatternsForDifferentCurrencies() { \Locale::setDefault('de_DE'); - $form1 = $this->factory->create('money', null, array('currency' => 'GBP')); - $form2 = $this->factory->create('money', null, array('currency' => 'EUR')); + $form1 = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType', null, array('currency' => 'GBP')); + $form2 = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\MoneyType', null, array('currency' => 'EUR')); $view1 = $form1->createView(); $view2 = $form2->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php index f21a7d1ec47d4..79f5a6a77b031 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php @@ -26,9 +26,19 @@ protected function setUp() \Locale::setDefault('de_DE'); } - public function testDefaultFormatting() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('number'); + + $this->assertSame('number', $form->getConfig()->getType()->getName()); + } + + public function testDefaultFormatting() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType'); $form->setData('12345.67890'); $view = $form->createView(); @@ -37,7 +47,7 @@ public function testDefaultFormatting() public function testDefaultFormattingWithGrouping() { - $form = $this->factory->create('number', null, array('grouping' => true)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType', null, array('grouping' => true)); $form->setData('12345.67890'); $view = $form->createView(); @@ -46,7 +56,7 @@ public function testDefaultFormattingWithGrouping() public function testDefaultFormattingWithScale() { - $form = $this->factory->create('number', null, array('scale' => 2)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType', null, array('scale' => 2)); $form->setData('12345.67890'); $view = $form->createView(); @@ -55,7 +65,7 @@ public function testDefaultFormattingWithScale() public function testDefaultFormattingWithRounding() { - $form = $this->factory->create('number', null, array('scale' => 0, 'rounding_mode' => \NumberFormatter::ROUND_UP)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\NumberType', null, array('scale' => 0, 'rounding_mode' => \NumberFormatter::ROUND_UP)); $form->setData('12345.54321'); $view = $form->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php index bccb6f7b770ab..e703a8d160912 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php @@ -13,9 +13,19 @@ class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { - public function testEmptyIfNotSubmitted() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('password'); + + $this->assertSame('password', $form->getConfig()->getType()->getName()); + } + + public function testEmptyIfNotSubmitted() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType'); $form->setData('pAs5w0rd'); $view = $form->createView(); @@ -24,7 +34,7 @@ public function testEmptyIfNotSubmitted() public function testEmptyIfSubmitted() { - $form = $this->factory->create('password'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType'); $form->submit('pAs5w0rd'); $view = $form->createView(); @@ -33,7 +43,7 @@ public function testEmptyIfSubmitted() public function testNotEmptyIfSubmittedAndNotAlwaysEmpty() { - $form = $this->factory->create('password', null, array('always_empty' => false)); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array('always_empty' => false)); $form->submit('pAs5w0rd'); $view = $form->createView(); @@ -42,7 +52,7 @@ public function testNotEmptyIfSubmittedAndNotAlwaysEmpty() public function testNotTrimmed() { - $form = $this->factory->create('password', null); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\PasswordType', null); $form->submit(' pAs5w0rd '); $data = $form->getData(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php index 8e56b8feb9eb3..275e23986c218 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php @@ -19,12 +19,24 @@ protected function setUp() { parent::setUp(); - $this->form = $this->factory->create('repeated', null, array( - 'type' => 'text', + $this->form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->form->setData(null); } + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('repeated', array( + 'type' => 'text', + )); + + $this->assertSame('repeated', $form->getConfig()->getType()->getName()); + } + public function testSetData() { $this->form->setData('foobar'); @@ -35,8 +47,8 @@ public function testSetData() public function testSetOptions() { - $form = $this->factory->create('repeated', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'options' => array('label' => 'Global'), )); @@ -48,9 +60,9 @@ public function testSetOptions() public function testSetOptionsPerChild() { - $form = $this->factory->create('repeated', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( // the global required value cannot be overridden - 'type' => 'text', + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'first_options' => array('label' => 'Test', 'required' => false), 'second_options' => array('label' => 'Test2'), )); @@ -63,9 +75,9 @@ public function testSetOptionsPerChild() public function testSetRequired() { - $form = $this->factory->create('repeated', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( 'required' => false, - 'type' => 'text', + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', )); $this->assertFalse($form['first']->isRequired()); @@ -77,8 +89,8 @@ public function testSetRequired() */ public function testSetInvalidOptions() { - $this->factory->create('repeated', null, array( - 'type' => 'text', + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'options' => 'bad value', )); } @@ -88,8 +100,8 @@ public function testSetInvalidOptions() */ public function testSetInvalidFirstOptions() { - $this->factory->create('repeated', null, array( - 'type' => 'text', + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'first_options' => 'bad value', )); } @@ -99,15 +111,15 @@ public function testSetInvalidFirstOptions() */ public function testSetInvalidSecondOptions() { - $this->factory->create('repeated', null, array( - 'type' => 'text', + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'second_options' => 'bad value', )); } public function testSetErrorBubblingToTrue() { - $form = $this->factory->create('repeated', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( 'error_bubbling' => true, )); @@ -118,7 +130,7 @@ public function testSetErrorBubblingToTrue() public function testSetErrorBubblingToFalse() { - $form = $this->factory->create('repeated', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( 'error_bubbling' => false, )); @@ -129,7 +141,7 @@ public function testSetErrorBubblingToFalse() public function testSetErrorBubblingIndividually() { - $form = $this->factory->create('repeated', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( 'error_bubbling' => true, 'options' => array('error_bubbling' => false), 'second_options' => array('error_bubbling' => true), @@ -142,8 +154,8 @@ public function testSetErrorBubblingIndividually() public function testSetOptionsPerChildAndOverwrite() { - $form = $this->factory->create('repeated', null, array( - 'type' => 'text', + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\RepeatedType', null, array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'options' => array('label' => 'Label'), 'second_options' => array('label' => 'Second label'), )); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php index 212ffd4007bb1..debe92c66648d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php @@ -18,21 +18,31 @@ */ class SubmitTypeTest extends TestCase { + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('submit'); + + $this->assertSame('submit', $form->getConfig()->getType()->getName()); + } + public function testCreateSubmitButtonInstances() { - $this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create('submit')); + $this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType')); } public function testNotClickedByDefault() { - $button = $this->factory->create('submit'); + $button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType'); $this->assertFalse($button->isClicked()); } public function testNotClickedIfSubmittedWithNull() { - $button = $this->factory->create('submit'); + $button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType'); $button->submit(null); $this->assertFalse($button->isClicked()); @@ -40,7 +50,7 @@ public function testNotClickedIfSubmittedWithNull() public function testClickedIfSubmittedWithEmptyString() { - $button = $this->factory->create('submit'); + $button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType'); $button->submit(''); $this->assertTrue($button->isClicked()); @@ -48,7 +58,7 @@ public function testClickedIfSubmittedWithEmptyString() public function testClickedIfSubmittedWithUnemptyString() { - $button = $this->factory->create('submit'); + $button = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType'); $button->submit('foo'); $this->assertTrue($button->isClicked()); @@ -57,9 +67,9 @@ public function testClickedIfSubmittedWithUnemptyString() public function testSubmitCanBeAddedToForm() { $form = $this->factory - ->createBuilder('form') + ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType') ->getForm(); - $this->assertSame($form, $form->add('send', 'submit')); + $this->assertSame($form, $form->add('send', 'Symfony\Component\Form\Extension\Core\Type\SubmitType')); } } 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 a1bb3a53f7648..63540b8c76644 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -14,20 +14,22 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormError; use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; class TimeTypeTest extends TestCase { - protected function setUp() + /** + * @group legacy + */ + public function testLegacyName() { - IntlTestHelper::requireIntl($this); + $form = $this->factory->create('time'); - parent::setUp(); + $this->assertSame('time', $form->getConfig()->getType()->getName()); } public function testSubmitDateTime() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'datetime', @@ -48,7 +50,7 @@ public function testSubmitDateTime() public function testSubmitString() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'string', @@ -67,7 +69,7 @@ public function testSubmitString() public function testSubmitTimestamp() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'timestamp', @@ -88,7 +90,7 @@ public function testSubmitTimestamp() public function testSubmitArray() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'array', @@ -107,7 +109,7 @@ public function testSubmitArray() public function testSubmitDatetimeSingleText() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'datetime', @@ -122,7 +124,7 @@ public function testSubmitDatetimeSingleText() public function testSubmitDatetimeSingleTextWithoutMinutes() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'datetime', @@ -138,7 +140,7 @@ public function testSubmitDatetimeSingleTextWithoutMinutes() public function testSubmitArraySingleText() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'array', @@ -158,7 +160,7 @@ public function testSubmitArraySingleText() public function testSubmitArraySingleTextWithoutMinutes() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'array', @@ -178,7 +180,7 @@ public function testSubmitArraySingleTextWithoutMinutes() public function testSubmitArraySingleTextWithSeconds() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'array', @@ -200,7 +202,7 @@ public function testSubmitArraySingleTextWithSeconds() public function testSubmitStringSingleText() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'string', @@ -215,7 +217,7 @@ public function testSubmitStringSingleText() public function testSubmitStringSingleTextWithoutMinutes() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'string', @@ -231,7 +233,7 @@ public function testSubmitStringSingleTextWithoutMinutes() public function testSetDataWithoutMinutes() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'datetime', @@ -245,7 +247,7 @@ public function testSetDataWithoutMinutes() public function testSetDataWithSeconds() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', 'input' => 'datetime', @@ -259,7 +261,7 @@ public function testSetDataWithSeconds() public function testSetDataDifferentTimezones() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'America/New_York', 'view_timezone' => 'Asia/Hong_Kong', 'input' => 'string', @@ -285,7 +287,7 @@ public function testSetDataDifferentTimezones() public function testSetDataDifferentTimezonesDateTime() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'model_timezone' => 'America/New_York', 'view_timezone' => 'Asia/Hong_Kong', 'input' => 'datetime', @@ -312,7 +314,7 @@ public function testSetDataDifferentTimezonesDateTime() public function testHoursOption() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'hours' => array(6, 7), )); @@ -326,7 +328,7 @@ public function testHoursOption() public function testIsMinuteWithinRangeReturnsTrueIfWithin() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'minutes' => array(6, 7), )); @@ -340,7 +342,7 @@ public function testIsMinuteWithinRangeReturnsTrueIfWithin() public function testIsSecondWithinRangeReturnsTrueIfWithin() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'seconds' => array(6, 7), 'with_seconds' => true, )); @@ -357,7 +359,7 @@ public function testIsPartiallyFilledReturnsFalseIfCompletelyEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', )); @@ -373,7 +375,7 @@ public function testIsPartiallyFilledReturnsFalseIfCompletelyEmptyWithSeconds() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', 'with_seconds' => true, )); @@ -391,7 +393,7 @@ public function testIsPartiallyFilledReturnsFalseIfCompletelyFilled() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', )); @@ -407,7 +409,7 @@ public function testIsPartiallyFilledReturnsFalseIfCompletelyFilledWithSeconds() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', 'with_seconds' => true, )); @@ -425,7 +427,7 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndHourEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', 'with_seconds' => true, )); @@ -443,7 +445,7 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndMinuteEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', 'with_seconds' => true, )); @@ -461,7 +463,7 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndSecondsEmpty() { $this->markTestIncomplete('Needs to be reimplemented using validators'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'choice', 'with_seconds' => true, )); @@ -480,12 +482,12 @@ public function testInitializeWithDateTime() { // Throws an exception if "data_class" option is not explicitly set // to null in the type - $this->factory->create('time', new \DateTime()); + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', new \DateTime()); } public function testSingleTextWidgetShouldUseTheRightInputType() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'single_text', )); @@ -495,7 +497,7 @@ public function testSingleTextWidgetShouldUseTheRightInputType() public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'single_text', 'with_seconds' => true, )); @@ -507,7 +509,7 @@ public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute() public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'single_text', 'with_seconds' => true, 'attr' => array( @@ -522,7 +524,7 @@ public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute() public function testDontPassHtml5TypeIfHtml5NotAllowed() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => 'single_text', 'html5' => false, )); @@ -533,7 +535,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed() public function testPassDefaultPlaceholderToViewIfNotRequired() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'required' => false, 'with_seconds' => true, )); @@ -546,7 +548,7 @@ public function testPassDefaultPlaceholderToViewIfNotRequired() public function testPassNoPlaceholderToViewIfRequired() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'required' => true, 'with_seconds' => true, )); @@ -559,7 +561,7 @@ public function testPassNoPlaceholderToViewIfRequired() public function testPassPlaceholderAsString() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'placeholder' => 'Empty', 'with_seconds' => true, )); @@ -572,7 +574,7 @@ public function testPassPlaceholderAsString() public function testPassEmptyValueBC() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'empty_value' => 'Empty', 'with_seconds' => true, )); @@ -588,7 +590,7 @@ public function testPassEmptyValueBC() public function testPassPlaceholderAsArray() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'placeholder' => array( 'hour' => 'Empty hour', 'minute' => 'Empty minute', @@ -605,7 +607,7 @@ public function testPassPlaceholderAsArray() public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'required' => false, 'placeholder' => array( 'hour' => 'Empty hour', @@ -622,7 +624,7 @@ public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() public function testPassPlaceholderAsPartialArrayAddNullIfRequired() { - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'required' => true, 'placeholder' => array( 'hour' => 'Empty hour', @@ -651,7 +653,7 @@ public function provideCompoundWidgets() public function testHourErrorsBubbleUp($widget) { $error = new FormError('Invalid!'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => $widget, )); $form['hour']->addError($error); @@ -666,7 +668,7 @@ public function testHourErrorsBubbleUp($widget) public function testMinuteErrorsBubbleUp($widget) { $error = new FormError('Invalid!'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => $widget, )); $form['minute']->addError($error); @@ -681,7 +683,7 @@ public function testMinuteErrorsBubbleUp($widget) public function testSecondErrorsBubbleUp($widget) { $error = new FormError('Invalid!'); - $form = $this->factory->create('time', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'widget' => $widget, 'with_seconds' => true, )); @@ -696,7 +698,7 @@ public function testSecondErrorsBubbleUp($widget) */ public function testInitializeWithSecondsAndWithoutMinutes() { - $this->factory->create('time', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'with_minutes' => false, 'with_seconds' => true, )); @@ -707,7 +709,7 @@ public function testInitializeWithSecondsAndWithoutMinutes() */ public function testThrowExceptionIfHoursIsInvalid() { - $this->factory->create('time', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'hours' => 'bad value', )); } @@ -717,7 +719,7 @@ public function testThrowExceptionIfHoursIsInvalid() */ public function testThrowExceptionIfMinutesIsInvalid() { - $this->factory->create('time', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'minutes' => 'bad value', )); } @@ -727,7 +729,7 @@ public function testThrowExceptionIfMinutesIsInvalid() */ public function testThrowExceptionIfSecondsIsInvalid() { - $this->factory->create('time', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( 'seconds' => 'bad value', )); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php index 05e234698404c..96a90dbed825f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php @@ -15,9 +15,19 @@ class TimezoneTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { - public function testTimezonesAreSelectable() + /** + * @group legacy + */ + public function testLegacyName() { $form = $this->factory->create('timezone'); + + $this->assertSame('timezone', $form->getConfig()->getType()->getName()); + } + + public function testTimezonesAreSelectable() + { + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimezoneType'); $view = $form->createView(); $choices = $view->vars['choices']; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php index f5c38ea752193..fdea34ee46692 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php @@ -15,9 +15,19 @@ class UrlTypeTest extends TestCase { + /** + * @group legacy + */ + public function testLegacyName() + { + $form = $this->factory->create('url'); + + $this->assertSame('url', $form->getConfig()->getType()->getName()); + } + public function testSubmitAddsDefaultProtocolIfNoneIsIncluded() { - $form = $this->factory->create('url', 'name'); + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', 'name'); $form->submit('www.domain.com'); @@ -27,7 +37,7 @@ public function testSubmitAddsDefaultProtocolIfNoneIsIncluded() public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded() { - $form = $this->factory->create('url', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array( 'default_protocol' => 'http', )); @@ -39,7 +49,7 @@ public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded() public function testSubmitAddsNoDefaultProtocolIfEmpty() { - $form = $this->factory->create('url', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array( 'default_protocol' => 'http', )); @@ -51,7 +61,7 @@ public function testSubmitAddsNoDefaultProtocolIfEmpty() public function testSubmitAddsNoDefaultProtocolIfNull() { - $form = $this->factory->create('url', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array( 'default_protocol' => 'http', )); @@ -63,7 +73,7 @@ public function testSubmitAddsNoDefaultProtocolIfNull() public function testSubmitAddsNoDefaultProtocolIfSetToNull() { - $form = $this->factory->create('url', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array( 'default_protocol' => null, )); @@ -78,7 +88,7 @@ public function testSubmitAddsNoDefaultProtocolIfSetToNull() */ public function testThrowExceptionIfDefaultProtocolIsInvalid() { - $this->factory->create('url', null, array( + $this->factory->create('Symfony\Component\Form\Extension\Core\Type\UrlType', null, array( 'default_protocol' => array(), )); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index bc78a4a442b91..1a1e15b53fe8f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -24,12 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) { // The form needs a child in order to trigger CSRF protection by // default - $builder->add('name', 'text'); - } - - public function getName() - { - return 'csrf_collection_test'; + $builder->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); } } @@ -71,7 +66,7 @@ protected function getExtensions() public function testCsrfProtectionByDefaultIfRootAndCompound() { $view = $this->factory - ->create('form', null, array( + ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'compound' => true, )) @@ -83,9 +78,9 @@ public function testCsrfProtectionByDefaultIfRootAndCompound() public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot() { $view = $this->factory - ->createNamedBuilder('root', 'form') + ->createNamedBuilder('root', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory - ->createNamedBuilder('form', 'form', null, array( + ->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'compound' => true, )) @@ -100,7 +95,7 @@ public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot() public function testNoCsrfProtectionByDefaultIfRootButNotCompound() { $view = $this->factory - ->create('form', null, array( + ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'compound' => false, )) @@ -112,7 +107,7 @@ public function testNoCsrfProtectionByDefaultIfRootButNotCompound() public function testCsrfProtectionCanBeDisabled() { $view = $this->factory - ->create('form', null, array( + ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_protection' => false, 'compound' => true, @@ -130,7 +125,7 @@ public function testGenerateCsrfToken() ->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token'))); $view = $this->factory - ->create('form', null, array( + ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'csrf_token_id' => 'TOKEN_ID', @@ -149,7 +144,7 @@ public function testGenerateCsrfTokenUsesFormNameAsIntentionByDefault() ->will($this->returnValue('token')); $view = $this->factory - ->createNamed('FORM_NAME', 'form', null, array( + ->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'compound' => true, @@ -167,7 +162,7 @@ public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName() ->will($this->returnValue('token')); $view = $this->factory - ->createNamed('', 'form', null, array( + ->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'compound' => true, @@ -196,13 +191,13 @@ public function testValidateTokenOnSubmitIfRootAndCompound($valid) ->will($this->returnValue($valid)); $form = $this->factory - ->createBuilder('form', null, array( + ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'csrf_token_id' => 'TOKEN_ID', 'compound' => true, )) - ->add('child', 'text') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $form->submit(array( @@ -228,12 +223,12 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesFormNameAsIntentio ->will($this->returnValue($valid)); $form = $this->factory - ->createNamedBuilder('FORM_NAME', 'form', null, array( + ->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'compound' => true, )) - ->add('child', 'text') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $form->submit(array( @@ -259,12 +254,12 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntenti ->will($this->returnValue($valid)); $form = $this->factory - ->createNamedBuilder('', 'form', null, array( + ->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'compound' => true, )) - ->add('child', 'text') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $form->submit(array( @@ -285,13 +280,13 @@ public function testFailIfRootAndCompoundAndTokenMissing() ->method('isTokenValid'); $form = $this->factory - ->createBuilder('form', null, array( + ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'csrf_token_id' => 'TOKEN_ID', 'compound' => true, )) - ->add('child', 'text') + ->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->getForm(); $form->submit(array( @@ -312,9 +307,9 @@ public function testDontValidateTokenIfCompoundButNoRoot() ->method('isTokenValid'); $form = $this->factory - ->createNamedBuilder('root', 'form') + ->createNamedBuilder('root', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory - ->createNamedBuilder('form', 'form', null, array( + ->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'csrf_token_id' => 'TOKEN_ID', @@ -336,7 +331,7 @@ public function testDontValidateTokenIfRootButNotCompound() ->method('isTokenValid'); $form = $this->factory - ->create('form', null, array( + ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'csrf_token_id' => 'TOKEN_ID', @@ -351,8 +346,8 @@ public function testDontValidateTokenIfRootButNotCompound() public function testNoCsrfProtectionOnPrototype() { $prototypeView = $this->factory - ->create('collection', null, array( - 'type' => new FormTypeCsrfExtensionTest_ChildType(), + ->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', null, array( + 'type' => __CLASS__.'_ChildType', 'options' => array( 'csrf_field_name' => 'csrf', ), @@ -379,7 +374,7 @@ public function testsTranslateCustomErrorMessage() ->will($this->returnValue('[trans]Foobar[/trans]')); $form = $this->factory - ->createBuilder('form', null, array( + ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'csrf_field_name' => 'csrf', 'csrf_token_manager' => $this->tokenManager, 'csrf_message' => 'Foobar', diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index f4774a5cc4d98..f6fa2493d55c7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -1,4 +1,5 @@ setMaxRunningTime(1); - $builder = $this->factory->createBuilder('form'); + $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType'); for ($i = 0; $i < 40; ++$i) { - $builder->add($i, 'form'); + $builder->add($i, 'Symfony\Component\Form\Extension\Core\Type\FormType'); $builder->get($i) ->add('a') diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php index 9adb364a39f86..7ea58b7cef2fc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php @@ -15,6 +15,7 @@ /** * @since 2.5.3 + * * @author Bernhard Schussek * @group legacy */ diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index f24f8404418c2..644d51a46a9d8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -20,13 +20,13 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest public function testSubmitValidatesData() { $builder = $this->factory->createBuilder( - 'form', + 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array( 'validation_groups' => 'group', ) ); - $builder->add('firstName', 'form'); + $builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\FormType'); $form = $builder->getForm(); $this->validator->expects($this->once()) @@ -93,6 +93,6 @@ public function testInvalidValidatorInterface() protected function createForm(array $options = array()) { - return $this->factory->create('form', null, $options); + return $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, $options); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php index c37cf6733c445..48fc8de51d9c8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php @@ -15,6 +15,6 @@ class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTest { protected function createForm(array $options = array()) { - return $this->factory->create('submit', null, $options); + return $this->factory->create('Symfony\Component\Form\Extension\Core\Type\SubmitType', null, $options); } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php b/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php index ee7d135339dcf..131b3fd614457 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php @@ -15,13 +15,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) { $form = $event->getForm(); - $type = $form->getName() % 2 === 0 ? 'text' : 'textarea'; + $type = $form->getName() % 2 === 0 + ? 'Symfony\Component\Form\Extension\Core\Type\TextType' + : 'Symfony\Component\Form\Extension\Core\Type\TextareaType'; $form->add('title', $type); }); } - - public function getName() - { - return 'alternating_row'; - } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/AuthorType.php b/src/Symfony/Component/Form/Tests/Fixtures/AuthorType.php index 62c80cbb37669..504f812dff3a5 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/AuthorType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/AuthorType.php @@ -16,11 +16,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) ; } - public function getName() - { - return 'author'; - } - public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( diff --git a/src/Symfony/Component/Security/Acl/Exception/Exception.php b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php similarity index 57% rename from src/Symfony/Component/Security/Acl/Exception/Exception.php rename to src/Symfony/Component/Form/Tests/Fixtures/FBooType.php index f1e100157ef31..fd9ca41dfbc85 100644 --- a/src/Symfony/Component/Security/Acl/Exception/Exception.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php @@ -9,13 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Security\Acl\Exception; +namespace Symfony\Component\Form\Tests\Fixtures; -/** - * Base ACL exception. - * - * @author Johannes M. Schmitt - */ -class Exception extends \RuntimeException +use Symfony\Component\Form\AbstractType; + +class FBooType extends AbstractType { } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Foo.php b/src/Symfony/Component/Form/Tests/Fixtures/Foo.php new file mode 100644 index 0000000000000..0920bc3d72756 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/Foo.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class Foo extends AbstractType +{ +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Foo1Bar2Type.php b/src/Symfony/Component/Form/Tests/Fixtures/Foo1Bar2Type.php new file mode 100644 index 0000000000000..17bef7ba1f2db --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/Foo1Bar2Type.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class Foo1Bar2Type extends AbstractType +{ +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooBarHTMLType.php b/src/Symfony/Component/Form/Tests/Fixtures/FooBarHTMLType.php new file mode 100644 index 0000000000000..c9969273530e6 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooBarHTMLType.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class FooBarHTMLType extends AbstractType +{ +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php index 52cefb44cfdc8..e4a4f3612e19d 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooSubType.php @@ -15,13 +15,8 @@ class FooSubType extends AbstractType { - public function getName() - { - return 'foo_sub_type'; - } - public function getParent() { - return 'foo'; + return __NAMESPACE__.'\FooType'; } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooType.php b/src/Symfony/Component/Form/Tests/Fixtures/FooType.php index bc19110792185..2e144ad0bd1c4 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooType.php @@ -15,11 +15,6 @@ class FooType extends AbstractType { - public function getName() - { - return 'foo'; - } - public function getParent() { } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php index c5f92e1191b2b..8d72132f2f1f6 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php @@ -30,6 +30,6 @@ public function getAllowedOptionValues() public function getExtendedType() { - return 'foo'; + return __NAMESPACE__.'\FooType'; } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php index 2e364754498de..646d41f7ffe00 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php @@ -23,6 +23,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function getExtendedType() { - return 'foo'; + return __NAMESPACE__.'\FooType'; } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooSubType.php new file mode 100644 index 0000000000000..7b309f42f64ec --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooSubType.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class LegacyFooSubType extends AbstractType +{ + public function getName() + { + return 'foo_sub_type'; + } + + public function getParent() + { + return 'foo'; + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooSubTypeWithParentInstance.php similarity index 82% rename from src/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php rename to src/Symfony/Component/Form/Tests/Fixtures/LegacyFooSubTypeWithParentInstance.php index 9416d7b4ed5d3..29123a6b72551 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooSubTypeWithParentInstance.php @@ -13,7 +13,7 @@ use Symfony\Component\Form\AbstractType; -class FooSubTypeWithParentInstance extends AbstractType +class LegacyFooSubTypeWithParentInstance extends AbstractType { public function getName() { @@ -22,6 +22,6 @@ public function getName() public function getParent() { - return new FooType(); + return new LegacyFooType(); } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooType.php b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooType.php new file mode 100644 index 0000000000000..717183a8632d7 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooType.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class LegacyFooType extends AbstractType +{ + public function getName() + { + return 'foo'; + } + + public function getParent() + { + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooTypeBarExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooTypeBarExtension.php new file mode 100644 index 0000000000000..c1e2888836173 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooTypeBarExtension.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\FormBuilderInterface; + +class LegacyFooTypeBarExtension extends AbstractTypeExtension +{ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->setAttribute('bar', 'x'); + } + + public function getAllowedOptionValues() + { + return array( + 'a_or_b' => array('c'), + ); + } + + public function getExtendedType() + { + return 'foo'; + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooTypeBazExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooTypeBazExtension.php new file mode 100644 index 0000000000000..49aba3f004650 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/LegacyFooTypeBazExtension.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\FormBuilderInterface; + +class LegacyFooTypeBazExtension extends AbstractTypeExtension +{ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->setAttribute('baz', 'x'); + } + + public function getExtendedType() + { + return 'foo'; + } +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php index f9de560f031d3..8e8628ab8fc67 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php @@ -31,7 +31,7 @@ public function __construct(FormTypeGuesserInterface $guesser) public function addType(FormTypeInterface $type) { - $this->types[$type->getName()] = $type; + $this->types[$type->getName() ?: get_class($type)] = $type; } public function getType($name) diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Type.php b/src/Symfony/Component/Form/Tests/Fixtures/Type.php new file mode 100644 index 0000000000000..61ca7d1319886 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/Type.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class Type extends AbstractType +{ +} diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 8c7b96587dc0b..86f50b50ecee0 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -67,21 +67,21 @@ public function testAddWithGuessFluent() public function testAddIsFluent() { - $builder = $this->builder->add('foo', 'text', array('bar' => 'baz')); + $builder = $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('bar' => 'baz')); $this->assertSame($builder, $this->builder); } public function testAdd() { $this->assertFalse($this->builder->has('foo')); - $this->builder->add('foo', 'text'); + $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->assertTrue($this->builder->has('foo')); } public function testAddIntegerName() { $this->assertFalse($this->builder->has(0)); - $this->builder->add(0, 'text'); + $this->builder->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->assertTrue($this->builder->has(0)); } @@ -89,13 +89,13 @@ public function testAll() { $this->factory->expects($this->once()) ->method('createNamedBuilder') - ->with('foo', 'text') + ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); $this->assertCount(0, $this->builder->all()); $this->assertFalse($this->builder->has('foo')); - $this->builder->add('foo', 'text'); + $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $children = $this->builder->all(); $this->assertTrue($this->builder->has('foo')); @@ -108,9 +108,9 @@ public function testAll() */ public function testMaintainOrderOfLazyAndExplicitChildren() { - $this->builder->add('foo', 'text'); + $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->builder->add($this->getFormBuilder('bar')); - $this->builder->add('baz', 'text'); + $this->builder->add('baz', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $children = $this->builder->all(); @@ -126,7 +126,7 @@ public function testAddFormType() public function testRemove() { - $this->builder->add('foo', 'text'); + $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->builder->remove('foo'); $this->assertFalse($this->builder->has('foo')); } @@ -140,7 +140,7 @@ public function testRemoveUnknown() // https://github.com/symfony/symfony/pull/4826 public function testRemoveAndGetForm() { - $this->builder->add('foo', 'text'); + $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->builder->remove('foo'); $form = $this->builder->getForm(); $this->assertInstanceOf('Symfony\Component\Form\Form', $form); @@ -150,7 +150,7 @@ public function testCreateNoTypeNo() { $this->factory->expects($this->once()) ->method('createNamedBuilder') - ->with('foo', 'text', null, array()) + ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array()) ; $this->builder->create('foo'); @@ -170,7 +170,7 @@ public function testGetUnknown() public function testGetExplicitType() { - $expectedType = 'text'; + $expectedType = 'Symfony\Component\Form\Extension\Core\Type\TextType'; $expectedName = 'foo'; $expectedOptions = array('bar' => 'baz'); diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 2c3ab000ffe30..20a1c0052c0ee 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Form\Tests; use Symfony\Component\Form\FormFactoryBuilder; -use Symfony\Component\Form\Tests\Fixtures\FooType; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooType; class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase { @@ -27,7 +27,7 @@ protected function setUp() $this->registry->setAccessible(true); $this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->type = new FooType(); + $this->type = new LegacyFooType(); } public function testAddType() diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index d89969f021be0..28e14bbebc61a 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -16,9 +16,9 @@ use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\ValueGuess; use Symfony\Component\Form\Guess\TypeGuess; -use Symfony\Component\Form\Tests\Fixtures\FooType; -use Symfony\Component\Form\Tests\Fixtures\FooSubType; -use Symfony\Component\Form\Tests\Fixtures\FooSubTypeWithParentInstance; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooType; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooSubType; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooSubTypeWithParentInstance; /** * @author Bernhard Schussek @@ -99,11 +99,14 @@ public function testCreateNamedBuilderWithTypeName() $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', null, $options)); } + /** + * @group legacy + */ public function testCreateNamedBuilderWithTypeInstance() { $options = array('a' => '1', 'b' => '2'); $resolvedOptions = array('a' => '2', 'b' => '3'); - $type = new FooType(); + $type = new LegacyFooType(); $resolvedType = $this->getMockResolvedType(); $this->resolvedTypeFactory->expects($this->once()) @@ -127,11 +130,14 @@ public function testCreateNamedBuilderWithTypeInstance() $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $type, null, $options)); } + /** + * @group legacy + */ public function testCreateNamedBuilderWithTypeInstanceWithParentType() { $options = array('a' => '1', 'b' => '2'); $resolvedOptions = array('a' => '2', 'b' => '3'); - $type = new FooSubType(); + $type = new LegacyFooSubType(); $resolvedType = $this->getMockResolvedType(); $parentResolvedType = $this->getMockResolvedType(); @@ -161,11 +167,14 @@ public function testCreateNamedBuilderWithTypeInstanceWithParentType() $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $type, null, $options)); } + /** + * @group legacy + */ public function testCreateNamedBuilderWithTypeInstanceWithParentTypeInstance() { $options = array('a' => '1', 'b' => '2'); $resolvedOptions = array('a' => '2', 'b' => '3'); - $type = new FooSubTypeWithParentInstance(); + $type = new LegacyFooSubTypeWithParentInstance(); $resolvedType = $this->getMockResolvedType(); $parentResolvedType = $this->getMockResolvedType(); @@ -195,6 +204,9 @@ public function testCreateNamedBuilderWithTypeInstanceWithParentTypeInstance() $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $type, null, $options)); } + /** + * @group legacy + */ public function testCreateNamedBuilderWithResolvedTypeInstance() { $options = array('a' => '1', 'b' => '2'); @@ -312,6 +324,164 @@ public function testCreateUsesTypeNameIfTypeGivenAsString() $this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); } + public function testCreateStripsNamespaceOffTypeName() + { + $options = array('a' => '1', 'b' => '2'); + $resolvedOptions = array('a' => '2', 'b' => '3'); + $resolvedType = $this->getMockResolvedType(); + + $this->registry->expects($this->once()) + ->method('getType') + ->with('Vendor\Name\Space\UserForm') + ->will($this->returnValue($resolvedType)); + + $resolvedType->expects($this->once()) + ->method('createBuilder') + ->with($this->factory, 'user_form', $options) + ->will($this->returnValue($this->builder)); + + $this->builder->expects($this->any()) + ->method('getOptions') + ->will($this->returnValue($resolvedOptions)); + + $resolvedType->expects($this->once()) + ->method('buildForm') + ->with($this->builder, $resolvedOptions); + + $this->builder->expects($this->once()) + ->method('getForm') + ->will($this->returnValue('FORM')); + + $this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\UserForm', null, $options)); + } + + public function testLegacyCreateStripsNamespaceOffTypeNameAccessByFQCN() + { + $options = array('a' => '1', 'b' => '2'); + $resolvedOptions = array('a' => '2', 'b' => '3'); + $resolvedType = $this->getMockResolvedType(); + + $this->registry->expects($this->once()) + ->method('getType') + ->with('userform') + ->will($this->returnValue($resolvedType)); + + $resolvedType->expects($this->once()) + ->method('createBuilder') + ->with($this->factory, 'userform', $options) + ->will($this->returnValue($this->builder)); + + $this->builder->expects($this->any()) + ->method('getOptions') + ->will($this->returnValue($resolvedOptions)); + + $resolvedType->expects($this->once()) + ->method('buildForm') + ->with($this->builder, $resolvedOptions); + + $this->builder->expects($this->once()) + ->method('getForm') + ->will($this->returnValue('FORM')); + + $this->assertSame('FORM', $this->factory->create('userform', null, $options)); + } + + public function testCreateStripsTypeSuffixOffTypeName() + { + $options = array('a' => '1', 'b' => '2'); + $resolvedOptions = array('a' => '2', 'b' => '3'); + $resolvedType = $this->getMockResolvedType(); + + $this->registry->expects($this->once()) + ->method('getType') + ->with('Vendor\Name\Space\UserType') + ->will($this->returnValue($resolvedType)); + + $resolvedType->expects($this->once()) + ->method('createBuilder') + ->with($this->factory, 'user', $options) + ->will($this->returnValue($this->builder)); + + $this->builder->expects($this->any()) + ->method('getOptions') + ->will($this->returnValue($resolvedOptions)); + + $resolvedType->expects($this->once()) + ->method('buildForm') + ->with($this->builder, $resolvedOptions); + + $this->builder->expects($this->once()) + ->method('getForm') + ->will($this->returnValue('FORM')); + + $this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\UserType', null, $options)); + } + + public function testCreateDoesNotStripTypeSuffixIfResultEmpty() + { + $options = array('a' => '1', 'b' => '2'); + $resolvedOptions = array('a' => '2', 'b' => '3'); + $resolvedType = $this->getMockResolvedType(); + + $this->registry->expects($this->once()) + ->method('getType') + ->with('Vendor\Name\Space\Type') + ->will($this->returnValue($resolvedType)); + + $resolvedType->expects($this->once()) + ->method('createBuilder') + ->with($this->factory, 'type', $options) + ->will($this->returnValue($this->builder)); + + $this->builder->expects($this->any()) + ->method('getOptions') + ->will($this->returnValue($resolvedOptions)); + + $resolvedType->expects($this->once()) + ->method('buildForm') + ->with($this->builder, $resolvedOptions); + + $this->builder->expects($this->once()) + ->method('getForm') + ->will($this->returnValue('FORM')); + + $this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\Type', null, $options)); + } + + public function testCreateConvertsTypeToUnderscoreSyntax() + { + $options = array('a' => '1', 'b' => '2'); + $resolvedOptions = array('a' => '2', 'b' => '3'); + $resolvedType = $this->getMockResolvedType(); + + $this->registry->expects($this->once()) + ->method('getType') + ->with('Vendor\Name\Space\MyProfileHTMLType') + ->will($this->returnValue($resolvedType)); + + $resolvedType->expects($this->once()) + ->method('createBuilder') + ->with($this->factory, 'my_profile_html', $options) + ->will($this->returnValue($this->builder)); + + $this->builder->expects($this->any()) + ->method('getOptions') + ->will($this->returnValue($resolvedOptions)); + + $resolvedType->expects($this->once()) + ->method('buildForm') + ->with($this->builder, $resolvedOptions); + + $this->builder->expects($this->once()) + ->method('getForm') + ->will($this->returnValue('FORM')); + + $this->assertSame('FORM', $this->factory->create('Vendor\Name\Space\MyProfileHTMLType', null, $options)); + } + + /** + * @group legacy + */ public function testCreateUsesTypeNameIfTypeGivenAsObject() { $options = array('a' => '1', 'b' => '2'); @@ -383,7 +553,7 @@ public function testCreateBuilderForPropertyWithoutTypeGuesser() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text', null, array()) + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array()) ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -397,7 +567,7 @@ public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() ->method('guessType') ->with('Application\Author', 'firstName') ->will($this->returnValue(new TypeGuess( - 'text', + 'Symfony\Component\Form\Extension\Core\Type\TextType', array('attr' => array('maxlength' => 10)), Guess::MEDIUM_CONFIDENCE ))); @@ -434,7 +604,7 @@ public function testCreateBuilderCreatesTextFormIfNoGuess() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text') + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -448,7 +618,7 @@ public function testOptionsCanBeOverridden() ->method('guessType') ->with('Application\Author', 'firstName') ->will($this->returnValue(new TypeGuess( - 'text', + 'Symfony\Component\Form\Extension\Core\Type\TextType', array('attr' => array('maxlength' => 10)), Guess::MEDIUM_CONFIDENCE ))); @@ -457,7 +627,7 @@ public function testOptionsCanBeOverridden() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('maxlength' => 11))) + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('maxlength' => 11))) ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty( @@ -492,7 +662,7 @@ public function testCreateBuilderUsesMaxLengthIfFound() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('maxlength' => 20))) + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('maxlength' => 20))) ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty( @@ -525,7 +695,7 @@ public function testCreateBuilderUsesMaxLengthAndPattern() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce'))) + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce'))) ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty( @@ -560,7 +730,7 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('required' => false)) + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('required' => false)) ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty( @@ -593,7 +763,7 @@ public function testCreateBuilderUsesPatternIfFound() $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('pattern' => '[a-zA-Z]'))) + ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('pattern' => '[a-zA-Z]'))) ->will($this->returnValue('builderInstance')); $this->builder = $factory->createBuilderForProperty( diff --git a/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php b/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php index 2961ab58bba1e..09fd394fb9ccf 100644 --- a/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php +++ b/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php @@ -20,8 +20,8 @@ abstract class FormIntegrationTestCase extends BaseFormIntegrationTestCase { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ protected function setUp() { @trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Test\FormIntegrationTestCase class instead.', E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php b/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php index ce24c03fa7696..884bfe3733bb4 100644 --- a/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php +++ b/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php @@ -20,8 +20,8 @@ abstract class FormPerformanceTestCase extends BaseFormPerformanceTestCase { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ protected function setUp() { @trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Test\FormPerformanceTestCase class instead.', E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index 0c8bb6b44151a..849f49476a49e 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\Form\Tests\Fixtures\TestExtension; -use Symfony\Component\Form\Tests\Fixtures\FooSubTypeWithParentInstance; +use Symfony\Component\Form\ResolvedFormType; +use Symfony\Component\Form\ResolvedFormTypeFactoryInterface; use Symfony\Component\Form\Tests\Fixtures\FooSubType; -use Symfony\Component\Form\Tests\Fixtures\FooTypeBazExtension; -use Symfony\Component\Form\Tests\Fixtures\FooTypeBarExtension; use Symfony\Component\Form\Tests\Fixtures\FooType; +use Symfony\Component\Form\Tests\Fixtures\FooTypeBarExtension; +use Symfony\Component\Form\Tests\Fixtures\FooTypeBazExtension; +use Symfony\Component\Form\Tests\Fixtures\TestExtension; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooSubTypeWithParentInstance; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooSubType; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooTypeBazExtension; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooTypeBarExtension; +use Symfony\Component\Form\Tests\Fixtures\LegacyFooType; /** * @author Bernhard Schussek @@ -31,7 +37,7 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase private $registry; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject|ResolvedFormTypeFactoryInterface */ private $resolvedTypeFactory; @@ -71,22 +77,64 @@ protected function setUp() public function testGetTypeFromExtension() { $type = new FooType(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $resolvedType = new ResolvedFormType($type); $this->extension2->addType($type); $this->resolvedTypeFactory->expects($this->once()) ->method('createResolvedType') ->with($type) - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); + + $this->assertSame($resolvedType, $this->registry->getType(get_class($type))); + } + + public function testLoadUnregisteredType() + { + $type = new FooType(); + $resolvedType = new ResolvedFormType($type); + + $this->resolvedTypeFactory->expects($this->once()) + ->method('createResolvedType') + ->with($type) + ->willReturn($resolvedType); + + $this->assertSame($resolvedType, $this->registry->getType('Symfony\Component\Form\Tests\Fixtures\FooType')); + } + + /** + * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException + */ + public function testFailIfUnregisteredTypeNoClass() + { + $this->registry->getType('Symfony\Blubb'); + } + + /** + * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException + */ + public function testFailIfUnregisteredTypeNoFormType() + { + $this->registry->getType('stdClass'); + } - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); + public function testLegacyGetTypeFromExtension() + { + $type = new LegacyFooType(); + $resolvedType = new ResolvedFormType($type); - $resolvedType = $this->registry->getType('foo'); + $this->extension2->addType($type); + + $this->resolvedTypeFactory->expects($this->once()) + ->method('createResolvedType') + ->with($type) + ->willReturn($resolvedType); $this->assertSame($resolvedType, $this->registry->getType('foo')); + + // Even types with explicit getName() methods must support access by + // FQCN to support a smooth transition from 2.8 => 3.0 + $this->assertSame($resolvedType, $this->registry->getType(get_class($type))); } public function testGetTypeWithTypeExtensions() @@ -94,7 +142,7 @@ public function testGetTypeWithTypeExtensions() $type = new FooType(); $ext1 = new FooTypeBarExtension(); $ext2 = new FooTypeBazExtension(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $resolvedType = new ResolvedFormType($type, array($ext1, $ext2)); $this->extension2->addType($type); $this->extension1->addTypeExtension($ext1); @@ -103,11 +151,26 @@ public function testGetTypeWithTypeExtensions() $this->resolvedTypeFactory->expects($this->once()) ->method('createResolvedType') ->with($type, array($ext1, $ext2)) - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); + + $this->assertSame($resolvedType, $this->registry->getType(get_class($type))); + } + + public function testLegacyGetTypeWithTypeExtensions() + { + $type = new LegacyFooType(); + $ext1 = new LegacyFooTypeBarExtension(); + $ext2 = new LegacyFooTypeBazExtension(); + $resolvedType = new ResolvedFormType($type, array($ext1, $ext2)); - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); + $this->extension2->addType($type); + $this->extension1->addTypeExtension($ext1); + $this->extension2->addTypeExtension($ext2); + + $this->resolvedTypeFactory->expects($this->once()) + ->method('createResolvedType') + ->with($type, array($ext1, $ext2)) + ->willReturn($resolvedType); $this->assertSame($resolvedType, $this->registry->getType('foo')); } @@ -116,8 +179,8 @@ public function testGetTypeConnectsParent() { $parentType = new FooType(); $type = new FooSubType(); - $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $parentResolvedType = new ResolvedFormType($parentType); + $resolvedType = new ResolvedFormType($type); $this->extension1->addType($parentType); $this->extension2->addType($type); @@ -125,49 +188,59 @@ public function testGetTypeConnectsParent() $this->resolvedTypeFactory->expects($this->at(0)) ->method('createResolvedType') ->with($parentType) - ->will($this->returnValue($parentResolvedType)); + ->willReturn($parentResolvedType); $this->resolvedTypeFactory->expects($this->at(1)) ->method('createResolvedType') ->with($type, array(), $parentResolvedType) - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); + + $this->assertSame($resolvedType, $this->registry->getType(get_class($type))); + } + + public function testLegacyGetTypeConnectsParent() + { + $parentType = new LegacyFooType(); + $type = new LegacyFooSubType(); + $parentResolvedType = new ResolvedFormType($parentType); + $resolvedType = new ResolvedFormType($type); - $parentResolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); + $this->extension1->addType($parentType); + $this->extension2->addType($type); - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo_sub_type')); + $this->resolvedTypeFactory->expects($this->at(0)) + ->method('createResolvedType') + ->with($parentType) + ->willReturn($parentResolvedType); + + $this->resolvedTypeFactory->expects($this->at(1)) + ->method('createResolvedType') + ->with($type, array(), $parentResolvedType) + ->willReturn($resolvedType); $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type')); } + /** + * @group legacy + */ public function testGetTypeConnectsParentIfGetParentReturnsInstance() { - $type = new FooSubTypeWithParentInstance(); - $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $type = new LegacyFooSubTypeWithParentInstance(); + $parentResolvedType = new ResolvedFormType($type->getParent()); + $resolvedType = new ResolvedFormType($type); $this->extension1->addType($type); $this->resolvedTypeFactory->expects($this->at(0)) ->method('createResolvedType') - ->with($this->isInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType')) - ->will($this->returnValue($parentResolvedType)); + ->with($type->getParent()) + ->willReturn($parentResolvedType); $this->resolvedTypeFactory->expects($this->at(1)) ->method('createResolvedType') ->with($type, array(), $parentResolvedType) - ->will($this->returnValue($resolvedType)); - - $parentResolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); - - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo_sub_type_parent_instance')); + ->willReturn($resolvedType); $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type_parent_instance')); } @@ -184,6 +257,18 @@ public function testGetTypeThrowsExceptionIfParentNotFound() $this->registry->getType($type); } + /** + * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + */ + public function testLegacyGetTypeThrowsExceptionIfParentNotFound() + { + $type = new LegacyFooSubType(); + + $this->extension1->addType($type); + + $this->registry->getType($type); + } + /** * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException */ @@ -203,18 +288,42 @@ public function testGetTypeThrowsExceptionIfNoString() public function testHasTypeAfterLoadingFromExtension() { $type = new FooType(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); + $resolvedType = new ResolvedFormType($type); $this->resolvedTypeFactory->expects($this->once()) ->method('createResolvedType') ->with($type) - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); + $this->extension2->addType($type); + + $this->assertTrue($this->registry->hasType(get_class($type))); + } + + public function testHasTypeIfFQCN() + { + $this->assertTrue($this->registry->hasType('Symfony\Component\Form\Tests\Fixtures\FooType')); + } - $this->assertFalse($this->registry->hasType('foo')); + public function testDoesNotHaveTypeIfNonExistingClass() + { + $this->assertFalse($this->registry->hasType('Symfony\Blubb')); + } + + public function testDoesNotHaveTypeIfNoFormType() + { + $this->assertFalse($this->registry->hasType('stdClass')); + } + + public function testLegacyHasTypeAfterLoadingFromExtension() + { + $type = new LegacyFooType(); + $resolvedType = new ResolvedFormType($type); + + $this->resolvedTypeFactory->expects($this->once()) + ->method('createResolvedType') + ->with($type) + ->willReturn($resolvedType); $this->extension2->addType($type); @@ -229,7 +338,8 @@ public function testGetTypeGuesser() $registry = new FormRegistry( array($this->getMock('Symfony\Component\Form\FormExtensionInterface')), - $this->resolvedTypeFactory); + $this->resolvedTypeFactory + ); $this->assertNull($registry->getTypeGuesser()); } diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 234d52cf3903e..36804ebebe8bc 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Tests; +use Symfony\Component\Form\FormTypeExtensionInterface; +use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\Form\ResolvedFormType; use Symfony\Component\Form\FormBuilder; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -34,11 +36,35 @@ class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject */ private $dataMapper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|FormTypeInterface + */ private $parentType; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|FormTypeInterface + */ private $type; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|FormTypeExtensionInterface + */ private $extension1; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|FormTypeExtensionInterface + */ private $extension2; + + /** + * @var ResolvedFormType + */ private $parentResolvedType; + + /** + * @var ResolvedFormType + */ private $resolvedType; protected function setUp() @@ -305,12 +331,107 @@ public function testFinishView() $this->resolvedType->finishView($view, $form, $options); } + /** + * @dataProvider provideValidNames + */ + public function testGetName($name) + { + $this->type->expects($this->once()) + ->method('getName') + ->willReturn($name); + + $resolvedType = new ResolvedFormType($this->type); + + $this->assertSame($name, $resolvedType->getName()); + } + + /** + * @dataProvider provideInvalidNames + * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException + */ + public function testGetNameFailsIfInvalidChars($name) + { + $this->type->expects($this->once()) + ->method('getName') + ->willReturn($name); + + new ResolvedFormType($this->type); + } + + public function provideValidNames() + { + return array( + array('text'), + array('type123'), + array('my_type123'), + ); + } + + public function provideInvalidNames() + { + return array( + array('my-type'), + array('my[type]'), + array('my{type}'), + ); + } + + public function testGetBlockPrefix() + { + $this->type->expects($this->once()) + ->method('getBlockPrefix') + ->willReturn('my_prefix'); + + $resolvedType = new ResolvedFormType($this->type); + + $this->assertSame('my_prefix', $resolvedType->getBlockPrefix()); + } + + /** + * @group legacy + */ + public function testBlockPrefixDefaultsToNameIfSet() + { + // Type without getBlockPrefix() method + $type = $this->getMock('Symfony\Component\Form\FormTypeInterface'); + + $type->expects($this->once()) + ->method('getName') + ->willReturn('my_prefix'); + + $resolvedType = new ResolvedFormType($type); + + $this->assertSame('my_prefix', $resolvedType->getBlockPrefix()); + } + + /** + * @dataProvider provideTypeClassBlockPrefixTuples + */ + public function testBlockPrefixDefaultsToFQCNIfNoName($typeClass, $blockPrefix) + { + $resolvedType = new ResolvedFormType(new $typeClass()); + + $this->assertSame($blockPrefix, $resolvedType->getBlockPrefix()); + } + + public function provideTypeClassBlockPrefixTuples() + { + return array( + array(__NAMESPACE__.'\Fixtures\FooType', 'foo'), + array(__NAMESPACE__.'\Fixtures\Foo', 'foo'), + array(__NAMESPACE__.'\Fixtures\Type', 'type'), + array(__NAMESPACE__.'\Fixtures\FooBarHTMLType', 'foo_bar_html'), + array(__NAMESPACE__.'\Fixtures\Foo1Bar2Type', 'foo1_bar2'), + array(__NAMESPACE__.'\Fixtures\FBooType', 'f_boo'), + ); + } + /** * @return \PHPUnit_Framework_MockObject_MockObject */ - private function getMockFormType() + private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractType') { - return $this->getMock('Symfony\Component\Form\AbstractType', array('getName', 'configureOptions', 'finishView', 'buildView', 'buildForm')); + return $this->getMock($typeClass, array('getName', 'getBlockPrefix', 'configureOptions', 'finishView', 'buildView', 'buildForm')); } /** diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 6fb24a8cdc9c7..9f5de6dfd764c 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -1063,7 +1063,7 @@ public function testInitializeFailsIfParent() */ public function testCustomOptionsResolver() { - $fooType = new Fixtures\FooType(); + $fooType = new Fixtures\LegacyFooType(); $resolver = new Fixtures\CustomOptionsResolver(); $fooType->setDefaultOptions($resolver); } diff --git a/src/Symfony/Component/Form/Util/StringUtil.php b/src/Symfony/Component/Form/Util/StringUtil.php index 2f51e74afcaac..ee71ae7a52e14 100644 --- a/src/Symfony/Component/Form/Util/StringUtil.php +++ b/src/Symfony/Component/Form/Util/StringUtil.php @@ -39,4 +39,19 @@ public static function trim($string) return trim($string); } + + /** + * Converts a fully-qualified class name to a block prefix. + * + * @param string $fqcn The fully-qualified class name + * + * @return string|null The block prefix or null if not a valid FQCN + */ + public static function fqcnToBlockPrefix($fqcn) + { + // Non-greedy ("+?") to match "type" suffix, if present + if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) { + return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $matches[1])); + } + } } diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index ac41c8fe910a6..ca407b4d93452 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -308,6 +308,7 @@ public static function trustXSendfileTypeHeader() /** * If this is set to true, the file will be unlinked after the request is send * Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used. + * * @param bool $shouldDelete * * @return BinaryFileResponse diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index c6d1e31ab374c..36ae61ba41765 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1577,7 +1577,7 @@ public function getContent($asResource = false) // Content passed in parameter (test) if (is_string($this->content)) { - $resource = fopen('php://temp','r+'); + $resource = fopen('php://temp', 'r+'); fwrite($resource, $this->content); rewind($resource); @@ -2001,7 +2001,7 @@ private static function createRequestFromFactory(array $query = array(), array $ if (self::$requestFactory) { $request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content); - if (!$request instanceof Request) { + if (!$request instanceof self) { throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.'); } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 9f8c7ef29279c..98df646b6048e 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -631,7 +631,7 @@ public function setPublic() */ public function mustRevalidate() { - return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->has('proxy-revalidate'); + return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->hasCacheControlDirective('proxy-revalidate'); } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php index eefaf8d8fa0d5..111541d92d521 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php @@ -260,7 +260,7 @@ private function getMergeSql() } /** - * Return a PDO instance + * Return a PDO instance. * * @return \PDO */ diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php index 183093f87a43a..f6f99eda48c1b 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php @@ -108,7 +108,7 @@ public function gc($maxlifetime) } /** - * Return a Memcache instance + * Return a Memcache instance. * * @return \Memcache */ diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index 1f9d97e45d7b8..d87bef852f9a3 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -114,7 +114,7 @@ public function gc($maxlifetime) } /** - * Return a Memcached instance + * Return a Memcached instance. * * @return \Memcached */ diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index fa4ecfb0a40c8..f1df25d0a629b 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -177,7 +177,7 @@ private function getCollection() } /** - * Return a Mongo instance + * Return a Mongo instance. * * @return \Mongo */ diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 38986e8aa7f84..0da42b2292dfa 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -51,7 +51,7 @@ public function __construct($callback = null, $status = 200, $headers = array()) } /** - * Factory method for chainability + * Factory method for chainability. * * @param callable|null $callback A valid PHP callback or null to set it later * @param int $status The response status code diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index ed46999e87840..ca86abdb03f03 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -980,7 +980,7 @@ public function testGetContentReturnsResourceWhenContentSetInConstructor() public function testContentAsResource() { - $resource = fopen('php://memory','r+'); + $resource = fopen('php://memory', 'r+'); fwrite($resource, 'My other content'); rewind($resource); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 4319a39c2c76c..02a62acc1101e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -105,6 +105,22 @@ public function testMustRevalidate() $this->assertFalse($response->mustRevalidate()); } + public function testMustRevalidateWithMustRevalidateCacheControlHeader() + { + $response = new Response(); + $response->headers->set('cache-control', 'must-revalidate'); + + $this->assertTrue($response->mustRevalidate()); + } + + public function testMustRevalidateWithProxyRevalidateCacheControlHeader() + { + $response = new Response(); + $response->headers->set('cache-control', 'proxy-revalidate'); + + $this->assertTrue($response->mustRevalidate()); + } + public function testSetNotModified() { $response = new Response(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index ba06fccff9103..a6cde7296013e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -205,7 +205,7 @@ public function testReadingRequiresExactlySameId() } /** - * Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace) + * Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace). */ public function testWriteDifferentSessionIdThanRead() { diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 94df05eee415f..fec0006662d17 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -157,7 +157,7 @@ protected function createController($controller) } /** - * Returns an instantiated controller + * Returns an instantiated controller. * * @param string $class A class name * diff --git a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php index 20d60748955c1..d2f0898605968 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php @@ -54,7 +54,7 @@ public function exportValue($value, $depth = 1, $deep = false) return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1)); } - return sprintf("[%s]", implode(', ', $a)); + return sprintf('[%s]', implode(', ', $a)); } if (is_resource($value)) { diff --git a/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php b/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php index c37a537009e98..14a5d435115d7 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** - * Adds configured formats to each request + * Adds configured formats to each request. * * @author Gildas Quemener */ @@ -36,7 +36,7 @@ public function __construct(array $formats) } /** - * Adds request formats + * Adds request formats. * * @param GetResponseEvent $event */ diff --git a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php index 00dc60ca3fa58..297aab6fa12b2 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -140,7 +140,7 @@ public function onKernelRequest(GetResponseEvent $event) } if (null !== $this->logger) { - $this->logger->info(sprintf('Matched route "%s".', $parameters['_route']), array( + $this->logger->info(sprintf('Matched route "%s".', isset($parameters['_route']) ? $parameters['_route'] : 'n/a'), array( 'route_parameters' => $parameters, 'request_uri' => $request->getUri(), )); diff --git a/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php b/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php index 00f4fbf24ee74..dc815a216f6c0 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php @@ -17,7 +17,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates + * SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates. * * @author Fabien Potencier */ diff --git a/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php index 42a0f20bd491a..8fc8e57579a3c 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php @@ -48,7 +48,7 @@ public function onKernelRequest(GetResponseEvent $event) /** * Checks if session was initialized and saves if current request is master - * Runs on 'kernel.response' in test environment + * Runs on 'kernel.response' in test environment. * * @param FilterResponseEvent $event */ diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 445f59c6f0fff..f2d9972cb7173 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -156,11 +156,16 @@ public function getKernel() * Gets the Surrogate instance. * * @throws \LogicException + * * @return SurrogateInterface A Surrogate instance */ public function getSurrogate() { - return $this->getEsi(); + if (!$this->surrogate instanceof Esi) { + throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate'); + } + + return $this->surrogate; } /** @@ -176,11 +181,7 @@ public function getEsi() { @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the getSurrogate() method instead.', E_USER_DEPRECATED); - if (!$this->surrogate instanceof Esi) { - throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate'); - } - - return $this->surrogate; + return $this->getSurrogate(); } /** diff --git a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php index d22dff1e5f08f..67ffd97cf1d8c 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php @@ -45,7 +45,7 @@ public function add(Response $response) $this->maxAges[] = $response->getMaxAge(); } - $this->embeddedResponses++; + ++$this->embeddedResponses; } /** diff --git a/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php b/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php index 46b788d53eb08..5d65fd65a4436 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php @@ -17,7 +17,7 @@ interface SurrogateInterface { /** - * Returns surrogate name + * Returns surrogate name. * * @return string */ diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index 26bdf70673743..3a82ce0fb6ac7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\KernelEvents; /** - * Test AddRequestFormatsListener class + * Test AddRequestFormatsListener class. * * @author Gildas Quemener */ diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index f3cd05e239dd3..4584a48a76846 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -25,7 +25,7 @@ use Symfony\Component\HttpKernel\KernelEvents; /** - * DebugHandlersListenerTest + * DebugHandlersListenerTest. * * @author Nicolas Grekas */ diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php index a9b715bacc7dd..9bbdadedcff49 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php @@ -19,7 +19,7 @@ use Symfony\Component\VarDumper\VarDumper; /** - * DumpListenerTest + * DumpListenerTest. * * @author Nicolas Grekas */ diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 84ff0d6f50bc5..261b7fa393e20 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -23,7 +23,7 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase { /** - * Test to ensure BC without RequestStack + * Test to ensure BC without RequestStack. * * @group legacy */ @@ -79,7 +79,7 @@ public function testKernelTerminate() ->disableOriginalConstructor() ->getMock(); - $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index d6e5b45ba1303..245b53aceaff8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -128,4 +128,34 @@ public function testSubRequestWithDifferentMethod() $this->assertEquals('GET', $context->getMethod()); } + + /** + * @dataProvider getLoggingParameterData + */ + public function testLoggingParameter($parameter, $log) + { + $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $requestMatcher->expects($this->once()) + ->method('matchRequest') + ->will($this->returnValue($parameter)); + + $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger->expects($this->once()) + ->method('info') + ->with($this->equalTo($log)); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $request = Request::create('http://localhost/'); + + $listener = new RouterListener($requestMatcher, new RequestContext(), $logger, $this->requestStack); + $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + } + + public function getLoggingParameterData() + { + return array( + array(array('_route' => 'foo'), 'Matched route "foo".'), + array(array(), 'Matched route "n/a".'), + ); + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index c9e00dd68ea75..753125ca8566c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -765,7 +765,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() } /** - * Returns a mock for the BundleInterface + * Returns a mock for the BundleInterface. * * @return BundleInterface */ diff --git a/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php b/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php index f4d07282fb8af..6b1fd9066b4f6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php @@ -43,7 +43,7 @@ public function testCheckWithDifferentArgSeparator() $signer = new UriSigner('foobar'); $this->assertSame( - "http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D", + 'http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', $signer->sign('http://example.com/foo?foo=bar&baz=bay') ); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); diff --git a/src/Symfony/Component/Intl/Collator/Collator.php b/src/Symfony/Component/Intl/Collator/Collator.php index 272a6c13e15b3..90fba8d4919f1 100644 --- a/src/Symfony/Component/Intl/Collator/Collator.php +++ b/src/Symfony/Component/Intl/Collator/Collator.php @@ -70,13 +70,13 @@ class Collator /** * Constructor. * - * @param string $locale The locale code. The only currently supported locale is "en". + * @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en"). * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed + * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed */ public function __construct($locale) { - if ('en' != $locale) { + if ('en' !== $locale && null !== $locale) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); } } @@ -84,11 +84,11 @@ public function __construct($locale) /** * Static constructor. * - * @param string $locale The locale code. The only currently supported locale is "en". + * @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en"). * * @return Collator * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed + * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed */ public static function create($locale) { diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 6c296eeafca42..1b5b90091cc9a 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -129,10 +129,10 @@ class IntlDateFormatter /** * Constructor. * - * @param string $locale The locale code. The only currently supported locale is "en". + * @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en"). * @param int $datetype Type of date formatting, one of the format type constants * @param int $timetype Type of time formatting, one of the format type constants - * @param string $timezone Timezone identifier + * @param mixed $timezone Timezone identifier * @param int $calendar Calendar to use for formatting or parsing. The only currently * supported value is IntlDateFormatter::GREGORIAN. * @param string $pattern Optional pattern to use when formatting @@ -140,12 +140,12 @@ class IntlDateFormatter * @see http://www.php.net/manual/en/intldateformatter.create.php * @see http://userguide.icu-project.org/formatparse/datetime * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed + * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed * @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed */ public function __construct($locale, $datetype, $timetype, $timezone = null, $calendar = self::GREGORIAN, $pattern = null) { - if ('en' !== $locale) { + if ('en' !== $locale && null !== $locale) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); } @@ -157,13 +157,13 @@ public function __construct($locale, $datetype, $timetype, $timezone = null, $ca $this->timetype = $timetype; $this->setPattern($pattern); - $this->setTimeZoneId($timezone); + $this->setTimeZone($timezone); } /** * Static constructor. * - * @param string $locale The locale code. The only currently supported locale is "en". + * @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en"). * @param int $datetype Type of date formatting, one of the format type constants * @param int $timetype Type of time formatting, one of the format type constants * @param string $timezone Timezone identifier @@ -176,7 +176,7 @@ public function __construct($locale, $datetype, $timetype, $timezone = null, $ca * @see http://www.php.net/manual/en/intldateformatter.create.php * @see http://userguide.icu-project.org/formatparse/datetime * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed + * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed * @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed */ public static function create($locale, $datetype, $timetype, $timezone = null, $calendar = self::GREGORIAN, $pattern = null) @@ -583,6 +583,19 @@ public function setTimeZoneId($timeZoneId) */ public function setTimeZone($timeZone) { + if ($timeZone instanceof \IntlTimeZone) { + $timeZone = $timeZone->getID(); + } + + if ($timeZone instanceof \DateTimeZone) { + $timeZone = $timeZone->getName(); + + // DateTimeZone returns the GMT offset timezones without the leading GMT, while our parsing requires it. + if (!empty($timeZone) && ('+' === $timeZone[0] || '-' === $timeZone[0])) { + $timeZone = 'GMT'.$timeZone; + } + } + return $this->setTimeZoneId($timeZone); } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 52e2dccf3e785..fe8a30742803a 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -263,7 +263,7 @@ class NumberFormatter /** * Constructor. * - * @param string $locale The locale code. The only currently supported locale is "en". + * @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en"). * @param int $style Style of the formatting, one of the format style constants. * The only supported styles are NumberFormatter::DECIMAL * and NumberFormatter::CURRENCY. @@ -275,13 +275,13 @@ class NumberFormatter * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details * @see http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed + * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed * @throws MethodArgumentValueNotImplementedException When the $style is not supported * @throws MethodArgumentNotImplementedException When the pattern value is different than null */ public function __construct($locale = 'en', $style = null, $pattern = null) { - if ('en' != $locale) { + if ('en' !== $locale && null !== $locale) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); } @@ -300,7 +300,7 @@ public function __construct($locale = 'en', $style = null, $pattern = null) /** * Static constructor. * - * @param string $locale The locale code. The only supported locale is "en". + * @param string $locale The locale code. The only supported locale is "en" (or null using the default locale, i.e. "en"). * @param int $style Style of the formatting, one of the format style constants. * The only currently supported styles are NumberFormatter::DECIMAL * and NumberFormatter::CURRENCY. @@ -314,7 +314,7 @@ public function __construct($locale = 'en', $style = null, $pattern = null) * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details * @see http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed + * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed * @throws MethodArgumentValueNotImplementedException When the $style is not supported * @throws MethodArgumentNotImplementedException When the pattern value is different than null */ diff --git a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php index 38254fa036188..5a4b35519f8b6 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php @@ -76,7 +76,7 @@ public function getCurrencyNames($displayLocale = null) try { return $this->getNames($displayLocale); } catch (MissingResourceException $e) { - return; + return array(); } } @@ -112,7 +112,7 @@ public function getLocales() try { return $this->localeProvider->getLocales(); } catch (MissingResourceException $e) { - return; + return array(); } } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php index bb393d2063b7d..cfe82ca3c3135 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php @@ -80,7 +80,7 @@ public function getLanguageNames($displayLocale = null) try { return $this->getNames($displayLocale); } catch (MissingResourceException $e) { - return; + return array(); } } @@ -104,7 +104,7 @@ public function getScriptNames($displayLocale = null) try { return $this->scriptProvider->getNames($displayLocale); } catch (MissingResourceException $e) { - return; + return array(); } } @@ -116,7 +116,7 @@ public function getLocales() try { return $this->localeProvider->getLocales(); } catch (MissingResourceException $e) { - return; + return array(); } } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php index 22c9aecfb3697..b14048a40ff94 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php @@ -31,7 +31,7 @@ public function getLocales() try { return parent::getLocales(); } catch (MissingResourceException $e) { - return; + return array(); } } @@ -55,7 +55,7 @@ public function getLocaleNames($displayLocale = null) try { return $this->getNames($displayLocale); } catch (MissingResourceException $e) { - return; + return array(); } } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php index 126d62ac04a4b..29697d6883dd0 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php @@ -64,7 +64,7 @@ public function getCountryNames($displayLocale = null) try { return $this->getNames($displayLocale); } catch (MissingResourceException $e) { - return; + return array(); } } @@ -76,7 +76,7 @@ public function getLocales() try { return $this->localeProvider->getLocales(); } catch (MissingResourceException $e) { - return; + return array(); } } } diff --git a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php index a4e4e56b20776..840d97532f09c 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php @@ -60,6 +60,12 @@ public function testGetLocale() $this->assertEquals('en', $collator->getLocale()); } + public function testConstructWithoutLocale() + { + $collator = $this->getCollator(null); + $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator); + } + /** * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException */ diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php index 3346570105a28..f7284c3d7c2e0 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Intl\Tests\Data\Bundle\Reader; use Symfony\Component\Intl\Data\Bundle\Reader\IntlBundleReader; -use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek @@ -26,7 +26,10 @@ class IntlBundleReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - IntlTestHelper::requireFullIntl($this); + // We only run tests if the intl extension is loaded... + if (!Intl::isExtensionLoaded()) { + $this->markTestSkipped('The intl extension is not available.'); + } $this->reader = new IntlBundleReader(); } @@ -52,6 +55,14 @@ public function testReadFollowsAlias() public function testReadDoesNotFollowFallback() { + if (PHP_VERSION_ID < 50307 || PHP_VERSION_ID === 50400) { + $this->markTestSkipped('ResourceBundle handles disabling fallback properly only as of PHP 5.3.7 and 5.4.1.'); + } + + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('ResourceBundle does not support disabling fallback properly on HHVM.'); + } + // "ro_MD" -> "ro" $data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro_MD'); @@ -64,6 +75,14 @@ public function testReadDoesNotFollowFallback() public function testReadDoesNotFollowFallbackAlias() { + if (PHP_VERSION_ID < 50307 || PHP_VERSION_ID === 50400) { + $this->markTestSkipped('ResourceBundle handles disabling fallback properly only as of PHP 5.3.7 and 5.4.1.'); + } + + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('ResourceBundle does not support disabling fallback properly on HHVM.'); + } + // "mo" = "ro_MD" -> "ro" $data = $this->reader->read(__DIR__.'/Fixtures/res', 'mo'); diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index c449cf82db6f1..5cf92a54e4d39 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter; -use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek @@ -74,7 +74,10 @@ public function testWrite() public function testWriteResourceBundle() { - IntlTestHelper::requireFullIntl($this); + // We only run tests if the intl extension is loaded... + if (!Intl::isExtensionLoaded()) { + $this->markTestSkipped('The intl extension is not available.'); + } $bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false); diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php index a855fbffefd3e..efc3519e3a7ba 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter; -use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek @@ -66,7 +66,14 @@ public function testWrite() public function testWriteResourceBundle() { - IntlTestHelper::requireFullIntl($this); + // We only run tests if the intl extension is loaded... + if (!Intl::isExtensionLoaded()) { + $this->markTestSkipped('The intl extension is not available.'); + } + + if (PHP_VERSION_ID < 50315 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { + $this->markTestSkipped('ResourceBundle implements Traversable only as of PHP 5.3.15 and 5.4.4'); + } $bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 5487e3396bc94..6cae5aedd0465 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -380,6 +380,36 @@ public function testFormatWithConstructorTimezone() ); } + public function testFormatWithDateTimeZone() + { + if (PHP_VERSION_ID < 50500) { + $this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.'); + } + + if (defined('HHVM_VERSION_ID')) { + $this->markTestSkipped('This test cannot work on HHVM. See https://github.com/facebook/hhvm/issues/5875 for the issue.'); + } + + $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz'); + + $this->assertEquals('GMT+03:00', $formatter->format(0)); + } + + public function testFormatWithIntlTimeZone() + { + if (PHP_VERSION_ID < 50500) { + $this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.'); + } + + if (!class_exists('IntlTimeZone')) { + $this->markTestSkipped('This test requires the IntlTimeZone class from the Intl extension.'); + } + + $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, \IntlTimeZone::createTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz'); + + $this->assertEquals('GMT+03:00', $formatter->format(0)); + } + public function testFormatWithTimezoneFromEnvironmentVariable() { if (PHP_VERSION_ID >= 50500) { diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 4e7b0160fb3ad..b38d30cf6cc0f 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -22,6 +22,12 @@ public function testConstructor() $this->assertEquals('y-M-d', $formatter->getPattern()); } + public function testConstructorWithoutLocale() + { + $formatter = new IntlDateFormatter(null, IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, 'y-M-d'); + $this->assertEquals('y-M-d', $formatter->getPattern()); + } + /** * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException */ diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index df4169fea0e56..9bde822486e77 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -56,8 +56,6 @@ public function formatCurrencyWithDecimalStyleProvider() */ public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals($expected, $formatter->formatCurrency($value, $currency)); } @@ -84,8 +82,6 @@ public function formatCurrencyWithCurrencyStyleProvider() */ public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($value, $currency, $symbol, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } @@ -104,8 +100,6 @@ public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider( */ public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } @@ -133,8 +127,6 @@ public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider() */ public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $currency, $symbol, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php index 519e753bd5be0..4a6fa9d3f7414 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Intl\Globals\IntlGlobals; use Symfony\Component\Intl\NumberFormatter\NumberFormatter; -use Symfony\Component\Intl\Util\IntlTestHelper; /** * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known @@ -21,13 +20,6 @@ */ class NumberFormatterTest extends AbstractNumberFormatterTest { - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - /** * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException */ @@ -70,6 +62,14 @@ public function testSetAttributeInvalidRoundingMode() $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, null); } + public function testConstructWithoutLocale() + { + $this->assertInstanceOf( + '\Symfony\Component\Intl\NumberFormatter\NumberFormatter', + $this->getNumberFormatter(null, NumberFormatter::DECIMAL) + ); + } + public function testCreate() { $this->assertInstanceOf( diff --git a/src/Symfony/Component/Locale/Tests/LocaleTest.php b/src/Symfony/Component/Locale/Tests/LocaleTest.php index a8a375a13391c..033d68903c43c 100644 --- a/src/Symfony/Component/Locale/Tests/LocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/LocaleTest.php @@ -11,20 +11,20 @@ namespace Symfony\Component\Locale\Tests; -use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Locale\Locale; /** * Test case for the {@link Locale} class. * * @author Bernhard Schussek + * + * @group legacy */ class LocaleTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - // Locale extends \Locale, so intl must be present - IntlTestHelper::requireIntl($this); + \Locale::setDefault('en'); } public function testGetDisplayCountries() diff --git a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php index 146d6fadd5958..b79ea86ea322b 100644 --- a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php @@ -11,20 +11,15 @@ namespace Symfony\Component\Locale\Tests\Stub; -use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Locale\Stub\StubLocale; /** * @author Bernhard Schussek + * + * @group legacy */ class StubLocaleTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - // Locale extends \Locale, so intl must be present - IntlTestHelper::requireIntl($this); - } - public function testGetCurrenciesData() { $currencies = StubLocale::getCurrenciesData('en'); diff --git a/src/Symfony/Component/Locale/composer.json b/src/Symfony/Component/Locale/composer.json index d3f9466bc8720..467d9405ab3a9 100644 --- a/src/Symfony/Component/Locale/composer.json +++ b/src/Symfony/Component/Locale/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.9", - "symfony/intl": "~2.3|~3.0.0" + "symfony/intl": "~2.7|~3.0.0" }, "require-dev": { "symfony/phpunit-bridge": "~2.7|~3.0.0" diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index c4b8f564a44e6..e42d7bbfd1684 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -434,7 +434,6 @@ public function setNormalizer($option, \Closure $normalizer) * @throws AccessException If called from a lazy option or normalizer * * @see setNormalizer() - * * @deprecated since version 2.6, to be removed in 3.0. */ public function setNormalizers(array $normalizers) diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index d8b57d07a778a..1ca85739f59c3 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -54,7 +54,7 @@ protected function hasSystemCallBeenInterrupted() } /** - * Unblocks streams + * Unblocks streams. */ protected function unblock() { diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index b3841031c4c4e..f8a0d1997dc36 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -200,7 +200,7 @@ public function areOpen() } /** - * Creates a new UnixPipes instance + * Creates a new UnixPipes instance. * * @param Process $process * @param string|resource $input diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index 01dd5d0600f20..b20f3ec34dd44 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -173,7 +173,7 @@ public static function create(Process $process, $input) } /** - * Removes temporary files + * Removes temporary files. */ private function removeFiles() { @@ -186,7 +186,7 @@ private function removeFiles() } /** - * Writes input to stdin + * Writes input to stdin. * * @param bool $blocking * @param bool $close diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 2add8cc938528..eb3f65dc93945 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -524,7 +524,7 @@ public function testMustRun() $process = $this->getProcess('echo foo'); $this->assertSame($process, $process->mustRun()); - $this->assertEquals("foo".PHP_EOL, $process->getOutput()); + $this->assertEquals('foo'.PHP_EOL, $process->getOutput()); } public function testSuccessfulMustRunHasCorrectExitCode() @@ -559,7 +559,7 @@ public function testStartIsNonBlocking() $start = microtime(true); $process->start(); $end = microtime(true); - $this->assertLessThan(0.2, $end-$start); + $this->assertLessThan(0.2, $end - $start); $process->wait(); } diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index b028395f9b4de..de37353f91752 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -91,7 +91,7 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( /** * Tests that ProcessFailedException does not extract information from - * process output if it was previously disabled + * process output if it was previously disabled. */ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() { diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index b68d0c2ad857f..d4e8c78a9b408 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -229,7 +229,7 @@ private function &readPropertiesUntil(&$objectOrArray, PropertyPathInterface $pr // the final value of the path must not be validated if ($i + 1 < $propertyPath->getLength() && !is_object($objectOrArray) && !is_array($objectOrArray)) { - throw new UnexpectedTypeException($objectOrArray, $propertyPath, $i+1); + throw new UnexpectedTypeException($objectOrArray, $propertyPath, $i + 1); } $propertyValues[] = &$propertyValue; diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php index d07c7c0fa80c0..4e966cdacb39e 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php @@ -24,4 +24,4 @@ public function __construct($value) { $this->value = $value; } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php index 638afee6af84a..f0a7f1f47ca97 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php @@ -29,4 +29,4 @@ public function __construct($value) { $this->value = $value; } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index a9f7834305de7..51b712cf752c2 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -458,7 +458,6 @@ public function getReferenceChainObjectsForSetValue() array(new TestClassSetValue(array('a' => array('b' => 'old-value'))), 'value[a][b]', 'new-value'), array(new \ArrayIterator(array('a' => array('b' => array('c' => 'old-value')))), '[a][b][c]', 'new-value'), ); - } /** @@ -478,7 +477,6 @@ public function getReferenceChainObjectsForIsWritable() array(new TestClassIsWritable(new \ArrayIterator(array('a' => array('b' => 'old-value')))), 'value[a][b]', true), array(new TestClassIsWritable(array('a' => array('b' => array('c' => new TestClassSetValue('old-value'))))), 'value[a][b][c].value', true), ); - } /** @@ -488,5 +486,4 @@ public function testIsWritableForReferenceChainIssue($object, $path, $value) { $this->assertEquals($value, $this->propertyAccessor->isWritable($object, $path)); } - -} \ No newline at end of file +} diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index da881ef2956b8..7b0ef25b205be 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -139,7 +139,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl $defaults = array_replace($globals['defaults'], $annot->getDefaults()); foreach ($method->getParameters() as $param) { - if (!isset($defaults[$param->getName()]) && $param->isOptional()) { + if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) { $defaults[$param->getName()] = $param->getDefaultValue(); } } diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index e2651ef8b93ae..2cbbb2bdad342 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -355,7 +355,9 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac /** * This method is public because it needs to be callable from a closure in PHP 5.3. It should be converted back to protected in 3.0. + * * @internal + * * @return GeneratorDumperInterface */ public function getGeneratorDumperInstance() @@ -365,7 +367,9 @@ public function getGeneratorDumperInstance() /** * This method is public because it needs to be callable from a closure in PHP 5.3. It should be converted back to protected in 3.0. + * * @internal + * * @return MatcherDumperInterface */ public function getMatcherDumperInstance() diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php b/src/Symfony/Component/Routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php new file mode 100644 index 0000000000000..729c9b4d07b38 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Tests\Fixtures\OtherAnnotatedClasses; + +class VariadicClass +{ + public function routeAction(...$params) + { + } +} diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index 5f8f4945efe17..83bf7108fb28b 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -16,6 +16,7 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest { protected $loader; + private $reader; protected function setUp() { @@ -151,14 +152,14 @@ public function testClassRouteLoad() $classRouteData = array( 'path' => '/prefix', 'schemes' => array('https'), - 'methods' => array('GET') + 'methods' => array('GET'), ); $methodRouteData = array( 'name' => 'route1', 'path' => '/path', 'schemes' => array('http'), - 'methods' => array('POST', 'PUT') + 'methods' => array('POST', 'PUT'), ); $this->reader diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index f0a8a0e329539..9a83994f9a7cf 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Routing\Loader\AnnotationFileLoader; use Symfony\Component\Config\FileLocator; +use Symfony\Component\Routing\Annotation\Route; class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest { @@ -34,6 +35,19 @@ public function testLoad() $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); } + /** + * @requires PHP 5.6 + */ + public function testLoadVariadic() + { + $route = new Route(array('path' => '/path/to/{id}')); + $this->reader->expects($this->once())->method('getClassAnnotation'); + $this->reader->expects($this->once())->method('getMethodAnnotations') + ->will($this->returnValue(array($route))); + + $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php'); + } + public function testSupports() { $fixture = __DIR__.'/../Fixtures/annotated.php'; diff --git a/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php index db29530564a29..fc29d371ed15d 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/DirectoryLoaderTest.php @@ -57,7 +57,7 @@ private function verifyCollection(RouteCollection $collection) $this->assertCount(3, $routes, 'Three routes are loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - for ($i = 1; $i <= 3; $i++) { + for ($i = 1; $i <= 3; ++$i) { $this->assertSame('/route/'.$i, $routes['route'.$i]->getPath()); } } diff --git a/src/Symfony/Component/Security/Acl/.gitignore b/src/Symfony/Component/Security/Acl/.gitignore deleted file mode 100644 index c49a5d8df5c65..0000000000000 --- a/src/Symfony/Component/Security/Acl/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php deleted file mode 100644 index 989e40b4a776b..0000000000000 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ /dev/null @@ -1,695 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Dbal; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Statement; -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Domain\Acl; -use Symfony\Component\Security\Acl\Domain\Entry; -use Symfony\Component\Security\Acl\Domain\FieldEntry; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Exception\AclNotFoundException; -use Symfony\Component\Security\Acl\Exception\NotAllAclsFoundException; -use Symfony\Component\Security\Acl\Model\AclCacheInterface; -use Symfony\Component\Security\Acl\Model\AclProviderInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; -use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface; - -/** - * An ACL provider implementation. - * - * This provider assumes that all ACLs share the same PermissionGrantingStrategy. - * - * @author Johannes M. Schmitt - */ -class AclProvider implements AclProviderInterface -{ - const MAX_BATCH_SIZE = 30; - - /** - * @var AclCacheInterface|null - */ - protected $cache; - - /** - * @var Connection - */ - protected $connection; - protected $loadedAces = array(); - protected $loadedAcls = array(); - protected $options; - - /** - * @var PermissionGrantingStrategyInterface - */ - private $permissionGrantingStrategy; - - /** - * Constructor. - * - * @param Connection $connection - * @param PermissionGrantingStrategyInterface $permissionGrantingStrategy - * @param array $options - * @param AclCacheInterface $cache - */ - public function __construct(Connection $connection, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $options, AclCacheInterface $cache = null) - { - $this->cache = $cache; - $this->connection = $connection; - $this->options = $options; - $this->permissionGrantingStrategy = $permissionGrantingStrategy; - } - - /** - * {@inheritdoc} - */ - public function findChildren(ObjectIdentityInterface $parentOid, $directChildrenOnly = false) - { - $sql = $this->getFindChildrenSql($parentOid, $directChildrenOnly); - - $children = array(); - foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) { - $children[] = new ObjectIdentity($data['object_identifier'], $data['class_type']); - } - - return $children; - } - - /** - * {@inheritdoc} - */ - public function findAcl(ObjectIdentityInterface $oid, array $sids = array()) - { - return $this->findAcls(array($oid), $sids)->offsetGet($oid); - } - - /** - * {@inheritdoc} - */ - public function findAcls(array $oids, array $sids = array()) - { - $result = new \SplObjectStorage(); - $currentBatch = array(); - $oidLookup = array(); - - for ($i = 0, $c = count($oids); $i < $c; ++$i) { - $oid = $oids[$i]; - $oidLookupKey = $oid->getIdentifier().$oid->getType(); - $oidLookup[$oidLookupKey] = $oid; - $aclFound = false; - - // check if result already contains an ACL - if ($result->contains($oid)) { - $aclFound = true; - } - - // check if this ACL has already been hydrated - if (!$aclFound && isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) { - $acl = $this->loadedAcls[$oid->getType()][$oid->getIdentifier()]; - - if (!$acl->isSidLoaded($sids)) { - // FIXME: we need to load ACEs for the missing SIDs. This is never - // reached by the default implementation, since we do not - // filter by SID - throw new \RuntimeException('This is not supported by the default implementation.'); - } else { - $result->attach($oid, $acl); - $aclFound = true; - } - } - - // check if we can locate the ACL in the cache - if (!$aclFound && null !== $this->cache) { - $acl = $this->cache->getFromCacheByIdentity($oid); - - if (null !== $acl) { - if ($acl->isSidLoaded($sids)) { - // check if any of the parents has been loaded since we need to - // ensure that there is only ever one ACL per object identity - $parentAcl = $acl->getParentAcl(); - while (null !== $parentAcl) { - $parentOid = $parentAcl->getObjectIdentity(); - - if (isset($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()])) { - $acl->setParentAcl($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()]); - break; - } else { - $this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()] = $parentAcl; - $this->updateAceIdentityMap($parentAcl); - } - - $parentAcl = $parentAcl->getParentAcl(); - } - - $this->loadedAcls[$oid->getType()][$oid->getIdentifier()] = $acl; - $this->updateAceIdentityMap($acl); - $result->attach($oid, $acl); - $aclFound = true; - } else { - $this->cache->evictFromCacheByIdentity($oid); - - foreach ($this->findChildren($oid) as $childOid) { - $this->cache->evictFromCacheByIdentity($childOid); - } - } - } - } - - // looks like we have to load the ACL from the database - if (!$aclFound) { - $currentBatch[] = $oid; - } - - // Is it time to load the current batch? - $currentBatchesCount = count($currentBatch); - if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) { - try { - $loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup); - } catch (AclNotFoundException $e) { - if ($result->count()) { - $partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.'); - $partialResultException->setPartialResult($result); - throw $partialResultException; - } else { - throw $e; - } - } - foreach ($loadedBatch as $loadedOid) { - $loadedAcl = $loadedBatch->offsetGet($loadedOid); - - if (null !== $this->cache) { - $this->cache->putInCache($loadedAcl); - } - - if (isset($oidLookup[$loadedOid->getIdentifier().$loadedOid->getType()])) { - $result->attach($loadedOid, $loadedAcl); - } - } - - $currentBatch = array(); - } - } - - // check that we got ACLs for all the identities - foreach ($oids as $oid) { - if (!$result->contains($oid)) { - if (1 === count($oids)) { - $objectName = method_exists($oid, '__toString') ? $oid : get_class($oid); - throw new AclNotFoundException(sprintf('No ACL found for %s.', $objectName)); - } - - $partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.'); - $partialResultException->setPartialResult($result); - - throw $partialResultException; - } - } - - return $result; - } - - /** - * Constructs the query used for looking up object identities and associated - * ACEs, and security identities. - * - * @param array $ancestorIds - * - * @return string - */ - protected function getLookupSql(array $ancestorIds) - { - // FIXME: add support for filtering by sids (right now we select all sids) - - $sql = <<options['oid_table_name']} o - INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id - LEFT JOIN {$this->options['entry_table_name']} e ON ( - e.class_id = o.class_id AND (e.object_identity_id = o.id OR {$this->connection->getDatabasePlatform()->getIsNullExpression('e.object_identity_id')}) - ) - LEFT JOIN {$this->options['sid_table_name']} s ON ( - s.id = e.security_identity_id - ) - - WHERE (o.id = -SELECTCLAUSE; - - $sql .= implode(' OR o.id = ', $ancestorIds).')'; - - return $sql; - } - - protected function getAncestorLookupSql(array $batch) - { - $sql = <<options['oid_table_name']} o - INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id - INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id - WHERE ( -SELECTCLAUSE; - - $types = array(); - $count = count($batch); - for ($i = 0; $i < $count; ++$i) { - if (!isset($types[$batch[$i]->getType()])) { - $types[$batch[$i]->getType()] = true; - - // if there is more than one type we can safely break out of the - // loop, because it is the differentiator factor on whether to - // query for only one or more class types - if (count($types) > 1) { - break; - } - } - } - - if (1 === count($types)) { - $ids = array(); - for ($i = 0; $i < $count; ++$i) { - $identifier = (string) $batch[$i]->getIdentifier(); - $ids[] = $this->connection->quote($identifier); - } - - $sql .= sprintf( - '(o.object_identifier IN (%s) AND c.class_type = %s)', - implode(',', $ids), - $this->connection->quote($batch[0]->getType()) - ); - } else { - $where = '(o.object_identifier = %s AND c.class_type = %s)'; - for ($i = 0; $i < $count; ++$i) { - $sql .= sprintf( - $where, - $this->connection->quote($batch[$i]->getIdentifier()), - $this->connection->quote($batch[$i]->getType()) - ); - - if ($i + 1 < $count) { - $sql .= ' OR '; - } - } - } - - $sql .= ')'; - - return $sql; - } - - /** - * Constructs the SQL for retrieving child object identities for the given - * object identities. - * - * @param ObjectIdentityInterface $oid - * @param bool $directChildrenOnly - * - * @return string - */ - protected function getFindChildrenSql(ObjectIdentityInterface $oid, $directChildrenOnly) - { - if (false === $directChildrenOnly) { - $query = <<options['oid_table_name']} o - INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id - INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id - WHERE - a.ancestor_id = %d AND a.object_identity_id != a.ancestor_id -FINDCHILDREN; - } else { - $query = <<options['oid_table_name']} o - INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id - WHERE o.parent_object_identity_id = %d -FINDCHILDREN; - } - - return sprintf($query, $this->retrieveObjectIdentityPrimaryKey($oid)); - } - - /** - * Constructs the SQL for retrieving the primary key of the given object - * identity. - * - * @param ObjectIdentityInterface $oid - * - * @return string - */ - protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid) - { - $query = <<options['oid_table_name'], - $this->options['class_table_name'], - $this->connection->quote((string) $oid->getIdentifier()), - $this->connection->quote((string) $oid->getType()) - ); - } - - /** - * Returns the primary key of the passed object identity. - * - * @param ObjectIdentityInterface $oid - * - * @return int - */ - final protected function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid) - { - return $this->connection->executeQuery($this->getSelectObjectIdentityIdSql($oid))->fetchColumn(); - } - - /** - * This method is called when an ACL instance is retrieved from the cache. - * - * @param AclInterface $acl - */ - private function updateAceIdentityMap(AclInterface $acl) - { - foreach (array('classAces', 'classFieldAces', 'objectAces', 'objectFieldAces') as $property) { - $reflection = new \ReflectionProperty($acl, $property); - $reflection->setAccessible(true); - $value = $reflection->getValue($acl); - - if ('classAces' === $property || 'objectAces' === $property) { - $this->doUpdateAceIdentityMap($value); - } else { - foreach ($value as $field => $aces) { - $this->doUpdateAceIdentityMap($value[$field]); - } - } - - $reflection->setValue($acl, $value); - $reflection->setAccessible(false); - } - } - - /** - * Retrieves all the ids which need to be queried from the database - * including the ids of parent ACLs. - * - * @param array $batch - * - * @return array - */ - private function getAncestorIds(array $batch) - { - $sql = $this->getAncestorLookupSql($batch); - - $ancestorIds = array(); - foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) { - // FIXME: skip ancestors which are cached - // Fix: Oracle returns keys in uppercase - $ancestorIds[] = reset($data); - } - - return $ancestorIds; - } - - /** - * Does either overwrite the passed ACE, or saves it in the global identity - * map to ensure every ACE only gets instantiated once. - * - * @param array &$aces - */ - private function doUpdateAceIdentityMap(array &$aces) - { - foreach ($aces as $index => $ace) { - if (isset($this->loadedAces[$ace->getId()])) { - $aces[$index] = $this->loadedAces[$ace->getId()]; - } else { - $this->loadedAces[$ace->getId()] = $ace; - } - } - } - - /** - * This method is called for object identities which could not be retrieved - * from the cache, and for which thus a database query is required. - * - * @param array $batch - * @param array $sids - * @param array $oidLookup - * - * @return \SplObjectStorage mapping object identities to ACL instances - * - * @throws AclNotFoundException - */ - private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup) - { - $ancestorIds = $this->getAncestorIds($batch); - if (!$ancestorIds) { - throw new AclNotFoundException('There is no ACL for the given object identity.'); - } - - $sql = $this->getLookupSql($ancestorIds); - $stmt = $this->connection->executeQuery($sql); - - return $this->hydrateObjectIdentities($stmt, $oidLookup, $sids); - } - - /** - * This method is called to hydrate ACLs and ACEs. - * - * This method was designed for performance; thus, a lot of code has been - * inlined at the cost of readability, and maintainability. - * - * Keep in mind that changes to this method might severely reduce the - * performance of the entire ACL system. - * - * @param Statement $stmt - * @param array $oidLookup - * @param array $sids - * - * @return \SplObjectStorage - * - * @throws \RuntimeException - */ - private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, array $sids) - { - $parentIdToFill = new \SplObjectStorage(); - $acls = $aces = $emptyArray = array(); - $oidCache = $oidLookup; - $result = new \SplObjectStorage(); - $loadedAces = &$this->loadedAces; - $loadedAcls = &$this->loadedAcls; - $permissionGrantingStrategy = $this->permissionGrantingStrategy; - - // we need these to set protected properties on hydrated objects - $aclReflection = new \ReflectionClass('Symfony\Component\Security\Acl\Domain\Acl'); - $aclClassAcesProperty = $aclReflection->getProperty('classAces'); - $aclClassAcesProperty->setAccessible(true); - $aclClassFieldAcesProperty = $aclReflection->getProperty('classFieldAces'); - $aclClassFieldAcesProperty->setAccessible(true); - $aclObjectAcesProperty = $aclReflection->getProperty('objectAces'); - $aclObjectAcesProperty->setAccessible(true); - $aclObjectFieldAcesProperty = $aclReflection->getProperty('objectFieldAces'); - $aclObjectFieldAcesProperty->setAccessible(true); - $aclParentAclProperty = $aclReflection->getProperty('parentAcl'); - $aclParentAclProperty->setAccessible(true); - - // fetchAll() consumes more memory than consecutive calls to fetch(), - // but it is faster - foreach ($stmt->fetchAll(\PDO::FETCH_NUM) as $data) { - list($aclId, - $objectIdentifier, - $parentObjectIdentityId, - $entriesInheriting, - $classType, - $aceId, - $objectIdentityId, - $fieldName, - $aceOrder, - $mask, - $granting, - $grantingStrategy, - $auditSuccess, - $auditFailure, - $username, - $securityIdentifier) = array_values($data); - - // has the ACL been hydrated during this hydration cycle? - if (isset($acls[$aclId])) { - $acl = $acls[$aclId]; - // has the ACL been hydrated during any previous cycle, or was possibly loaded - // from cache? - } elseif (isset($loadedAcls[$classType][$objectIdentifier])) { - $acl = $loadedAcls[$classType][$objectIdentifier]; - - // keep reference in local array (saves us some hash calculations) - $acls[$aclId] = $acl; - - // attach ACL to the result set; even though we do not enforce that every - // object identity has only one instance, we must make sure to maintain - // referential equality with the oids passed to findAcls() - $oidCacheKey = $objectIdentifier.$classType; - if (!isset($oidCache[$oidCacheKey])) { - $oidCache[$oidCacheKey] = $acl->getObjectIdentity(); - } - $result->attach($oidCache[$oidCacheKey], $acl); - // so, this hasn't been hydrated yet - } else { - // create object identity if we haven't done so yet - $oidLookupKey = $objectIdentifier.$classType; - if (!isset($oidCache[$oidLookupKey])) { - $oidCache[$oidLookupKey] = new ObjectIdentity($objectIdentifier, $classType); - } - - $acl = new Acl((int) $aclId, $oidCache[$oidLookupKey], $permissionGrantingStrategy, $emptyArray, !!$entriesInheriting); - - // keep a local, and global reference to this ACL - $loadedAcls[$classType][$objectIdentifier] = $acl; - $acls[$aclId] = $acl; - - // try to fill in parent ACL, or defer until all ACLs have been hydrated - if (null !== $parentObjectIdentityId) { - if (isset($acls[$parentObjectIdentityId])) { - $aclParentAclProperty->setValue($acl, $acls[$parentObjectIdentityId]); - } else { - $parentIdToFill->attach($acl, $parentObjectIdentityId); - } - } - - $result->attach($oidCache[$oidLookupKey], $acl); - } - - // check if this row contains an ACE record - if (null !== $aceId) { - // have we already hydrated ACEs for this ACL? - if (!isset($aces[$aclId])) { - $aces[$aclId] = array($emptyArray, $emptyArray, $emptyArray, $emptyArray); - } - - // has this ACE already been hydrated during a previous cycle, or - // possible been loaded from cache? - // It is important to only ever have one ACE instance per actual row since - // some ACEs are shared between ACL instances - if (!isset($loadedAces[$aceId])) { - if (!isset($sids[$key = ($username ? '1' : '0').$securityIdentifier])) { - if ($username) { - $sids[$key] = new UserSecurityIdentity( - substr($securityIdentifier, 1 + $pos = strpos($securityIdentifier, '-')), - substr($securityIdentifier, 0, $pos) - ); - } else { - $sids[$key] = new RoleSecurityIdentity($securityIdentifier); - } - } - - if (null === $fieldName) { - $loadedAces[$aceId] = new Entry((int) $aceId, $acl, $sids[$key], $grantingStrategy, (int) $mask, !!$granting, !!$auditFailure, !!$auditSuccess); - } else { - $loadedAces[$aceId] = new FieldEntry((int) $aceId, $acl, $fieldName, $sids[$key], $grantingStrategy, (int) $mask, !!$granting, !!$auditFailure, !!$auditSuccess); - } - } - $ace = $loadedAces[$aceId]; - - // assign ACE to the correct property - if (null === $objectIdentityId) { - if (null === $fieldName) { - $aces[$aclId][0][$aceOrder] = $ace; - } else { - $aces[$aclId][1][$fieldName][$aceOrder] = $ace; - } - } else { - if (null === $fieldName) { - $aces[$aclId][2][$aceOrder] = $ace; - } else { - $aces[$aclId][3][$fieldName][$aceOrder] = $ace; - } - } - } - } - - // We do not sort on database level since we only want certain subsets to be sorted, - // and we are going to read the entire result set anyway. - // Sorting on DB level increases query time by an order of magnitude while it is - // almost negligible when we use PHPs array sort functions. - foreach ($aces as $aclId => $aceData) { - $acl = $acls[$aclId]; - - ksort($aceData[0]); - $aclClassAcesProperty->setValue($acl, $aceData[0]); - - foreach (array_keys($aceData[1]) as $fieldName) { - ksort($aceData[1][$fieldName]); - } - $aclClassFieldAcesProperty->setValue($acl, $aceData[1]); - - ksort($aceData[2]); - $aclObjectAcesProperty->setValue($acl, $aceData[2]); - - foreach (array_keys($aceData[3]) as $fieldName) { - ksort($aceData[3][$fieldName]); - } - $aclObjectFieldAcesProperty->setValue($acl, $aceData[3]); - } - - // fill-in parent ACLs where this hasn't been done yet cause the parent ACL was not - // yet available - $processed = 0; - foreach ($parentIdToFill as $acl) { - $parentId = $parentIdToFill->offsetGet($acl); - - // let's see if we have already hydrated this - if (isset($acls[$parentId])) { - $aclParentAclProperty->setValue($acl, $acls[$parentId]); - ++$processed; - - continue; - } - } - - // reset reflection changes - $aclClassAcesProperty->setAccessible(false); - $aclClassFieldAcesProperty->setAccessible(false); - $aclObjectAcesProperty->setAccessible(false); - $aclObjectFieldAcesProperty->setAccessible(false); - $aclParentAclProperty->setAccessible(false); - - // this should never be true if the database integrity hasn't been compromised - if ($processed < count($parentIdToFill)) { - throw new \RuntimeException('Not all parent ids were populated. This implies an integrity problem.'); - } - - return $result; - } -} diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php deleted file mode 100644 index 9129e8b75b980..0000000000000 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ /dev/null @@ -1,1034 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Dbal; - -use Doctrine\Common\PropertyChangedListener; -use Doctrine\DBAL\Connection; -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException; -use Symfony\Component\Security\Acl\Exception\ConcurrentModificationException; -use Symfony\Component\Security\Acl\Model\AclCacheInterface; -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Model\EntryInterface; -use Symfony\Component\Security\Acl\Model\MutableAclInterface; -use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; -use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; - -/** - * An implementation of the MutableAclProviderInterface using Doctrine DBAL. - * - * @author Johannes M. Schmitt - */ -class MutableAclProvider extends AclProvider implements MutableAclProviderInterface, PropertyChangedListener -{ - private $propertyChanges; - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $options, AclCacheInterface $cache = null) - { - parent::__construct($connection, $permissionGrantingStrategy, $options, $cache); - - $this->propertyChanges = new \SplObjectStorage(); - } - - /** - * {@inheritdoc} - */ - public function createAcl(ObjectIdentityInterface $oid) - { - if (false !== $this->retrieveObjectIdentityPrimaryKey($oid)) { - $objectName = method_exists($oid, '__toString') ? $oid : get_class($oid); - throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $objectName)); - } - - $this->connection->beginTransaction(); - try { - $this->createObjectIdentity($oid); - - $pk = $this->retrieveObjectIdentityPrimaryKey($oid); - $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk)); - - $this->connection->commit(); - } catch (\Exception $e) { - $this->connection->rollBack(); - - throw $e; - } - - // re-read the ACL from the database to ensure proper caching, etc. - return $this->findAcl($oid); - } - - /** - * {@inheritdoc} - */ - public function deleteAcl(ObjectIdentityInterface $oid) - { - $this->connection->beginTransaction(); - try { - foreach ($this->findChildren($oid, true) as $childOid) { - $this->deleteAcl($childOid); - } - - $oidPK = $this->retrieveObjectIdentityPrimaryKey($oid); - - $this->deleteAccessControlEntries($oidPK); - $this->deleteObjectIdentityRelations($oidPK); - $this->deleteObjectIdentity($oidPK); - - $this->connection->commit(); - } catch (\Exception $e) { - $this->connection->rollBack(); - - throw $e; - } - - // evict the ACL from the in-memory identity map - if (isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) { - $this->propertyChanges->offsetUnset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()]); - unset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()]); - } - - // evict the ACL from any caches - if (null !== $this->cache) { - $this->cache->evictFromCacheByIdentity($oid); - } - } - - /** - * Deletes the security identity from the database. - * ACL entries have the CASCADE option on their foreign key so they will also get deleted - * - * @param SecurityIdentityInterface $sid - * - * @throws \InvalidArgumentException - */ - public function deleteSecurityIdentity(SecurityIdentityInterface $sid) - { - $this->connection->executeQuery($this->getDeleteSecurityIdentityIdSql($sid)); - } - - /** - * {@inheritdoc} - */ - public function findAcls(array $oids, array $sids = array()) - { - $result = parent::findAcls($oids, $sids); - - foreach ($result as $oid) { - $acl = $result->offsetGet($oid); - - if (false === $this->propertyChanges->contains($acl) && $acl instanceof MutableAclInterface) { - $acl->addPropertyChangedListener($this); - $this->propertyChanges->attach($acl, array()); - } - - $parentAcl = $acl->getParentAcl(); - while (null !== $parentAcl) { - if (false === $this->propertyChanges->contains($parentAcl) && $acl instanceof MutableAclInterface) { - $parentAcl->addPropertyChangedListener($this); - $this->propertyChanges->attach($parentAcl, array()); - } - - $parentAcl = $parentAcl->getParentAcl(); - } - } - - return $result; - } - - /** - * Implementation of PropertyChangedListener. - * - * This allows us to keep track of which values have been changed, so we don't - * have to do a full introspection when ->updateAcl() is called. - * - * @param mixed $sender - * @param string $propertyName - * @param mixed $oldValue - * @param mixed $newValue - * - * @throws \InvalidArgumentException - */ - public function propertyChanged($sender, $propertyName, $oldValue, $newValue) - { - if (!$sender instanceof MutableAclInterface && !$sender instanceof EntryInterface) { - throw new \InvalidArgumentException('$sender must be an instance of MutableAclInterface, or EntryInterface.'); - } - - if ($sender instanceof EntryInterface) { - if (null === $sender->getId()) { - return; - } - - $ace = $sender; - $sender = $ace->getAcl(); - } else { - $ace = null; - } - - if (false === $this->propertyChanges->contains($sender)) { - throw new \InvalidArgumentException('$sender is not being tracked by this provider.'); - } - - $propertyChanges = $this->propertyChanges->offsetGet($sender); - if (null === $ace) { - if (isset($propertyChanges[$propertyName])) { - $oldValue = $propertyChanges[$propertyName][0]; - if ($oldValue === $newValue) { - unset($propertyChanges[$propertyName]); - } else { - $propertyChanges[$propertyName] = array($oldValue, $newValue); - } - } else { - $propertyChanges[$propertyName] = array($oldValue, $newValue); - } - } else { - if (!isset($propertyChanges['aces'])) { - $propertyChanges['aces'] = new \SplObjectStorage(); - } - - $acePropertyChanges = $propertyChanges['aces']->contains($ace) ? $propertyChanges['aces']->offsetGet($ace) : array(); - - if (isset($acePropertyChanges[$propertyName])) { - $oldValue = $acePropertyChanges[$propertyName][0]; - if ($oldValue === $newValue) { - unset($acePropertyChanges[$propertyName]); - } else { - $acePropertyChanges[$propertyName] = array($oldValue, $newValue); - } - } else { - $acePropertyChanges[$propertyName] = array($oldValue, $newValue); - } - - if (count($acePropertyChanges) > 0) { - $propertyChanges['aces']->offsetSet($ace, $acePropertyChanges); - } else { - $propertyChanges['aces']->offsetUnset($ace); - - if (0 === count($propertyChanges['aces'])) { - unset($propertyChanges['aces']); - } - } - } - - $this->propertyChanges->offsetSet($sender, $propertyChanges); - } - - /** - * {@inheritdoc} - */ - public function updateAcl(MutableAclInterface $acl) - { - if (!$this->propertyChanges->contains($acl)) { - throw new \InvalidArgumentException('$acl is not tracked by this provider.'); - } - - $propertyChanges = $this->propertyChanges->offsetGet($acl); - // check if any changes were made to this ACL - if (0 === count($propertyChanges)) { - return; - } - - $sets = $sharedPropertyChanges = array(); - - $this->connection->beginTransaction(); - try { - if (isset($propertyChanges['entriesInheriting'])) { - $sets[] = 'entries_inheriting = '.$this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['entriesInheriting'][1]); - } - - if (isset($propertyChanges['parentAcl'])) { - if (null === $propertyChanges['parentAcl'][1]) { - $sets[] = 'parent_object_identity_id = NULL'; - } else { - $sets[] = 'parent_object_identity_id = '.(int) $propertyChanges['parentAcl'][1]->getId(); - } - - $this->regenerateAncestorRelations($acl); - $childAcls = $this->findAcls($this->findChildren($acl->getObjectIdentity(), false)); - foreach ($childAcls as $childOid) { - $this->regenerateAncestorRelations($childAcls[$childOid]); - } - } - - // check properties for deleted, and created ACEs, and perform deletions - // we need to perform deletions before updating existing ACEs, in order to - // preserve uniqueness of the order field - if (isset($propertyChanges['classAces'])) { - $this->updateOldAceProperty('classAces', $propertyChanges['classAces']); - } - if (isset($propertyChanges['classFieldAces'])) { - $this->updateOldFieldAceProperty('classFieldAces', $propertyChanges['classFieldAces']); - } - if (isset($propertyChanges['objectAces'])) { - $this->updateOldAceProperty('objectAces', $propertyChanges['objectAces']); - } - if (isset($propertyChanges['objectFieldAces'])) { - $this->updateOldFieldAceProperty('objectFieldAces', $propertyChanges['objectFieldAces']); - } - - // this includes only updates of existing ACEs, but neither the creation, nor - // the deletion of ACEs; these are tracked by changes to the ACL's respective - // properties (classAces, classFieldAces, objectAces, objectFieldAces) - if (isset($propertyChanges['aces'])) { - $this->updateAces($propertyChanges['aces']); - } - - // check properties for deleted, and created ACEs, and perform creations - if (isset($propertyChanges['classAces'])) { - $this->updateNewAceProperty('classAces', $propertyChanges['classAces']); - $sharedPropertyChanges['classAces'] = $propertyChanges['classAces']; - } - if (isset($propertyChanges['classFieldAces'])) { - $this->updateNewFieldAceProperty('classFieldAces', $propertyChanges['classFieldAces']); - $sharedPropertyChanges['classFieldAces'] = $propertyChanges['classFieldAces']; - } - if (isset($propertyChanges['objectAces'])) { - $this->updateNewAceProperty('objectAces', $propertyChanges['objectAces']); - } - if (isset($propertyChanges['objectFieldAces'])) { - $this->updateNewFieldAceProperty('objectFieldAces', $propertyChanges['objectFieldAces']); - } - - // if there have been changes to shared properties, we need to synchronize other - // ACL instances for object identities of the same type that are already in-memory - if (count($sharedPropertyChanges) > 0) { - $classAcesProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Acl', 'classAces'); - $classAcesProperty->setAccessible(true); - $classFieldAcesProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Acl', 'classFieldAces'); - $classFieldAcesProperty->setAccessible(true); - - foreach ($this->loadedAcls[$acl->getObjectIdentity()->getType()] as $sameTypeAcl) { - if (isset($sharedPropertyChanges['classAces'])) { - if ($acl !== $sameTypeAcl && $classAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classAces'][0]) { - throw new ConcurrentModificationException('The "classAces" property has been modified concurrently.'); - } - - $classAcesProperty->setValue($sameTypeAcl, $sharedPropertyChanges['classAces'][1]); - } - - if (isset($sharedPropertyChanges['classFieldAces'])) { - if ($acl !== $sameTypeAcl && $classFieldAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classFieldAces'][0]) { - throw new ConcurrentModificationException('The "classFieldAces" property has been modified concurrently.'); - } - - $classFieldAcesProperty->setValue($sameTypeAcl, $sharedPropertyChanges['classFieldAces'][1]); - } - } - } - - // persist any changes to the acl_object_identities table - if (count($sets) > 0) { - $this->connection->executeQuery($this->getUpdateObjectIdentitySql($acl->getId(), $sets)); - } - - $this->connection->commit(); - } catch (\Exception $e) { - $this->connection->rollBack(); - - throw $e; - } - - $this->propertyChanges->offsetSet($acl, array()); - - if (null !== $this->cache) { - if (count($sharedPropertyChanges) > 0) { - // FIXME: Currently, there is no easy way to clear the cache for ACLs - // of a certain type. The problem here is that we need to make - // sure to clear the cache of all child ACLs as well, and these - // child ACLs might be of a different class type. - $this->cache->clearCache(); - } else { - // if there are no shared property changes, it's sufficient to just delete - // the cache for this ACL - $this->cache->evictFromCacheByIdentity($acl->getObjectIdentity()); - - foreach ($this->findChildren($acl->getObjectIdentity()) as $childOid) { - $this->cache->evictFromCacheByIdentity($childOid); - } - } - } - } - - /** - * Updates a user security identity when the user's username changes - * - * @param UserSecurityIdentity $usid - * @param string $oldUsername - */ - public function updateUserSecurityIdentity(UserSecurityIdentity $usid, $oldUsername) - { - $this->connection->executeQuery($this->getUpdateUserSecurityIdentitySql($usid, $oldUsername)); - } - - /** - * Constructs the SQL for deleting access control entries. - * - * @param int $oidPK - * - * @return string - */ - protected function getDeleteAccessControlEntriesSql($oidPK) - { - return sprintf( - 'DELETE FROM %s WHERE object_identity_id = %d', - $this->options['entry_table_name'], - $oidPK - ); - } - - /** - * Constructs the SQL for deleting a specific ACE. - * - * @param int $acePK - * - * @return string - */ - protected function getDeleteAccessControlEntrySql($acePK) - { - return sprintf( - 'DELETE FROM %s WHERE id = %d', - $this->options['entry_table_name'], - $acePK - ); - } - - /** - * Constructs the SQL for deleting an object identity. - * - * @param int $pk - * - * @return string - */ - protected function getDeleteObjectIdentitySql($pk) - { - return sprintf( - 'DELETE FROM %s WHERE id = %d', - $this->options['oid_table_name'], - $pk - ); - } - - /** - * Constructs the SQL for deleting relation entries. - * - * @param int $pk - * - * @return string - */ - protected function getDeleteObjectIdentityRelationsSql($pk) - { - return sprintf( - 'DELETE FROM %s WHERE object_identity_id = %d', - $this->options['oid_ancestors_table_name'], - $pk - ); - } - - /** - * Constructs the SQL for inserting an ACE. - * - * @param int $classId - * @param int|null $objectIdentityId - * @param string|null $field - * @param int $aceOrder - * @param int $securityIdentityId - * @param string $strategy - * @param int $mask - * @param bool $granting - * @param bool $auditSuccess - * @param bool $auditFailure - * - * @return string - */ - protected function getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $aceOrder, $securityIdentityId, $strategy, $mask, $granting, $auditSuccess, $auditFailure) - { - $query = <<options['entry_table_name'], - $classId, - null === $objectIdentityId ? 'NULL' : (int) $objectIdentityId, - null === $field ? 'NULL' : $this->connection->quote($field), - $aceOrder, - $securityIdentityId, - $mask, - $this->connection->getDatabasePlatform()->convertBooleans($granting), - $this->connection->quote($strategy), - $this->connection->getDatabasePlatform()->convertBooleans($auditSuccess), - $this->connection->getDatabasePlatform()->convertBooleans($auditFailure) - ); - } - - /** - * Constructs the SQL for inserting a new class type. - * - * @param string $classType - * - * @return string - */ - protected function getInsertClassSql($classType) - { - return sprintf( - 'INSERT INTO %s (class_type) VALUES (%s)', - $this->options['class_table_name'], - $this->connection->quote($classType) - ); - } - - /** - * Constructs the SQL for inserting a relation entry. - * - * @param int $objectIdentityId - * @param int $ancestorId - * - * @return string - */ - protected function getInsertObjectIdentityRelationSql($objectIdentityId, $ancestorId) - { - return sprintf( - 'INSERT INTO %s (object_identity_id, ancestor_id) VALUES (%d, %d)', - $this->options['oid_ancestors_table_name'], - $objectIdentityId, - $ancestorId - ); - } - - /** - * Constructs the SQL for inserting an object identity. - * - * @param string $identifier - * @param int $classId - * @param bool $entriesInheriting - * - * @return string - */ - protected function getInsertObjectIdentitySql($identifier, $classId, $entriesInheriting) - { - $query = <<options['oid_table_name'], - $classId, - $this->connection->quote($identifier), - $this->connection->getDatabasePlatform()->convertBooleans($entriesInheriting) - ); - } - - /** - * Constructs the SQL for inserting a security identity. - * - * @param SecurityIdentityInterface $sid - * - * @throws \InvalidArgumentException - * - * @return string - */ - protected function getInsertSecurityIdentitySql(SecurityIdentityInterface $sid) - { - if ($sid instanceof UserSecurityIdentity) { - $identifier = $sid->getClass().'-'.$sid->getUsername(); - $username = true; - } elseif ($sid instanceof RoleSecurityIdentity) { - $identifier = $sid->getRole(); - $username = false; - } else { - throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.'); - } - - return sprintf( - 'INSERT INTO %s (identifier, username) VALUES (%s, %s)', - $this->options['sid_table_name'], - $this->connection->quote($identifier), - $this->connection->getDatabasePlatform()->convertBooleans($username) - ); - } - - /** - * Constructs the SQL for selecting an ACE. - * - * @param int $classId - * @param int $oid - * @param string $field - * @param int $order - * - * @return string - */ - protected function getSelectAccessControlEntryIdSql($classId, $oid, $field, $order) - { - return sprintf( - 'SELECT id FROM %s WHERE class_id = %d AND %s AND %s AND ace_order = %d', - $this->options['entry_table_name'], - $classId, - null === $oid ? - $this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id') - : 'object_identity_id = '.(int) $oid, - null === $field ? - $this->connection->getDatabasePlatform()->getIsNullExpression('field_name') - : 'field_name = '.$this->connection->quote($field), - $order - ); - } - - /** - * Constructs the SQL for selecting the primary key associated with - * the passed class type. - * - * @param string $classType - * - * @return string - */ - protected function getSelectClassIdSql($classType) - { - return sprintf( - 'SELECT id FROM %s WHERE class_type = %s', - $this->options['class_table_name'], - $this->connection->quote($classType) - ); - } - - /** - * Constructs the SQL for selecting the primary key of a security identity. - * - * @param SecurityIdentityInterface $sid - * - * @throws \InvalidArgumentException - * - * @return string - */ - protected function getSelectSecurityIdentityIdSql(SecurityIdentityInterface $sid) - { - if ($sid instanceof UserSecurityIdentity) { - $identifier = $sid->getClass().'-'.$sid->getUsername(); - $username = true; - } elseif ($sid instanceof RoleSecurityIdentity) { - $identifier = $sid->getRole(); - $username = false; - } else { - throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.'); - } - - return sprintf( - 'SELECT id FROM %s WHERE identifier = %s AND username = %s', - $this->options['sid_table_name'], - $this->connection->quote($identifier), - $this->connection->getDatabasePlatform()->convertBooleans($username) - ); - } - - /** - * Constructs the SQL to delete a security identity. - * - * @param SecurityIdentityInterface $sid - * - * @throws \InvalidArgumentException - * - * @return string - */ - protected function getDeleteSecurityIdentityIdSql(SecurityIdentityInterface $sid) - { - $select = $this->getSelectSecurityIdentityIdSql($sid); - $delete = preg_replace('/^SELECT id FROM/', 'DELETE FROM', $select); - - return $delete; - } - - /** - * Constructs the SQL for updating an object identity. - * - * @param int $pk - * @param array $changes - * - * @throws \InvalidArgumentException - * - * @return string - */ - protected function getUpdateObjectIdentitySql($pk, array $changes) - { - if (0 === count($changes)) { - throw new \InvalidArgumentException('There are no changes.'); - } - - return sprintf( - 'UPDATE %s SET %s WHERE id = %d', - $this->options['oid_table_name'], - implode(', ', $changes), - $pk - ); - } - - /** - * Constructs the SQL for updating a user security identity. - * - * @param UserSecurityIdentity $usid - * @param string $oldUsername - * - * @return string - */ - protected function getUpdateUserSecurityIdentitySql(UserSecurityIdentity $usid, $oldUsername) - { - if ($usid->getUsername() == $oldUsername) { - throw new \InvalidArgumentException('There are no changes.'); - } - - $oldIdentifier = $usid->getClass().'-'.$oldUsername; - $newIdentifier = $usid->getClass().'-'.$usid->getUsername(); - - return sprintf( - 'UPDATE %s SET identifier = %s WHERE identifier = %s AND username = %s', - $this->options['sid_table_name'], - $this->connection->quote($newIdentifier), - $this->connection->quote($oldIdentifier), - $this->connection->getDatabasePlatform()->convertBooleans(true) - ); - } - - /** - * Constructs the SQL for updating an ACE. - * - * @param int $pk - * @param array $sets - * - * @throws \InvalidArgumentException - * - * @return string - */ - protected function getUpdateAccessControlEntrySql($pk, array $sets) - { - if (0 === count($sets)) { - throw new \InvalidArgumentException('There are no changes.'); - } - - return sprintf( - 'UPDATE %s SET %s WHERE id = %d', - $this->options['entry_table_name'], - implode(', ', $sets), - $pk - ); - } - - /** - * Creates the ACL for the passed object identity. - * - * @param ObjectIdentityInterface $oid - */ - private function createObjectIdentity(ObjectIdentityInterface $oid) - { - $classId = $this->createOrRetrieveClassId($oid->getType()); - - $this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true)); - } - - /** - * Returns the primary key for the passed class type. - * - * If the type does not yet exist in the database, it will be created. - * - * @param string $classType - * - * @return int - */ - private function createOrRetrieveClassId($classType) - { - if (false !== $id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn()) { - return $id; - } - - $this->connection->executeQuery($this->getInsertClassSql($classType)); - - return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn(); - } - - /** - * Returns the primary key for the passed security identity. - * - * If the security identity does not yet exist in the database, it will be - * created. - * - * @param SecurityIdentityInterface $sid - * - * @return int - */ - private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid) - { - if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) { - return $id; - } - - $this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid)); - - return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn(); - } - - /** - * Deletes all ACEs for the given object identity primary key. - * - * @param int $oidPK - */ - private function deleteAccessControlEntries($oidPK) - { - $this->connection->executeQuery($this->getDeleteAccessControlEntriesSql($oidPK)); - } - - /** - * Deletes the object identity from the database. - * - * @param int $pk - */ - private function deleteObjectIdentity($pk) - { - $this->connection->executeQuery($this->getDeleteObjectIdentitySql($pk)); - } - - /** - * Deletes all entries from the relations table from the database. - * - * @param int $pk - */ - private function deleteObjectIdentityRelations($pk) - { - $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk)); - } - - /** - * This regenerates the ancestor table which is used for fast read access. - * - * @param AclInterface $acl - */ - private function regenerateAncestorRelations(AclInterface $acl) - { - $pk = $acl->getId(); - $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk)); - $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk)); - - $parentAcl = $acl->getParentAcl(); - while (null !== $parentAcl) { - $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId())); - - $parentAcl = $parentAcl->getParentAcl(); - } - } - - /** - * This processes new entries changes on an ACE related property (classFieldAces, or objectFieldAces). - * - * @param string $name - * @param array $changes - */ - private function updateNewFieldAceProperty($name, array $changes) - { - $sids = new \SplObjectStorage(); - $classIds = new \SplObjectStorage(); - foreach ($changes[1] as $field => $new) { - for ($i = 0, $c = count($new); $i < $c; ++$i) { - $ace = $new[$i]; - - if (null === $ace->getId()) { - if ($sids->contains($ace->getSecurityIdentity())) { - $sid = $sids->offsetGet($ace->getSecurityIdentity()); - } else { - $sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity()); - } - - $oid = $ace->getAcl()->getObjectIdentity(); - if ($classIds->contains($oid)) { - $classId = $classIds->offsetGet($oid); - } else { - $classId = $this->createOrRetrieveClassId($oid->getType()); - } - - $objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId(); - - $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure())); - $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn(); - $this->loadedAces[$aceId] = $ace; - - $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id'); - $aceIdProperty->setAccessible(true); - $aceIdProperty->setValue($ace, (int) $aceId); - } - } - } - } - - /** - * This processes old entries changes on an ACE related property (classFieldAces, or objectFieldAces). - * - * @param string $name - * @param array $changes - */ - private function updateOldFieldAceProperty($name, array $changes) - { - $currentIds = array(); - foreach ($changes[1] as $field => $new) { - for ($i = 0, $c = count($new); $i < $c; ++$i) { - $ace = $new[$i]; - - if (null !== $ace->getId()) { - $currentIds[$ace->getId()] = true; - } - } - } - - foreach ($changes[0] as $old) { - for ($i = 0, $c = count($old); $i < $c; ++$i) { - $ace = $old[$i]; - - if (!isset($currentIds[$ace->getId()])) { - $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId())); - unset($this->loadedAces[$ace->getId()]); - } - } - } - } - - /** - * This processes new entries changes on an ACE related property (classAces, or objectAces). - * - * @param string $name - * @param array $changes - */ - private function updateNewAceProperty($name, array $changes) - { - list($old, $new) = $changes; - - $sids = new \SplObjectStorage(); - $classIds = new \SplObjectStorage(); - for ($i = 0, $c = count($new); $i < $c; ++$i) { - $ace = $new[$i]; - - if (null === $ace->getId()) { - if ($sids->contains($ace->getSecurityIdentity())) { - $sid = $sids->offsetGet($ace->getSecurityIdentity()); - } else { - $sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity()); - } - - $oid = $ace->getAcl()->getObjectIdentity(); - if ($classIds->contains($oid)) { - $classId = $classIds->offsetGet($oid); - } else { - $classId = $this->createOrRetrieveClassId($oid->getType()); - } - - $objectIdentityId = $name === 'classAces' ? null : $ace->getAcl()->getId(); - - $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, null, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure())); - $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i))->fetchColumn(); - $this->loadedAces[$aceId] = $ace; - - $aceIdProperty = new \ReflectionProperty($ace, 'id'); - $aceIdProperty->setAccessible(true); - $aceIdProperty->setValue($ace, (int) $aceId); - } - } - } - - /** - * This processes old entries changes on an ACE related property (classAces, or objectAces). - * - * @param string $name - * @param array $changes - */ - private function updateOldAceProperty($name, array $changes) - { - list($old, $new) = $changes; - $currentIds = array(); - - for ($i = 0, $c = count($new); $i < $c; ++$i) { - $ace = $new[$i]; - - if (null !== $ace->getId()) { - $currentIds[$ace->getId()] = true; - } - } - - for ($i = 0, $c = count($old); $i < $c; ++$i) { - $ace = $old[$i]; - - if (!isset($currentIds[$ace->getId()])) { - $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId())); - unset($this->loadedAces[$ace->getId()]); - } - } - } - - /** - * Persists the changes which were made to ACEs to the database. - * - * @param \SplObjectStorage $aces - */ - private function updateAces(\SplObjectStorage $aces) - { - foreach ($aces as $ace) { - $this->updateAce($aces, $ace); - } - } - - private function updateAce(\SplObjectStorage $aces, $ace) - { - $propertyChanges = $aces->offsetGet($ace); - $sets = array(); - - if (isset($propertyChanges['aceOrder']) - && $propertyChanges['aceOrder'][1] > $propertyChanges['aceOrder'][0] - && $propertyChanges == $aces->offsetGet($ace)) { - $aces->next(); - if ($aces->valid()) { - $this->updateAce($aces, $aces->current()); - } - } - - if (isset($propertyChanges['mask'])) { - $sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]); - } - if (isset($propertyChanges['strategy'])) { - $sets[] = sprintf('granting_strategy = %s', $this->connection->quote($propertyChanges['strategy'])); - } - if (isset($propertyChanges['aceOrder'])) { - $sets[] = sprintf('ace_order = %d', $propertyChanges['aceOrder'][1]); - } - if (isset($propertyChanges['auditSuccess'])) { - $sets[] = sprintf('audit_success = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditSuccess'][1])); - } - if (isset($propertyChanges['auditFailure'])) { - $sets[] = sprintf('audit_failure = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditFailure'][1])); - } - - $this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets)); - } -} diff --git a/src/Symfony/Component/Security/Acl/Dbal/Schema.php b/src/Symfony/Component/Security/Acl/Dbal/Schema.php deleted file mode 100644 index ed9327ce7b139..0000000000000 --- a/src/Symfony/Component/Security/Acl/Dbal/Schema.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Dbal; - -use Doctrine\DBAL\Schema\Schema as BaseSchema; -use Doctrine\DBAL\Connection; - -/** - * The schema used for the ACL system. - * - * @author Johannes M. Schmitt - */ -final class Schema extends BaseSchema -{ - protected $options; - - /** - * Constructor. - * - * @param array $options the names for tables - * @param Connection $connection - */ - public function __construct(array $options, Connection $connection = null) - { - $schemaConfig = null === $connection ? null : $connection->getSchemaManager()->createSchemaConfig(); - - parent::__construct(array(), array(), $schemaConfig); - - $this->options = $options; - - $this->addClassTable(); - $this->addSecurityIdentitiesTable(); - $this->addObjectIdentitiesTable(); - $this->addObjectIdentityAncestorsTable(); - $this->addEntryTable(); - } - - /** - * Merges ACL schema with the given schema. - * - * @param BaseSchema $schema - */ - public function addToSchema(BaseSchema $schema) - { - foreach ($this->getTables() as $table) { - $schema->_addTable($table); - } - - foreach ($this->getSequences() as $sequence) { - $schema->_addSequence($sequence); - } - } - - /** - * Adds the class table to the schema. - */ - protected function addClassTable() - { - $table = $this->createTable($this->options['class_table_name']); - $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => 'auto')); - $table->addColumn('class_type', 'string', array('length' => 200)); - $table->setPrimaryKey(array('id')); - $table->addUniqueIndex(array('class_type')); - } - - /** - * Adds the entry table to the schema. - */ - protected function addEntryTable() - { - $table = $this->createTable($this->options['entry_table_name']); - - $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => 'auto')); - $table->addColumn('class_id', 'integer', array('unsigned' => true)); - $table->addColumn('object_identity_id', 'integer', array('unsigned' => true, 'notnull' => false)); - $table->addColumn('field_name', 'string', array('length' => 50, 'notnull' => false)); - $table->addColumn('ace_order', 'smallint', array('unsigned' => true)); - $table->addColumn('security_identity_id', 'integer', array('unsigned' => true)); - $table->addColumn('mask', 'integer'); - $table->addColumn('granting', 'boolean'); - $table->addColumn('granting_strategy', 'string', array('length' => 30)); - $table->addColumn('audit_success', 'boolean'); - $table->addColumn('audit_failure', 'boolean'); - - $table->setPrimaryKey(array('id')); - $table->addUniqueIndex(array('class_id', 'object_identity_id', 'field_name', 'ace_order')); - $table->addIndex(array('class_id', 'object_identity_id', 'security_identity_id')); - - $table->addForeignKeyConstraint($this->getTable($this->options['class_table_name']), array('class_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); - $table->addForeignKeyConstraint($this->getTable($this->options['oid_table_name']), array('object_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); - $table->addForeignKeyConstraint($this->getTable($this->options['sid_table_name']), array('security_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); - } - - /** - * Adds the object identity table to the schema. - */ - protected function addObjectIdentitiesTable() - { - $table = $this->createTable($this->options['oid_table_name']); - - $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => 'auto')); - $table->addColumn('class_id', 'integer', array('unsigned' => true)); - $table->addColumn('object_identifier', 'string', array('length' => 100)); - $table->addColumn('parent_object_identity_id', 'integer', array('unsigned' => true, 'notnull' => false)); - $table->addColumn('entries_inheriting', 'boolean'); - - $table->setPrimaryKey(array('id')); - $table->addUniqueIndex(array('object_identifier', 'class_id')); - $table->addIndex(array('parent_object_identity_id')); - - $table->addForeignKeyConstraint($table, array('parent_object_identity_id'), array('id')); - } - - /** - * Adds the object identity relation table to the schema. - */ - protected function addObjectIdentityAncestorsTable() - { - $table = $this->createTable($this->options['oid_ancestors_table_name']); - - $table->addColumn('object_identity_id', 'integer', array('unsigned' => true)); - $table->addColumn('ancestor_id', 'integer', array('unsigned' => true)); - - $table->setPrimaryKey(array('object_identity_id', 'ancestor_id')); - - $oidTable = $this->getTable($this->options['oid_table_name']); - $table->addForeignKeyConstraint($oidTable, array('object_identity_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); - $table->addForeignKeyConstraint($oidTable, array('ancestor_id'), array('id'), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')); - } - - /** - * Adds the security identity table to the schema. - */ - protected function addSecurityIdentitiesTable() - { - $table = $this->createTable($this->options['sid_table_name']); - - $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => 'auto')); - $table->addColumn('identifier', 'string', array('length' => 200)); - $table->addColumn('username', 'boolean'); - - $table->setPrimaryKey(array('id')); - $table->addUniqueIndex(array('identifier', 'username')); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/Acl.php b/src/Symfony/Component/Security/Acl/Domain/Acl.php deleted file mode 100644 index f417c8fda0475..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/Acl.php +++ /dev/null @@ -1,667 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Doctrine\Common\NotifyPropertyChanged; -use Doctrine\Common\PropertyChangedListener; -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Model\AuditableAclInterface; -use Symfony\Component\Security\Acl\Model\EntryInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; -use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; - -/** - * An ACL implementation. - * - * Each object identity has exactly one associated ACL. Each ACL can have four - * different types of ACEs (class ACEs, object ACEs, class field ACEs, object field - * ACEs). - * - * You should not iterate over the ACEs yourself, but instead use isGranted(), - * or isFieldGranted(). These will utilize an implementation of PermissionGrantingStrategy - * internally. - * - * @author Johannes M. Schmitt - */ -class Acl implements AuditableAclInterface, NotifyPropertyChanged -{ - private $parentAcl; - private $permissionGrantingStrategy; - private $objectIdentity; - private $classAces = array(); - private $classFieldAces = array(); - private $objectAces = array(); - private $objectFieldAces = array(); - private $id; - private $loadedSids; - private $entriesInheriting; - private $listeners = array(); - - /** - * Constructor. - * - * @param int $id - * @param ObjectIdentityInterface $objectIdentity - * @param PermissionGrantingStrategyInterface $permissionGrantingStrategy - * @param array $loadedSids - * @param bool $entriesInheriting - */ - public function __construct($id, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSids = array(), $entriesInheriting) - { - $this->id = $id; - $this->objectIdentity = $objectIdentity; - $this->permissionGrantingStrategy = $permissionGrantingStrategy; - $this->loadedSids = $loadedSids; - $this->entriesInheriting = $entriesInheriting; - } - - /** - * Adds a property changed listener. - * - * @param PropertyChangedListener $listener - */ - public function addPropertyChangedListener(PropertyChangedListener $listener) - { - $this->listeners[] = $listener; - } - - /** - * {@inheritdoc} - */ - public function deleteClassAce($index) - { - $this->deleteAce('classAces', $index); - } - - /** - * {@inheritdoc} - */ - public function deleteClassFieldAce($index, $field) - { - $this->deleteFieldAce('classFieldAces', $index, $field); - } - - /** - * {@inheritdoc} - */ - public function deleteObjectAce($index) - { - $this->deleteAce('objectAces', $index); - } - - /** - * {@inheritdoc} - */ - public function deleteObjectFieldAce($index, $field) - { - $this->deleteFieldAce('objectFieldAces', $index, $field); - } - - /** - * {@inheritdoc} - */ - public function getClassAces() - { - return $this->classAces; - } - - /** - * {@inheritdoc} - */ - public function getClassFieldAces($field) - { - return isset($this->classFieldAces[$field]) ? $this->classFieldAces[$field] : array(); - } - - /** - * {@inheritdoc} - */ - public function getObjectAces() - { - return $this->objectAces; - } - - /** - * {@inheritdoc} - */ - public function getObjectFieldAces($field) - { - return isset($this->objectFieldAces[$field]) ? $this->objectFieldAces[$field] : array(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getObjectIdentity() - { - return $this->objectIdentity; - } - - /** - * {@inheritdoc} - */ - public function getParentAcl() - { - return $this->parentAcl; - } - - /** - * {@inheritdoc} - */ - public function insertClassAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null) - { - $this->insertAce('classAces', $index, $mask, $sid, $granting, $strategy); - } - - /** - * {@inheritdoc} - */ - public function insertClassFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null) - { - $this->insertFieldAce('classFieldAces', $index, $field, $mask, $sid, $granting, $strategy); - } - - /** - * {@inheritdoc} - */ - public function insertObjectAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null) - { - $this->insertAce('objectAces', $index, $mask, $sid, $granting, $strategy); - } - - /** - * {@inheritdoc} - */ - public function insertObjectFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null) - { - $this->insertFieldAce('objectFieldAces', $index, $field, $mask, $sid, $granting, $strategy); - } - - /** - * {@inheritdoc} - */ - public function isEntriesInheriting() - { - return $this->entriesInheriting; - } - - /** - * {@inheritdoc} - */ - public function isFieldGranted($field, array $masks, array $securityIdentities, $administrativeMode = false) - { - return $this->permissionGrantingStrategy->isFieldGranted($this, $field, $masks, $securityIdentities, $administrativeMode); - } - - /** - * {@inheritdoc} - */ - public function isGranted(array $masks, array $securityIdentities, $administrativeMode = false) - { - return $this->permissionGrantingStrategy->isGranted($this, $masks, $securityIdentities, $administrativeMode); - } - - /** - * {@inheritdoc} - */ - public function isSidLoaded($sids) - { - if (!$this->loadedSids) { - return true; - } - - if (!is_array($sids)) { - $sids = array($sids); - } - - foreach ($sids as $sid) { - if (!$sid instanceof SecurityIdentityInterface) { - throw new \InvalidArgumentException( - '$sid must be an instance of SecurityIdentityInterface.'); - } - - foreach ($this->loadedSids as $loadedSid) { - if ($loadedSid->equals($sid)) { - continue 2; - } - } - - return false; - } - - return true; - } - - /** - * Implementation for the \Serializable interface. - * - * @return string - */ - public function serialize() - { - return serialize(array( - null === $this->parentAcl ? null : $this->parentAcl->getId(), - $this->objectIdentity, - $this->classAces, - $this->classFieldAces, - $this->objectAces, - $this->objectFieldAces, - $this->id, - $this->loadedSids, - $this->entriesInheriting, - )); - } - - /** - * Implementation for the \Serializable interface. - * - * @param string $serialized - */ - public function unserialize($serialized) - { - list($this->parentAcl, - $this->objectIdentity, - $this->classAces, - $this->classFieldAces, - $this->objectAces, - $this->objectFieldAces, - $this->id, - $this->loadedSids, - $this->entriesInheriting - ) = unserialize($serialized); - - $this->listeners = array(); - } - - /** - * {@inheritdoc} - */ - public function setEntriesInheriting($boolean) - { - if ($this->entriesInheriting !== $boolean) { - $this->onPropertyChanged('entriesInheriting', $this->entriesInheriting, $boolean); - $this->entriesInheriting = $boolean; - } - } - - /** - * {@inheritdoc} - */ - public function setParentAcl(AclInterface $acl = null) - { - if (null !== $acl && null === $acl->getId()) { - throw new \InvalidArgumentException('$acl must have an ID.'); - } - - if ($this->parentAcl !== $acl) { - $this->onPropertyChanged('parentAcl', $this->parentAcl, $acl); - $this->parentAcl = $acl; - } - } - - /** - * {@inheritdoc} - */ - public function updateClassAce($index, $mask, $strategy = null) - { - $this->updateAce('classAces', $index, $mask, $strategy); - } - - /** - * {@inheritdoc} - */ - public function updateClassFieldAce($index, $field, $mask, $strategy = null) - { - $this->updateFieldAce('classFieldAces', $index, $field, $mask, $strategy); - } - - /** - * {@inheritdoc} - */ - public function updateObjectAce($index, $mask, $strategy = null) - { - $this->updateAce('objectAces', $index, $mask, $strategy); - } - - /** - * {@inheritdoc} - */ - public function updateObjectFieldAce($index, $field, $mask, $strategy = null) - { - $this->updateFieldAce('objectFieldAces', $index, $field, $mask, $strategy); - } - - /** - * {@inheritdoc} - */ - public function updateClassAuditing($index, $auditSuccess, $auditFailure) - { - $this->updateAuditing($this->classAces, $index, $auditSuccess, $auditFailure); - } - - /** - * {@inheritdoc} - */ - public function updateClassFieldAuditing($index, $field, $auditSuccess, $auditFailure) - { - if (!isset($this->classFieldAces[$field])) { - throw new \InvalidArgumentException(sprintf('There are no ACEs for field "%s".', $field)); - } - - $this->updateAuditing($this->classFieldAces[$field], $index, $auditSuccess, $auditFailure); - } - - /** - * {@inheritdoc} - */ - public function updateObjectAuditing($index, $auditSuccess, $auditFailure) - { - $this->updateAuditing($this->objectAces, $index, $auditSuccess, $auditFailure); - } - - /** - * {@inheritdoc} - */ - public function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditFailure) - { - if (!isset($this->objectFieldAces[$field])) { - throw new \InvalidArgumentException(sprintf('There are no ACEs for field "%s".', $field)); - } - - $this->updateAuditing($this->objectFieldAces[$field], $index, $auditSuccess, $auditFailure); - } - - /** - * Deletes an ACE. - * - * @param string $property - * @param int $index - * - * @throws \OutOfBoundsException - */ - private function deleteAce($property, $index) - { - $aces = &$this->$property; - if (!isset($aces[$index])) { - throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); - } - - $oldValue = $this->$property; - unset($aces[$index]); - $this->$property = array_values($this->$property); - $this->onPropertyChanged($property, $oldValue, $this->$property); - - for ($i = $index, $c = count($this->$property); $i < $c; ++$i) { - $this->onEntryPropertyChanged($aces[$i], 'aceOrder', $i + 1, $i); - } - } - - /** - * Deletes a field-based ACE. - * - * @param string $property - * @param int $index - * @param string $field - * - * @throws \OutOfBoundsException - */ - private function deleteFieldAce($property, $index, $field) - { - $aces = &$this->$property; - if (!isset($aces[$field][$index])) { - throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); - } - - $oldValue = $this->$property; - unset($aces[$field][$index]); - $aces[$field] = array_values($aces[$field]); - $this->onPropertyChanged($property, $oldValue, $this->$property); - - for ($i = $index, $c = count($aces[$field]); $i < $c; ++$i) { - $this->onEntryPropertyChanged($aces[$field][$i], 'aceOrder', $i + 1, $i); - } - } - - /** - * Inserts an ACE. - * - * @param string $property - * @param int $index - * @param int $mask - * @param SecurityIdentityInterface $sid - * @param bool $granting - * @param string $strategy - * - * @throws \OutOfBoundsException - * @throws \InvalidArgumentException - */ - private function insertAce($property, $index, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null) - { - if ($index < 0 || $index > count($this->$property)) { - throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property))); - } - - if (!is_int($mask)) { - throw new \InvalidArgumentException('$mask must be an integer.'); - } - - if (null === $strategy) { - if (true === $granting) { - $strategy = PermissionGrantingStrategy::ALL; - } else { - $strategy = PermissionGrantingStrategy::ANY; - } - } - - $aces = &$this->$property; - $oldValue = $this->$property; - if (isset($aces[$index])) { - $this->$property = array_merge( - array_slice($this->$property, 0, $index), - array(true), - array_slice($this->$property, $index) - ); - - for ($i = $index, $c = count($this->$property) - 1; $i < $c; ++$i) { - $this->onEntryPropertyChanged($aces[$i + 1], 'aceOrder', $i, $i + 1); - } - } - - $aces[$index] = new Entry(null, $this, $sid, $strategy, $mask, $granting, false, false); - $this->onPropertyChanged($property, $oldValue, $this->$property); - } - - /** - * Inserts a field-based ACE. - * - * @param string $property - * @param int $index - * @param string $field - * @param int $mask - * @param SecurityIdentityInterface $sid - * @param bool $granting - * @param string $strategy - * - * @throws \InvalidArgumentException - * @throws \OutOfBoundsException - */ - private function insertFieldAce($property, $index, $field, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null) - { - if (0 === strlen($field)) { - throw new \InvalidArgumentException('$field cannot be empty.'); - } - - if (!is_int($mask)) { - throw new \InvalidArgumentException('$mask must be an integer.'); - } - - if (null === $strategy) { - if (true === $granting) { - $strategy = PermissionGrantingStrategy::ALL; - } else { - $strategy = PermissionGrantingStrategy::ANY; - } - } - - $aces = &$this->$property; - if (!isset($aces[$field])) { - $aces[$field] = array(); - } - - if ($index < 0 || $index > count($aces[$field])) { - throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property))); - } - - $oldValue = $aces; - if (isset($aces[$field][$index])) { - $aces[$field] = array_merge( - array_slice($aces[$field], 0, $index), - array(true), - array_slice($aces[$field], $index) - ); - - for ($i = $index, $c = count($aces[$field]) - 1; $i < $c; ++$i) { - $this->onEntryPropertyChanged($aces[$field][$i + 1], 'aceOrder', $i, $i + 1); - } - } - - $aces[$field][$index] = new FieldEntry(null, $this, $field, $sid, $strategy, $mask, $granting, false, false); - $this->onPropertyChanged($property, $oldValue, $this->$property); - } - - /** - * Updates an ACE. - * - * @param string $property - * @param int $index - * @param int $mask - * @param string $strategy - * - * @throws \OutOfBoundsException - */ - private function updateAce($property, $index, $mask, $strategy = null) - { - $aces = &$this->$property; - if (!isset($aces[$index])) { - throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); - } - - $ace = $aces[$index]; - if ($mask !== $oldMask = $ace->getMask()) { - $this->onEntryPropertyChanged($ace, 'mask', $oldMask, $mask); - $ace->setMask($mask); - } - if (null !== $strategy && $strategy !== $oldStrategy = $ace->getStrategy()) { - $this->onEntryPropertyChanged($ace, 'strategy', $oldStrategy, $strategy); - $ace->setStrategy($strategy); - } - } - - /** - * Updates auditing for an ACE. - * - * @param array &$aces - * @param int $index - * @param bool $auditSuccess - * @param bool $auditFailure - * - * @throws \OutOfBoundsException - */ - private function updateAuditing(array &$aces, $index, $auditSuccess, $auditFailure) - { - if (!isset($aces[$index])) { - throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); - } - - if ($auditSuccess !== $aces[$index]->isAuditSuccess()) { - $this->onEntryPropertyChanged($aces[$index], 'auditSuccess', !$auditSuccess, $auditSuccess); - $aces[$index]->setAuditSuccess($auditSuccess); - } - - if ($auditFailure !== $aces[$index]->isAuditFailure()) { - $this->onEntryPropertyChanged($aces[$index], 'auditFailure', !$auditFailure, $auditFailure); - $aces[$index]->setAuditFailure($auditFailure); - } - } - - /** - * Updates a field-based ACE. - * - * @param string $property - * @param int $index - * @param string $field - * @param int $mask - * @param string $strategy - * - * @throws \InvalidArgumentException - * @throws \OutOfBoundsException - */ - private function updateFieldAce($property, $index, $field, $mask, $strategy = null) - { - if (0 === strlen($field)) { - throw new \InvalidArgumentException('$field cannot be empty.'); - } - - $aces = &$this->$property; - if (!isset($aces[$field][$index])) { - throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); - } - - $ace = $aces[$field][$index]; - if ($mask !== $oldMask = $ace->getMask()) { - $this->onEntryPropertyChanged($ace, 'mask', $oldMask, $mask); - $ace->setMask($mask); - } - if (null !== $strategy && $strategy !== $oldStrategy = $ace->getStrategy()) { - $this->onEntryPropertyChanged($ace, 'strategy', $oldStrategy, $strategy); - $ace->setStrategy($strategy); - } - } - - /** - * Called when a property of the ACL changes. - * - * @param string $name - * @param mixed $oldValue - * @param mixed $newValue - */ - private function onPropertyChanged($name, $oldValue, $newValue) - { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($this, $name, $oldValue, $newValue); - } - } - - /** - * Called when a property of an ACE associated with this ACL changes. - * - * @param EntryInterface $entry - * @param string $name - * @param mixed $oldValue - * @param mixed $newValue - */ - private function onEntryPropertyChanged(EntryInterface $entry, $name, $oldValue, $newValue) - { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($entry, $name, $oldValue, $newValue); - } - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/AclCollectionCache.php b/src/Symfony/Component/Security/Acl/Domain/AclCollectionCache.php deleted file mode 100644 index 5dfef08839e6e..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/AclCollectionCache.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Model\AclProviderInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; - -/** - * This service caches ACLs for an entire collection of objects. - * - * @author Johannes M. Schmitt - */ -class AclCollectionCache -{ - private $aclProvider; - private $objectIdentityRetrievalStrategy; - private $securityIdentityRetrievalStrategy; - - /** - * Constructor. - * - * @param AclProviderInterface $aclProvider - * @param ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy - * @param SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy - */ - public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy) - { - $this->aclProvider = $aclProvider; - $this->objectIdentityRetrievalStrategy = $oidRetrievalStrategy; - $this->securityIdentityRetrievalStrategy = $sidRetrievalStrategy; - } - - /** - * Batch loads ACLs for an entire collection; thus, it reduces the number - * of required queries considerably. - * - * @param mixed $collection anything that can be passed to foreach() - * @param TokenInterface[] $tokens an array of TokenInterface implementations - */ - public function cache($collection, array $tokens = array()) - { - $sids = array(); - foreach ($tokens as $token) { - $sids = array_merge($sids, $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token)); - } - - $oids = array(); - foreach ($collection as $domainObject) { - $oids[] = $this->objectIdentityRetrievalStrategy->getObjectIdentity($domainObject); - } - - $this->aclProvider->findAcls($oids, $sids); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/AuditLogger.php b/src/Symfony/Component/Security/Acl/Domain/AuditLogger.php deleted file mode 100644 index e3f3bdd29568b..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/AuditLogger.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Model\AuditableEntryInterface; -use Symfony\Component\Security\Acl\Model\EntryInterface; -use Symfony\Component\Security\Acl\Model\AuditLoggerInterface; - -/** - * Base audit logger implementation. - * - * @author Johannes M. Schmitt - */ -abstract class AuditLogger implements AuditLoggerInterface -{ - /** - * Performs some checks if logging was requested. - * - * @param bool $granted - * @param EntryInterface $ace - */ - public function logIfNeeded($granted, EntryInterface $ace) - { - if (!$ace instanceof AuditableEntryInterface) { - return; - } - - if ($granted && $ace->isAuditSuccess()) { - $this->doLog($granted, $ace); - } elseif (!$granted && $ace->isAuditFailure()) { - $this->doLog($granted, $ace); - } - } - - /** - * This method is only called when logging is needed. - * - * @param bool $granted - * @param EntryInterface $ace - */ - abstract protected function doLog($granted, EntryInterface $ace); -} diff --git a/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php b/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php deleted file mode 100644 index 667a19e0a1ce2..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php +++ /dev/null @@ -1,229 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Doctrine\Common\Cache\Cache; -use Doctrine\Common\Cache\CacheProvider; -use Symfony\Component\Security\Acl\Model\AclCacheInterface; -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; -use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface; - -/** - * This class is a wrapper around the actual cache implementation. - * - * @author Johannes M. Schmitt - */ -class DoctrineAclCache implements AclCacheInterface -{ - const PREFIX = 'sf2_acl_'; - - private $cache; - private $prefix; - private $permissionGrantingStrategy; - - /** - * Constructor. - * - * @param Cache $cache - * @param PermissionGrantingStrategyInterface $permissionGrantingStrategy - * @param string $prefix - * - * @throws \InvalidArgumentException - */ - public function __construct(Cache $cache, PermissionGrantingStrategyInterface $permissionGrantingStrategy, $prefix = self::PREFIX) - { - if (0 === strlen($prefix)) { - throw new \InvalidArgumentException('$prefix cannot be empty.'); - } - - $this->cache = $cache; - $this->permissionGrantingStrategy = $permissionGrantingStrategy; - $this->prefix = $prefix; - } - - /** - * {@inheritdoc} - */ - public function clearCache() - { - if ($this->cache instanceof CacheProvider) { - $this->cache->deleteAll(); - } - } - - /** - * {@inheritdoc} - */ - public function evictFromCacheById($aclId) - { - $lookupKey = $this->getAliasKeyForIdentity($aclId); - if (!$this->cache->contains($lookupKey)) { - return; - } - - $key = $this->cache->fetch($lookupKey); - if ($this->cache->contains($key)) { - $this->cache->delete($key); - } - - $this->cache->delete($lookupKey); - } - - /** - * {@inheritdoc} - */ - public function evictFromCacheByIdentity(ObjectIdentityInterface $oid) - { - $key = $this->getDataKeyByIdentity($oid); - if (!$this->cache->contains($key)) { - return; - } - - $this->cache->delete($key); - } - - /** - * {@inheritdoc} - */ - public function getFromCacheById($aclId) - { - $lookupKey = $this->getAliasKeyForIdentity($aclId); - if (!$this->cache->contains($lookupKey)) { - return; - } - - $key = $this->cache->fetch($lookupKey); - if (!$this->cache->contains($key)) { - $this->cache->delete($lookupKey); - - return; - } - - return $this->unserializeAcl($this->cache->fetch($key)); - } - - /** - * {@inheritdoc} - */ - public function getFromCacheByIdentity(ObjectIdentityInterface $oid) - { - $key = $this->getDataKeyByIdentity($oid); - if (!$this->cache->contains($key)) { - return; - } - - return $this->unserializeAcl($this->cache->fetch($key)); - } - - /** - * {@inheritdoc} - */ - public function putInCache(AclInterface $acl) - { - if (null === $acl->getId()) { - throw new \InvalidArgumentException('Transient ACLs cannot be cached.'); - } - - if (null !== $parentAcl = $acl->getParentAcl()) { - $this->putInCache($parentAcl); - } - - $key = $this->getDataKeyByIdentity($acl->getObjectIdentity()); - $this->cache->save($key, serialize($acl)); - $this->cache->save($this->getAliasKeyForIdentity($acl->getId()), $key); - } - - /** - * Unserializes the ACL. - * - * @param string $serialized - * - * @return AclInterface - */ - private function unserializeAcl($serialized) - { - $acl = unserialize($serialized); - - if (null !== $parentId = $acl->getParentAcl()) { - $parentAcl = $this->getFromCacheById($parentId); - - if (null === $parentAcl) { - return; - } - - $acl->setParentAcl($parentAcl); - } - - $reflectionProperty = new \ReflectionProperty($acl, 'permissionGrantingStrategy'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($acl, $this->permissionGrantingStrategy); - $reflectionProperty->setAccessible(false); - - $aceAclProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'acl'); - $aceAclProperty->setAccessible(true); - - foreach ($acl->getObjectAces() as $ace) { - $aceAclProperty->setValue($ace, $acl); - } - foreach ($acl->getClassAces() as $ace) { - $aceAclProperty->setValue($ace, $acl); - } - - $aceClassFieldProperty = new \ReflectionProperty($acl, 'classFieldAces'); - $aceClassFieldProperty->setAccessible(true); - foreach ($aceClassFieldProperty->getValue($acl) as $aces) { - foreach ($aces as $ace) { - $aceAclProperty->setValue($ace, $acl); - } - } - $aceClassFieldProperty->setAccessible(false); - - $aceObjectFieldProperty = new \ReflectionProperty($acl, 'objectFieldAces'); - $aceObjectFieldProperty->setAccessible(true); - foreach ($aceObjectFieldProperty->getValue($acl) as $aces) { - foreach ($aces as $ace) { - $aceAclProperty->setValue($ace, $acl); - } - } - $aceObjectFieldProperty->setAccessible(false); - - $aceAclProperty->setAccessible(false); - - return $acl; - } - - /** - * Returns the key for the object identity. - * - * @param ObjectIdentityInterface $oid - * - * @return string - */ - private function getDataKeyByIdentity(ObjectIdentityInterface $oid) - { - return $this->prefix.md5($oid->getType()).sha1($oid->getType()) - .'_'.md5($oid->getIdentifier()).sha1($oid->getIdentifier()); - } - - /** - * Returns the alias key for the object identity key. - * - * @param string $aclId - * - * @return string - */ - private function getAliasKeyForIdentity($aclId) - { - return $this->prefix.$aclId; - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/Entry.php b/src/Symfony/Component/Security/Acl/Domain/Entry.php deleted file mode 100644 index 55c4b378a74b2..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/Entry.php +++ /dev/null @@ -1,208 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Model\AuditableEntryInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; - -/** - * Auditable ACE implementation. - * - * @author Johannes M. Schmitt - */ -class Entry implements AuditableEntryInterface -{ - private $acl; - private $mask; - private $id; - private $securityIdentity; - private $strategy; - private $auditFailure; - private $auditSuccess; - private $granting; - - /** - * Constructor. - * - * @param int $id - * @param AclInterface $acl - * @param SecurityIdentityInterface $sid - * @param string $strategy - * @param int $mask - * @param bool $granting - * @param bool $auditFailure - * @param bool $auditSuccess - */ - public function __construct($id, AclInterface $acl, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess) - { - $this->id = $id; - $this->acl = $acl; - $this->securityIdentity = $sid; - $this->strategy = $strategy; - $this->mask = $mask; - $this->granting = $granting; - $this->auditFailure = $auditFailure; - $this->auditSuccess = $auditSuccess; - } - - /** - * {@inheritdoc} - */ - public function getAcl() - { - return $this->acl; - } - - /** - * {@inheritdoc} - */ - public function getMask() - { - return $this->mask; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getSecurityIdentity() - { - return $this->securityIdentity; - } - - /** - * {@inheritdoc} - */ - public function getStrategy() - { - return $this->strategy; - } - - /** - * {@inheritdoc} - */ - public function isAuditFailure() - { - return $this->auditFailure; - } - - /** - * {@inheritdoc} - */ - public function isAuditSuccess() - { - return $this->auditSuccess; - } - - /** - * {@inheritdoc} - */ - public function isGranting() - { - return $this->granting; - } - - /** - * Turns on/off auditing on permissions denials. - * - * Do never call this method directly. Use the respective methods on the - * AclInterface instead. - * - * @param bool $boolean - */ - public function setAuditFailure($boolean) - { - $this->auditFailure = $boolean; - } - - /** - * Turns on/off auditing on permission grants. - * - * Do never call this method directly. Use the respective methods on the - * AclInterface instead. - * - * @param bool $boolean - */ - public function setAuditSuccess($boolean) - { - $this->auditSuccess = $boolean; - } - - /** - * Sets the permission mask. - * - * Do never call this method directly. Use the respective methods on the - * AclInterface instead. - * - * @param int $mask - */ - public function setMask($mask) - { - $this->mask = $mask; - } - - /** - * Sets the mask comparison strategy. - * - * Do never call this method directly. Use the respective methods on the - * AclInterface instead. - * - * @param string $strategy - */ - public function setStrategy($strategy) - { - $this->strategy = $strategy; - } - - /** - * Implementation of \Serializable. - * - * @return string - */ - public function serialize() - { - return serialize(array( - $this->mask, - $this->id, - $this->securityIdentity, - $this->strategy, - $this->auditFailure, - $this->auditSuccess, - $this->granting, - )); - } - - /** - * Implementation of \Serializable. - * - * @param string $serialized - */ - public function unserialize($serialized) - { - list($this->mask, - $this->id, - $this->securityIdentity, - $this->strategy, - $this->auditFailure, - $this->auditSuccess, - $this->granting - ) = unserialize($serialized); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/FieldEntry.php b/src/Symfony/Component/Security/Acl/Domain/FieldEntry.php deleted file mode 100644 index 86b1e5b30274b..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/FieldEntry.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Model\FieldEntryInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; - -/** - * Field-aware ACE implementation which is auditable. - * - * @author Johannes M. Schmitt - */ -class FieldEntry extends Entry implements FieldEntryInterface -{ - private $field; - - /** - * Constructor. - * - * @param int $id - * @param AclInterface $acl - * @param string $field - * @param SecurityIdentityInterface $sid - * @param string $strategy - * @param int $mask - * @param bool $granting - * @param bool $auditFailure - * @param bool $auditSuccess - */ - public function __construct($id, AclInterface $acl, $field, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess) - { - parent::__construct($id, $acl, $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess); - - $this->field = $field; - } - - /** - * {@inheritdoc} - */ - public function getField() - { - return $this->field; - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array( - $this->field, - parent::serialize(), - )); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - list($this->field, $parentStr) = unserialize($serialized); - parent::unserialize($parentStr); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php b/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php deleted file mode 100644 index 871bda7b10970..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Core\Util\ClassUtils; -use Symfony\Component\Security\Acl\Exception\InvalidDomainObjectException; -use Symfony\Component\Security\Acl\Model\DomainObjectInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; - -/** - * ObjectIdentity implementation. - * - * @author Johannes M. Schmitt - */ -final class ObjectIdentity implements ObjectIdentityInterface -{ - private $identifier; - private $type; - - /** - * Constructor. - * - * @param string $identifier - * @param string $type - * - * @throws \InvalidArgumentException - */ - public function __construct($identifier, $type) - { - if ('' === $identifier) { - throw new \InvalidArgumentException('$identifier cannot be empty.'); - } - if (empty($type)) { - throw new \InvalidArgumentException('$type cannot be empty.'); - } - - $this->identifier = $identifier; - $this->type = $type; - } - - /** - * Constructs an ObjectIdentity for the given domain object. - * - * @param object $domainObject - * - * @throws InvalidDomainObjectException - * - * @return ObjectIdentity - */ - public static function fromDomainObject($domainObject) - { - if (!is_object($domainObject)) { - throw new InvalidDomainObjectException('$domainObject must be an object.'); - } - - try { - if ($domainObject instanceof DomainObjectInterface) { - return new self($domainObject->getObjectIdentifier(), ClassUtils::getRealClass($domainObject)); - } elseif (method_exists($domainObject, 'getId')) { - return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject)); - } - } catch (\InvalidArgumentException $e) { - throw new InvalidDomainObjectException($e->getMessage(), 0, $e); - } - - throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".'); - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return $this->identifier; - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return $this->type; - } - - /** - * {@inheritdoc} - */ - public function equals(ObjectIdentityInterface $identity) - { - // comparing the identifier with === might lead to problems, so we - // waive this restriction - return $this->identifier == $identity->getIdentifier() - && $this->type === $identity->getType(); - } - - /** - * Returns a textual representation of this object identity. - * - * @return string - */ - public function __toString() - { - return sprintf('ObjectIdentity(%s, %s)', $this->identifier, $this->type); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentityRetrievalStrategy.php b/src/Symfony/Component/Security/Acl/Domain/ObjectIdentityRetrievalStrategy.php deleted file mode 100644 index 80de6e028406a..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/ObjectIdentityRetrievalStrategy.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Exception\InvalidDomainObjectException; -use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; - -/** - * Strategy to be used for retrieving object identities from domain objects. - * - * @author Johannes M. Schmitt - */ -class ObjectIdentityRetrievalStrategy implements ObjectIdentityRetrievalStrategyInterface -{ - /** - * {@inheritdoc} - */ - public function getObjectIdentity($domainObject) - { - try { - return ObjectIdentity::fromDomainObject($domainObject); - } catch (InvalidDomainObjectException $e) { - return; - } - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php b/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php deleted file mode 100644 index 742c4e5fbfcc8..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php +++ /dev/null @@ -1,211 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Exception\NoAceFoundException; -use Symfony\Component\Security\Acl\Model\AclInterface; -use Symfony\Component\Security\Acl\Model\AuditLoggerInterface; -use Symfony\Component\Security\Acl\Model\EntryInterface; -use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; - -/** - * The permission granting strategy to apply to the access control list. - * - * @author Johannes M. Schmitt - */ -class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface -{ - const EQUAL = 'equal'; - const ALL = 'all'; - const ANY = 'any'; - - private $auditLogger; - - /** - * Sets the audit logger. - * - * @param AuditLoggerInterface $auditLogger - */ - public function setAuditLogger(AuditLoggerInterface $auditLogger) - { - $this->auditLogger = $auditLogger; - } - - /** - * {@inheritdoc} - */ - public function isGranted(AclInterface $acl, array $masks, array $sids, $administrativeMode = false) - { - try { - try { - $aces = $acl->getObjectAces(); - - if (!$aces) { - throw new NoAceFoundException(); - } - - return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode); - } catch (NoAceFoundException $e) { - $aces = $acl->getClassAces(); - - if (!$aces) { - throw $e; - } - - return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode); - } - } catch (NoAceFoundException $e) { - if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) { - return $parentAcl->isGranted($masks, $sids, $administrativeMode); - } - - throw $e; - } - } - - /** - * {@inheritdoc} - */ - public function isFieldGranted(AclInterface $acl, $field, array $masks, array $sids, $administrativeMode = false) - { - try { - try { - $aces = $acl->getObjectFieldAces($field); - if (!$aces) { - throw new NoAceFoundException(); - } - - return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode); - } catch (NoAceFoundException $e) { - $aces = $acl->getClassFieldAces($field); - if (!$aces) { - throw $e; - } - - return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode); - } - } catch (NoAceFoundException $e) { - if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) { - return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode); - } - - throw $e; - } - } - - /** - * Makes an authorization decision. - * - * The order of ACEs, and SIDs is significant; the order of permission masks - * not so much. It is important to note that the more specific security - * identities should be at the beginning of the SIDs array in order for this - * strategy to produce intuitive authorization decisions. - * - * First, we will iterate over permissions, then over security identities. - * For each combination of permission, and identity we will test the - * available ACEs until we find one which is applicable. - * - * The first applicable ACE will make the ultimate decision for the - * permission/identity combination. If it is granting, this method will return - * true, if it is denying, the method will continue to check the next - * permission/identity combination. - * - * This process is repeated until either a granting ACE is found, or no - * permission/identity combinations are left. Finally, we will either throw - * an NoAceFoundException, or deny access. - * - * @param AclInterface $acl - * @param EntryInterface[] $aces An array of ACE to check against - * @param array $masks An array of permission masks - * @param SecurityIdentityInterface[] $sids An array of SecurityIdentityInterface implementations - * @param bool $administrativeMode True turns off audit logging - * - * @return bool true, or false; either granting, or denying access respectively. - * - * @throws NoAceFoundException - */ - private function hasSufficientPermissions(AclInterface $acl, array $aces, array $masks, array $sids, $administrativeMode) - { - $firstRejectedAce = null; - - foreach ($masks as $requiredMask) { - foreach ($sids as $sid) { - foreach ($aces as $ace) { - if ($sid->equals($ace->getSecurityIdentity()) && $this->isAceApplicable($requiredMask, $ace)) { - if ($ace->isGranting()) { - if (!$administrativeMode && null !== $this->auditLogger) { - $this->auditLogger->logIfNeeded(true, $ace); - } - - return true; - } - - if (null === $firstRejectedAce) { - $firstRejectedAce = $ace; - } - - break 2; - } - } - } - } - - if (null !== $firstRejectedAce) { - if (!$administrativeMode && null !== $this->auditLogger) { - $this->auditLogger->logIfNeeded(false, $firstRejectedAce); - } - - return false; - } - - throw new NoAceFoundException(); - } - - /** - * Determines whether the ACE is applicable to the given permission/security - * identity combination. - * - * Per default, we support three different comparison strategies. - * - * Strategy ALL: - * The ACE will be considered applicable when all the turned-on bits in the - * required mask are also turned-on in the ACE mask. - * - * Strategy ANY: - * The ACE will be considered applicable when any of the turned-on bits in - * the required mask is also turned-on the in the ACE mask. - * - * Strategy EQUAL: - * The ACE will be considered applicable when the bitmasks are equal. - * - * @param int $requiredMask - * @param EntryInterface $ace - * - * @return bool - * - * @throws \RuntimeException if the ACE strategy is not supported - */ - private function isAceApplicable($requiredMask, EntryInterface $ace) - { - $strategy = $ace->getStrategy(); - if (self::ALL === $strategy) { - return $requiredMask === ($ace->getMask() & $requiredMask); - } elseif (self::ANY === $strategy) { - return 0 !== ($ace->getMask() & $requiredMask); - } elseif (self::EQUAL === $strategy) { - return $requiredMask === $ace->getMask(); - } - - throw new \RuntimeException(sprintf('The strategy "%s" is not supported.', $strategy)); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php b/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php deleted file mode 100644 index c28a1c522da0d..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; -use Symfony\Component\Security\Core\Role\Role; - -/** - * A SecurityIdentity implementation for roles. - * - * @author Johannes M. Schmitt - */ -final class RoleSecurityIdentity implements SecurityIdentityInterface -{ - private $role; - - /** - * Constructor. - * - * @param mixed $role a Role instance, or its string representation - */ - public function __construct($role) - { - if ($role instanceof Role) { - $role = $role->getRole(); - } - - $this->role = $role; - } - - /** - * Returns the role name. - * - * @return string - */ - public function getRole() - { - return $this->role; - } - - /** - * {@inheritdoc} - */ - public function equals(SecurityIdentityInterface $sid) - { - if (!$sid instanceof self) { - return false; - } - - return $this->role === $sid->getRole(); - } - - /** - * Returns a textual representation of this security identity. - * - * This is solely used for debugging purposes, not to make an equality decision. - * - * @return string - */ - public function __toString() - { - return sprintf('RoleSecurityIdentity(%s)', $this->role); - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/SecurityIdentityRetrievalStrategy.php b/src/Symfony/Component/Security/Acl/Domain/SecurityIdentityRetrievalStrategy.php deleted file mode 100644 index a08f67e295515..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/SecurityIdentityRetrievalStrategy.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface; -use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; -use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; -use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; - -/** - * Strategy for retrieving security identities. - * - * @author Johannes M. Schmitt - */ -class SecurityIdentityRetrievalStrategy implements SecurityIdentityRetrievalStrategyInterface -{ - private $roleHierarchy; - private $authenticationTrustResolver; - - /** - * Constructor. - * - * @param RoleHierarchyInterface $roleHierarchy - * @param AuthenticationTrustResolver $authenticationTrustResolver - */ - public function __construct(RoleHierarchyInterface $roleHierarchy, AuthenticationTrustResolver $authenticationTrustResolver) - { - $this->roleHierarchy = $roleHierarchy; - $this->authenticationTrustResolver = $authenticationTrustResolver; - } - - /** - * {@inheritdoc} - */ - public function getSecurityIdentities(TokenInterface $token) - { - $sids = array(); - - // add user security identity - if (!$token instanceof AnonymousToken) { - try { - $sids[] = UserSecurityIdentity::fromToken($token); - } catch (\InvalidArgumentException $e) { - // ignore, user has no user security identity - } - } - - // add all reachable roles - foreach ($this->roleHierarchy->getReachableRoles($token->getRoles()) as $role) { - $sids[] = new RoleSecurityIdentity($role); - } - - // add built-in special roles - if ($this->authenticationTrustResolver->isFullFledged($token)) { - $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_FULLY); - $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED); - $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY); - } elseif ($this->authenticationTrustResolver->isRememberMe($token)) { - $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED); - $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY); - } elseif ($this->authenticationTrustResolver->isAnonymous($token)) { - $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY); - } - - return $sids; - } -} diff --git a/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php b/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php deleted file mode 100644 index ea17c635d512c..0000000000000 --- a/src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Domain; - -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Core\Util\ClassUtils; -use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; - -/** - * A SecurityIdentity implementation used for actual users. - * - * @author Johannes M. Schmitt - */ -final class UserSecurityIdentity implements SecurityIdentityInterface -{ - private $username; - private $class; - - /** - * Constructor. - * - * @param string $username the username representation - * @param string $class the user's fully qualified class name - * - * @throws \InvalidArgumentException - */ - public function __construct($username, $class) - { - if ('' === $username || null === $username) { - throw new \InvalidArgumentException('$username must not be empty.'); - } - if (empty($class)) { - throw new \InvalidArgumentException('$class must not be empty.'); - } - - $this->username = (string) $username; - $this->class = $class; - } - - /** - * Creates a user security identity from a UserInterface. - * - * @param UserInterface $user - * - * @return UserSecurityIdentity - */ - public static function fromAccount(UserInterface $user) - { - return new self($user->getUsername(), ClassUtils::getRealClass($user)); - } - - /** - * Creates a user security identity from a TokenInterface. - * - * @param TokenInterface $token - * - * @return UserSecurityIdentity - */ - public static function fromToken(TokenInterface $token) - { - $user = $token->getUser(); - - if ($user instanceof UserInterface) { - return self::fromAccount($user); - } - - return new self((string) $user, is_object($user) ? ClassUtils::getRealClass($user) : ClassUtils::getRealClass($token)); - } - - /** - * Returns the username. - * - * @return string - */ - public function getUsername() - { - return $this->username; - } - - /** - * Returns the user's class name. - * - * @return string - */ - public function getClass() - { - return $this->class; - } - - /** - * {@inheritdoc} - */ - public function equals(SecurityIdentityInterface $sid) - { - if (!$sid instanceof self) { - return false; - } - - return $this->username === $sid->getUsername() - && $this->class === $sid->getClass(); - } - - /** - * A textual representation of this security identity. - * - * This is not used for equality comparison, but only for debugging. - * - * @return string - */ - public function __toString() - { - return sprintf('UserSecurityIdentity(%s, %s)', $this->username, $this->class); - } -} diff --git a/src/Symfony/Component/Security/Acl/Exception/AclAlreadyExistsException.php b/src/Symfony/Component/Security/Acl/Exception/AclAlreadyExistsException.php deleted file mode 100644 index 512da7feebbed..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/AclAlreadyExistsException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown when someone tries to create an ACL for an object - * identity that already has one. - * - * @author Johannes M. Schmitt - */ -class AclAlreadyExistsException extends Exception -{ -} diff --git a/src/Symfony/Component/Security/Acl/Exception/AclNotFoundException.php b/src/Symfony/Component/Security/Acl/Exception/AclNotFoundException.php deleted file mode 100644 index bd66c005c8c8e..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/AclNotFoundException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown when we cannot locate an ACL for a passed - * ObjectIdentity implementation. - * - * @author Johannes M. Schmitt - */ -class AclNotFoundException extends Exception -{ -} diff --git a/src/Symfony/Component/Security/Acl/Exception/ConcurrentModificationException.php b/src/Symfony/Component/Security/Acl/Exception/ConcurrentModificationException.php deleted file mode 100644 index a527d9c47b52e..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/ConcurrentModificationException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown whenever you change shared properties of more than - * one ACL of the same class type concurrently. - * - * @author Johannes M. Schmitt - */ -class ConcurrentModificationException extends Exception -{ -} diff --git a/src/Symfony/Component/Security/Acl/Exception/InvalidDomainObjectException.php b/src/Symfony/Component/Security/Acl/Exception/InvalidDomainObjectException.php deleted file mode 100644 index fc1a646aecc56..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/InvalidDomainObjectException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown when ObjectIdentity fails to construct an object - * identity from the passed domain object. - * - * @author Johannes M. Schmitt - */ -class InvalidDomainObjectException extends Exception -{ -} diff --git a/src/Symfony/Component/Security/Acl/Exception/NoAceFoundException.php b/src/Symfony/Component/Security/Acl/Exception/NoAceFoundException.php deleted file mode 100644 index 4d194d9a27db6..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/NoAceFoundException.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown when we cannot locate an ACE that matches the - * combination of permission masks and security identities. - * - * @author Johannes M. Schmitt - */ -class NoAceFoundException extends Exception -{ - public function __construct() - { - parent::__construct('No applicable ACE was found.'); - } -} diff --git a/src/Symfony/Component/Security/Acl/Exception/NotAllAclsFoundException.php b/src/Symfony/Component/Security/Acl/Exception/NotAllAclsFoundException.php deleted file mode 100644 index a6343823ad51a..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/NotAllAclsFoundException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown when you have requested ACLs for multiple object - * identities, but the AclProvider implementation failed to find ACLs for all - * identities. - * - * This exception contains the partial result. - * - * @author Johannes M. Schmitt - */ -class NotAllAclsFoundException extends AclNotFoundException -{ - private $partialResult; - - /** - * Sets the partial result. - * - * @param \SplObjectStorage $result - */ - public function setPartialResult(\SplObjectStorage $result) - { - $this->partialResult = $result; - } - - /** - * Returns the partial result. - * - * @return \SplObjectStorage - */ - public function getPartialResult() - { - return $this->partialResult; - } -} diff --git a/src/Symfony/Component/Security/Acl/Exception/SidNotLoadedException.php b/src/Symfony/Component/Security/Acl/Exception/SidNotLoadedException.php deleted file mode 100644 index cb8c4cc6f0b9f..0000000000000 --- a/src/Symfony/Component/Security/Acl/Exception/SidNotLoadedException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Exception; - -/** - * This exception is thrown when ACEs for an SID are requested which has not - * been loaded from the database. - * - * @author Johannes M. Schmitt - */ -class SidNotLoadedException extends Exception -{ -} diff --git a/src/Symfony/Component/Security/Acl/LICENSE b/src/Symfony/Component/Security/Acl/LICENSE deleted file mode 100644 index 43028bc600f26..0000000000000 --- a/src/Symfony/Component/Security/Acl/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Symfony/Component/Security/Acl/Model/AclCacheInterface.php b/src/Symfony/Component/Security/Acl/Model/AclCacheInterface.php deleted file mode 100644 index 1e7458540be4d..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/AclCacheInterface.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * AclCache Interface. - * - * @author Johannes M. Schmitt - */ -interface AclCacheInterface -{ - /** - * Removes an ACL from the cache. - * - * @param string $primaryKey a serialized primary key - */ - public function evictFromCacheById($primaryKey); - - /** - * Removes an ACL from the cache. - * - * The ACL which is returned, must reference the passed object identity. - * - * @param ObjectIdentityInterface $oid - */ - public function evictFromCacheByIdentity(ObjectIdentityInterface $oid); - - /** - * Retrieves an ACL for the given object identity primary key from the cache. - * - * @param int $primaryKey - * - * @return AclInterface - */ - public function getFromCacheById($primaryKey); - - /** - * Retrieves an ACL for the given object identity from the cache. - * - * @param ObjectIdentityInterface $oid - * - * @return AclInterface - */ - public function getFromCacheByIdentity(ObjectIdentityInterface $oid); - - /** - * Stores a new ACL in the cache. - * - * @param AclInterface $acl - */ - public function putInCache(AclInterface $acl); - - /** - * Removes all ACLs from the cache. - */ - public function clearCache(); -} diff --git a/src/Symfony/Component/Security/Acl/Model/AclInterface.php b/src/Symfony/Component/Security/Acl/Model/AclInterface.php deleted file mode 100644 index 6a70a7c5943ac..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/AclInterface.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -use Symfony\Component\Security\Acl\Exception\NoAceFoundException; - -/** - * This interface represents an access control list (ACL) for a domain object. - * Each domain object can have exactly one associated ACL. - * - * An ACL contains all access control entries (ACE) for a given domain object. - * In order to avoid needing references to the domain object itself, implementations - * use ObjectIdentity implementations as an additional level of indirection. - * - * @author Johannes M. Schmitt - */ -interface AclInterface extends \Serializable -{ - /** - * Returns all class-based ACEs associated with this ACL. - * - * @return array - */ - public function getClassAces(); - - /** - * Returns all class-field-based ACEs associated with this ACL. - * - * @param string $field - * - * @return array - */ - public function getClassFieldAces($field); - - /** - * Returns all object-based ACEs associated with this ACL. - * - * @return array - */ - public function getObjectAces(); - - /** - * Returns all object-field-based ACEs associated with this ACL. - * - * @param string $field - * - * @return array - */ - public function getObjectFieldAces($field); - - /** - * Returns the object identity associated with this ACL. - * - * @return ObjectIdentityInterface - */ - public function getObjectIdentity(); - - /** - * Returns the parent ACL, or null if there is none. - * - * @return AclInterface|null - */ - public function getParentAcl(); - - /** - * Whether this ACL is inheriting ACEs from a parent ACL. - * - * @return bool - */ - public function isEntriesInheriting(); - - /** - * Determines whether field access is granted. - * - * @param string $field - * @param array $masks - * @param array $securityIdentities - * @param bool $administrativeMode - * - * @return bool - */ - public function isFieldGranted($field, array $masks, array $securityIdentities, $administrativeMode = false); - - /** - * Determines whether access is granted. - * - * @param array $masks - * @param array $securityIdentities - * @param bool $administrativeMode - * - * @throws NoAceFoundException when no ACE was applicable for this request - * - * @return bool - */ - public function isGranted(array $masks, array $securityIdentities, $administrativeMode = false); - - /** - * Whether the ACL has loaded ACEs for all of the passed security identities. - * - * @param mixed $securityIdentities an implementation of SecurityIdentityInterface, or an array thereof - * - * @return bool - */ - public function isSidLoaded($securityIdentities); -} diff --git a/src/Symfony/Component/Security/Acl/Model/AclProviderInterface.php b/src/Symfony/Component/Security/Acl/Model/AclProviderInterface.php deleted file mode 100644 index f9b41cb35ed09..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/AclProviderInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -use Symfony\Component\Security\Acl\Exception\AclNotFoundException; - -/** - * Provides a common interface for retrieving ACLs. - * - * @author Johannes M. Schmitt - */ -interface AclProviderInterface -{ - /** - * Retrieves all child object identities from the database. - * - * @param ObjectIdentityInterface $parentOid - * @param bool $directChildrenOnly - * - * @return array returns an array of child 'ObjectIdentity's - */ - public function findChildren(ObjectIdentityInterface $parentOid, $directChildrenOnly = false); - - /** - * Returns the ACL that belongs to the given object identity. - * - * @param ObjectIdentityInterface $oid - * @param SecurityIdentityInterface[] $sids - * - * @return AclInterface - * - * @throws AclNotFoundException when there is no ACL - */ - public function findAcl(ObjectIdentityInterface $oid, array $sids = array()); - - /** - * Returns the ACLs that belong to the given object identities. - * - * @param ObjectIdentityInterface[] $oids an array of ObjectIdentityInterface implementations - * @param SecurityIdentityInterface[] $sids an array of SecurityIdentityInterface implementations - * - * @return \SplObjectStorage mapping the passed object identities to ACLs - * - * @throws AclNotFoundException when we cannot find an ACL for all identities - */ - public function findAcls(array $oids, array $sids = array()); -} diff --git a/src/Symfony/Component/Security/Acl/Model/AuditLoggerInterface.php b/src/Symfony/Component/Security/Acl/Model/AuditLoggerInterface.php deleted file mode 100644 index fde4de6abe345..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/AuditLoggerInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * Interface for audit loggers. - * - * @author Johannes M. Schmitt - */ -interface AuditLoggerInterface -{ - /** - * This method is called whenever access is granted, or denied, and - * administrative mode is turned off. - * - * @param bool $granted - * @param EntryInterface $ace - */ - public function logIfNeeded($granted, EntryInterface $ace); -} diff --git a/src/Symfony/Component/Security/Acl/Model/AuditableAclInterface.php b/src/Symfony/Component/Security/Acl/Model/AuditableAclInterface.php deleted file mode 100644 index e7a60e5eb851c..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/AuditableAclInterface.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * This interface adds auditing capabilities to the ACL. - * - * @author Johannes M. Schmitt - */ -interface AuditableAclInterface extends MutableAclInterface -{ - /** - * Updates auditing for class-based ACE. - * - * @param int $index - * @param bool $auditSuccess - * @param bool $auditFailure - */ - public function updateClassAuditing($index, $auditSuccess, $auditFailure); - - /** - * Updates auditing for class-field-based ACE. - * - * @param int $index - * @param string $field - * @param bool $auditSuccess - * @param bool $auditFailure - */ - public function updateClassFieldAuditing($index, $field, $auditSuccess, $auditFailure); - - /** - * Updates auditing for object-based ACE. - * - * @param int $index - * @param bool $auditSuccess - * @param bool $auditFailure - */ - public function updateObjectAuditing($index, $auditSuccess, $auditFailure); - - /** - * Updates auditing for object-field-based ACE. - * - * @param int $index - * @param string $field - * @param bool $auditSuccess - * @param bool $auditFailure - */ - public function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditFailure); -} diff --git a/src/Symfony/Component/Security/Acl/Model/AuditableEntryInterface.php b/src/Symfony/Component/Security/Acl/Model/AuditableEntryInterface.php deleted file mode 100644 index 95615775d53ae..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/AuditableEntryInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * ACEs can implement this interface if they support auditing capabilities. - * - * @author Johannes M. Schmitt - */ -interface AuditableEntryInterface extends EntryInterface -{ - /** - * Whether auditing for successful grants is turned on. - * - * @return bool - */ - public function isAuditFailure(); - - /** - * Whether auditing for successful denies is turned on. - * - * @return bool - */ - public function isAuditSuccess(); -} diff --git a/src/Symfony/Component/Security/Acl/Model/DomainObjectInterface.php b/src/Symfony/Component/Security/Acl/Model/DomainObjectInterface.php deleted file mode 100644 index 195cb4ec64927..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/DomainObjectInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * This method can be implemented by domain objects which you want to store - * ACLs for if they do not have a getId() method, or getId() does not return - * a unique identifier. - * - * @author Johannes M. Schmitt - */ -interface DomainObjectInterface -{ - /** - * Returns a unique identifier for this domain object. - * - * @return string - */ - public function getObjectIdentifier(); -} diff --git a/src/Symfony/Component/Security/Acl/Model/EntryInterface.php b/src/Symfony/Component/Security/Acl/Model/EntryInterface.php deleted file mode 100644 index 0b244b75882f9..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/EntryInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * This class represents an individual entry in the ACL list. - * - * Instances MUST be immutable, as they are returned by the ACL and should not - * allow client modification. - * - * @author Johannes M. Schmitt - */ -interface EntryInterface extends \Serializable -{ - /** - * The ACL this ACE is associated with. - * - * @return AclInterface - */ - public function getAcl(); - - /** - * The primary key of this ACE. - * - * @return int - */ - public function getId(); - - /** - * The permission mask of this ACE. - * - * @return int - */ - public function getMask(); - - /** - * The security identity associated with this ACE. - * - * @return SecurityIdentityInterface - */ - public function getSecurityIdentity(); - - /** - * The strategy for comparing masks. - * - * @return string - */ - public function getStrategy(); - - /** - * Returns whether this ACE is granting, or denying. - * - * @return bool - */ - public function isGranting(); -} diff --git a/src/Symfony/Component/Security/Acl/Model/FieldEntryInterface.php b/src/Symfony/Component/Security/Acl/Model/FieldEntryInterface.php deleted file mode 100644 index ae2f808f5dcaf..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/FieldEntryInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * Interface for entries which are restricted to specific fields. - * - * @author Johannes M. Schmitt - */ -interface FieldEntryInterface extends EntryInterface -{ - /** - * Returns the field used for this entry. - * - * @return string - */ - public function getField(); -} diff --git a/src/Symfony/Component/Security/Acl/Model/MutableAclInterface.php b/src/Symfony/Component/Security/Acl/Model/MutableAclInterface.php deleted file mode 100644 index 2ba7bd5365ee4..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/MutableAclInterface.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * This interface adds mutators for the AclInterface. - * - * All changes to Access Control Entries must go through this interface. Access - * Control Entries must never be modified directly. - * - * @author Johannes M. Schmitt - */ -interface MutableAclInterface extends AclInterface -{ - /** - * Deletes a class-based ACE. - * - * @param int $index - */ - public function deleteClassAce($index); - - /** - * Deletes a class-field-based ACE. - * - * @param int $index - * @param string $field - */ - public function deleteClassFieldAce($index, $field); - - /** - * Deletes an object-based ACE. - * - * @param int $index - */ - public function deleteObjectAce($index); - - /** - * Deletes an object-field-based ACE. - * - * @param int $index - * @param string $field - */ - public function deleteObjectFieldAce($index, $field); - - /** - * Returns the primary key of this ACL. - * - * @return int - */ - public function getId(); - - /** - * Inserts a class-based ACE. - * - * @param SecurityIdentityInterface $sid - * @param int $mask - * @param int $index - * @param bool $granting - * @param string $strategy - */ - public function insertClassAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); - - /** - * Inserts a class-field-based ACE. - * - * @param string $field - * @param SecurityIdentityInterface $sid - * @param int $mask - * @param int $index - * @param bool $granting - * @param string $strategy - */ - public function insertClassFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); - - /** - * Inserts an object-based ACE. - * - * @param SecurityIdentityInterface $sid - * @param int $mask - * @param int $index - * @param bool $granting - * @param string $strategy - */ - public function insertObjectAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); - - /** - * Inserts an object-field-based ACE. - * - * @param string $field - * @param SecurityIdentityInterface $sid - * @param int $mask - * @param int $index - * @param bool $granting - * @param string $strategy - */ - public function insertObjectFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); - - /** - * Sets whether entries are inherited. - * - * @param bool $boolean - */ - public function setEntriesInheriting($boolean); - - /** - * Sets the parent ACL. - * - * @param AclInterface|null $acl - */ - public function setParentAcl(AclInterface $acl = null); - - /** - * Updates a class-based ACE. - * - * @param int $index - * @param int $mask - * @param string $strategy if null the strategy should not be changed - */ - public function updateClassAce($index, $mask, $strategy = null); - - /** - * Updates a class-field-based ACE. - * - * @param int $index - * @param string $field - * @param int $mask - * @param string $strategy if null the strategy should not be changed - */ - public function updateClassFieldAce($index, $field, $mask, $strategy = null); - - /** - * Updates an object-based ACE. - * - * @param int $index - * @param int $mask - * @param string $strategy if null the strategy should not be changed - */ - public function updateObjectAce($index, $mask, $strategy = null); - - /** - * Updates an object-field-based ACE. - * - * @param int $index - * @param string $field - * @param int $mask - * @param string $strategy if null the strategy should not be changed - */ - public function updateObjectFieldAce($index, $field, $mask, $strategy = null); -} diff --git a/src/Symfony/Component/Security/Acl/Model/MutableAclProviderInterface.php b/src/Symfony/Component/Security/Acl/Model/MutableAclProviderInterface.php deleted file mode 100644 index 95f531e09ba76..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/MutableAclProviderInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -use Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException; - -/** - * Provides support for creating and storing ACL instances. - * - * @author Johannes M. Schmitt - */ -interface MutableAclProviderInterface extends AclProviderInterface -{ - /** - * Creates a new ACL for the given object identity. - * - * @param ObjectIdentityInterface $oid - * - * @throws AclAlreadyExistsException when there already is an ACL for the given - * object identity - * - * @return MutableAclInterface - */ - public function createAcl(ObjectIdentityInterface $oid); - - /** - * Deletes the ACL for a given object identity. - * - * This will automatically trigger a delete for any child ACLs. If you don't - * want child ACLs to be deleted, you will have to set their parent ACL to null. - * - * @param ObjectIdentityInterface $oid - */ - public function deleteAcl(ObjectIdentityInterface $oid); - - /** - * Persists any changes which were made to the ACL, or any associated - * access control entries. - * - * Changes to parent ACLs are not persisted. - * - * @param MutableAclInterface $acl - */ - public function updateAcl(MutableAclInterface $acl); -} diff --git a/src/Symfony/Component/Security/Acl/Model/ObjectIdentityInterface.php b/src/Symfony/Component/Security/Acl/Model/ObjectIdentityInterface.php deleted file mode 100644 index 6574b49313a28..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/ObjectIdentityInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * Represents the identity of an individual domain object instance. - * - * @author Johannes M. Schmitt - */ -interface ObjectIdentityInterface -{ - /** - * We specifically require this method so we can check for object equality - * explicitly, and do not have to rely on referencial equality instead. - * - * Though in most cases, both checks should result in the same outcome. - * - * Referential Equality: $object1 === $object2 - * Example for Object Equality: $object1->getId() === $object2->getId() - * - * @param ObjectIdentityInterface $identity - * - * @return bool - */ - public function equals(ObjectIdentityInterface $identity); - - /** - * Obtains a unique identifier for this object. The identifier must not be - * re-used for other objects with the same type. - * - * @return string cannot return null - */ - public function getIdentifier(); - - /** - * Returns a type for the domain object. Typically, this is the PHP class name. - * - * @return string cannot return null - */ - public function getType(); -} diff --git a/src/Symfony/Component/Security/Acl/Model/ObjectIdentityRetrievalStrategyInterface.php b/src/Symfony/Component/Security/Acl/Model/ObjectIdentityRetrievalStrategyInterface.php deleted file mode 100644 index 542066a6faaa2..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/ObjectIdentityRetrievalStrategyInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * Retrieves the object identity for a given domain object. - * - * @author Johannes M. Schmitt - */ -interface ObjectIdentityRetrievalStrategyInterface -{ - /** - * Retrieves the object identity from a domain object. - * - * @param object $domainObject - * - * @return ObjectIdentityInterface - */ - public function getObjectIdentity($domainObject); -} diff --git a/src/Symfony/Component/Security/Acl/Model/PermissionGrantingStrategyInterface.php b/src/Symfony/Component/Security/Acl/Model/PermissionGrantingStrategyInterface.php deleted file mode 100644 index fa3430da9ddae..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/PermissionGrantingStrategyInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * Interface used by permission granting implementations. - * - * @author Johannes M. Schmitt - */ -interface PermissionGrantingStrategyInterface -{ - /** - * Determines whether access to a domain object is to be granted. - * - * @param AclInterface $acl - * @param array $masks - * @param array $sids - * @param bool $administrativeMode - * - * @return bool - */ - public function isGranted(AclInterface $acl, array $masks, array $sids, $administrativeMode = false); - - /** - * Determines whether access to a domain object's field is to be granted. - * - * @param AclInterface $acl - * @param string $field - * @param array $masks - * @param array $sids - * @param bool $administrativeMode - * - * @return bool - */ - public function isFieldGranted(AclInterface $acl, $field, array $masks, array $sids, $administrativeMode = false); -} diff --git a/src/Symfony/Component/Security/Acl/Model/SecurityIdentityInterface.php b/src/Symfony/Component/Security/Acl/Model/SecurityIdentityInterface.php deleted file mode 100644 index 0a24a543d22ed..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/SecurityIdentityInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -/** - * This interface provides an additional level of indirection, so that - * we can work with abstracted versions of security objects and do - * not have to save the entire objects. - * - * @author Johannes M. Schmitt - */ -interface SecurityIdentityInterface -{ - /** - * This method is used to compare two security identities in order to - * not rely on referential equality. - * - * @param SecurityIdentityInterface $identity - */ - public function equals(SecurityIdentityInterface $identity); -} diff --git a/src/Symfony/Component/Security/Acl/Model/SecurityIdentityRetrievalStrategyInterface.php b/src/Symfony/Component/Security/Acl/Model/SecurityIdentityRetrievalStrategyInterface.php deleted file mode 100644 index b5fcb752f9e04..0000000000000 --- a/src/Symfony/Component/Security/Acl/Model/SecurityIdentityRetrievalStrategyInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Model; - -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; - -/** - * Interface for retrieving security identities from tokens. - * - * @author Johannes M. Schmitt - */ -interface SecurityIdentityRetrievalStrategyInterface -{ - /** - * Retrieves the available security identities for the given token. - * - * The order in which the security identities are returned is significant. - * Typically, security identities should be ordered from most specific to - * least specific. - * - * @param TokenInterface $token - * - * @return SecurityIdentityInterface[] An array of SecurityIdentityInterface implementations - */ - public function getSecurityIdentities(TokenInterface $token); -} diff --git a/src/Symfony/Component/Security/Acl/Permission/AbstractMaskBuilder.php b/src/Symfony/Component/Security/Acl/Permission/AbstractMaskBuilder.php deleted file mode 100644 index 867d2e216ef80..0000000000000 --- a/src/Symfony/Component/Security/Acl/Permission/AbstractMaskBuilder.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Permission; - -/** - * This abstract class implements nearly all the MaskBuilderInterface methods - */ -abstract class AbstractMaskBuilder implements MaskBuilderInterface -{ - /** - * @var int - */ - protected $mask; - - /** - * Constructor. - * - * @param int $mask optional; defaults to 0 - */ - public function __construct($mask = 0) - { - $this->set($mask); - } - - /** - * {@inheritdoc} - */ - public function set($mask) - { - if (!is_int($mask)) { - throw new \InvalidArgumentException('$mask must be an integer.'); - } - - $this->mask = $mask; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function get() - { - return $this->mask; - } - - /** - * {@inheritdoc} - */ - public function add($mask) - { - $this->mask |= $this->resolveMask($mask); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function remove($mask) - { - $this->mask &= ~$this->resolveMask($mask); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function reset() - { - $this->mask = 0; - - return $this; - } -} diff --git a/src/Symfony/Component/Security/Acl/Permission/BasicPermissionMap.php b/src/Symfony/Component/Security/Acl/Permission/BasicPermissionMap.php deleted file mode 100644 index fa5437dd91dcc..0000000000000 --- a/src/Symfony/Component/Security/Acl/Permission/BasicPermissionMap.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Permission; - -/** - * This is basic permission map complements the masks which have been defined - * on the standard implementation of the MaskBuilder. - * - * @author Johannes M. Schmitt - */ -class BasicPermissionMap implements PermissionMapInterface, MaskBuilderRetrievalInterface -{ - const PERMISSION_VIEW = 'VIEW'; - const PERMISSION_EDIT = 'EDIT'; - const PERMISSION_CREATE = 'CREATE'; - const PERMISSION_DELETE = 'DELETE'; - const PERMISSION_UNDELETE = 'UNDELETE'; - const PERMISSION_OPERATOR = 'OPERATOR'; - const PERMISSION_MASTER = 'MASTER'; - const PERMISSION_OWNER = 'OWNER'; - - protected $map; - - public function __construct() - { - $this->map = array( - self::PERMISSION_VIEW => array( - MaskBuilder::MASK_VIEW, - MaskBuilder::MASK_EDIT, - MaskBuilder::MASK_OPERATOR, - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_EDIT => array( - MaskBuilder::MASK_EDIT, - MaskBuilder::MASK_OPERATOR, - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_CREATE => array( - MaskBuilder::MASK_CREATE, - MaskBuilder::MASK_OPERATOR, - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_DELETE => array( - MaskBuilder::MASK_DELETE, - MaskBuilder::MASK_OPERATOR, - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_UNDELETE => array( - MaskBuilder::MASK_UNDELETE, - MaskBuilder::MASK_OPERATOR, - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_OPERATOR => array( - MaskBuilder::MASK_OPERATOR, - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_MASTER => array( - MaskBuilder::MASK_MASTER, - MaskBuilder::MASK_OWNER, - ), - - self::PERMISSION_OWNER => array( - MaskBuilder::MASK_OWNER, - ), - ); - } - - /** - * {@inheritdoc} - */ - public function getMasks($permission, $object) - { - if (!isset($this->map[$permission])) { - return; - } - - return $this->map[$permission]; - } - - /** - * {@inheritdoc} - */ - public function contains($permission) - { - return isset($this->map[$permission]); - } - - /** - * {@inheritdoc} - */ - public function getMaskBuilder() - { - return new MaskBuilder(); - } -} diff --git a/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php b/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php deleted file mode 100644 index 4788a1f6470bb..0000000000000 --- a/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php +++ /dev/null @@ -1,151 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Permission; - -/** - * This class allows you to build cumulative permissions easily, or convert - * masks to a human-readable format. - * - * - * $builder = new MaskBuilder(); - * $builder - * ->add('view') - * ->add('create') - * ->add('edit') - * ; - * var_dump($builder->get()); // int(7) - * var_dump($builder->getPattern()); // string(32) ".............................ECV" - * - * - * We have defined some commonly used base permissions which you can use: - * - VIEW: the SID is allowed to view the domain object / field - * - CREATE: the SID is allowed to create new instances of the domain object / fields - * - EDIT: the SID is allowed to edit existing instances of the domain object / field - * - DELETE: the SID is allowed to delete domain objects - * - UNDELETE: the SID is allowed to recover domain objects from trash - * - OPERATOR: the SID is allowed to perform any action on the domain object - * except for granting others permissions - * - MASTER: the SID is allowed to perform any action on the domain object, - * and is allowed to grant other SIDs any permission except for - * MASTER and OWNER permissions - * - OWNER: the SID is owning the domain object in question and can perform any - * action on the domain object as well as grant any permission - * - * @author Johannes M. Schmitt - */ -class MaskBuilder extends AbstractMaskBuilder -{ - const MASK_VIEW = 1; // 1 << 0 - const MASK_CREATE = 2; // 1 << 1 - const MASK_EDIT = 4; // 1 << 2 - const MASK_DELETE = 8; // 1 << 3 - const MASK_UNDELETE = 16; // 1 << 4 - const MASK_OPERATOR = 32; // 1 << 5 - const MASK_MASTER = 64; // 1 << 6 - const MASK_OWNER = 128; // 1 << 7 - const MASK_IDDQD = 1073741823; // 1 << 0 | 1 << 1 | ... | 1 << 30 - - const CODE_VIEW = 'V'; - const CODE_CREATE = 'C'; - const CODE_EDIT = 'E'; - const CODE_DELETE = 'D'; - const CODE_UNDELETE = 'U'; - const CODE_OPERATOR = 'O'; - const CODE_MASTER = 'M'; - const CODE_OWNER = 'N'; - - const ALL_OFF = '................................'; - const OFF = '.'; - const ON = '*'; - - /** - * Returns a human-readable representation of the permission. - * - * @return string - */ - public function getPattern() - { - $pattern = self::ALL_OFF; - $length = strlen($pattern); - $bitmask = str_pad(decbin($this->mask), $length, '0', STR_PAD_LEFT); - - for ($i = $length - 1; $i >= 0; --$i) { - if ('1' === $bitmask[$i]) { - try { - $pattern[$i] = self::getCode(1 << ($length - $i - 1)); - } catch (\Exception $e) { - $pattern[$i] = self::ON; - } - } - } - - return $pattern; - } - - /** - * Returns the code for the passed mask. - * - * @param int $mask - * - * @throws \InvalidArgumentException - * @throws \RuntimeException - * - * @return string - */ - public static function getCode($mask) - { - if (!is_int($mask)) { - throw new \InvalidArgumentException('$mask must be an integer.'); - } - - $reflection = new \ReflectionClass(get_called_class()); - foreach ($reflection->getConstants() as $name => $cMask) { - if (0 !== strpos($name, 'MASK_') || $mask !== $cMask) { - continue; - } - - if (!defined($cName = 'static::CODE_'.substr($name, 5))) { - throw new \RuntimeException('There was no code defined for this mask.'); - } - - return constant($cName); - } - - throw new \InvalidArgumentException(sprintf('The mask "%d" is not supported.', $mask)); - } - - /** - * Returns the mask for the passed code - * - * @param mixed $code - * - * @return int - * - * @throws \InvalidArgumentException - */ - public function resolveMask($code) - { - if (is_string($code)) { - if (!defined($name = sprintf('static::MASK_%s', strtoupper($code)))) { - throw new \InvalidArgumentException(sprintf('The code "%s" is not supported', $code)); - } - - return constant($name); - } - - if (!is_int($code)) { - throw new \InvalidArgumentException('$code must be an integer.'); - } - - return $code; - } -} diff --git a/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php b/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php deleted file mode 100644 index ba4183014cf1d..0000000000000 --- a/src/Symfony/Component/Security/Acl/Permission/MaskBuilderInterface.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Permission; - -/** - * This is the interface that must be implemented by mask builders. - */ -interface MaskBuilderInterface -{ - /** - * Set the mask of this permission - * - * @param int $mask - * - * @return MaskBuilderInterface - * @throws \InvalidArgumentException if $mask is not an integer - */ - public function set($mask); - - /** - * Returns the mask of this permission. - * - * @return int - */ - public function get(); - - /** - * Adds a mask to the permission. - * - * @param mixed $mask - * - * @return MaskBuilderInterface - * - * @throws \InvalidArgumentException - */ - public function add($mask); - - /** - * Removes a mask from the permission. - * - * @param mixed $mask - * - * @return MaskBuilderInterface - * - * @throws \InvalidArgumentException - */ - public function remove($mask); - - /** - * Resets the PermissionBuilder. - * - * @return MaskBuilderInterface - */ - public function reset(); - - /** - * Returns the mask for the passed code - * - * @param mixed $code - * - * @return int - * - * @throws \InvalidArgumentException - */ - public function resolveMask($code); -} diff --git a/src/Symfony/Component/Security/Acl/Permission/MaskBuilderRetrievalInterface.php b/src/Symfony/Component/Security/Acl/Permission/MaskBuilderRetrievalInterface.php deleted file mode 100644 index 7a99bca363f19..0000000000000 --- a/src/Symfony/Component/Security/Acl/Permission/MaskBuilderRetrievalInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Permission; - -/** - * Retrieves the MaskBuilder - */ -interface MaskBuilderRetrievalInterface -{ - /** - * Returns a new instance of the MaskBuilder used in the permissionMap - * - * @return MaskBuilderInterface - */ - public function getMaskBuilder(); -} diff --git a/src/Symfony/Component/Security/Acl/Permission/PermissionMapInterface.php b/src/Symfony/Component/Security/Acl/Permission/PermissionMapInterface.php deleted file mode 100644 index 0b2f1ceafcab9..0000000000000 --- a/src/Symfony/Component/Security/Acl/Permission/PermissionMapInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Permission; - -/** - * This is the interface that must be implemented by permission maps. - * - * @author Johannes M. Schmitt - */ -interface PermissionMapInterface -{ - /** - * Returns an array of bitmasks. - * - * The security identity must have been granted access to at least one of - * these bitmasks. - * - * @param string $permission - * @param object $object - * - * @return array may return null if permission/object combination is not supported - */ - public function getMasks($permission, $object); - - /** - * Whether this map contains the given permission. - * - * @param string $permission - * - * @return bool - */ - public function contains($permission); -} diff --git a/src/Symfony/Component/Security/Acl/README.md b/src/Symfony/Component/Security/Acl/README.md deleted file mode 100644 index 458820e812ebe..0000000000000 --- a/src/Symfony/Component/Security/Acl/README.md +++ /dev/null @@ -1,23 +0,0 @@ -Security Component - ACL (Access Control List) -============================================== - -Security provides an infrastructure for sophisticated authorization systems, -which makes it possible to easily separate the actual authorization logic from -so called user providers that hold the users credentials. It is inspired by -the Java Spring framework. - -Resources ---------- - -Documentation: - -https://symfony.com/doc/2.8/book/security.html - -Tests ------ - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Security/Acl/ - $ composer.phar install --dev - $ phpunit diff --git a/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php b/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php deleted file mode 100644 index 4b1b38d5847f0..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require_once __DIR__.'/../../../../ClassLoader/ClassLoader.php'; - -use Symfony\Component\ClassLoader\ClassLoader; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Security\Acl\Dbal\Schema; - -$loader = new ClassLoader(); -$loader->addPrefixes(array( - 'Symfony' => __DIR__.'/../../../../../..', - 'Doctrine\\Common' => __DIR__.'/../../../../../../../vendor/doctrine-common/lib', - 'Doctrine\\DBAL\\Migrations' => __DIR__.'/../../../../../../../vendor/doctrine-migrations/lib', - 'Doctrine\\DBAL' => __DIR__.'/../../../../../../../vendor/doctrine/dbal/lib', - 'Doctrine' => __DIR__.'/../../../../../../../vendor/doctrine/lib', -)); -$loader->register(); - -$schema = new Schema(array( - 'class_table_name' => 'acl_classes', - 'entry_table_name' => 'acl_entries', - 'oid_table_name' => 'acl_object_identities', - 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', - 'sid_table_name' => 'acl_security_identities', -)); - -$reflection = new ReflectionClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform'); -$finder = new Finder(); -$finder->name('*Platform.php')->in(dirname($reflection->getFileName())); -foreach ($finder as $file) { - require_once $file->getPathName(); - $className = 'Doctrine\\DBAL\\Platforms\\'.$file->getBasename('.php'); - - $reflection = new ReflectionClass($className); - if ($reflection->isAbstract()) { - continue; - } - - $platform = $reflection->newInstance(); - $targetFile = sprintf(__DIR__.'/../schema/%s.sql', $platform->getName()); - file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform))); -} diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/db2.sql b/src/Symfony/Component/Security/Acl/Resources/schema/db2.sql deleted file mode 100644 index 2d10c14d6834f..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/db2.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE acl_classes (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, class_type VARCHAR(200) NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type) - -CREATE TABLE acl_security_identities (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, identifier VARCHAR(200) NOT NULL, username SMALLINT NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username) - -CREATE TABLE acl_object_identities (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, parent_object_identity_id INTEGER DEFAULT NULL, class_id INTEGER NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting SMALLINT NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id) - -CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id) - -CREATE TABLE acl_object_identity_ancestors (object_identity_id INTEGER NOT NULL, ancestor_id INTEGER NOT NULL, PRIMARY KEY(object_identity_id, ancestor_id)) - -CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id) - -CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id) - -CREATE TABLE acl_entries (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, class_id INTEGER NOT NULL, object_identity_id INTEGER DEFAULT NULL, security_identity_id INTEGER NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order SMALLINT NOT NULL, mask INTEGER NOT NULL, granting SMALLINT NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success SMALLINT NOT NULL, audit_failure SMALLINT NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order) - -CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id) - -CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id) - -CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id) - -CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id) - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/drizzle.sql b/src/Symfony/Component/Security/Acl/Resources/schema/drizzle.sql deleted file mode 100644 index 9398c2951431c..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/drizzle.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE acl_classes (id INT AUTO_INCREMENT NOT NULL, class_type VARCHAR(200) NOT NULL, UNIQUE INDEX UNIQ_69DD750638A36066 (class_type), PRIMARY KEY(id)) COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_security_identities (id INT AUTO_INCREMENT NOT NULL, identifier VARCHAR(200) NOT NULL, username BOOLEAN NOT NULL, UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 (identifier, username), PRIMARY KEY(id)) COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_object_identities (id INT AUTO_INCREMENT NOT NULL, parent_object_identity_id INT DEFAULT NULL, class_id INT NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting BOOLEAN NOT NULL, UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 (object_identifier, class_id), INDEX IDX_9407E54977FA751A (parent_object_identity_id), PRIMARY KEY(id)) COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_object_identity_ancestors (object_identity_id INT NOT NULL, ancestor_id INT NOT NULL, INDEX IDX_825DE2993D9AB4A6 (object_identity_id), INDEX IDX_825DE299C671CEA1 (ancestor_id), PRIMARY KEY(object_identity_id, ancestor_id)) COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_entries (id INT AUTO_INCREMENT NOT NULL, class_id INT NOT NULL, object_identity_id INT DEFAULT NULL, security_identity_id INT NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order INT NOT NULL, mask INT NOT NULL, granting BOOLEAN NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success BOOLEAN NOT NULL, audit_failure BOOLEAN NOT NULL, UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 (class_id, object_identity_id, field_name, ace_order), INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 (class_id, object_identity_id, security_identity_id), INDEX IDX_46C8B806EA000B10 (class_id), INDEX IDX_46C8B8063D9AB4A6 (object_identity_id), INDEX IDX_46C8B806DF9183C9 (security_identity_id), PRIMARY KEY(id)) COLLATE utf8_unicode_ci ENGINE = InnoDB - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/mssql.sql b/src/Symfony/Component/Security/Acl/Resources/schema/mssql.sql deleted file mode 100644 index 8126f7851947b..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/mssql.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE acl_classes (id INT IDENTITY NOT NULL, class_type NVARCHAR(200) NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type) WHERE class_type IS NOT NULL - -CREATE TABLE acl_security_identities (id INT IDENTITY NOT NULL, identifier NVARCHAR(200) NOT NULL, username BIT NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username) WHERE identifier IS NOT NULL AND username IS NOT NULL - -CREATE TABLE acl_object_identities (id INT IDENTITY NOT NULL, parent_object_identity_id INT, class_id INT NOT NULL, object_identifier NVARCHAR(100) NOT NULL, entries_inheriting BIT NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id) WHERE object_identifier IS NOT NULL AND class_id IS NOT NULL - -CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id) - -CREATE TABLE acl_object_identity_ancestors (object_identity_id INT NOT NULL, ancestor_id INT NOT NULL, PRIMARY KEY (object_identity_id, ancestor_id)) - -CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id) - -CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id) - -CREATE TABLE acl_entries (id INT IDENTITY NOT NULL, class_id INT NOT NULL, object_identity_id INT, security_identity_id INT NOT NULL, field_name NVARCHAR(50), ace_order SMALLINT NOT NULL, mask INT NOT NULL, granting BIT NOT NULL, granting_strategy NVARCHAR(30) NOT NULL, audit_success BIT NOT NULL, audit_failure BIT NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order) WHERE class_id IS NOT NULL AND object_identity_id IS NOT NULL AND field_name IS NOT NULL AND ace_order IS NOT NULL - -CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id) - -CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id) - -CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id) - -CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id) - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/mysql.sql b/src/Symfony/Component/Security/Acl/Resources/schema/mysql.sql deleted file mode 100644 index 1c63f4dfe7ba4..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/mysql.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE acl_classes (id INT UNSIGNED AUTO_INCREMENT NOT NULL, class_type VARCHAR(200) NOT NULL, UNIQUE INDEX UNIQ_69DD750638A36066 (class_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_security_identities (id INT UNSIGNED AUTO_INCREMENT NOT NULL, identifier VARCHAR(200) NOT NULL, username TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 (identifier, username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_object_identities (id INT UNSIGNED AUTO_INCREMENT NOT NULL, parent_object_identity_id INT UNSIGNED DEFAULT NULL, class_id INT UNSIGNED NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 (object_identifier, class_id), INDEX IDX_9407E54977FA751A (parent_object_identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_object_identity_ancestors (object_identity_id INT UNSIGNED NOT NULL, ancestor_id INT UNSIGNED NOT NULL, INDEX IDX_825DE2993D9AB4A6 (object_identity_id), INDEX IDX_825DE299C671CEA1 (ancestor_id), PRIMARY KEY(object_identity_id, ancestor_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB - -CREATE TABLE acl_entries (id INT UNSIGNED AUTO_INCREMENT NOT NULL, class_id INT UNSIGNED NOT NULL, object_identity_id INT UNSIGNED DEFAULT NULL, security_identity_id INT UNSIGNED NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order SMALLINT UNSIGNED NOT NULL, mask INT NOT NULL, granting TINYINT(1) NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success TINYINT(1) NOT NULL, audit_failure TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 (class_id, object_identity_id, field_name, ace_order), INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 (class_id, object_identity_id, security_identity_id), INDEX IDX_46C8B806EA000B10 (class_id), INDEX IDX_46C8B8063D9AB4A6 (object_identity_id), INDEX IDX_46C8B806DF9183C9 (security_identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/oracle.sql b/src/Symfony/Component/Security/Acl/Resources/schema/oracle.sql deleted file mode 100644 index 94821dc988745..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/oracle.sql +++ /dev/null @@ -1,175 +0,0 @@ -CREATE TABLE acl_classes (id NUMBER(10) NOT NULL, class_type VARCHAR2(200) NOT NULL, PRIMARY KEY(id)) - -DECLARE - constraints_Count NUMBER; -BEGIN - SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_CLASSES' AND CONSTRAINT_TYPE = 'P'; - IF constraints_Count = 0 OR constraints_Count = '' THEN - EXECUTE IMMEDIATE 'ALTER TABLE ACL_CLASSES ADD CONSTRAINT ACL_CLASSES_AI_PK PRIMARY KEY (ID)'; - END IF; -END; - -CREATE SEQUENCE ACL_CLASSES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 - -CREATE TRIGGER ACL_CLASSES_AI_PK - BEFORE INSERT - ON ACL_CLASSES - FOR EACH ROW -DECLARE - last_Sequence NUMBER; - last_InsertID NUMBER; -BEGIN - SELECT ACL_CLASSES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN - SELECT ACL_CLASSES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - ELSE - SELECT NVL(Last_Number, 0) INTO last_Sequence - FROM User_Sequences - WHERE Sequence_Name = 'ACL_CLASSES_SEQ'; - SELECT :NEW.ID INTO last_InsertID FROM DUAL; - WHILE (last_InsertID > last_Sequence) LOOP - SELECT ACL_CLASSES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; - END LOOP; - END IF; -END; - -CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type) - -CREATE TABLE acl_security_identities (id NUMBER(10) NOT NULL, identifier VARCHAR2(200) NOT NULL, username NUMBER(1) NOT NULL, PRIMARY KEY(id)) - -DECLARE - constraints_Count NUMBER; -BEGIN - SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_SECURITY_IDENTITIES' AND CONSTRAINT_TYPE = 'P'; - IF constraints_Count = 0 OR constraints_Count = '' THEN - EXECUTE IMMEDIATE 'ALTER TABLE ACL_SECURITY_IDENTITIES ADD CONSTRAINT ACL_SECURITY_IDENTITIES_AI_PK PRIMARY KEY (ID)'; - END IF; -END; - -CREATE SEQUENCE ACL_SECURITY_IDENTITIES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 - -CREATE TRIGGER ACL_SECURITY_IDENTITIES_AI_PK - BEFORE INSERT - ON ACL_SECURITY_IDENTITIES - FOR EACH ROW -DECLARE - last_Sequence NUMBER; - last_InsertID NUMBER; -BEGIN - SELECT ACL_SECURITY_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN - SELECT ACL_SECURITY_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - ELSE - SELECT NVL(Last_Number, 0) INTO last_Sequence - FROM User_Sequences - WHERE Sequence_Name = 'ACL_SECURITY_IDENTITIES_SEQ'; - SELECT :NEW.ID INTO last_InsertID FROM DUAL; - WHILE (last_InsertID > last_Sequence) LOOP - SELECT ACL_SECURITY_IDENTITIES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; - END LOOP; - END IF; -END; - -CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username) - -CREATE TABLE acl_object_identities (id NUMBER(10) NOT NULL, parent_object_identity_id NUMBER(10) DEFAULT NULL NULL, class_id NUMBER(10) NOT NULL, object_identifier VARCHAR2(100) NOT NULL, entries_inheriting NUMBER(1) NOT NULL, PRIMARY KEY(id)) - -DECLARE - constraints_Count NUMBER; -BEGIN - SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_OBJECT_IDENTITIES' AND CONSTRAINT_TYPE = 'P'; - IF constraints_Count = 0 OR constraints_Count = '' THEN - EXECUTE IMMEDIATE 'ALTER TABLE ACL_OBJECT_IDENTITIES ADD CONSTRAINT ACL_OBJECT_IDENTITIES_AI_PK PRIMARY KEY (ID)'; - END IF; -END; - -CREATE SEQUENCE ACL_OBJECT_IDENTITIES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 - -CREATE TRIGGER ACL_OBJECT_IDENTITIES_AI_PK - BEFORE INSERT - ON ACL_OBJECT_IDENTITIES - FOR EACH ROW -DECLARE - last_Sequence NUMBER; - last_InsertID NUMBER; -BEGIN - SELECT ACL_OBJECT_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN - SELECT ACL_OBJECT_IDENTITIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - ELSE - SELECT NVL(Last_Number, 0) INTO last_Sequence - FROM User_Sequences - WHERE Sequence_Name = 'ACL_OBJECT_IDENTITIES_SEQ'; - SELECT :NEW.ID INTO last_InsertID FROM DUAL; - WHILE (last_InsertID > last_Sequence) LOOP - SELECT ACL_OBJECT_IDENTITIES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; - END LOOP; - END IF; -END; - -CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id) - -CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id) - -CREATE TABLE acl_object_identity_ancestors (object_identity_id NUMBER(10) NOT NULL, ancestor_id NUMBER(10) NOT NULL, PRIMARY KEY(object_identity_id, ancestor_id)) - -CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id) - -CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id) - -CREATE TABLE acl_entries (id NUMBER(10) NOT NULL, class_id NUMBER(10) NOT NULL, object_identity_id NUMBER(10) DEFAULT NULL NULL, security_identity_id NUMBER(10) NOT NULL, field_name VARCHAR2(50) DEFAULT NULL NULL, ace_order NUMBER(5) NOT NULL, mask NUMBER(10) NOT NULL, granting NUMBER(1) NOT NULL, granting_strategy VARCHAR2(30) NOT NULL, audit_success NUMBER(1) NOT NULL, audit_failure NUMBER(1) NOT NULL, PRIMARY KEY(id)) - -DECLARE - constraints_Count NUMBER; -BEGIN - SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'ACL_ENTRIES' AND CONSTRAINT_TYPE = 'P'; - IF constraints_Count = 0 OR constraints_Count = '' THEN - EXECUTE IMMEDIATE 'ALTER TABLE ACL_ENTRIES ADD CONSTRAINT ACL_ENTRIES_AI_PK PRIMARY KEY (ID)'; - END IF; -END; - -CREATE SEQUENCE ACL_ENTRIES_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 - -CREATE TRIGGER ACL_ENTRIES_AI_PK - BEFORE INSERT - ON ACL_ENTRIES - FOR EACH ROW -DECLARE - last_Sequence NUMBER; - last_InsertID NUMBER; -BEGIN - SELECT ACL_ENTRIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - IF (:NEW.ID IS NULL OR :NEW.ID = 0) THEN - SELECT ACL_ENTRIES_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - ELSE - SELECT NVL(Last_Number, 0) INTO last_Sequence - FROM User_Sequences - WHERE Sequence_Name = 'ACL_ENTRIES_SEQ'; - SELECT :NEW.ID INTO last_InsertID FROM DUAL; - WHILE (last_InsertID > last_Sequence) LOOP - SELECT ACL_ENTRIES_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; - END LOOP; - END IF; -END; - -CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order) - -CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id) - -CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id) - -CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id) - -CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id) - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON DELETE CASCADE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/postgresql.sql b/src/Symfony/Component/Security/Acl/Resources/schema/postgresql.sql deleted file mode 100644 index 05ca43977d0ec..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/postgresql.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE acl_classes (id SERIAL NOT NULL, class_type VARCHAR(200) NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type) - -CREATE TABLE acl_security_identities (id SERIAL NOT NULL, identifier VARCHAR(200) NOT NULL, username BOOLEAN NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username) - -CREATE TABLE acl_object_identities (id SERIAL NOT NULL, parent_object_identity_id INT DEFAULT NULL, class_id INT NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting BOOLEAN NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id) - -CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id) - -CREATE TABLE acl_object_identity_ancestors (object_identity_id INT NOT NULL, ancestor_id INT NOT NULL, PRIMARY KEY(object_identity_id, ancestor_id)) - -CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id) - -CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id) - -CREATE TABLE acl_entries (id SERIAL NOT NULL, class_id INT NOT NULL, object_identity_id INT DEFAULT NULL, security_identity_id INT NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order SMALLINT NOT NULL, mask INT NOT NULL, granting BOOLEAN NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success BOOLEAN NOT NULL, audit_failure BOOLEAN NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order) - -CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id) - -CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id) - -CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id) - -CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id) - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) NOT DEFERRABLE INITIALLY IMMEDIATE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/sqlanywhere.sql b/src/Symfony/Component/Security/Acl/Resources/schema/sqlanywhere.sql deleted file mode 100644 index d73b102ce0af6..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/sqlanywhere.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE acl_classes (id UNSIGNED INT IDENTITY NOT NULL, class_type VARCHAR(200) NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type) - -CREATE TABLE acl_security_identities (id UNSIGNED INT IDENTITY NOT NULL, identifier VARCHAR(200) NOT NULL, username BIT NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username) - -CREATE TABLE acl_object_identities (id UNSIGNED INT IDENTITY NOT NULL, parent_object_identity_id UNSIGNED INT DEFAULT NULL, class_id UNSIGNED INT NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting BIT NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id) - -CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id) - -CREATE TABLE acl_object_identity_ancestors (object_identity_id UNSIGNED INT NOT NULL, ancestor_id UNSIGNED INT NOT NULL, PRIMARY KEY (object_identity_id, ancestor_id)) - -CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id) - -CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id) - -CREATE TABLE acl_entries (id UNSIGNED INT IDENTITY NOT NULL, class_id UNSIGNED INT NOT NULL, object_identity_id UNSIGNED INT DEFAULT NULL, security_identity_id UNSIGNED INT NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order UNSIGNED SMALLINT NOT NULL, mask INT NOT NULL, granting BIT NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success BIT NOT NULL, audit_failure BIT NOT NULL, PRIMARY KEY (id)) - -CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order) - -CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id) - -CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id) - -CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id) - -CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id) - -ALTER TABLE acl_object_identities ADD CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_object_identity_ancestors ADD CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON UPDATE CASCADE ON DELETE CASCADE - -ALTER TABLE acl_entries ADD CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON UPDATE CASCADE ON DELETE CASCADE \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Resources/schema/sqlite.sql b/src/Symfony/Component/Security/Acl/Resources/schema/sqlite.sql deleted file mode 100644 index 4429bfa888b4d..0000000000000 --- a/src/Symfony/Component/Security/Acl/Resources/schema/sqlite.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE acl_classes (id INTEGER NOT NULL, class_type VARCHAR(200) NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_69DD750638A36066 ON acl_classes (class_type) - -CREATE TABLE acl_security_identities (id INTEGER NOT NULL, identifier VARCHAR(200) NOT NULL, username BOOLEAN NOT NULL, PRIMARY KEY(id)) - -CREATE UNIQUE INDEX UNIQ_8835EE78772E836AF85E0677 ON acl_security_identities (identifier, username) - -CREATE TABLE acl_object_identities (id INTEGER NOT NULL, parent_object_identity_id INTEGER UNSIGNED DEFAULT NULL, class_id INTEGER UNSIGNED NOT NULL, object_identifier VARCHAR(100) NOT NULL, entries_inheriting BOOLEAN NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_9407E54977FA751A FOREIGN KEY (parent_object_identity_id) REFERENCES acl_object_identities (id) NOT DEFERRABLE INITIALLY IMMEDIATE) - -CREATE UNIQUE INDEX UNIQ_9407E5494B12AD6EA000B10 ON acl_object_identities (object_identifier, class_id) - -CREATE INDEX IDX_9407E54977FA751A ON acl_object_identities (parent_object_identity_id) - -CREATE TABLE acl_object_identity_ancestors (object_identity_id INTEGER UNSIGNED NOT NULL, ancestor_id INTEGER UNSIGNED NOT NULL, PRIMARY KEY(object_identity_id, ancestor_id), CONSTRAINT FK_825DE2993D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_825DE299C671CEA1 FOREIGN KEY (ancestor_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE) - -CREATE INDEX IDX_825DE2993D9AB4A6 ON acl_object_identity_ancestors (object_identity_id) - -CREATE INDEX IDX_825DE299C671CEA1 ON acl_object_identity_ancestors (ancestor_id) - -CREATE TABLE acl_entries (id INTEGER NOT NULL, class_id INTEGER UNSIGNED NOT NULL, object_identity_id INTEGER UNSIGNED DEFAULT NULL, security_identity_id INTEGER UNSIGNED NOT NULL, field_name VARCHAR(50) DEFAULT NULL, ace_order SMALLINT UNSIGNED NOT NULL, mask INTEGER NOT NULL, granting BOOLEAN NOT NULL, granting_strategy VARCHAR(30) NOT NULL, audit_success BOOLEAN NOT NULL, audit_failure BOOLEAN NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_46C8B806EA000B10 FOREIGN KEY (class_id) REFERENCES acl_classes (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_46C8B8063D9AB4A6 FOREIGN KEY (object_identity_id) REFERENCES acl_object_identities (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_46C8B806DF9183C9 FOREIGN KEY (security_identity_id) REFERENCES acl_security_identities (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE) - -CREATE UNIQUE INDEX UNIQ_46C8B806EA000B103D9AB4A64DEF17BCE4289BF4 ON acl_entries (class_id, object_identity_id, field_name, ace_order) - -CREATE INDEX IDX_46C8B806EA000B103D9AB4A6DF9183C9 ON acl_entries (class_id, object_identity_id, security_identity_id) - -CREATE INDEX IDX_46C8B806EA000B10 ON acl_entries (class_id) - -CREATE INDEX IDX_46C8B8063D9AB4A6 ON acl_entries (object_identity_id) - -CREATE INDEX IDX_46C8B806DF9183C9 ON acl_entries (security_identity_id) \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php b/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php deleted file mode 100644 index c95b474dca030..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php +++ /dev/null @@ -1,267 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Dbal; - -use Symfony\Component\Security\Acl\Dbal\AclProvider; -use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Acl\Dbal\Schema; -use Doctrine\DBAL\DriverManager; - -/** - * @group benchmark - */ -class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Doctrine\DBAL\Connection */ - protected $con; - protected $insertClassStmt; - protected $insertSidStmt; - protected $insertOidAncestorStmt; - protected $insertOidStmt; - protected $insertEntryStmt; - - protected function setUp() - { - try { - $this->con = DriverManager::getConnection(array( - 'driver' => 'pdo_mysql', - 'host' => 'localhost', - 'user' => 'root', - 'dbname' => 'testdb', - )); - $this->con->connect(); - } catch (\Exception $e) { - $this->markTestSkipped('Unable to connect to the database: '.$e->getMessage()); - } - } - - protected function tearDown() - { - $this->con = null; - } - - public function testFindAcls() - { - // $this->generateTestData(); - - // get some random test object identities from the database - $oids = array(); - $stmt = $this->con->executeQuery('SELECT object_identifier, class_type FROM acl_object_identities o INNER JOIN acl_classes c ON c.id = o.class_id ORDER BY RAND() LIMIT 25'); - foreach ($stmt->fetchAll() as $oid) { - $oids[] = new ObjectIdentity($oid['object_identifier'], $oid['class_type']); - } - - $provider = $this->getProvider(); - - $start = microtime(true); - $provider->findAcls($oids); - $time = microtime(true) - $start; - echo 'Total Time: '.$time."s\n"; - } - - /** - * This generates a huge amount of test data to be used mainly for benchmarking - * purposes, not so much for testing. That's why it's not called by default. - */ - protected function generateTestData() - { - $sm = $this->con->getSchemaManager(); - $sm->dropAndCreateDatabase('testdb'); - $this->con->exec('USE testdb'); - - // import the schema - $schema = new Schema($options = $this->getOptions()); - foreach ($schema->toSql($this->con->getDatabasePlatform()) as $sql) { - $this->con->exec($sql); - } - - // setup prepared statements - $this->insertClassStmt = $this->con->prepare('INSERT INTO acl_classes (id, class_type) VALUES (?, ?)'); - $this->insertSidStmt = $this->con->prepare('INSERT INTO acl_security_identities (id, identifier, username) VALUES (?, ?, ?)'); - $this->insertOidStmt = $this->con->prepare('INSERT INTO acl_object_identities (id, class_id, object_identifier, parent_object_identity_id, entries_inheriting) VALUES (?, ?, ?, ?, ?)'); - $this->insertEntryStmt = $this->con->prepare('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); - $this->insertOidAncestorStmt = $this->con->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)'); - - for ($i = 0; $i < 40000; ++$i) { - $this->generateAclHierarchy(); - } - } - - protected function generateAclHierarchy() - { - $rootId = $this->generateAcl($this->chooseClassId(), null, array()); - - $this->generateAclLevel(rand(1, 15), $rootId, array($rootId)); - } - - protected function generateAclLevel($depth, $parentId, $ancestors) - { - $level = count($ancestors); - for ($i = 0, $t = rand(1, 10); $i < $t; ++$i) { - $id = $this->generateAcl($this->chooseClassId(), $parentId, $ancestors); - - if ($level < $depth) { - $this->generateAclLevel($depth, $id, array_merge($ancestors, array($id))); - } - } - } - - protected function chooseClassId() - { - static $id = 1000; - - if ($id === 1000 || ($id < 1500 && rand(0, 1))) { - $this->insertClassStmt->execute(array($id, $this->getRandomString(rand(20, 100), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\_'))); - ++$id; - - return $id - 1; - } else { - return rand(1000, $id - 1); - } - } - - protected function generateAcl($classId, $parentId, $ancestors) - { - static $id = 1000; - - $this->insertOidStmt->execute(array( - $id, - $classId, - $this->getRandomString(rand(20, 50)), - $parentId, - rand(0, 1), - )); - - $this->insertOidAncestorStmt->execute(array($id, $id)); - foreach ($ancestors as $ancestor) { - $this->insertOidAncestorStmt->execute(array($id, $ancestor)); - } - - $this->generateAces($classId, $id); - ++$id; - - return $id - 1; - } - - protected function chooseSid() - { - static $id = 1000; - - if ($id === 1000 || ($id < 11000 && rand(0, 1))) { - $this->insertSidStmt->execute(array( - $id, - $this->getRandomString(rand(5, 30)), - rand(0, 1), - )); - ++$id; - - return $id - 1; - } else { - return rand(1000, $id - 1); - } - } - - protected function generateAces($classId, $objectId) - { - static $id = 1000; - - $sids = array(); - $fieldOrder = array(); - - for ($i = 0; $i <= 30; ++$i) { - $fieldName = rand(0, 1) ? null : $this->getRandomString(rand(10, 20)); - - do { - $sid = $this->chooseSid(); - } while (array_key_exists($sid, $sids) && in_array($fieldName, $sids[$sid], true)); - - $fieldOrder[$fieldName] = array_key_exists($fieldName, $fieldOrder) ? $fieldOrder[$fieldName] + 1 : 0; - if (!isset($sids[$sid])) { - $sids[$sid] = array(); - } - $sids[$sid][] = $fieldName; - - $strategy = rand(0, 2); - if ($strategy === 0) { - $strategy = PermissionGrantingStrategy::ALL; - } elseif ($strategy === 1) { - $strategy = PermissionGrantingStrategy::ANY; - } else { - $strategy = PermissionGrantingStrategy::EQUAL; - } - - // id, cid, oid, field, order, sid, mask, granting, strategy, a success, a failure - $this->insertEntryStmt->execute(array( - $id, - $classId, - rand(0, 5) ? $objectId : null, - $fieldName, - $fieldOrder[$fieldName], - $sid, - $this->generateMask(), - rand(0, 1), - $strategy, - rand(0, 1), - rand(0, 1), - )); - - ++$id; - } - } - - protected function generateMask() - { - $i = rand(1, 30); - $mask = 0; - - while ($i <= 30) { - $mask |= 1 << rand(0, 30); - ++$i; - } - - return $mask; - } - - protected function getRandomString($length, $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') - { - $s = ''; - $cLength = strlen($chars); - - while (strlen($s) < $length) { - $s .= $chars[mt_rand(0, $cLength - 1)]; - } - - return $s; - } - - protected function getOptions() - { - return array( - 'oid_table_name' => 'acl_object_identities', - 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', - 'class_table_name' => 'acl_classes', - 'sid_table_name' => 'acl_security_identities', - 'entry_table_name' => 'acl_entries', - ); - } - - protected function getStrategy() - { - return new PermissionGrantingStrategy(); - } - - protected function getProvider() - { - return new AclProvider($this->con, $this->getStrategy(), $this->getOptions()); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderTest.php b/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderTest.php deleted file mode 100644 index becfb511ca549..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderTest.php +++ /dev/null @@ -1,281 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Dbal; - -use Symfony\Component\Security\Acl\Dbal\AclProvider; -use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Acl\Dbal\Schema; -use Doctrine\DBAL\DriverManager; - -class AclProviderTest extends \PHPUnit_Framework_TestCase -{ - protected $con; - protected $insertClassStmt; - protected $insertEntryStmt; - protected $insertOidStmt; - protected $insertOidAncestorStmt; - protected $insertSidStmt; - - /** - * @expectedException \Symfony\Component\Security\Acl\Exception\AclNotFoundException - * @expectedMessage There is no ACL for the given object identity. - */ - public function testFindAclThrowsExceptionWhenNoAclExists() - { - $this->getProvider()->findAcl(new ObjectIdentity('foo', 'foo')); - } - - public function testFindAclsThrowsExceptionUnlessAnACLIsFoundForEveryOID() - { - $oids = array(); - $oids[] = new ObjectIdentity('1', 'foo'); - $oids[] = new ObjectIdentity('foo', 'foo'); - - try { - $this->getProvider()->findAcls($oids); - - $this->fail('Provider did not throw an expected exception.'); - } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Security\Acl\Exception\AclNotFoundException', $e); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Exception\NotAllAclsFoundException', $e); - - $partialResult = $e->getPartialResult(); - $this->assertTrue($partialResult->contains($oids[0])); - $this->assertFalse($partialResult->contains($oids[1])); - } - } - - public function testFindAcls() - { - $oids = array(); - $oids[] = new ObjectIdentity('1', 'foo'); - $oids[] = new ObjectIdentity('2', 'foo'); - - $provider = $this->getProvider(); - - $acls = $provider->findAcls($oids); - $this->assertInstanceOf('SplObjectStorage', $acls); - $this->assertCount(2, $acls); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl0 = $acls->offsetGet($oids[0])); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl1 = $acls->offsetGet($oids[1])); - $this->assertTrue($oids[0]->equals($acl0->getObjectIdentity())); - $this->assertTrue($oids[1]->equals($acl1->getObjectIdentity())); - } - - public function testFindAclsWithDifferentTypes() - { - $oids = array(); - $oids[] = new ObjectIdentity('123', 'Bundle\SomeVendor\MyBundle\Entity\SomeEntity'); - $oids[] = new ObjectIdentity('123', 'Bundle\MyBundle\Entity\AnotherEntity'); - - $provider = $this->getProvider(); - - $acls = $provider->findAcls($oids); - $this->assertInstanceOf('SplObjectStorage', $acls); - $this->assertCount(2, $acls); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl0 = $acls->offsetGet($oids[0])); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl1 = $acls->offsetGet($oids[1])); - $this->assertTrue($oids[0]->equals($acl0->getObjectIdentity())); - $this->assertTrue($oids[1]->equals($acl1->getObjectIdentity())); - } - - public function testFindAclCachesAclInMemory() - { - $oid = new ObjectIdentity('1', 'foo'); - $provider = $this->getProvider(); - - $acl = $provider->findAcl($oid); - $this->assertSame($acl, $cAcl = $provider->findAcl($oid)); - - $cAces = $cAcl->getObjectAces(); - foreach ($acl->getObjectAces() as $index => $ace) { - $this->assertSame($ace, $cAces[$index]); - } - } - - public function testFindAcl() - { - $oid = new ObjectIdentity('1', 'foo'); - $provider = $this->getProvider(); - - $acl = $provider->findAcl($oid); - - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl); - $this->assertTrue($oid->equals($acl->getObjectIdentity())); - $this->assertEquals(4, $acl->getId()); - $this->assertCount(0, $acl->getClassAces()); - $this->assertCount(0, $this->getField($acl, 'classFieldAces')); - $this->assertCount(3, $acl->getObjectAces()); - $this->assertCount(0, $this->getField($acl, 'objectFieldAces')); - - $aces = $acl->getObjectAces(); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Entry', $aces[0]); - $this->assertTrue($aces[0]->isGranting()); - $this->assertTrue($aces[0]->isAuditSuccess()); - $this->assertTrue($aces[0]->isAuditFailure()); - $this->assertEquals('all', $aces[0]->getStrategy()); - $this->assertSame(2, $aces[0]->getMask()); - - // check ACE are in correct order - $i = 0; - foreach ($aces as $index => $ace) { - $this->assertEquals($i, $index); - ++$i; - } - - $sid = $aces[0]->getSecurityIdentity(); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\UserSecurityIdentity', $sid); - $this->assertEquals('john.doe', $sid->getUsername()); - $this->assertEquals('SomeClass', $sid->getClass()); - } - - protected function setUp() - { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - self::markTestSkipped('This test requires SQLite support in your environment'); - } - - $this->con = DriverManager::getConnection(array( - 'driver' => 'pdo_sqlite', - 'memory' => true, - )); - - // import the schema - $schema = new Schema($options = $this->getOptions()); - foreach ($schema->toSql($this->con->getDatabasePlatform()) as $sql) { - $this->con->exec($sql); - } - - // populate the schema with some test data - $this->insertClassStmt = $this->con->prepare('INSERT INTO acl_classes (id, class_type) VALUES (?, ?)'); - foreach ($this->getClassData() as $data) { - $this->insertClassStmt->execute($data); - } - - $this->insertSidStmt = $this->con->prepare('INSERT INTO acl_security_identities (id, identifier, username) VALUES (?, ?, ?)'); - foreach ($this->getSidData() as $data) { - $this->insertSidStmt->execute($data); - } - - $this->insertOidStmt = $this->con->prepare('INSERT INTO acl_object_identities (id, class_id, object_identifier, parent_object_identity_id, entries_inheriting) VALUES (?, ?, ?, ?, ?)'); - foreach ($this->getOidData() as $data) { - $this->insertOidStmt->execute($data); - } - - $this->insertEntryStmt = $this->con->prepare('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); - foreach ($this->getEntryData() as $data) { - $this->insertEntryStmt->execute($data); - } - - $this->insertOidAncestorStmt = $this->con->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)'); - foreach ($this->getOidAncestorData() as $data) { - $this->insertOidAncestorStmt->execute($data); - } - } - - protected function tearDown() - { - $this->con = null; - } - - protected function getField($object, $field) - { - $reflection = new \ReflectionProperty($object, $field); - $reflection->setAccessible(true); - - return $reflection->getValue($object); - } - - protected function getEntryData() - { - // id, cid, oid, field, order, sid, mask, granting, strategy, a success, a failure - return array( - array(1, 1, 1, null, 0, 1, 1, 1, 'all', 1, 1), - array(2, 1, 1, null, 1, 2, 1 << 2 | 1 << 1, 0, 'any', 0, 0), - array(3, 3, 4, null, 0, 1, 2, 1, 'all', 1, 1), - array(4, 3, 4, null, 2, 2, 1, 1, 'all', 1, 1), - array(5, 3, 4, null, 1, 3, 1, 1, 'all', 1, 1), - ); - } - - protected function getOidData() - { - // id, cid, oid, parent_oid, entries_inheriting - return array( - array(1, 1, '123', null, 1), - array(2, 2, '123', 1, 1), - array(3, 2, 'i:3:123', 1, 1), - array(4, 3, '1', 2, 1), - array(5, 3, '2', 2, 1), - ); - } - - protected function getOidAncestorData() - { - return array( - array(1, 1), - array(2, 1), - array(2, 2), - array(3, 1), - array(3, 3), - array(4, 2), - array(4, 1), - array(4, 4), - array(5, 2), - array(5, 1), - array(5, 5), - ); - } - - protected function getSidData() - { - return array( - array(1, 'SomeClass-john.doe', 1), - array(2, 'MyClass-john.doe@foo.com', 1), - array(3, 'FooClass-123', 1), - array(4, 'MooClass-ROLE_USER', 1), - array(5, 'ROLE_USER', 0), - array(6, 'IS_AUTHENTICATED_FULLY', 0), - ); - } - - protected function getClassData() - { - return array( - array(1, 'Bundle\SomeVendor\MyBundle\Entity\SomeEntity'), - array(2, 'Bundle\MyBundle\Entity\AnotherEntity'), - array(3, 'foo'), - ); - } - - protected function getOptions() - { - return array( - 'oid_table_name' => 'acl_object_identities', - 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', - 'class_table_name' => 'acl_classes', - 'sid_table_name' => 'acl_security_identities', - 'entry_table_name' => 'acl_entries', - ); - } - - protected function getStrategy() - { - return new PermissionGrantingStrategy(); - } - - protected function getProvider() - { - return new AclProvider($this->con, $this->getStrategy(), $this->getOptions()); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php b/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php deleted file mode 100644 index 37e1d772e3155..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php +++ /dev/null @@ -1,573 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Dbal; - -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Model\FieldEntryInterface; -use Symfony\Component\Security\Acl\Model\AuditableEntryInterface; -use Symfony\Component\Security\Acl\Model\EntryInterface; -use Symfony\Component\Security\Acl\Domain\Entry; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\Acl; -use Symfony\Component\Security\Acl\Exception\AclNotFoundException; -use Symfony\Component\Security\Acl\Exception\ConcurrentModificationException; -use Symfony\Component\Security\Acl\Dbal\AclProvider; -use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy; -use Symfony\Component\Security\Acl\Dbal\MutableAclProvider; -use Symfony\Component\Security\Acl\Dbal\Schema; -use Doctrine\DBAL\DriverManager; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; - -class MutableAclProviderTest extends \PHPUnit_Framework_TestCase -{ - protected $con; - - public static function assertAceEquals(EntryInterface $a, EntryInterface $b) - { - self::assertInstanceOf(get_class($a), $b); - - foreach (array('getId', 'getMask', 'getStrategy', 'isGranting') as $getter) { - self::assertSame($a->$getter(), $b->$getter()); - } - - self::assertTrue($a->getSecurityIdentity()->equals($b->getSecurityIdentity())); - self::assertSame($a->getAcl()->getId(), $b->getAcl()->getId()); - - if ($a instanceof AuditableEntryInterface) { - self::assertSame($a->isAuditSuccess(), $b->isAuditSuccess()); - self::assertSame($a->isAuditFailure(), $b->isAuditFailure()); - } - - if ($a instanceof FieldEntryInterface) { - self::assertSame($a->getField(), $b->getField()); - } - } - - /** - * @expectedException \Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException - */ - public function testCreateAclThrowsExceptionWhenAclAlreadyExists() - { - $provider = $this->getProvider(); - $oid = new ObjectIdentity('123456', 'FOO'); - $provider->createAcl($oid); - $provider->createAcl($oid); - } - - public function testCreateAcl() - { - $provider = $this->getProvider(); - $oid = new ObjectIdentity('123456', 'FOO'); - $acl = $provider->createAcl($oid); - $cachedAcl = $provider->findAcl($oid); - - $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl); - $this->assertSame($acl, $cachedAcl); - $this->assertTrue($acl->getObjectIdentity()->equals($oid)); - } - - public function testDeleteAcl() - { - $provider = $this->getProvider(); - $oid = new ObjectIdentity(1, 'Foo'); - $acl = $provider->createAcl($oid); - - $provider->deleteAcl($oid); - $loadedAcls = $this->getField($provider, 'loadedAcls'); - $this->assertCount(0, $loadedAcls['Foo']); - - try { - $provider->findAcl($oid); - $this->fail('ACL has not been properly deleted.'); - } catch (AclNotFoundException $e) { - } - } - - public function testDeleteAclDeletesChildren() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $parentAcl = $provider->createAcl(new ObjectIdentity(2, 'Foo')); - $acl->setParentAcl($parentAcl); - $provider->updateAcl($acl); - $provider->deleteAcl($parentAcl->getObjectIdentity()); - - try { - $provider->findAcl(new ObjectIdentity(1, 'Foo')); - $this->fail('Child-ACLs have not been deleted.'); - } catch (AclNotFoundException $e) { - } - } - - public function testFindAclsAddsPropertyListener() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - - $propertyChanges = $this->getField($provider, 'propertyChanges'); - $this->assertCount(1, $propertyChanges); - $this->assertTrue($propertyChanges->contains($acl)); - $this->assertEquals(array(), $propertyChanges->offsetGet($acl)); - - $listeners = $this->getField($acl, 'listeners'); - $this->assertSame($provider, $listeners[0]); - } - - public function testFindAclsAddsPropertyListenerOnlyOnce() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $acl = $provider->findAcl(new ObjectIdentity(1, 'Foo')); - - $propertyChanges = $this->getField($provider, 'propertyChanges'); - $this->assertCount(1, $propertyChanges); - $this->assertTrue($propertyChanges->contains($acl)); - $this->assertEquals(array(), $propertyChanges->offsetGet($acl)); - - $listeners = $this->getField($acl, 'listeners'); - $this->assertCount(1, $listeners); - $this->assertSame($provider, $listeners[0]); - } - - public function testFindAclsAddsPropertyListenerToParentAcls() - { - $provider = $this->getProvider(); - $this->importAcls($provider, array( - 'main' => array( - 'object_identifier' => '1', - 'class_type' => 'foo', - 'parent_acl' => 'parent', - ), - 'parent' => array( - 'object_identifier' => '1', - 'class_type' => 'anotherFoo', - ), - )); - - $propertyChanges = $this->getField($provider, 'propertyChanges'); - $this->assertCount(0, $propertyChanges); - - $acl = $provider->findAcl(new ObjectIdentity('1', 'foo')); - $this->assertCount(2, $propertyChanges); - $this->assertTrue($propertyChanges->contains($acl)); - $this->assertTrue($propertyChanges->contains($acl->getParentAcl())); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testPropertyChangedDoesNotTrackUnmanagedAcls() - { - $provider = $this->getProvider(); - $acl = new Acl(1, new ObjectIdentity(1, 'foo'), new PermissionGrantingStrategy(), array(), false); - - $provider->propertyChanged($acl, 'classAces', array(), array('foo')); - } - - public function testPropertyChangedTracksChangesToAclProperties() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $propertyChanges = $this->getField($provider, 'propertyChanges'); - - $provider->propertyChanged($acl, 'entriesInheriting', false, true); - $changes = $propertyChanges->offsetGet($acl); - $this->assertTrue(isset($changes['entriesInheriting'])); - $this->assertFalse($changes['entriesInheriting'][0]); - $this->assertTrue($changes['entriesInheriting'][1]); - - $provider->propertyChanged($acl, 'entriesInheriting', true, false); - $provider->propertyChanged($acl, 'entriesInheriting', false, true); - $provider->propertyChanged($acl, 'entriesInheriting', true, false); - $changes = $propertyChanges->offsetGet($acl); - $this->assertFalse(isset($changes['entriesInheriting'])); - } - - public function testPropertyChangedTracksChangesToAceProperties() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $ace = new Entry(1, $acl, new UserSecurityIdentity('foo', 'FooClass'), 'all', 1, true, true, true); - $ace2 = new Entry(2, $acl, new UserSecurityIdentity('foo', 'FooClass'), 'all', 1, true, true, true); - $propertyChanges = $this->getField($provider, 'propertyChanges'); - - $provider->propertyChanged($ace, 'mask', 1, 3); - $changes = $propertyChanges->offsetGet($acl); - $this->assertTrue(isset($changes['aces'])); - $this->assertInstanceOf('\SplObjectStorage', $changes['aces']); - $this->assertTrue($changes['aces']->contains($ace)); - $aceChanges = $changes['aces']->offsetGet($ace); - $this->assertTrue(isset($aceChanges['mask'])); - $this->assertEquals(1, $aceChanges['mask'][0]); - $this->assertEquals(3, $aceChanges['mask'][1]); - - $provider->propertyChanged($ace, 'strategy', 'all', 'any'); - $changes = $propertyChanges->offsetGet($acl); - $this->assertTrue(isset($changes['aces'])); - $this->assertInstanceOf('\SplObjectStorage', $changes['aces']); - $this->assertTrue($changes['aces']->contains($ace)); - $aceChanges = $changes['aces']->offsetGet($ace); - $this->assertTrue(isset($aceChanges['mask'])); - $this->assertTrue(isset($aceChanges['strategy'])); - $this->assertEquals('all', $aceChanges['strategy'][0]); - $this->assertEquals('any', $aceChanges['strategy'][1]); - - $provider->propertyChanged($ace, 'mask', 3, 1); - $changes = $propertyChanges->offsetGet($acl); - $aceChanges = $changes['aces']->offsetGet($ace); - $this->assertFalse(isset($aceChanges['mask'])); - $this->assertTrue(isset($aceChanges['strategy'])); - - $provider->propertyChanged($ace2, 'mask', 1, 3); - $provider->propertyChanged($ace, 'strategy', 'any', 'all'); - $changes = $propertyChanges->offsetGet($acl); - $this->assertTrue(isset($changes['aces'])); - $this->assertFalse($changes['aces']->contains($ace)); - $this->assertTrue($changes['aces']->contains($ace2)); - - $provider->propertyChanged($ace2, 'mask', 3, 4); - $provider->propertyChanged($ace2, 'mask', 4, 1); - $changes = $propertyChanges->offsetGet($acl); - $this->assertFalse(isset($changes['aces'])); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testUpdateAclDoesNotAcceptUntrackedAcls() - { - $provider = $this->getProvider(); - $acl = new Acl(1, new ObjectIdentity(1, 'Foo'), new PermissionGrantingStrategy(), array(), true); - $provider->updateAcl($acl); - } - - public function testUpdateDoesNothingWhenThereAreNoChanges() - { - $con = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - $con - ->expects($this->never()) - ->method('beginTransaction') - ; - $con - ->expects($this->never()) - ->method('executeQuery') - ; - - $provider = new MutableAclProvider($con, new PermissionGrantingStrategy(), array()); - $acl = new Acl(1, new ObjectIdentity(1, 'Foo'), new PermissionGrantingStrategy(), array(), true); - $propertyChanges = $this->getField($provider, 'propertyChanges'); - $propertyChanges->offsetSet($acl, array()); - $provider->updateAcl($acl); - } - - public function testUpdateAclThrowsExceptionOnConcurrentModificationOfSharedProperties() - { - $provider = $this->getProvider(); - $acl1 = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $acl2 = $provider->createAcl(new ObjectIdentity(2, 'Foo')); - $acl3 = $provider->createAcl(new ObjectIdentity(1, 'AnotherFoo')); - $sid = new RoleSecurityIdentity('ROLE_FOO'); - - $acl1->insertClassAce($sid, 1); - $acl3->insertClassAce($sid, 1); - $provider->updateAcl($acl1); - $provider->updateAcl($acl3); - - $acl2->insertClassAce($sid, 16); - $provider->updateAcl($acl2); - - $acl1->insertClassAce($sid, 3); - $acl2->insertClassAce($sid, 5); - try { - $provider->updateAcl($acl1); - $this->fail('Provider failed to detect a concurrent modification.'); - } catch (ConcurrentModificationException $e) { - } - } - - public function testUpdateAcl() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $sid = new UserSecurityIdentity('johannes', 'FooClass'); - $acl->setEntriesInheriting(!$acl->isEntriesInheriting()); - - $acl->insertObjectAce($sid, 1); - $acl->insertClassAce($sid, 5, 0, false); - $acl->insertObjectAce($sid, 2, 1, true); - $acl->insertClassFieldAce('field', $sid, 2, 0, true); - $provider->updateAcl($acl); - - $acl->updateObjectAce(0, 3); - $acl->deleteObjectAce(1); - $acl->updateObjectAuditing(0, true, false); - $acl->updateClassFieldAce(0, 'field', 15); - $provider->updateAcl($acl); - - $reloadProvider = $this->getProvider(); - $reloadedAcl = $reloadProvider->findAcl(new ObjectIdentity(1, 'Foo')); - $this->assertNotSame($acl, $reloadedAcl); - $this->assertSame($acl->isEntriesInheriting(), $reloadedAcl->isEntriesInheriting()); - - $aces = $acl->getObjectAces(); - $reloadedAces = $reloadedAcl->getObjectAces(); - $this->assertEquals(count($aces), count($reloadedAces)); - foreach ($aces as $index => $ace) { - $this->assertAceEquals($ace, $reloadedAces[$index]); - } - } - - public function testUpdateAclWorksForChangingTheParentAcl() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $parentAcl = $provider->createAcl(new ObjectIdentity(1, 'AnotherFoo')); - $acl->setParentAcl($parentAcl); - $provider->updateAcl($acl); - - $reloadProvider = $this->getProvider(); - $reloadedAcl = $reloadProvider->findAcl(new ObjectIdentity(1, 'Foo')); - $this->assertNotSame($acl, $reloadedAcl); - $this->assertSame($parentAcl->getId(), $reloadedAcl->getParentAcl()->getId()); - } - - public function testUpdateAclUpdatesChildAclsCorrectly() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - - $parentAcl = $provider->createAcl(new ObjectIdentity(1, 'Bar')); - $acl->setParentAcl($parentAcl); - $provider->updateAcl($acl); - - $parentParentAcl = $provider->createAcl(new ObjectIdentity(1, 'Baz')); - $parentAcl->setParentAcl($parentParentAcl); - $provider->updateAcl($parentAcl); - - $newParentParentAcl = $provider->createAcl(new ObjectIdentity(2, 'Baz')); - $parentAcl->setParentAcl($newParentParentAcl); - $provider->updateAcl($parentAcl); - - $reloadProvider = $this->getProvider(); - $reloadedAcl = $reloadProvider->findAcl(new ObjectIdentity(1, 'Foo')); - $this->assertEquals($newParentParentAcl->getId(), $reloadedAcl->getParentAcl()->getParentAcl()->getId()); - } - - public function testUpdateAclInsertingMultipleObjectFieldAcesThrowsDBConstraintViolations() - { - $provider = $this->getProvider(); - $oid = new ObjectIdentity(1, 'Foo'); - $sid1 = new UserSecurityIdentity('johannes', 'FooClass'); - $sid2 = new UserSecurityIdentity('guilro', 'FooClass'); - $sid3 = new UserSecurityIdentity('bmaz', 'FooClass'); - $fieldName = 'fieldName'; - - $acl = $provider->createAcl($oid); - $acl->insertObjectFieldAce($fieldName, $sid1, 4); - $provider->updateAcl($acl); - - $acl = $provider->findAcl($oid); - $acl->insertObjectFieldAce($fieldName, $sid2, 4); - $provider->updateAcl($acl); - - $acl = $provider->findAcl($oid); - $acl->insertObjectFieldAce($fieldName, $sid3, 4); - $provider->updateAcl($acl); - } - - public function testUpdateAclDeletingObjectFieldAcesThrowsDBConstraintViolations() - { - $provider = $this->getProvider(); - $oid = new ObjectIdentity(1, 'Foo'); - $sid1 = new UserSecurityIdentity('johannes', 'FooClass'); - $sid2 = new UserSecurityIdentity('guilro', 'FooClass'); - $sid3 = new UserSecurityIdentity('bmaz', 'FooClass'); - $fieldName = 'fieldName'; - - $acl = $provider->createAcl($oid); - $acl->insertObjectFieldAce($fieldName, $sid1, 4); - $provider->updateAcl($acl); - - $acl = $provider->findAcl($oid); - $acl->insertObjectFieldAce($fieldName, $sid2, 4); - $provider->updateAcl($acl); - - $index = 0; - $acl->deleteObjectFieldAce($index, $fieldName); - $provider->updateAcl($acl); - - $acl = $provider->findAcl($oid); - $acl->insertObjectFieldAce($fieldName, $sid3, 4); - $provider->updateAcl($acl); - } - - public function testUpdateUserSecurityIdentity() - { - $provider = $this->getProvider(); - $acl = $provider->createAcl(new ObjectIdentity(1, 'Foo')); - $sid = new UserSecurityIdentity('johannes', 'FooClass'); - $acl->setEntriesInheriting(!$acl->isEntriesInheriting()); - - $acl->insertObjectAce($sid, 1); - $acl->insertClassAce($sid, 5, 0, false); - $acl->insertObjectAce($sid, 2, 1, true); - $acl->insertClassFieldAce('field', $sid, 2, 0, true); - $provider->updateAcl($acl); - - $newSid = new UserSecurityIdentity('mathieu', 'FooClass'); - $provider->updateUserSecurityIdentity($newSid, 'johannes'); - - $reloadProvider = $this->getProvider(); - $reloadedAcl = $reloadProvider->findAcl(new ObjectIdentity(1, 'Foo')); - - $this->assertNotSame($acl, $reloadedAcl); - $this->assertSame($acl->isEntriesInheriting(), $reloadedAcl->isEntriesInheriting()); - - $aces = $acl->getObjectAces(); - $reloadedAces = $reloadedAcl->getObjectAces(); - $this->assertEquals(count($aces), count($reloadedAces)); - foreach ($reloadedAces as $ace) { - $this->assertTrue($ace->getSecurityIdentity()->equals($newSid)); - } - } - - /** - * Imports acls. - * - * Data must have the following format: - * array( - * *name* => array( - * 'object_identifier' => *required* - * 'class_type' => *required*, - * 'parent_acl' => *name (optional)* - * ), - * ) - * - * @param AclProvider $provider - * @param array $data - * - * @throws \InvalidArgumentException - * @throws \Exception - */ - protected function importAcls(AclProvider $provider, array $data) - { - $aclIds = $parentAcls = array(); - $con = $this->getField($provider, 'connection'); - $con->beginTransaction(); - try { - foreach ($data as $name => $aclData) { - if (!isset($aclData['object_identifier'], $aclData['class_type'])) { - throw new \InvalidArgumentException('"object_identifier", and "class_type" must be present.'); - } - - $this->callMethod($provider, 'createObjectIdentity', array(new ObjectIdentity($aclData['object_identifier'], $aclData['class_type']))); - $aclId = $con->lastInsertId(); - $aclIds[$name] = $aclId; - - $sql = $this->callMethod($provider, 'getInsertObjectIdentityRelationSql', array($aclId, $aclId)); - $con->executeQuery($sql); - - if (isset($aclData['parent_acl'])) { - if (isset($aclIds[$aclData['parent_acl']])) { - $con->executeQuery('UPDATE acl_object_identities SET parent_object_identity_id = '.$aclIds[$aclData['parent_acl']].' WHERE id = '.$aclId); - $con->executeQuery($this->callMethod($provider, 'getInsertObjectIdentityRelationSql', array($aclId, $aclIds[$aclData['parent_acl']]))); - } else { - $parentAcls[$aclId] = $aclData['parent_acl']; - } - } - } - - foreach ($parentAcls as $aclId => $name) { - if (!isset($aclIds[$name])) { - throw new \InvalidArgumentException(sprintf('"%s" does not exist.', $name)); - } - - $con->executeQuery(sprintf('UPDATE acl_object_identities SET parent_object_identity_id = %d WHERE id = %d', $aclIds[$name], $aclId)); - $con->executeQuery($this->callMethod($provider, 'getInsertObjectIdentityRelationSql', array($aclId, $aclIds[$name]))); - } - - $con->commit(); - } catch (\Exception $e) { - $con->rollBack(); - - throw $e; - } - } - - protected function callMethod($object, $method, array $args) - { - $method = new \ReflectionMethod($object, $method); - $method->setAccessible(true); - - return $method->invokeArgs($object, $args); - } - - protected function setUp() - { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - self::markTestSkipped('This test requires SQLite support in your environment'); - } - - $this->con = DriverManager::getConnection(array( - 'driver' => 'pdo_sqlite', - 'memory' => true, - )); - - // import the schema - $schema = new Schema($this->getOptions()); - foreach ($schema->toSql($this->con->getDatabasePlatform()) as $sql) { - $this->con->exec($sql); - } - } - - protected function tearDown() - { - $this->con = null; - } - - protected function getField($object, $field) - { - $reflection = new \ReflectionProperty($object, $field); - $reflection->setAccessible(true); - - return $reflection->getValue($object); - } - - public function setField($object, $field, $value) - { - $reflection = new \ReflectionProperty($object, $field); - $reflection->setAccessible(true); - $reflection->setValue($object, $value); - $reflection->setAccessible(false); - } - - protected function getOptions() - { - return array( - 'oid_table_name' => 'acl_object_identities', - 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', - 'class_table_name' => 'acl_classes', - 'sid_table_name' => 'acl_security_identities', - 'entry_table_name' => 'acl_entries', - ); - } - - protected function getStrategy() - { - return new PermissionGrantingStrategy(); - } - - protected function getProvider($cache = null) - { - return new MutableAclProvider($this->con, $this->getStrategy(), $this->getOptions(), $cache); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php deleted file mode 100644 index 84b9ba9005995..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/AclTest.php +++ /dev/null @@ -1,513 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Acl\Domain\Acl; - -class AclTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $acl = new Acl(1, $oid = new ObjectIdentity('foo', 'foo'), $permissionStrategy = new PermissionGrantingStrategy(), array(), true); - - $this->assertSame(1, $acl->getId()); - $this->assertSame($oid, $acl->getObjectIdentity()); - $this->assertNull($acl->getParentAcl()); - $this->assertTrue($acl->isEntriesInheriting()); - } - - /** - * @expectedException \OutOfBoundsException - * @dataProvider getDeleteAceTests - */ - public function testDeleteAceThrowsExceptionOnInvalidIndex($type) - { - $acl = $this->getAcl(); - $acl->{'delete'.$type.'Ace'}(0); - } - - /** - * @dataProvider getDeleteAceTests - */ - public function testDeleteAce($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type.'Ace'}(new RoleSecurityIdentity('foo'), 1); - $acl->{'insert'.$type.'Ace'}(new RoleSecurityIdentity('foo'), 2, 1); - $acl->{'insert'.$type.'Ace'}(new RoleSecurityIdentity('foo'), 3, 2); - - $listener = $this->getListener(array( - $type.'Aces', 'aceOrder', 'aceOrder', $type.'Aces', - )); - $acl->addPropertyChangedListener($listener); - - $this->assertCount(3, $acl->{'get'.$type.'Aces'}()); - - $acl->{'delete'.$type.'Ace'}(0); - $this->assertCount(2, $aces = $acl->{'get'.$type.'Aces'}()); - $this->assertEquals(2, $aces[0]->getMask()); - $this->assertEquals(3, $aces[1]->getMask()); - - $acl->{'delete'.$type.'Ace'}(1); - $this->assertCount(1, $aces = $acl->{'get'.$type.'Aces'}()); - $this->assertEquals(2, $aces[0]->getMask()); - } - - public function getDeleteAceTests() - { - return array( - array('class'), - array('object'), - ); - } - - /** - * @expectedException \OutOfBoundsException - * @dataProvider getDeleteFieldAceTests - */ - public function testDeleteFieldAceThrowsExceptionOnInvalidIndex($type) - { - $acl = $this->getAcl(); - $acl->{'delete'.$type.'Ace'}('foo', 0); - } - - /** - * @dataProvider getDeleteFieldAceTests - */ - public function testDeleteFieldAce($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type.'Ace'}('foo', new RoleSecurityIdentity('foo'), 1, 0); - $acl->{'insert'.$type.'Ace'}('foo', new RoleSecurityIdentity('foo'), 2, 1); - $acl->{'insert'.$type.'Ace'}('foo', new RoleSecurityIdentity('foo'), 3, 2); - - $listener = $this->getListener(array( - $type.'Aces', 'aceOrder', 'aceOrder', $type.'Aces', - )); - $acl->addPropertyChangedListener($listener); - - $this->assertCount(3, $acl->{'get'.$type.'Aces'}('foo')); - - $acl->{'delete'.$type.'Ace'}(0, 'foo'); - $this->assertCount(2, $aces = $acl->{'get'.$type.'Aces'}('foo')); - $this->assertEquals(2, $aces[0]->getMask()); - $this->assertEquals(3, $aces[1]->getMask()); - - $acl->{'delete'.$type.'Ace'}(1, 'foo'); - $this->assertCount(1, $aces = $acl->{'get'.$type.'Aces'}('foo')); - $this->assertEquals(2, $aces[0]->getMask()); - } - - public function getDeleteFieldAceTests() - { - return array( - array('classField'), - array('objectField'), - ); - } - - /** - * @dataProvider getInsertAceTests - */ - public function testInsertAce($property, $method) - { - $acl = $this->getAcl(); - - $listener = $this->getListener(array( - $property, 'aceOrder', $property, 'aceOrder', $property, - )); - $acl->addPropertyChangedListener($listener); - - $sid = new RoleSecurityIdentity('foo'); - $acl->$method($sid, 1); - $acl->$method($sid, 2); - $acl->$method($sid, 3, 1, false); - - $this->assertCount(3, $aces = $acl->{'get'.$property}()); - $this->assertEquals(2, $aces[0]->getMask()); - $this->assertEquals(3, $aces[1]->getMask()); - $this->assertEquals(1, $aces[2]->getMask()); - } - - /** - * @expectedException \OutOfBoundsException - * @dataProvider getInsertAceTests - */ - public function testInsertClassAceThrowsExceptionOnInvalidIndex($property, $method) - { - $acl = $this->getAcl(); - $acl->$method(new RoleSecurityIdentity('foo'), 1, 1); - } - - public function getInsertAceTests() - { - return array( - array('classAces', 'insertClassAce'), - array('objectAces', 'insertObjectAce'), - ); - } - - /** - * @dataProvider getInsertFieldAceTests - */ - public function testInsertClassFieldAce($property, $method) - { - $acl = $this->getAcl(); - - $listener = $this->getListener(array( - $property, $property, 'aceOrder', $property, - 'aceOrder', 'aceOrder', $property, - )); - $acl->addPropertyChangedListener($listener); - - $sid = new RoleSecurityIdentity('foo'); - $acl->$method('foo', $sid, 1); - $acl->$method('foo2', $sid, 1); - $acl->$method('foo', $sid, 3); - $acl->$method('foo', $sid, 2); - - $this->assertCount(3, $aces = $acl->{'get'.$property}('foo')); - $this->assertCount(1, $acl->{'get'.$property}('foo2')); - $this->assertEquals(2, $aces[0]->getMask()); - $this->assertEquals(3, $aces[1]->getMask()); - $this->assertEquals(1, $aces[2]->getMask()); - } - - /** - * @expectedException \OutOfBoundsException - * @dataProvider getInsertFieldAceTests - */ - public function testInsertClassFieldAceThrowsExceptionOnInvalidIndex($property, $method) - { - $acl = $this->getAcl(); - $acl->$method('foo', new RoleSecurityIdentity('foo'), 1, 1); - } - - public function getInsertFieldAceTests() - { - return array( - array('classFieldAces', 'insertClassFieldAce'), - array('objectFieldAces', 'insertObjectFieldAce'), - ); - } - - public function testIsFieldGranted() - { - $sids = array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_IDDQD')); - $masks = array(1, 2, 4); - $strategy = $this->getMock('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface'); - $acl = new Acl(1, new ObjectIdentity(1, 'foo'), $strategy, array(), true); - - $strategy - ->expects($this->once()) - ->method('isFieldGranted') - ->with($this->equalTo($acl), $this->equalTo('foo'), $this->equalTo($masks), $this->equalTo($sids), $this->isTrue()) - ->will($this->returnValue(true)) - ; - - $this->assertTrue($acl->isFieldGranted('foo', $masks, $sids, true)); - } - - public function testIsGranted() - { - $sids = array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_IDDQD')); - $masks = array(1, 2, 4); - $strategy = $this->getMock('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface'); - $acl = new Acl(1, new ObjectIdentity(1, 'foo'), $strategy, array(), true); - - $strategy - ->expects($this->once()) - ->method('isGranted') - ->with($this->equalTo($acl), $this->equalTo($masks), $this->equalTo($sids), $this->isTrue()) - ->will($this->returnValue(true)) - ; - - $this->assertTrue($acl->isGranted($masks, $sids, true)); - } - - public function testSetGetParentAcl() - { - $acl = $this->getAcl(); - $parentAcl = $this->getAcl(); - - $listener = $this->getListener(array('parentAcl')); - $acl->addPropertyChangedListener($listener); - - $this->assertNull($acl->getParentAcl()); - $acl->setParentAcl($parentAcl); - $this->assertSame($parentAcl, $acl->getParentAcl()); - - $acl->setParentAcl(null); - $this->assertNull($acl->getParentAcl()); - } - - public function testSetIsEntriesInheriting() - { - $acl = $this->getAcl(); - - $listener = $this->getListener(array('entriesInheriting')); - $acl->addPropertyChangedListener($listener); - - $this->assertTrue($acl->isEntriesInheriting()); - $acl->setEntriesInheriting(false); - $this->assertFalse($acl->isEntriesInheriting()); - } - - public function testIsSidLoadedWhenAllSidsAreLoaded() - { - $acl = $this->getAcl(); - - $this->assertTrue($acl->isSidLoaded(new UserSecurityIdentity('foo', 'Foo'))); - $this->assertTrue($acl->isSidLoaded(new RoleSecurityIdentity('ROLE_FOO', 'Foo'))); - } - - public function testIsSidLoaded() - { - $acl = new Acl(1, new ObjectIdentity('1', 'foo'), new PermissionGrantingStrategy(), array(new UserSecurityIdentity('foo', 'Foo'), new UserSecurityIdentity('johannes', 'Bar')), true); - - $this->assertTrue($acl->isSidLoaded(new UserSecurityIdentity('foo', 'Foo'))); - $this->assertTrue($acl->isSidLoaded(new UserSecurityIdentity('johannes', 'Bar'))); - $this->assertTrue($acl->isSidLoaded(array( - new UserSecurityIdentity('foo', 'Foo'), - new UserSecurityIdentity('johannes', 'Bar'), - ))); - $this->assertFalse($acl->isSidLoaded(new RoleSecurityIdentity('ROLE_FOO'))); - $this->assertFalse($acl->isSidLoaded(new UserSecurityIdentity('schmittjoh@gmail.com', 'Moo'))); - $this->assertFalse($acl->isSidLoaded(array( - new UserSecurityIdentity('foo', 'Foo'), - new UserSecurityIdentity('johannes', 'Bar'), - new RoleSecurityIdentity('ROLE_FOO'), - ))); - } - - /** - * @dataProvider getUpdateAceTests - * @expectedException \OutOfBoundsException - */ - public function testUpdateAceThrowsOutOfBoundsExceptionOnInvalidIndex($type) - { - $acl = $this->getAcl(); - $acl->{'update'.$type}(0, 1); - } - - /** - * @dataProvider getUpdateAceTests - */ - public function testUpdateAce($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type}(new RoleSecurityIdentity('foo'), 1); - - $listener = $this->getListener(array( - 'mask', 'mask', 'strategy', - )); - $acl->addPropertyChangedListener($listener); - - $aces = $acl->{'get'.$type.'s'}(); - $ace = reset($aces); - $this->assertEquals(1, $ace->getMask()); - $this->assertEquals('all', $ace->getStrategy()); - - $acl->{'update'.$type}(0, 3); - $this->assertEquals(3, $ace->getMask()); - $this->assertEquals('all', $ace->getStrategy()); - - $acl->{'update'.$type}(0, 1, 'foo'); - $this->assertEquals(1, $ace->getMask()); - $this->assertEquals('foo', $ace->getStrategy()); - } - - public function getUpdateAceTests() - { - return array( - array('classAce'), - array('objectAce'), - ); - } - - /** - * @dataProvider getUpdateFieldAceTests - * @expectedException \OutOfBoundsException - */ - public function testUpdateFieldAceThrowsExceptionOnInvalidIndex($type) - { - $acl = $this->getAcl(); - $acl->{'update'.$type}(0, 'foo', 1); - } - - /** - * @dataProvider getUpdateFieldAceTests - */ - public function testUpdateFieldAce($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type}('foo', new UserSecurityIdentity('foo', 'Foo'), 1); - - $listener = $this->getListener(array( - 'mask', 'mask', 'strategy', - )); - $acl->addPropertyChangedListener($listener); - - $aces = $acl->{'get'.$type.'s'}('foo'); - $ace = reset($aces); - $this->assertEquals(1, $ace->getMask()); - $this->assertEquals('all', $ace->getStrategy()); - - $acl->{'update'.$type}(0, 'foo', 3); - $this->assertEquals(3, $ace->getMask()); - $this->assertEquals('all', $ace->getStrategy()); - - $acl->{'update'.$type}(0, 'foo', 1, 'foo'); - $this->assertEquals(1, $ace->getMask()); - $this->assertEquals('foo', $ace->getStrategy()); - } - - public function getUpdateFieldAceTests() - { - return array( - array('classFieldAce'), - array('objectFieldAce'), - ); - } - - /** - * @dataProvider getUpdateAuditingTests - * @expectedException \OutOfBoundsException - */ - public function testUpdateAuditingThrowsExceptionOnInvalidIndex($type) - { - $acl = $this->getAcl(); - $acl->{'update'.$type.'Auditing'}(0, true, false); - } - - /** - * @dataProvider getUpdateAuditingTests - */ - public function testUpdateAuditing($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type.'Ace'}(new RoleSecurityIdentity('foo'), 1); - - $listener = $this->getListener(array( - 'auditFailure', 'auditSuccess', 'auditFailure', - )); - $acl->addPropertyChangedListener($listener); - - $aces = $acl->{'get'.$type.'Aces'}(); - $ace = reset($aces); - $this->assertFalse($ace->isAuditSuccess()); - $this->assertFalse($ace->isAuditFailure()); - - $acl->{'update'.$type.'Auditing'}(0, false, true); - $this->assertFalse($ace->isAuditSuccess()); - $this->assertTrue($ace->isAuditFailure()); - - $acl->{'update'.$type.'Auditing'}(0, true, false); - $this->assertTrue($ace->isAuditSuccess()); - $this->assertFalse($ace->isAuditFailure()); - } - - public function getUpdateAuditingTests() - { - return array( - array('class'), - array('object'), - ); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getUpdateFieldAuditingTests - */ - public function testUpdateFieldAuditingThrowsExceptionOnInvalidField($type) - { - $acl = $this->getAcl(); - $acl->{'update'.$type.'Auditing'}(0, 'foo', true, true); - } - - /** - * @expectedException \OutOfBoundsException - * @dataProvider getUpdateFieldAuditingTests - */ - public function testUpdateFieldAuditingThrowsExceptionOnInvalidIndex($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type.'Ace'}('foo', new RoleSecurityIdentity('foo'), 1); - $acl->{'update'.$type.'Auditing'}(1, 'foo', true, false); - } - - /** - * @dataProvider getUpdateFieldAuditingTests - */ - public function testUpdateFieldAuditing($type) - { - $acl = $this->getAcl(); - $acl->{'insert'.$type.'Ace'}('foo', new RoleSecurityIdentity('foo'), 1); - - $listener = $this->getListener(array( - 'auditSuccess', 'auditSuccess', 'auditFailure', - )); - $acl->addPropertyChangedListener($listener); - - $aces = $acl->{'get'.$type.'Aces'}('foo'); - $ace = reset($aces); - $this->assertFalse($ace->isAuditSuccess()); - $this->assertFalse($ace->isAuditFailure()); - - $acl->{'update'.$type.'Auditing'}(0, 'foo', true, false); - $this->assertTrue($ace->isAuditSuccess()); - $this->assertFalse($ace->isAuditFailure()); - - $acl->{'update'.$type.'Auditing'}(0, 'foo', false, true); - $this->assertFalse($ace->isAuditSuccess()); - $this->assertTrue($ace->isAuditFailure()); - } - - public function getUpdateFieldAuditingTests() - { - return array( - array('classField'), - array('objectField'), - ); - } - - protected function getListener($expectedChanges) - { - $aceProperties = array('aceOrder', 'mask', 'strategy', 'auditSuccess', 'auditFailure'); - - $listener = $this->getMock('Doctrine\Common\PropertyChangedListener'); - foreach ($expectedChanges as $index => $property) { - if (in_array($property, $aceProperties)) { - $class = 'Symfony\Component\Security\Acl\Domain\Entry'; - } else { - $class = 'Symfony\Component\Security\Acl\Domain\Acl'; - } - - $listener - ->expects($this->at($index)) - ->method('propertyChanged') - ->with($this->isInstanceOf($class), $this->equalTo($property)) - ; - } - - return $listener; - } - - protected function getAcl() - { - return new Acl(1, new ObjectIdentity(1, 'foo'), new PermissionGrantingStrategy(), array(), true); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php deleted file mode 100644 index 15538d346245a..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/AuditLoggerTest.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -class AuditLoggerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getTestLogData - */ - public function testLogIfNeeded($granting, $audit) - { - $logger = $this->getLogger(); - $ace = $this->getEntry(); - - if (true === $granting) { - $ace - ->expects($this->once()) - ->method('isAuditSuccess') - ->will($this->returnValue($audit)) - ; - - $ace - ->expects($this->never()) - ->method('isAuditFailure') - ; - } else { - $ace - ->expects($this->never()) - ->method('isAuditSuccess') - ; - - $ace - ->expects($this->once()) - ->method('isAuditFailure') - ->will($this->returnValue($audit)) - ; - } - - if (true === $audit) { - $logger - ->expects($this->once()) - ->method('doLog') - ->with($this->equalTo($granting), $this->equalTo($ace)) - ; - } else { - $logger - ->expects($this->never()) - ->method('doLog') - ; - } - - $logger->logIfNeeded($granting, $ace); - } - - public function getTestLogData() - { - return array( - array(true, false), - array(true, true), - array(false, false), - array(false, true), - ); - } - - protected function getEntry() - { - return $this->getMock('Symfony\Component\Security\Acl\Model\AuditableEntryInterface'); - } - - protected function getLogger() - { - return $this->getMockForAbstractClass('Symfony\Component\Security\Acl\Domain\AuditLogger'); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/DoctrineAclCacheTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/DoctrineAclCacheTest.php deleted file mode 100644 index 255f7f4447e69..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/DoctrineAclCacheTest.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy; -use Symfony\Component\Security\Acl\Domain\Acl; -use Symfony\Component\Security\Acl\Domain\DoctrineAclCache; -use Doctrine\Common\Cache\ArrayCache; - -class DoctrineAclCacheTest extends \PHPUnit_Framework_TestCase -{ - protected $permissionGrantingStrategy; - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getEmptyValue - */ - public function testConstructorDoesNotAcceptEmptyPrefix($empty) - { - new DoctrineAclCache(new ArrayCache(), $this->getPermissionGrantingStrategy(), $empty); - } - - public function getEmptyValue() - { - return array( - array(null), - array(false), - array(''), - ); - } - - public function test() - { - $cache = $this->getCache(); - - $aclWithParent = $this->getAcl(1); - $acl = $this->getAcl(); - - $cache->putInCache($aclWithParent); - $cache->putInCache($acl); - - $cachedAcl = $cache->getFromCacheByIdentity($acl->getObjectIdentity()); - $this->assertEquals($acl->getId(), $cachedAcl->getId()); - $this->assertNull($acl->getParentAcl()); - - $cachedAclWithParent = $cache->getFromCacheByIdentity($aclWithParent->getObjectIdentity()); - $this->assertEquals($aclWithParent->getId(), $cachedAclWithParent->getId()); - $this->assertNotNull($cachedParentAcl = $cachedAclWithParent->getParentAcl()); - $this->assertEquals($aclWithParent->getParentAcl()->getId(), $cachedParentAcl->getId()); - } - - protected function getAcl($depth = 0) - { - static $id = 1; - - $acl = new Acl($id, new ObjectIdentity($id, 'foo'), $this->getPermissionGrantingStrategy(), array(), $depth > 0); - - // insert some ACEs - $sid = new UserSecurityIdentity('johannes', 'Foo'); - $acl->insertClassAce($sid, 1); - $acl->insertClassFieldAce('foo', $sid, 1); - $acl->insertObjectAce($sid, 1); - $acl->insertObjectFieldAce('foo', $sid, 1); - ++$id; - - if ($depth > 0) { - $acl->setParentAcl($this->getAcl($depth - 1)); - } - - return $acl; - } - - protected function getPermissionGrantingStrategy() - { - if (null === $this->permissionGrantingStrategy) { - $this->permissionGrantingStrategy = new PermissionGrantingStrategy(); - } - - return $this->permissionGrantingStrategy; - } - - protected function getCache($cacheDriver = null, $prefix = DoctrineAclCache::PREFIX) - { - if (null === $cacheDriver) { - $cacheDriver = new ArrayCache(); - } - - return new DoctrineAclCache($cacheDriver, $this->getPermissionGrantingStrategy(), $prefix); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php deleted file mode 100644 index ab8e481daf5fa..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/EntryTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\Entry; - -class EntryTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $ace = $this->getAce($acl = $this->getAcl(), $sid = $this->getSid()); - - $this->assertEquals(123, $ace->getId()); - $this->assertSame($acl, $ace->getAcl()); - $this->assertSame($sid, $ace->getSecurityIdentity()); - $this->assertEquals('foostrat', $ace->getStrategy()); - $this->assertEquals(123456, $ace->getMask()); - $this->assertTrue($ace->isGranting()); - $this->assertTrue($ace->isAuditSuccess()); - $this->assertFalse($ace->isAuditFailure()); - } - - public function testSetAuditSuccess() - { - $ace = $this->getAce(); - - $this->assertTrue($ace->isAuditSuccess()); - $ace->setAuditSuccess(false); - $this->assertFalse($ace->isAuditSuccess()); - $ace->setAuditSuccess(true); - $this->assertTrue($ace->isAuditSuccess()); - } - - public function testSetAuditFailure() - { - $ace = $this->getAce(); - - $this->assertFalse($ace->isAuditFailure()); - $ace->setAuditFailure(true); - $this->assertTrue($ace->isAuditFailure()); - $ace->setAuditFailure(false); - $this->assertFalse($ace->isAuditFailure()); - } - - public function testSetMask() - { - $ace = $this->getAce(); - - $this->assertEquals(123456, $ace->getMask()); - $ace->setMask(4321); - $this->assertEquals(4321, $ace->getMask()); - } - - public function testSetStrategy() - { - $ace = $this->getAce(); - - $this->assertEquals('foostrat', $ace->getStrategy()); - $ace->setStrategy('foo'); - $this->assertEquals('foo', $ace->getStrategy()); - } - - public function testSerializeUnserialize() - { - $ace = $this->getAce(); - - $serialized = serialize($ace); - $uAce = unserialize($serialized); - - $this->assertNull($uAce->getAcl()); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity()); - $this->assertEquals($ace->getId(), $uAce->getId()); - $this->assertEquals($ace->getMask(), $uAce->getMask()); - $this->assertEquals($ace->getStrategy(), $uAce->getStrategy()); - $this->assertEquals($ace->isGranting(), $uAce->isGranting()); - $this->assertEquals($ace->isAuditSuccess(), $uAce->isAuditSuccess()); - $this->assertEquals($ace->isAuditFailure(), $uAce->isAuditFailure()); - } - - protected function getAce($acl = null, $sid = null) - { - if (null === $acl) { - $acl = $this->getAcl(); - } - if (null === $sid) { - $sid = $this->getSid(); - } - - return new Entry( - 123, - $acl, - $sid, - 'foostrat', - 123456, - true, - false, - true - ); - } - - protected function getAcl() - { - return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); - } - - protected function getSid() - { - return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface'); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php deleted file mode 100644 index 735e2e86da75d..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/FieldEntryTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\FieldEntry; - -class FieldEntryTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $ace = $this->getAce(); - - $this->assertEquals('foo', $ace->getField()); - } - - public function testSerializeUnserialize() - { - $ace = $this->getAce(); - - $serialized = serialize($ace); - $uAce = unserialize($serialized); - - $this->assertNull($uAce->getAcl()); - $this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity()); - $this->assertEquals($ace->getId(), $uAce->getId()); - $this->assertEquals($ace->getField(), $uAce->getField()); - $this->assertEquals($ace->getMask(), $uAce->getMask()); - $this->assertEquals($ace->getStrategy(), $uAce->getStrategy()); - $this->assertEquals($ace->isGranting(), $uAce->isGranting()); - $this->assertEquals($ace->isAuditSuccess(), $uAce->isAuditSuccess()); - $this->assertEquals($ace->isAuditFailure(), $uAce->isAuditFailure()); - } - - protected function getAce($acl = null, $sid = null) - { - if (null === $acl) { - $acl = $this->getAcl(); - } - if (null === $sid) { - $sid = $this->getSid(); - } - - return new FieldEntry( - 123, - $acl, - 'foo', - $sid, - 'foostrat', - 123456, - true, - false, - true - ); - } - - protected function getAcl() - { - return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); - } - - protected function getSid() - { - return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface'); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityRetrievalStrategyTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityRetrievalStrategyTest.php deleted file mode 100644 index 59fc3bdb7e37c..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityRetrievalStrategyTest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy; - -class ObjectIdentityRetrievalStrategyTest extends \PHPUnit_Framework_TestCase -{ - public function testGetObjectIdentityReturnsNullForInvalidDomainObject() - { - $strategy = new ObjectIdentityRetrievalStrategy(); - $this->assertNull($strategy->getObjectIdentity('foo')); - } - - public function testGetObjectIdentity() - { - $strategy = new ObjectIdentityRetrievalStrategy(); - $domainObject = new DomainObject(); - $objectIdentity = $strategy->getObjectIdentity($domainObject); - - $this->assertEquals($domainObject->getId(), $objectIdentity->getIdentifier()); - $this->assertEquals(get_class($domainObject), $objectIdentity->getType()); - } -} - -class DomainObject -{ - public function getId() - { - return 'foo'; - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityTest.php deleted file mode 100644 index 70f89a325438a..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/ObjectIdentityTest.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain -{ - use Symfony\Component\Security\Acl\Domain\ObjectIdentity; - - class ObjectIdentityTest extends \PHPUnit_Framework_TestCase - { - public function testConstructor() - { - $id = new ObjectIdentity('fooid', 'footype'); - - $this->assertEquals('fooid', $id->getIdentifier()); - $this->assertEquals('footype', $id->getType()); - } - - // Test that constructor never changes passed type, even with proxies - public function testConstructorWithProxy() - { - $id = new ObjectIdentity('fooid', 'Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject'); - - $this->assertEquals('fooid', $id->getIdentifier()); - $this->assertEquals('Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject', $id->getType()); - } - - public function testFromDomainObjectPrefersInterfaceOverGetId() - { - $domainObject = $this->getMock('Symfony\Component\Security\Acl\Model\DomainObjectInterface'); - $domainObject - ->expects($this->once()) - ->method('getObjectIdentifier') - ->will($this->returnValue('getObjectIdentifier()')) - ; - $domainObject - ->expects($this->never()) - ->method('getId') - ->will($this->returnValue('getId()')) - ; - - $id = ObjectIdentity::fromDomainObject($domainObject); - $this->assertEquals('getObjectIdentifier()', $id->getIdentifier()); - } - - public function testFromDomainObjectWithoutInterface() - { - $id = ObjectIdentity::fromDomainObject(new TestDomainObject()); - $this->assertEquals('getId()', $id->getIdentifier()); - $this->assertEquals('Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject', $id->getType()); - } - - public function testFromDomainObjectWithProxy() - { - $id = ObjectIdentity::fromDomainObject(new \Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject()); - $this->assertEquals('getId()', $id->getIdentifier()); - $this->assertEquals('Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject', $id->getType()); - } - - public function testFromDomainObjectWithoutInterfaceEnforcesStringIdentifier() - { - $domainObject = new TestDomainObject(); - $domainObject->id = 1; - $id = ObjectIdentity::fromDomainObject($domainObject); - - $this->assertSame('1', $id->getIdentifier()); - $this->assertEquals('Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject', $id->getType()); - } - - public function testFromDomainObjectWithoutInterfaceAllowsZeroAsIdentifier() - { - $domainObject = new TestDomainObject(); - $domainObject->id = '0'; - $id = ObjectIdentity::fromDomainObject($domainObject); - - $this->assertSame('0', $id->getIdentifier()); - $this->assertEquals('Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject', $id->getType()); - } - - /** - * @dataProvider getCompareData - */ - public function testEquals($oid1, $oid2, $equal) - { - if ($equal) { - $this->assertTrue($oid1->equals($oid2)); - } else { - $this->assertFalse($oid1->equals($oid2)); - } - } - - public function getCompareData() - { - return array( - array(new ObjectIdentity('123', 'foo'), new ObjectIdentity('123', 'foo'), true), - array(new ObjectIdentity('123', 'foo'), new ObjectIdentity(123, 'foo'), true), - array(new ObjectIdentity('1', 'foo'), new ObjectIdentity('2', 'foo'), false), - array(new ObjectIdentity('1', 'bla'), new ObjectIdentity('1', 'blub'), false), - ); - } - } - - class TestDomainObject - { - public $id = 'getId()'; - - public function getObjectIdentifier() - { - return 'getObjectIdentifier()'; - } - - public function getId() - { - return $this->id; - } - } -} - -namespace Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain -{ - class TestDomainObject extends \Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject - { - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php deleted file mode 100644 index 34ef69081971a..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/PermissionGrantingStrategyTest.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\Acl; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\PermissionGrantingStrategy; -use Symfony\Component\Security\Acl\Exception\NoAceFoundException; - -class PermissionGrantingStrategyTest extends \PHPUnit_Framework_TestCase -{ - public function testIsGrantedObjectAcesHavePriority() - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $acl->insertClassAce($sid, 1); - $acl->insertObjectAce($sid, 1, 0, false); - $this->assertFalse($strategy->isGranted($acl, array(1), array($sid))); - } - - public function testIsGrantedFallsBackToClassAcesIfNoApplicableObjectAceWasFound() - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $acl->insertClassAce($sid, 1); - $this->assertTrue($strategy->isGranted($acl, array(1), array($sid))); - } - - public function testIsGrantedFavorsLocalAcesOverParentAclAces() - { - $strategy = new PermissionGrantingStrategy(); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $acl = $this->getAcl($strategy); - $acl->insertClassAce($sid, 1); - - $parentAcl = $this->getAcl($strategy); - $acl->setParentAcl($parentAcl); - $parentAcl->insertClassAce($sid, 1, 0, false); - - $this->assertTrue($strategy->isGranted($acl, array(1), array($sid))); - } - - public function testIsGrantedFallsBackToParentAcesIfNoLocalAcesAreApplicable() - { - $strategy = new PermissionGrantingStrategy(); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - $anotherSid = new UserSecurityIdentity('ROLE_USER', 'Foo'); - - $acl = $this->getAcl($strategy); - $acl->insertClassAce($anotherSid, 1, 0, false); - - $parentAcl = $this->getAcl($strategy); - $acl->setParentAcl($parentAcl); - $parentAcl->insertClassAce($sid, 1); - - $this->assertTrue($strategy->isGranted($acl, array(1), array($sid))); - } - - /** - * @expectedException \Symfony\Component\Security\Acl\Exception\NoAceFoundException - */ - public function testIsGrantedReturnsExceptionIfNoAceIsFound() - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $strategy->isGranted($acl, array(1), array($sid)); - } - - public function testIsGrantedFirstApplicableEntryMakesUltimateDecisionForPermissionIdentityCombination() - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - $aSid = new RoleSecurityIdentity('ROLE_USER'); - - $acl->insertClassAce($aSid, 1); - $acl->insertClassAce($sid, 1, 1, false); - $acl->insertClassAce($sid, 1, 2); - $this->assertFalse($strategy->isGranted($acl, array(1), array($sid, $aSid))); - - $acl->insertObjectAce($sid, 1, 0, false); - $acl->insertObjectAce($aSid, 1, 1); - $this->assertFalse($strategy->isGranted($acl, array(1), array($sid, $aSid))); - } - - public function testIsGrantedCallsAuditLoggerOnGrant() - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $logger = $this->getMock('Symfony\Component\Security\Acl\Model\AuditLoggerInterface'); - $logger - ->expects($this->once()) - ->method('logIfNeeded') - ; - $strategy->setAuditLogger($logger); - - $acl->insertObjectAce($sid, 1); - $acl->updateObjectAuditing(0, true, false); - - $this->assertTrue($strategy->isGranted($acl, array(1), array($sid))); - } - - public function testIsGrantedCallsAuditLoggerOnDeny() - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $logger = $this->getMock('Symfony\Component\Security\Acl\Model\AuditLoggerInterface'); - $logger - ->expects($this->once()) - ->method('logIfNeeded') - ; - $strategy->setAuditLogger($logger); - - $acl->insertObjectAce($sid, 1, 0, false); - $acl->updateObjectAuditing(0, false, true); - - $this->assertFalse($strategy->isGranted($acl, array(1), array($sid))); - } - - /** - * @dataProvider getAllStrategyTests - */ - public function testIsGrantedStrategies($maskStrategy, $aceMask, $requiredMask, $result) - { - $strategy = new PermissionGrantingStrategy(); - $acl = $this->getAcl($strategy); - $sid = new UserSecurityIdentity('johannes', 'Foo'); - - $acl->insertObjectAce($sid, $aceMask, 0, true, $maskStrategy); - - if (false === $result) { - try { - $strategy->isGranted($acl, array($requiredMask), array($sid)); - $this->fail('The ACE is not supposed to match.'); - } catch (NoAceFoundException $e) { - } - } else { - $this->assertTrue($strategy->isGranted($acl, array($requiredMask), array($sid))); - } - } - - public function getAllStrategyTests() - { - return array( - array('all', 1 << 0 | 1 << 1, 1 << 0, true), - array('all', 1 << 0 | 1 << 1, 1 << 2, false), - array('all', 1 << 0 | 1 << 10, 1 << 0 | 1 << 10, true), - array('all', 1 << 0 | 1 << 1, 1 << 0 | 1 << 1 || 1 << 2, false), - array('any', 1 << 0 | 1 << 1, 1 << 0, true), - array('any', 1 << 0 | 1 << 1, 1 << 0 | 1 << 2, true), - array('any', 1 << 0 | 1 << 1, 1 << 2, false), - array('equal', 1 << 0 | 1 << 1, 1 << 0, false), - array('equal', 1 << 0 | 1 << 1, 1 << 1, false), - array('equal', 1 << 0 | 1 << 1, 1 << 0 | 1 << 1, true), - ); - } - - protected function getAcl($strategy) - { - static $id = 1; - - return new Acl($id++, new ObjectIdentity(1, 'Foo'), $strategy, array(), true); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/RoleSecurityIdentityTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/RoleSecurityIdentityTest.php deleted file mode 100644 index ad5f23639f17d..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/RoleSecurityIdentityTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Core\Role\Role; -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; - -class RoleSecurityIdentityTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $id = new RoleSecurityIdentity('ROLE_FOO'); - - $this->assertEquals('ROLE_FOO', $id->getRole()); - } - - public function testConstructorWithRoleInstance() - { - $id = new RoleSecurityIdentity(new Role('ROLE_FOO')); - - $this->assertEquals('ROLE_FOO', $id->getRole()); - } - - /** - * @dataProvider getCompareData - */ - public function testEquals($id1, $id2, $equal) - { - if ($equal) { - $this->assertTrue($id1->equals($id2)); - } else { - $this->assertFalse($id1->equals($id2)); - } - } - - public function getCompareData() - { - return array( - array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_FOO'), true), - array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity(new Role('ROLE_FOO')), true), - array(new RoleSecurityIdentity('ROLE_USER'), new RoleSecurityIdentity('ROLE_FOO'), false), - array(new RoleSecurityIdentity('ROLE_FOO'), new UserSecurityIdentity('ROLE_FOO', 'Foo'), false), - ); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php deleted file mode 100644 index 160c27cfdde32..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php +++ /dev/null @@ -1,196 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\SecurityIdentityRetrievalStrategy; - -class SecurityIdentityRetrievalStrategyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getSecurityIdentityRetrievalTests - */ - public function testGetSecurityIdentities($user, array $roles, $authenticationStatus, array $sids) - { - $strategy = $this->getStrategy($roles, $authenticationStatus); - - if ('anonymous' === $authenticationStatus) { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken') - ->disableOriginalConstructor() - ->getMock(); - } else { - $class = ''; - if (is_string($user)) { - $class = 'MyCustomTokenImpl'; - } - - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface') - ->setMockClassName($class) - ->getMock(); - } - $token - ->expects($this->once()) - ->method('getRoles') - ->will($this->returnValue(array('foo'))) - ; - if ('anonymous' === $authenticationStatus) { - $token - ->expects($this->never()) - ->method('getUser') - ; - } else { - $token - ->expects($this->once()) - ->method('getUser') - ->will($this->returnValue($user)) - ; - } - - $extractedSids = $strategy->getSecurityIdentities($token); - - foreach ($extractedSids as $index => $extractedSid) { - if (!isset($sids[$index])) { - $this->fail(sprintf('Expected SID at index %d, but there was none.', true)); - } - - if (false === $sids[$index]->equals($extractedSid)) { - $this->fail(sprintf('Index: %d, expected SID "%s", but got "%s".', $index, $sids[$index], $extractedSid)); - } - } - } - - public function getSecurityIdentityRetrievalTests() - { - return array( - array($this->getAccount('johannes', 'FooUser'), array('ROLE_USER', 'ROLE_SUPERADMIN'), 'fullFledged', array( - new UserSecurityIdentity('johannes', 'FooUser'), - new RoleSecurityIdentity('ROLE_USER'), - new RoleSecurityIdentity('ROLE_SUPERADMIN'), - new RoleSecurityIdentity('IS_AUTHENTICATED_FULLY'), - new RoleSecurityIdentity('IS_AUTHENTICATED_REMEMBERED'), - new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )), - array('johannes', array('ROLE_FOO'), 'fullFledged', array( - new UserSecurityIdentity('johannes', 'MyCustomTokenImpl'), - new RoleSecurityIdentity('ROLE_FOO'), - new RoleSecurityIdentity('IS_AUTHENTICATED_FULLY'), - new RoleSecurityIdentity('IS_AUTHENTICATED_REMEMBERED'), - new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )), - array(new CustomUserImpl('johannes'), array('ROLE_FOO'), 'fullFledged', array( - new UserSecurityIdentity('johannes', 'Symfony\Component\Security\Acl\Tests\Domain\CustomUserImpl'), - new RoleSecurityIdentity('ROLE_FOO'), - new RoleSecurityIdentity('IS_AUTHENTICATED_FULLY'), - new RoleSecurityIdentity('IS_AUTHENTICATED_REMEMBERED'), - new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )), - array($this->getAccount('foo', 'FooBarUser'), array('ROLE_FOO'), 'rememberMe', array( - new UserSecurityIdentity('foo', 'FooBarUser'), - new RoleSecurityIdentity('ROLE_FOO'), - new RoleSecurityIdentity('IS_AUTHENTICATED_REMEMBERED'), - new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )), - array('guest', array('ROLE_FOO'), 'anonymous', array( - new RoleSecurityIdentity('ROLE_FOO'), - new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )), - ); - } - - protected function getAccount($username, $class) - { - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface', array(), array(), $class); - $account - ->expects($this->any()) - ->method('getUsername') - ->will($this->returnValue($username)) - ; - - return $account; - } - - protected function getStrategy(array $roles = array(), $authenticationStatus = 'fullFledged') - { - $roleHierarchy = $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface'); - $roleHierarchy - ->expects($this->once()) - ->method('getReachableRoles') - ->with($this->equalTo(array('foo'))) - ->will($this->returnValue($roles)) - ; - - $trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver', array(), array('', '')); - - $trustResolver - ->expects($this->at(0)) - ->method('isAnonymous') - ->will($this->returnValue('anonymous' === $authenticationStatus)) - ; - - if ('fullFledged' === $authenticationStatus) { - $trustResolver - ->expects($this->once()) - ->method('isFullFledged') - ->will($this->returnValue(true)) - ; - $trustResolver - ->expects($this->never()) - ->method('isRememberMe') - ; - } elseif ('rememberMe' === $authenticationStatus) { - $trustResolver - ->expects($this->once()) - ->method('isFullFledged') - ->will($this->returnValue(false)) - ; - $trustResolver - ->expects($this->once()) - ->method('isRememberMe') - ->will($this->returnValue(true)) - ; - } else { - $trustResolver - ->expects($this->at(1)) - ->method('isAnonymous') - ->will($this->returnValue(true)) - ; - $trustResolver - ->expects($this->once()) - ->method('isFullFledged') - ->will($this->returnValue(false)) - ; - $trustResolver - ->expects($this->once()) - ->method('isRememberMe') - ->will($this->returnValue(false)) - ; - } - - return new SecurityIdentityRetrievalStrategy($roleHierarchy, $trustResolver); - } -} - -class CustomUserImpl -{ - protected $name; - - public function __construct($name) - { - $this->name = $name; - } - - public function __toString() - { - return $this->name; - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php b/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php deleted file mode 100644 index 09d3f0d560ffe..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Domain/UserSecurityIdentityTest.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Domain; - -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; - -class UserSecurityIdentityTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $id = new UserSecurityIdentity('foo', 'Foo'); - - $this->assertEquals('foo', $id->getUsername()); - $this->assertEquals('Foo', $id->getClass()); - } - - // Test that constructor never changes the type, even for proxies - public function testConstructorWithProxy() - { - $id = new UserSecurityIdentity('foo', 'Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain\Foo'); - - $this->assertEquals('foo', $id->getUsername()); - $this->assertEquals('Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Acl\Tests\Domain\Foo', $id->getClass()); - } - - /** - * @dataProvider getCompareData - */ - public function testEquals($id1, $id2, $equal) - { - $this->assertSame($equal, $id1->equals($id2)); - } - - public function getCompareData() - { - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface') - ->setMockClassName('USI_AccountImpl') - ->getMock(); - $account - ->expects($this->any()) - ->method('getUsername') - ->will($this->returnValue('foo')) - ; - - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - $token - ->expects($this->any()) - ->method('getUser') - ->will($this->returnValue($account)) - ; - - return array( - array(new UserSecurityIdentity('foo', 'Foo'), new UserSecurityIdentity('foo', 'Foo'), true), - array(new UserSecurityIdentity('foo', 'Bar'), new UserSecurityIdentity('foo', 'Foo'), false), - array(new UserSecurityIdentity('foo', 'Foo'), new UserSecurityIdentity('bar', 'Foo'), false), - array(new UserSecurityIdentity('foo', 'Foo'), UserSecurityIdentity::fromAccount($account), false), - array(new UserSecurityIdentity('bla', 'Foo'), new UserSecurityIdentity('blub', 'Foo'), false), - array(new UserSecurityIdentity('foo', 'Foo'), new RoleSecurityIdentity('foo'), false), - array(new UserSecurityIdentity('foo', 'Foo'), UserSecurityIdentity::fromToken($token), false), - array(new UserSecurityIdentity('foo', 'USI_AccountImpl'), UserSecurityIdentity::fromToken($token), true), - ); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Permission/BasicPermissionMapTest.php b/src/Symfony/Component/Security/Acl/Tests/Permission/BasicPermissionMapTest.php deleted file mode 100644 index 2afe588f038af..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Permission/BasicPermissionMapTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Permission; - -use Symfony\Component\Security\Acl\Permission\BasicPermissionMap; - -class BasicPermissionMapTest extends \PHPUnit_Framework_TestCase -{ - public function testGetMasksReturnsNullWhenNotSupportedMask() - { - $map = new BasicPermissionMap(); - $this->assertNull($map->getMasks('IS_AUTHENTICATED_REMEMBERED', null)); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php b/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php deleted file mode 100644 index 824566918025b..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Permission; - -use Symfony\Component\Security\Acl\Permission\MaskBuilder; - -class MaskBuilderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \InvalidArgumentException - * @dataProvider getInvalidConstructorData - */ - public function testConstructorWithNonInteger($invalidMask) - { - new MaskBuilder($invalidMask); - } - - public function getInvalidConstructorData() - { - return array( - array(234.463), - array('asdgasdf'), - array(array()), - array(new \stdClass()), - ); - } - - public function testConstructorWithoutArguments() - { - $builder = new MaskBuilder(); - - $this->assertEquals(0, $builder->get()); - } - - public function testConstructor() - { - $builder = new MaskBuilder(123456); - - $this->assertEquals(123456, $builder->get()); - } - - public function testAddAndRemove() - { - $builder = new MaskBuilder(); - - $builder - ->add('view') - ->add('eDiT') - ->add('ownEr') - ; - $mask = $builder->get(); - - $this->assertEquals(MaskBuilder::MASK_VIEW, $mask & MaskBuilder::MASK_VIEW); - $this->assertEquals(MaskBuilder::MASK_EDIT, $mask & MaskBuilder::MASK_EDIT); - $this->assertEquals(MaskBuilder::MASK_OWNER, $mask & MaskBuilder::MASK_OWNER); - $this->assertEquals(0, $mask & MaskBuilder::MASK_MASTER); - $this->assertEquals(0, $mask & MaskBuilder::MASK_CREATE); - $this->assertEquals(0, $mask & MaskBuilder::MASK_DELETE); - $this->assertEquals(0, $mask & MaskBuilder::MASK_UNDELETE); - - $builder->remove('edit')->remove('OWner'); - $mask = $builder->get(); - $this->assertEquals(0, $mask & MaskBuilder::MASK_EDIT); - $this->assertEquals(0, $mask & MaskBuilder::MASK_OWNER); - $this->assertEquals(MaskBuilder::MASK_VIEW, $mask & MaskBuilder::MASK_VIEW); - } - - public function testGetPattern() - { - $builder = new MaskBuilder(); - $this->assertEquals(MaskBuilder::ALL_OFF, $builder->getPattern()); - - $builder->add('view'); - $this->assertEquals(str_repeat('.', 31).'V', $builder->getPattern()); - - $builder->add('owner'); - $this->assertEquals(str_repeat('.', 24).'N......V', $builder->getPattern()); - - $builder->add(1 << 10); - $this->assertEquals(str_repeat('.', 21).MaskBuilder::ON.'..N......V', $builder->getPattern()); - } - - public function testReset() - { - $builder = new MaskBuilder(); - $this->assertEquals(0, $builder->get()); - - $builder->add('view'); - $this->assertTrue($builder->get() > 0); - - $builder->reset(); - $this->assertEquals(0, $builder->get()); - } -} diff --git a/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php b/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php deleted file mode 100644 index 2148135f4bce6..0000000000000 --- a/src/Symfony/Component/Security/Acl/Tests/Voter/AclVoterTest.php +++ /dev/null @@ -1,432 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Tests\Voter; - -use Symfony\Component\Security\Acl\Exception\NoAceFoundException; -use Symfony\Component\Security\Acl\Voter\FieldVote; -use Symfony\Component\Security\Acl\Exception\AclNotFoundException; -use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; -use Symfony\Component\Security\Acl\Domain\ObjectIdentity; -use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; -use Symfony\Component\Security\Acl\Voter\AclVoter; - -class AclVoterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getSupportsAttributeTests - */ - public function testSupportsAttribute($attribute, $supported) - { - list($voter, , $permissionMap) = $this->getVoter(true, false); - - $permissionMap - ->expects($this->once()) - ->method('contains') - ->with($this->identicalTo($attribute)) - ->will($this->returnValue($supported)) - ; - - $this->assertSame($supported, $voter->supportsAttribute($attribute)); - } - - /** - * @dataProvider getSupportsAttributeNonStringTests - */ - public function testSupportsAttributeNonString($attribute) - { - list($voter) = $this->getVoter(true, false); - - $this->assertFalse($voter->supportsAttribute($attribute)); - } - - public function getSupportsAttributeTests() - { - return array( - array('foo', true), - array('foo', false), - ); - } - - public function getSupportsAttributeNonStringTests() - { - return array( - array(new \stdClass()), - array(1), - array(true), - array(array()), - ); - } - - /** - * @dataProvider getSupportsClassTests - */ - public function testSupportsClass($class) - { - list($voter) = $this->getVoter(); - - $this->assertTrue($voter->supportsClass($class)); - } - - public function getSupportsClassTests() - { - return array( - array('foo'), - array('bar'), - array('moo'), - ); - } - - public function testVote() - { - list($voter, , $permissionMap) = $this->getVoter(); - $permissionMap - ->expects($this->atLeastOnce()) - ->method('getMasks') - ->will($this->returnValue(null)) - ; - - $this->assertSame(VoterInterface::ACCESS_ABSTAIN, $voter->vote($this->getToken(), null, array('VIEW', 'EDIT', 'DELETE'))); - } - - /** - * @dataProvider getTrueFalseTests - */ - public function testVoteWhenNoObjectIsPassed($allowIfObjectIdentityUnavailable) - { - list($voter, , $permissionMap) = $this->getVoter($allowIfObjectIdentityUnavailable); - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->will($this->returnValue(array())) - ; - - if ($allowIfObjectIdentityUnavailable) { - $vote = VoterInterface::ACCESS_GRANTED; - } else { - $vote = VoterInterface::ACCESS_ABSTAIN; - } - - $this->assertSame($vote, $voter->vote($this->getToken(), null, array('VIEW'))); - } - - /** - * @dataProvider getTrueFalseTests - */ - public function testVoteWhenOidStrategyReturnsNull($allowIfUnavailable) - { - list($voter, , $permissionMap, $oidStrategy) = $this->getVoter($allowIfUnavailable); - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->will($this->returnValue(array())) - ; - - $oidStrategy - ->expects($this->once()) - ->method('getObjectIdentity') - ->will($this->returnValue(null)) - ; - - if ($allowIfUnavailable) { - $vote = VoterInterface::ACCESS_GRANTED; - } else { - $vote = VoterInterface::ACCESS_ABSTAIN; - } - - $this->assertSame($vote, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); - } - - public function getTrueFalseTests() - { - return array(array(true), array(false)); - } - - public function testVoteNoAclFound() - { - list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); - - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->will($this->returnValue(array())) - ; - - $oidStrategy - ->expects($this->once()) - ->method('getObjectIdentity') - ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) - ; - - $sidStrategy - ->expects($this->once()) - ->method('getSecurityIdentities') - ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) - ; - - $provider - ->expects($this->once()) - ->method('findAcl') - ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->throwException(new AclNotFoundException('Not found.'))) - ; - - $this->assertSame(VoterInterface::ACCESS_DENIED, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); - } - - /** - * @dataProvider getTrueFalseTests - */ - public function testVoteGrantsAccess($grant) - { - list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); - - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->with($this->equalTo('VIEW')) - ->will($this->returnValue($masks = array(1, 2, 3))) - ; - - $oidStrategy - ->expects($this->once()) - ->method('getObjectIdentity') - ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) - ; - - $sidStrategy - ->expects($this->once()) - ->method('getSecurityIdentities') - ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) - ; - - $provider - ->expects($this->once()) - ->method('findAcl') - ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) - ; - - $acl - ->expects($this->once()) - ->method('isGranted') - ->with($this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) - ->will($this->returnValue($grant)) - ; - - if ($grant) { - $vote = VoterInterface::ACCESS_GRANTED; - } else { - $vote = VoterInterface::ACCESS_DENIED; - } - - $this->assertSame($vote, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); - } - - public function testVoteNoAceFound() - { - list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); - - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->with($this->equalTo('VIEW')) - ->will($this->returnValue($masks = array(1, 2, 3))) - ; - - $oidStrategy - ->expects($this->once()) - ->method('getObjectIdentity') - ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) - ; - - $sidStrategy - ->expects($this->once()) - ->method('getSecurityIdentities') - ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) - ; - - $provider - ->expects($this->once()) - ->method('findAcl') - ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) - ; - - $acl - ->expects($this->once()) - ->method('isGranted') - ->with($this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) - ->will($this->throwException(new NoAceFoundException('No ACE'))) - ; - - $this->assertSame(VoterInterface::ACCESS_DENIED, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); - } - - /** - * @dataProvider getTrueFalseTests - */ - public function testVoteGrantsFieldAccess($grant) - { - list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); - - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->with($this->equalTo('VIEW')) - ->will($this->returnValue($masks = array(1, 2, 3))) - ; - - $oidStrategy - ->expects($this->once()) - ->method('getObjectIdentity') - ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) - ; - - $sidStrategy - ->expects($this->once()) - ->method('getSecurityIdentities') - ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) - ; - - $provider - ->expects($this->once()) - ->method('findAcl') - ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) - ; - - $acl - ->expects($this->once()) - ->method('isFieldGranted') - ->with($this->identicalTo('foo'), $this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) - ->will($this->returnValue($grant)) - ; - - if ($grant) { - $vote = VoterInterface::ACCESS_GRANTED; - } else { - $vote = VoterInterface::ACCESS_DENIED; - } - - $this->assertSame($vote, $voter->vote($this->getToken(), new FieldVote(new \stdClass(), 'foo'), array('VIEW'))); - } - - public function testVoteNoFieldAceFound() - { - list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); - - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->with($this->equalTo('VIEW')) - ->will($this->returnValue($masks = array(1, 2, 3))) - ; - - $oidStrategy - ->expects($this->once()) - ->method('getObjectIdentity') - ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) - ; - - $sidStrategy - ->expects($this->once()) - ->method('getSecurityIdentities') - ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) - ; - - $provider - ->expects($this->once()) - ->method('findAcl') - ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) - ; - - $acl - ->expects($this->once()) - ->method('isFieldGranted') - ->with($this->identicalTo('foo'), $this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) - ->will($this->throwException(new NoAceFoundException('No ACE'))) - ; - - $this->assertSame(VoterInterface::ACCESS_DENIED, $voter->vote($this->getToken(), new FieldVote(new \stdClass(), 'foo'), array('VIEW'))); - } - - public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObjectIdentity() - { - list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); - - $oid = new ObjectIdentity('someID', 'someType'); - - $permissionMap - ->expects($this->once()) - ->method('getMasks') - ->with($this->equalTo('VIEW')) - ->will($this->returnValue($masks = array(1, 2, 3))) - ; - - $oidStrategy - ->expects($this->never()) - ->method('getObjectIdentity') - ; - - $sidStrategy - ->expects($this->once()) - ->method('getSecurityIdentities') - ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) - ; - - $provider - ->expects($this->once()) - ->method('findAcl') - ->with($this->equalTo($oid), $this->equalTo($sids)) - ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) - ; - - $acl - ->expects($this->once()) - ->method('isGranted') - ->with($this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) - ->will($this->throwException(new NoAceFoundException('No ACE'))) - ; - - $voter->vote($this->getToken(), $oid, array('VIEW')); - } - - protected function getToken() - { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - } - - protected function getVoter($allowIfObjectIdentityUnavailable = true, $alwaysContains = true) - { - $provider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface'); - $permissionMap = $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface'); - $oidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface'); - $sidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface'); - - if ($alwaysContains) { - $permissionMap - ->expects($this->any()) - ->method('contains') - ->will($this->returnValue(true)); - } - - return array( - new AclVoter($provider, $oidStrategy, $sidStrategy, $permissionMap, null, $allowIfObjectIdentityUnavailable), - $provider, - $permissionMap, - $oidStrategy, - $sidStrategy, - ); - } -} diff --git a/src/Symfony/Component/Security/Acl/Voter/AclVoter.php b/src/Symfony/Component/Security/Acl/Voter/AclVoter.php deleted file mode 100644 index ec6024a807915..0000000000000 --- a/src/Symfony/Component/Security/Acl/Voter/AclVoter.php +++ /dev/null @@ -1,147 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Voter; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Security\Acl\Exception\NoAceFoundException; -use Symfony\Component\Security\Acl\Exception\AclNotFoundException; -use Symfony\Component\Security\Acl\Model\AclProviderInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; -use Symfony\Component\Security\Acl\Permission\PermissionMapInterface; -use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface; -use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; - -/** - * This voter can be used as a base class for implementing your own permissions. - * - * @author Johannes M. Schmitt - */ -class AclVoter implements VoterInterface -{ - private $aclProvider; - private $permissionMap; - private $objectIdentityRetrievalStrategy; - private $securityIdentityRetrievalStrategy; - private $allowIfObjectIdentityUnavailable; - private $logger; - - public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy, PermissionMapInterface $permissionMap, LoggerInterface $logger = null, $allowIfObjectIdentityUnavailable = true) - { - $this->aclProvider = $aclProvider; - $this->permissionMap = $permissionMap; - $this->objectIdentityRetrievalStrategy = $oidRetrievalStrategy; - $this->securityIdentityRetrievalStrategy = $sidRetrievalStrategy; - $this->logger = $logger; - $this->allowIfObjectIdentityUnavailable = $allowIfObjectIdentityUnavailable; - } - - public function supportsAttribute($attribute) - { - return is_string($attribute) && $this->permissionMap->contains($attribute); - } - - public function vote(TokenInterface $token, $object, array $attributes) - { - foreach ($attributes as $attribute) { - if (!$this->supportsAttribute($attribute)) { - continue; - } - - if (null === $masks = $this->permissionMap->getMasks($attribute, $object)) { - continue; - } - - if (null === $object) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Object identity unavailable. Voting to %s.', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain')); - } - - return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; - } elseif ($object instanceof FieldVote) { - $field = $object->getField(); - $object = $object->getDomainObject(); - } else { - $field = null; - } - - if ($object instanceof ObjectIdentityInterface) { - $oid = $object; - } elseif (null === $oid = $this->objectIdentityRetrievalStrategy->getObjectIdentity($object)) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Object identity unavailable. Voting to %s.', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain')); - } - - return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; - } - - if (!$this->supportsClass($oid->getType())) { - return self::ACCESS_ABSTAIN; - } - - $sids = $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token); - - try { - $acl = $this->aclProvider->findAcl($oid, $sids); - - if (null === $field && $acl->isGranted($masks, $sids, false)) { - if (null !== $this->logger) { - $this->logger->debug('ACL found, permission granted. Voting to grant access.'); - } - - return self::ACCESS_GRANTED; - } elseif (null !== $field && $acl->isFieldGranted($field, $masks, $sids, false)) { - if (null !== $this->logger) { - $this->logger->debug('ACL found, permission granted. Voting to grant access.'); - } - - return self::ACCESS_GRANTED; - } - - if (null !== $this->logger) { - $this->logger->debug('ACL found, insufficient permissions. Voting to deny access.'); - } - - return self::ACCESS_DENIED; - } catch (AclNotFoundException $e) { - if (null !== $this->logger) { - $this->logger->debug('No ACL found for the object identity. Voting to deny access.'); - } - - return self::ACCESS_DENIED; - } catch (NoAceFoundException $e) { - if (null !== $this->logger) { - $this->logger->debug('ACL found, no ACE applicable. Voting to deny access.'); - } - - return self::ACCESS_DENIED; - } - } - - // no attribute was supported - return self::ACCESS_ABSTAIN; - } - - /** - * You can override this method when writing a voter for a specific domain - * class. - * - * @param string $class The class name - * - * @return bool - */ - public function supportsClass($class) - { - return true; - } -} diff --git a/src/Symfony/Component/Security/Acl/Voter/FieldVote.php b/src/Symfony/Component/Security/Acl/Voter/FieldVote.php deleted file mode 100644 index 8782f765d0acf..0000000000000 --- a/src/Symfony/Component/Security/Acl/Voter/FieldVote.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Acl\Voter; - -/** - * This class is a lightweight wrapper around field vote requests which does - * not violate any interface contracts. - * - * @author Johannes M. Schmitt - */ -class FieldVote -{ - private $domainObject; - private $field; - - public function __construct($domainObject, $field) - { - $this->domainObject = $domainObject; - $this->field = $field; - } - - public function getDomainObject() - { - return $this->domainObject; - } - - public function getField() - { - return $this->field; - } -} diff --git a/src/Symfony/Component/Security/Acl/composer.json b/src/Symfony/Component/Security/Acl/composer.json deleted file mode 100644 index b2ac560af9ad3..0000000000000 --- a/src/Symfony/Component/Security/Acl/composer.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "symfony/security-acl", - "type": "library", - "description": "Symfony Security Component - ACL (Access Control List)", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.9", - "symfony/security-core": "~2.4|~3.0.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7|~3.0.0", - "doctrine/common": "~2.2", - "doctrine/dbal": "~2.2", - "psr/log": "~1.0" - }, - "suggest": { - "symfony/class-loader": "For using the ACL generateSql script", - "symfony/finder": "For using the ACL generateSql script", - "doctrine/dbal": "For using the built-in ACL implementation" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\Security\\Acl\\": "" } - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - } -} diff --git a/src/Symfony/Component/Security/Acl/phpunit.xml.dist b/src/Symfony/Component/Security/Acl/phpunit.xml.dist deleted file mode 100644 index 755233957585a..0000000000000 --- a/src/Symfony/Component/Security/Acl/phpunit.xml.dist +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - ./vendor - ./Tests - - - - diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php index 4b6c11fc8517d..b4930813f50c8 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php @@ -14,7 +14,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; /** - * TokenStorage contains a TokenInterface + * TokenStorage contains a TokenInterface. * * It gives access to the token representing the current user authentication. * diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index 61debe39cce27..e021cc73547c8 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -150,7 +150,6 @@ private function decideConsensus(TokenInterface $token, array $attributes, $obje { $grant = 0; $deny = 0; - $abstain = 0; foreach ($this->voters as $voter) { $result = $voter->vote($token, $object, $attributes); @@ -163,11 +162,6 @@ private function decideConsensus(TokenInterface $token, array $attributes, $obje case VoterInterface::ACCESS_DENIED: ++$deny; - break; - - default: - ++$abstain; - break; } } @@ -180,7 +174,7 @@ private function decideConsensus(TokenInterface $token, array $attributes, $obje return false; } - if ($grant == $deny && $grant != 0) { + if ($grant > 0) { return $this->allowIfEqualGrantedDeniedDecisions; } diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php index 43ca558f5f159..efa156228e227 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php @@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; /** - * Abstract Voter implementation that reduces boilerplate code required to create a custom Voter + * Abstract Voter implementation that reduces boilerplate code required to create a custom Voter. * * @author Roman Marintšenko */ @@ -44,7 +44,7 @@ public function supportsClass($class) } /** - * Iteratively check all given attributes by calling isGranted + * Iteratively check all given attributes by calling isGranted. * * This method terminates as soon as it is able to return ACCESS_GRANTED * If at least one attribute is supported, but access not granted, then ACCESS_DENIED is returned @@ -83,14 +83,14 @@ public function vote(TokenInterface $token, $object, array $attributes) } /** - * Return an array of supported classes. This will be called by supportsClass + * Return an array of supported classes. This will be called by supportsClass. * * @return array an array of supported classes, i.e. array('Acme\DemoBundle\Model\Product') */ abstract protected function getSupportedClasses(); /** - * Return an array of supported attributes. This will be called by supportsAttribute + * Return an array of supported attributes. This will be called by supportsAttribute. * * @return array an array of supported attributes, i.e. array('CREATE', 'READ') */ @@ -101,7 +101,7 @@ abstract protected function getSupportedAttributes(); * It is safe to assume that $attribute and $object's class pass supportsAttribute/supportsClass * $user can be one of the following: * a UserInterface object (fully authenticated user) - * a string (anonymously authenticated user) + * a string (anonymously authenticated user). * * @param string $attribute * @param object $object diff --git a/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoder.php index 13ee835d4ad17..b09604952e0ef 100644 --- a/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoder.php @@ -14,7 +14,7 @@ use Symfony\Component\Security\Core\User\UserInterface; /** - * A generic password encoder + * A generic password encoder. * * @author Ariel Ferrandini */ diff --git a/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoderInterface.php b/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoderInterface.php index 39e906ac69a8e..7861caab20ca6 100644 --- a/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoderInterface.php +++ b/src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoderInterface.php @@ -21,7 +21,6 @@ interface UserPasswordEncoderInterface { /** - * * Encodes the plain password. * * @param UserInterface $user The user diff --git a/src/Symfony/Component/Security/Core/SecurityContext.php b/src/Symfony/Component/Security/Core/SecurityContext.php index 8bcbfee438e21..027ff49480926 100644 --- a/src/Symfony/Component/Security/Core/SecurityContext.php +++ b/src/Symfony/Component/Security/Core/SecurityContext.php @@ -28,6 +28,7 @@ * * @author Fabien Potencier * @author Johannes M. Schmitt + * * @deprecated since version 2.6, to be removed in 3.0. */ class SecurityContext implements SecurityContextInterface @@ -43,7 +44,7 @@ class SecurityContext implements SecurityContextInterface private $authorizationChecker; /** - * For backwards compatibility, the signature of sf <2.6 still works + * For backwards compatibility, the signature of sf <2.6 still works. * * @param TokenStorageInterface|AuthenticationManagerInterface $tokenStorage * @param AuthorizationCheckerInterface|AccessDecisionManagerInterface $authorizationChecker diff --git a/src/Symfony/Component/Security/Core/SecurityContextInterface.php b/src/Symfony/Component/Security/Core/SecurityContextInterface.php index 61cdf4f57988a..a759feb81076a 100644 --- a/src/Symfony/Component/Security/Core/SecurityContextInterface.php +++ b/src/Symfony/Component/Security/Core/SecurityContextInterface.php @@ -20,6 +20,7 @@ * The SecurityContextInterface. * * @author Johannes M. Schmitt + * * @deprecated since version 2.6, to be removed in 3.0. */ interface SecurityContextInterface extends TokenStorageInterface, AuthorizationCheckerInterface diff --git a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php index c5da22d315177..92d7c163a70fb 100644 --- a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php +++ b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php @@ -81,7 +81,7 @@ public function isGrantedDelegationProvider() } /** - * Test dedicated to check if the backwards compatibility is still working + * Test dedicated to check if the backwards compatibility is still working. */ public function testOldConstructorSignature() { diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php index 72e08c0a73d87..8053732beecad 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php @@ -15,6 +15,7 @@ /** * @since 2.5.4 + * * @author Bernhard Schussek * @group legacy */ diff --git a/src/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.php b/src/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.php index 5abe47cfc9c93..bccabe6c9c0f1 100644 --- a/src/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.php +++ b/src/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.php @@ -15,6 +15,7 @@ * Manages CSRF tokens. * * @since 2.4 + * * @author Bernhard Schussek */ interface CsrfTokenManagerInterface diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php index 4fb0c99d3005a..1b325e5d1e8c0 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenGenerator/UriSafeTokenGeneratorTest.php @@ -21,7 +21,8 @@ class UriSafeTokenGeneratorTest extends \PHPUnit_Framework_TestCase const ENTROPY = 1000; /** - * A non alpha-numeric byte string + * A non alpha-numeric byte string. + * * @var string */ private static $bytes; @@ -57,7 +58,7 @@ public function testGenerateToken() { $this->random->expects($this->once()) ->method('nextBytes') - ->with(self::ENTROPY/8) + ->with(self::ENTROPY / 8) ->will($this->returnValue(self::$bytes)); $token = $this->generator->generateToken(); diff --git a/src/Symfony/Component/Security/Csrf/TokenGenerator/TokenGeneratorInterface.php b/src/Symfony/Component/Security/Csrf/TokenGenerator/TokenGeneratorInterface.php index e02ac66ea09b4..1405b84f03322 100644 --- a/src/Symfony/Component/Security/Csrf/TokenGenerator/TokenGeneratorInterface.php +++ b/src/Symfony/Component/Security/Csrf/TokenGenerator/TokenGeneratorInterface.php @@ -15,6 +15,7 @@ * Generates CSRF tokens. * * @since 2.4 + * * @author Bernhard Schussek */ interface TokenGeneratorInterface diff --git a/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php b/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php index 122bc02bfb3fd..edeb435138f21 100644 --- a/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php +++ b/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php @@ -18,6 +18,7 @@ * Generates CSRF tokens. * * @since 2.4 + * * @author Bernhard Schussek */ class UriSafeTokenGenerator implements TokenGeneratorInterface diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php index 60145c65a05f1..2620156f369a6 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php @@ -17,12 +17,14 @@ * Token storage that uses PHP's native session handling. * * @since 2.4 + * * @author Bernhard Schussek */ class NativeSessionTokenStorage implements TokenStorageInterface { /** * The namespace used to store values in the session. + * * @var string */ const SESSION_NAMESPACE = '_csrf'; diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php index f08eb962172ad..a6a6ea389426e 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php @@ -18,18 +18,21 @@ * Token storage that uses a Symfony2 Session object. * * @since 2.4 + * * @author Bernhard Schussek */ class SessionTokenStorage implements TokenStorageInterface { /** * The namespace used to store values in the session. + * * @var string */ const SESSION_NAMESPACE = '_csrf'; /** - * The user session from which the session ID is returned + * The user session from which the session ID is returned. + * * @var SessionInterface */ private $session; diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/TokenStorageInterface.php b/src/Symfony/Component/Security/Csrf/TokenStorage/TokenStorageInterface.php index 0fadfa3606221..5efe72f694d4b 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/TokenStorageInterface.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/TokenStorageInterface.php @@ -15,6 +15,7 @@ * Stores CSRF tokens. * * @since 2.4 + * * @author Bernhard Schussek */ interface TokenStorageInterface diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php index 317c8a00ba4e8..4d5c71aa5c485 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php @@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\Security; /** - * Extracts Security Errors from Request + * Extracts Security Errors from Request. * * @author Boris Vujicic */ @@ -72,6 +72,7 @@ public function getLastUsername() /** * @return Request + * * @throws \LogicException */ private function getRequest() diff --git a/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php b/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php index 6a1311f3a5490..c5c43f2895734 100644 --- a/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php @@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; /** - * Class to proxy authentication success/failure handlers + * Class to proxy authentication success/failure handlers. * * Events are sent to the SimpleAuthenticatorInterface if it implements * the right interface, otherwise (or if it fails to return a Response) diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index 9a6fbfe74b01c..15b71efd4d8bb 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -101,7 +101,7 @@ public function handle(GetResponseEvent $event) if ($serverDigestMd5 !== $digestAuth->getResponse()) { if (null !== $this->logger) { - $this->logger->debug("Unexpected response from the DigestAuth received; is the header returning a clear text passwords?", array('expected' => $serverDigestMd5, 'received' => $digestAuth->getResponse())); + $this->logger->debug('Unexpected response from the DigestAuth received; is the header returning a clear text passwords?', array('expected' => $serverDigestMd5, 'received' => $digestAuth->getResponse())); } $this->fail($event, $request, new BadCredentialsException('Incorrect response')); diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index 6d1f27d8ec2f0..a1cae2a437214 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -47,8 +47,9 @@ class ExceptionListener private $errorPage; private $logger; private $httpUtils; + private $stateless; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, $stateless = false) { $this->tokenStorage = $tokenStorage; $this->accessDeniedHandler = $accessDeniedHandler; @@ -58,6 +59,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationT $this->authenticationTrustResolver = $trustResolver; $this->errorPage = $errorPage; $this->logger = $logger; + $this->stateless = $stateless; } /** @@ -185,7 +187,9 @@ private function startAuthentication(Request $request, AuthenticationException $ $this->logger->debug('Calling Authentication entry point.'); } - $this->setTargetPath($request); + if (!$this->stateless) { + $this->setTargetPath($request); + } if ($authException instanceof AccountStatusException) { // remove the security token to prevent infinite redirect loops diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Voter/AbstractVoterTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Voter/AbstractVoterTest.php index c5e946666f2ff..af7b82f35d5a2 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Voter/AbstractVoterTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Voter/AbstractVoterTest.php @@ -72,7 +72,7 @@ protected function getSupportedClasses() protected function getSupportedAttributes() { - return array( 'foo', 'bar', 'baz'); + return array('foo', 'bar', 'baz'); } protected function isGranted($attribute, $object, $user = null) diff --git a/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php b/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php index 57517bf7f41ff..5225eb52d6a76 100644 --- a/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php +++ b/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php @@ -20,7 +20,7 @@ class LegacySecurityContextInterfaceTest extends \PHPUnit_Framework_TestCase { /** - * Test if the BC Layer is working as intended + * Test if the BC Layer is working as intended. */ public function testConstantSync() { diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 75abcf82e0647..4f144118f9de2 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -22,7 +22,6 @@ "symfony/http-kernel": "~2.4|~3.0.0" }, "replace": { - "symfony/security-acl": "self.version", "symfony/security-core": "self.version", "symfony/security-csrf": "self.version", "symfony/security-http": "self.version" diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 1067296f9a588..5f5f2899f5fff 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -57,7 +57,6 @@ public function __construct($associative = false, $depth = 512) * * @deprecated since version 2.5, to be removed in 3.0. * The {@self decode()} method throws an exception if error found. - * * @see http://php.net/manual/en/function.json-last-error.php json_last_error */ public function getLastError() diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index 37f384b25756d..3a6b2fdbbb1a9 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -35,7 +35,6 @@ public function __construct($bitmask = 0) * * @deprecated since version 2.5, to be removed in 3.0. * The {@self encode()} throws an exception if error found. - * * @see http://php.net/manual/en/function.json-last-error.php json_last_error */ public function getLastError() diff --git a/src/Symfony/Component/Serializer/Exception/CircularReferenceException.php b/src/Symfony/Component/Serializer/Exception/CircularReferenceException.php index b2977b970608a..dc84183fc7d95 100644 --- a/src/Symfony/Component/Serializer/Exception/CircularReferenceException.php +++ b/src/Symfony/Component/Serializer/Exception/CircularReferenceException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Serializer\Exception; /** - * CircularReferenceException + * CircularReferenceException. * * @author Kévin Dunglas */ diff --git a/src/Symfony/Component/Serializer/Exception/MappingException.php b/src/Symfony/Component/Serializer/Exception/MappingException.php index 8b63dd0a6d345..4df4eec3903ac 100644 --- a/src/Symfony/Component/Serializer/Exception/MappingException.php +++ b/src/Symfony/Component/Serializer/Exception/MappingException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Serializer\Exception; /** - * MappingException + * MappingException. * * @author Kévin Dunglas */ diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php index 344d633b26cda..3a354e354e9e3 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php @@ -38,7 +38,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface /** * @param LoaderInterface $loader - * @param Cache|null $cache + * @param Cache|null $cache */ public function __construct(LoaderInterface $loader, Cache $cache = null) { diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php index 1c5d5e82e63f0..1c84698594e5b 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php @@ -26,7 +26,7 @@ class YamlFileLoader extends FileLoader private $yamlParser; /** - * An array of YAML class descriptions + * An array of YAML class descriptions. * * @var array */ diff --git a/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php b/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php index 27f4eee59a71a..8ef851c6528e5 100644 --- a/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php +++ b/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php @@ -46,7 +46,7 @@ public function normalize($propertyName) $snakeCasedName = ''; $len = strlen($propertyName); - for ($i = 0; $i < $len; $i++) { + for ($i = 0; $i < $len; ++$i) { if (ctype_upper($propertyName[$i])) { $snakeCasedName .= '_'.strtolower($propertyName[$i]); } else { diff --git a/src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php b/src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php index 306e6541218e0..c9f66b029a9e9 100644 --- a/src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php +++ b/src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php @@ -22,6 +22,7 @@ interface NameConverterInterface * Converts a property name to its normalized value. * * @param string $propertyName + * * @return string */ public function normalize($propertyName); @@ -30,6 +31,7 @@ public function normalize($propertyName); * Converts a property name to its denormalized value. * * @param string $propertyName + * * @return string */ public function denormalize($propertyName); diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 93dfba9a396b5..8cc85e5b61223 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -192,7 +192,7 @@ protected function isCircularReference($object, &$context) return true; } - $context['circular_reference_limit'][$objectHash]++; + ++$context['circular_reference_limit'][$objectHash]; } else { $context['circular_reference_limit'][$objectHash] = 1; } @@ -312,7 +312,15 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref $allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes); $ignored = in_array($paramName, $this->ignoredAttributes); - if ($allowed && !$ignored && array_key_exists($key, $data)) { + if (method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic()) { + if ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { + if (!is_array($data[$paramName])) { + throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name)); + } + + $params = array_merge($params, $data[$paramName]); + } + } elseif ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { $params[] = $data[$key]; // don't run set for a parameter passed to the constructor unset($data[$key]); diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 422021ae74876..a62de61485416 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -471,13 +471,13 @@ protected function getNamespacedArray() '@xmlns:media' => 'http://search.yahoo.com/mrss/', '@xmlns:gd' => 'http://schemas.google.com/g/2005', '@xmlns:yt' => 'http://gdata.youtube.com/schemas/2007', - 'qux' => "1", - 'app:foo' => "foo", - 'yt:bar' => array("a", "b"), + 'qux' => '1', + 'app:foo' => 'foo', + 'yt:bar' => array('a', 'b'), 'media:baz' => array( - 'media:key' => "val", - 'media:key2' => "val", - 'A B' => "bar", + 'media:key' => 'val', + 'media:key2' => 'val', + 'A B' => 'bar', 'item' => array( array( 'title' => 'title1', diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/VariadicConstructorArgsDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/VariadicConstructorArgsDummy.php new file mode 100644 index 0000000000000..c04aeba0c45d1 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/VariadicConstructorArgsDummy.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Serializer\Tests\Fixtures; + +class VariadicConstructorArgsDummy +{ + private $foo; + + public function __construct(...$foo) + { + $this->foo = $foo; + } + + public function getFoo() + { + return $this->foo; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 32d729a211476..24036292caceb 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -216,6 +216,28 @@ public function testConstructorDenormalizeWithOptionalDefaultArgument() $this->assertEquals('test', $obj->getBar()); } + /** + * @requires PHP 5.6 + */ + public function testConstructorDenormalizeWithVariadicArgument() + { + $obj = $this->normalizer->denormalize( + array('foo' => array(1, 2, 3)), + 'Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorArgsDummy', 'any'); + $this->assertEquals(array(1, 2, 3), $obj->getFoo()); + } + + /** + * @requires PHP 5.6 + */ + public function testConstructorDenormalizeWithMissingVariadicArgument() + { + $obj = $this->normalizer->denormalize( + array(), + 'Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorArgsDummy', 'any'); + $this->assertEquals(array(), $obj->getFoo()); + } + public function testConstructorWithObjectDenormalize() { $data = new \stdClass(); diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 4ed7c2d7c1e9b..19b8280fdb6d4 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "symfony/phpunit-bridge": "~2.7|~3.0.0", - "symfony/yaml": "~2.0|~3.0.0", + "symfony/yaml": "~2.0,>=2.0.5|~3.0.0", "symfony/config": "~2.2|~3.0.0", "symfony/property-access": "~2.3|~3.0.0", "doctrine/annotations": "~1.0", diff --git a/src/Symfony/Component/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index 5423741db81c5..80e17c8b0a24c 100644 --- a/src/Symfony/Component/Stopwatch/Section.php +++ b/src/Symfony/Component/Stopwatch/Section.php @@ -120,7 +120,7 @@ public function startEvent($name, $category) } /** - * Checks if the event was started + * Checks if the event was started. * * @param string $name The event name * @@ -164,7 +164,7 @@ public function lap($name) } /** - * Returns a specific event by name + * Returns a specific event by name. * * @param string $name The event name * diff --git a/src/Symfony/Component/Stopwatch/Stopwatch.php b/src/Symfony/Component/Stopwatch/Stopwatch.php index 1595385c63f2b..44f18d5e4252f 100644 --- a/src/Symfony/Component/Stopwatch/Stopwatch.php +++ b/src/Symfony/Component/Stopwatch/Stopwatch.php @@ -134,7 +134,7 @@ public function lap($name) } /** - * Returns a specific event by name + * Returns a specific event by name. * * @param string $name The event name * diff --git a/src/Symfony/Component/Stopwatch/StopwatchEvent.php b/src/Symfony/Component/Stopwatch/StopwatchEvent.php index 7f9b8c65e32a1..930722d2f598c 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchEvent.php +++ b/src/Symfony/Component/Stopwatch/StopwatchEvent.php @@ -177,7 +177,7 @@ public function getDuration() $stopped = count($periods); $left = count($this->started) - $stopped; - for ($i = 0; $i < $left; $i++) { + for ($i = 0; $i < $left; ++$i) { $index = $stopped + $i; $periods[] = new StopwatchPeriod($this->started[$index], $this->getNow()); } diff --git a/src/Symfony/Component/Templating/EngineInterface.php b/src/Symfony/Component/Templating/EngineInterface.php index 365b896952574..087687d48e0a0 100644 --- a/src/Symfony/Component/Templating/EngineInterface.php +++ b/src/Symfony/Component/Templating/EngineInterface.php @@ -14,7 +14,7 @@ /** * EngineInterface is the interface each engine must implement. * - * All methods relies on a template name. A template name is a + * All methods rely on a template name. A template name is a * "logical" name for the template, and as such it does not refer to * a path on the filesystem (in fact, the template can be stored * anywhere, like in a database). diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php index f33a7e5dd91b0..090f16d7ec16c 100644 --- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php +++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php @@ -109,7 +109,7 @@ private function sanitizeCollectedMessages($messages) $result[$messageId]['parameters'][] = $message['parameters']; } - $result[$messageId]['count']++; + ++$result[$messageId]['count']; } unset($messages[$key]); diff --git a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php index 58d19733dbb36..47e082c22e992 100644 --- a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php @@ -70,11 +70,17 @@ protected function format(MessageCatalogue $messages, $domain) // Does the target contain characters requiring a CDATA section? $text = 1 === preg_match('/[&<>]/', $target) ? $dom->createCDATASection($target) : $dom->createTextNode($target); - $t = $translation->appendChild($dom->createElement('target')); + $targetElement = $dom->createElement('target'); + $metadata = $messages->getMetadata($source, $domain); + if ($this->hasMetadataArrayInfo('target-attributes', $metadata)) { + foreach ($metadata['target-attributes'] as $name => $value) { + $targetElement->setAttribute($name, $value); + } + } + $t = $translation->appendChild($targetElement); $t->appendChild($text); - $metadata = $messages->getMetadata($source, $domain); - if (null !== $metadata && array_key_exists('notes', $metadata) && is_array($metadata['notes'])) { + if ($this->hasMetadataArrayInfo('notes', $metadata)) { foreach ($metadata['notes'] as $note) { if (!isset($note['content'])) { continue; @@ -106,4 +112,15 @@ protected function getExtension() { return 'xlf'; } + + /** + * @param string $key + * @param array|null $metadata + * + * @return bool + */ + private function hasMetadataArrayInfo($key, $metadata = null) + { + return null !== $metadata && array_key_exists($key, $metadata) && ($metadata[$key] instanceof \Traversable || is_array($metadata[$key])); + } } diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index d2b5407f82e1f..f2cbacb4f02e6 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -59,24 +59,15 @@ public function load($resource, $locale, $domain = 'messages') $catalogue->set((string) $source, $target, $domain); - if (isset($translation->note)) { - $notes = array(); - foreach ($translation->note as $xmlNote) { - $noteAttributes = $xmlNote->attributes(); - $note = array('content' => $this->utf8ToCharset((string) $xmlNote, $encoding)); - if (isset($noteAttributes['priority'])) { - $note['priority'] = (int) $noteAttributes['priority']; - } - - if (isset($noteAttributes['from'])) { - $note['from'] = (string) $noteAttributes['from']; - } - - $notes[] = $note; - } - - $catalogue->setMetadata((string) $source, array('notes' => $notes), $domain); + $metadata = array(); + if ($notes = $this->parseNotesMetadata($translation->note, $encoding)) { + $metadata['notes'] = $notes; } + if ($translation->target->attributes()) { + $metadata['target-attributes'] = $translation->target->attributes(); + } + + $catalogue->setMetadata((string) $source, $metadata, $domain); } if (class_exists('Symfony\Component\Config\Resource\FileResource')) { @@ -185,4 +176,35 @@ private function getXmlErrors($internalErrors) return $errors; } + + /** + * @param \SimpleXMLElement|null $noteElement + * @param string|null $encoding + * + * @return array + */ + private function parseNotesMetadata(\SimpleXMLElement $noteElement = null, $encoding = null) + { + $notes = array(); + + if (null === $noteElement) { + return $notes; + } + + foreach ($noteElement as $xmlNote) { + $noteAttributes = $xmlNote->attributes(); + $note = array('content' => $this->utf8ToCharset((string) $xmlNote, $encoding)); + if (isset($noteAttributes['priority'])) { + $note['priority'] = (int) $noteAttributes['priority']; + } + + if (isset($noteAttributes['from'])) { + $note['from'] = (string) $noteAttributes['from']; + } + + $notes[] = $note; + } + + return $notes; + } } diff --git a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php index dff2cc4c94a5b..b1f9826c295b9 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php @@ -38,4 +38,39 @@ public function testDump() unlink($tempDir.'/messages.en_US.xlf'); } + + public function testTargetAttributesMetadataIsSetInFile() + { + $catalogue = new MessageCatalogue('en_US'); + $catalogue->add(array( + 'foo' => 'bar', + )); + $catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation'))); + + $tempDir = sys_get_temp_dir(); + $dumper = new XliffFileDumper(); + $dumper->dump($catalogue, array('path' => $tempDir, 'default_locale' => 'fr_FR')); + + $content = << + + + + + foo + bar + + + + + +EOT; + + $this->assertEquals( + $content, + file_get_contents($tempDir.'/messages.en_US.xlf') + ); + + unlink($tempDir.'/messages.en_US.xlf'); + } } diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index c3d65b493202e..18c3aaeb250c9 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -73,6 +73,15 @@ public function testEncoding() $this->assertEquals(array('notes' => array(array('content' => utf8_decode('bäz')))), $catalogue->getMetadata('foo', 'domain1')); } + public function testTargetAttributesAreStoredCorrectly() + { + $loader = new XliffFileLoader(); + $catalogue = $loader->load(__DIR__.'/../fixtures/with-attributes.xlf', 'en', 'domain1'); + + $metadata = $catalogue->getMetadata('foo', 'domain1'); + $this->assertEquals('translated', $metadata['target-attributes']['state']); + } + /** * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException */ diff --git a/src/Symfony/Component/Translation/Tests/fixtures/with-attributes.xlf b/src/Symfony/Component/Translation/Tests/fixtures/with-attributes.xlf new file mode 100644 index 0000000000000..78730629cdc47 --- /dev/null +++ b/src/Symfony/Component/Translation/Tests/fixtures/with-attributes.xlf @@ -0,0 +1,21 @@ + + + + + + foo + bar + + + extra + bar + + + key + + baz + qux + + + + diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index ad86f4418dc26..1ddc1ae0a3e20 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -55,13 +55,15 @@ abstract class Constraint const PROPERTY_CONSTRAINT = 'property'; /** - * Maps error codes to the names of their constants + * Maps error codes to the names of their constants. + * * @var array */ protected static $errorNames = array(); /** - * Domain-specific data attached to a constraint + * Domain-specific data attached to a constraint. + * * @var mixed */ public $payload; diff --git a/src/Symfony/Component/Validator/Constraints/Composite.php b/src/Symfony/Component/Validator/Constraints/Composite.php index 22a748cbf42d1..90c98620f0055 100644 --- a/src/Symfony/Component/Validator/Constraints/Composite.php +++ b/src/Symfony/Component/Validator/Constraints/Composite.php @@ -25,6 +25,7 @@ * contains the nested constraints. * * @since 2.6 + * * @author Bernhard Schussek */ abstract class Composite extends Constraint @@ -58,7 +59,7 @@ public function __construct($options = null) $this->initializeNestedConstraints(); - /** @var Constraint[] $nestedConstraints */ + /* @var Constraint[] $nestedConstraints */ $compositeOption = $this->getCompositeOption(); $nestedConstraints = $this->$compositeOption; diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 5125a3265cdb4..62a6139a6efb9 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -294,7 +294,7 @@ private static function moreDecimalsThan($double, $numberOfDecimals) /** * Convert the limit to the smallest possible number - * (i.e. try "MB", then "kB", then "bytes") + * (i.e. try "MB", then "kB", then "bytes"). */ private function factorizeSizes($size, $limit, $binaryFormat) { diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php index b74f92caa8fd7..a28a442246265 100644 --- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -102,7 +102,6 @@ public function __construct(array $groups) * @return \Traversable The iterator * * @see \IteratorAggregate::getIterator() - * * @deprecated since version 2.5, to be removed in 3.0. */ public function getIterator() diff --git a/src/Symfony/Component/Validator/Constraints/Iban.php b/src/Symfony/Component/Validator/Constraints/Iban.php index a0d6b0982d645..9c4d3838fa0f8 100644 --- a/src/Symfony/Component/Validator/Constraints/Iban.php +++ b/src/Symfony/Component/Validator/Constraints/Iban.php @@ -23,11 +23,15 @@ */ class Iban extends Constraint { + /** @deprecated, to be removed in 3.0. */ const TOO_SHORT_ERROR = '88e5e319-0aeb-4979-a27e-3d9ce0c16166'; const INVALID_COUNTRY_CODE_ERROR = 'de78ee2c-bd50-44e2-aec8-3d8228aeadb9'; const INVALID_CHARACTERS_ERROR = '8d3d85e4-784f-4719-a5bc-d9e40d45a3a5'; + /** @deprecated, to be removed in 3.0. */ const INVALID_CASE_ERROR = 'f4bf62fe-03ec-42af-a53b-68e21b1e7274'; const CHECKSUM_FAILED_ERROR = 'b9401321-f9bf-4dcb-83c1-f31094440795'; + const INVALID_FORMAT_ERROR = 'c8d318f1-2ecc-41ba-b983-df70d225cf5a'; + const NOT_SUPPORTED_COUNTRY_CODE_ERROR = 'e2c259f3-4b46-48e6-b72e-891658158ec8'; protected static $errorNames = array( self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', @@ -35,6 +39,8 @@ class Iban extends Constraint self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', self::INVALID_CASE_ERROR => 'INVALID_CASE_ERROR', self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR', + self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', + self::NOT_SUPPORTED_COUNTRY_CODE_ERROR => 'NOT_SUPPORTED_COUNTRY_CODE_ERROR', ); public $message = 'This is not a valid International Bank Account Number (IBAN).'; diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 65c22ff9c0c97..72ae002675072 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -25,6 +25,118 @@ */ class IbanValidator extends ConstraintValidator { + /** + * IBAN country specific formats. + * + * The first 2 characters from an IBAN format are the two-character ISO country code. + * The following 2 characters represent the check digits calculated from the rest of the IBAN characters. + * The rest are up to thirty alphanumeric characters for + * a BBAN (Basic Bank Account Number) which has a fixed length per country and, + * included within it, a bank identifier with a fixed position and a fixed length per country + * + * @link http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf + * + * @var array + */ + private static $formats = array( + 'AD' => 'AD\d{2}\d{4}\d{4}[\dA-Z]{12}', // Andorra + 'AE' => 'AE\d{2}\d{3}\d{16}', // United Arab Emirates + 'AL' => 'AL\d{2}\d{8}[\dA-Z]{16}', // Albania + 'AO' => 'AO\d{2}\d{21}', // Angola + 'AT' => 'AT\d{2}\d{5}\d{11}', // Austria + 'AX' => 'FI\d{2}\d{6}\d{7}\d{1}', // Aland Islands + 'AZ' => 'AZ\d{2}[A-Z]{4}[\dA-Z]{20}', // Azerbaijan + 'BA' => 'BA\d{2}\d{3}\d{3}\d{8}\d{2}', // Bosnia and Herzegovina + 'BE' => 'BE\d{2}\d{3}\d{7}\d{2}', // Belgium + 'BF' => 'BF\d{2}\d{23}', // Burkina Faso + 'BG' => 'BG\d{2}[A-Z]{4}\d{4}\d{2}[\dA-Z]{8}', // Bulgaria + 'BH' => 'BH\d{2}[A-Z]{4}[\dA-Z]{14}', // Bahrain + 'BI' => 'BI\d{2}\d{12}', // Burundi + 'BJ' => 'BJ\d{2}[A-Z]{1}\d{23}', // Benin + 'BL' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Saint Barthelemy + 'BR' => 'BR\d{2}\d{8}\d{5}\d{10}[A-Z][\dA-Z]', // Brazil + 'CG' => 'CG\d{2}\d{23}', // Congo + 'CH' => 'CH\d{2}\d{5}[\dA-Z]{12}', // Switzerland + 'CI' => 'CI\d{2}[A-Z]{1}\d{23}', // Ivory Coast + 'CM' => 'CM\d{2}\d{23}', // Cameron + 'CR' => 'CR\d{2}\d{3}\d{14}', // Costa Rica + 'CV' => 'CV\d{2}\d{21}', // Cape Verde + 'CY' => 'CY\d{2}\d{3}\d{5}[\dA-Z]{16}', // Cyprus + 'CZ' => 'CZ\d{2}\d{20}', // Czech Republic + 'DE' => 'DE\d{2}\d{8}\d{10}', // Germany + 'DO' => 'DO\d{2}[\dA-Z]{4}\d{20}', // Dominican Republic + 'DK' => 'DK\d{2}\d{4}\d{10}', // Denmark + 'DZ' => 'DZ\d{2}\d{20}', // Algeria + 'EE' => 'EE\d{2}\d{2}\d{2}\d{11}\d{1}', // Estonia + 'ES' => 'ES\d{2}\d{4}\d{4}\d{1}\d{1}\d{10}', // Spain (also includes Canary Islands, Ceuta and Melilla) + 'FI' => 'FI\d{2}\d{6}\d{7}\d{1}', // Finland + 'FO' => 'FO\d{2}\d{4}\d{9}\d{1}', // Faroe Islands + 'FR' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France + 'GF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Guyana + 'GB' => 'GB\d{2}[A-Z]{4}\d{6}\d{8}', // United Kingdom of Great Britain and Northern Ireland + 'GE' => 'GE\d{2}[A-Z]{2}\d{16}', // Georgia + 'GI' => 'GI\d{2}[A-Z]{4}[\dA-Z]{15}', // Gibraltar + 'GL' => 'GL\d{2}\d{4}\d{9}\d{1}', // Greenland + 'GP' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Guadeloupe + 'GR' => 'GR\d{2}\d{3}\d{4}[\dA-Z]{16}', // Greece + 'GT' => 'GT\d{2}[\dA-Z]{4}[\dA-Z]{20}', // Guatemala + 'HR' => 'HR\d{2}\d{7}\d{10}', // Croatia + 'HU' => 'HU\d{2}\d{3}\d{4}\d{1}\d{15}\d{1}', // Hungary + 'IE' => 'IE\d{2}[A-Z]{4}\d{6}\d{8}', // Ireland + 'IL' => 'IL\d{2}\d{3}\d{3}\d{13}', // Israel + 'IR' => 'IR\d{2}\d{22}', // Iran + 'IS' => 'IS\d{2}\d{4}\d{2}\d{6}\d{10}', // Iceland + 'IT' => 'IT\d{2}[A-Z]{1}\d{5}\d{5}[\dA-Z]{12}', // Italy + 'JO' => 'JO\d{2}[A-Z]{4}\d{4}[\dA-Z]{18}', // Jordan + 'KW' => 'KW\d{2}[A-Z]{4}\d{22}', // KUWAIT + 'KZ' => 'KZ\d{2}\d{3}[\dA-Z]{13}', // Kazakhstan + 'LB' => 'LB\d{2}\d{4}[\dA-Z]{20}', // LEBANON + 'LI' => 'LI\d{2}\d{5}[\dA-Z]{12}', // Liechtenstein (Principality of) + 'LT' => 'LT\d{2}\d{5}\d{11}', // Lithuania + 'LU' => 'LU\d{2}\d{3}[\dA-Z]{13}', // Luxembourg + 'LV' => 'LV\d{2}[A-Z]{4}[\dA-Z]{13}', // Latvia + 'MC' => 'MC\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Monaco + 'MD' => 'MD\d{2}[\dA-Z]{2}[\dA-Z]{18}', // Moldova + 'ME' => 'ME\d{2}\d{3}\d{13}\d{2}', // Montenegro + 'MF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Saint Martin (French part) + 'MG' => 'MG\d{2}\d{23}', // Madagascar + 'MK' => 'MK\d{2}\d{3}[\dA-Z]{10}\d{2}', // Macedonia, Former Yugoslav Republic of + 'ML' => 'ML\d{2}[A-Z]{1}\d{23}', // Mali + 'MQ' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Martinique + 'MR' => 'MR13\d{5}\d{5}\d{11}\d{2}', // Mauritania + 'MT' => 'MT\d{2}[A-Z]{4}\d{5}[\dA-Z]{18}', // Malta + 'MU' => 'MU\d{2}[A-Z]{4}\d{2}\d{2}\d{12}\d{3}[A-Z]{3}', // Mauritius + 'MZ' => 'MZ\d{2}\d{21}', // Mozambique + 'NC' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // New Caledonia + 'NL' => 'NL\d{2}[A-Z]{4}\d{10}', // The Netherlands + 'NO' => 'NO\d{2}\d{4}\d{6}\d{1}', // Norway + 'PF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Polynesia + 'PK' => 'PK\d{2}[A-Z]{4}[\dA-Z]{16}', // Pakistan + 'PL' => 'PL\d{2}\d{8}\d{16}', // Poland + 'PM' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Saint Pierre et Miquelon + 'PS' => 'PS\d{2}[A-Z]{4}[\dA-Z]{21}', // Palestine, State of + 'PT' => 'PT\d{2}\d{4}\d{4}\d{11}\d{2}', // Portugal (plus Azores and Madeira) + 'QA' => 'QA\d{2}[A-Z]{4}[\dA-Z]{21}', // Qatar + 'RE' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Reunion + 'RO' => 'RO\d{2}[A-Z]{4}[\dA-Z]{16}', // Romania + 'RS' => 'RS\d{2}\d{3}\d{13}\d{2}', // Serbia + 'SA' => 'SA\d{2}\d{2}[\dA-Z]{18}', // Saudi Arabia + 'SE' => 'SE\d{2}\d{3}\d{16}\d{1}', // Sweden + 'SI' => 'SI\d{2}\d{5}\d{8}\d{2}', // Slovenia + 'SK' => 'SK\d{2}\d{4}\d{6}\d{10}', // Slovak Republic + 'SM' => 'SM\d{2}[A-Z]{1}\d{5}\d{5}[\dA-Z]{12}', // San Marino + 'SN' => 'SN\d{2}[A-Z]{1}\d{23}', // Senegal + 'TF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Southern Territories + 'TL' => 'TL\d{2}\d{3}\d{14}\d{2}', // Timor-Leste + 'TN' => 'TN59\d{2}\d{3}\d{13}\d{2}', // Tunisia + 'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}', // Turkey + 'UA' => 'UA\d{2}[A-Z]{6}[\dA-Z]{19}', // Ukraine + 'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands, British + 'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Wallis and Futuna Islands + 'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Republic of Kosovo + 'YT' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Mayotte + ); + /** * {@inheritdoc} */ @@ -44,28 +156,30 @@ public function validate($value, Constraint $constraint) $value = (string) $value; - // Remove spaces - $canonicalized = str_replace(' ', '', $value); + // Remove spaces and convert to uppercase + $canonicalized = str_replace(' ', '', strtoupper($value)); - // The IBAN must have at least 4 characters... - if (strlen($canonicalized) < 4) { + // The IBAN must contain only digits and characters... + if (!ctype_alnum($canonicalized)) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Iban::TOO_SHORT_ERROR) + ->setCode(Iban::INVALID_CHARACTERS_ERROR) ->addViolation(); } else { $this->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Iban::TOO_SHORT_ERROR) + ->setCode(Iban::INVALID_CHARACTERS_ERROR) ->addViolation(); } return; } - // ...start with a country code... - if (!ctype_alpha($canonicalized{0}) || !ctype_alpha($canonicalized{1})) { + // ...start with a two-letter country code + $countryCode = substr($canonicalized, 0, 2); + + if (!ctype_alpha($countryCode)) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) @@ -81,34 +195,35 @@ public function validate($value, Constraint $constraint) return; } - // ...contain only digits and characters... - if (!ctype_alnum($canonicalized)) { + // ...have a format available + if (!array_key_exists($countryCode, self::$formats)) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Iban::INVALID_CHARACTERS_ERROR) + ->setCode(Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR) ->addViolation(); } else { $this->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Iban::INVALID_CHARACTERS_ERROR) + ->setCode(Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR) ->addViolation(); } return; } - // ...and contain uppercase characters only - if ($canonicalized !== strtoupper($canonicalized)) { + // ...and have a valid format + if (!preg_match('/^'.self::$formats[$countryCode].'$/', $canonicalized) + ) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Iban::INVALID_CASE_ERROR) + ->setCode(Iban::INVALID_FORMAT_ERROR) ->addViolation(); } else { $this->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Iban::INVALID_CASE_ERROR) + ->setCode(Iban::INVALID_FORMAT_ERROR) ->addViolation(); } @@ -125,12 +240,12 @@ public function validate($value, Constraint $constraint) // data type, so we store it in a string instead. // e.g. 0076 2011 6238 5295 7 CH93 // -> 0076 2011 6238 5295 7 121893 - $checkSum = $this->toBigInt($canonicalized); + $checkSum = self::toBigInt($canonicalized); // Do a modulo-97 operation on the large integer // We cannot use PHP's modulo operator, so we calculate the // modulo step-wisely instead - if (1 !== $this->bigModulo97($checkSum)) { + if (1 !== self::bigModulo97($checkSum)) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) @@ -145,7 +260,7 @@ public function validate($value, Constraint $constraint) } } - private function toBigInt($string) + private static function toBigInt($string) { $chars = str_split($string); $bigInt = ''; @@ -165,7 +280,7 @@ private function toBigInt($string) return $bigInt; } - private function bigModulo97($bigInt) + private static function bigModulo97($bigInt) { $parts = str_split($bigInt, 7); $rest = 0; diff --git a/src/Symfony/Component/Validator/Constraints/Isbn.php b/src/Symfony/Component/Validator/Constraints/Isbn.php index 3c4251b39ea7c..f1e83b99ea02a 100644 --- a/src/Symfony/Component/Validator/Constraints/Isbn.php +++ b/src/Symfony/Component/Validator/Constraints/Isbn.php @@ -45,12 +45,14 @@ class Isbn extends Constraint /** * @deprecated since version 2.5, to be removed in 3.0. Use option "type" instead. + * * @var bool */ public $isbn10 = false; /** * @deprecated since version 2.5, to be removed in 3.0. Use option "type" instead. + * * @var bool */ public $isbn13 = false; diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index 301a8217718d4..aaf52dc561c3c 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -17,7 +17,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** - * Validates whether the value is a valid ISBN-10 or ISBN-13 + * Validates whether the value is a valid ISBN-10 or ISBN-13. * * @author The Whole Life To Learn * @author Manuel Reinhard diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php index 87bf83c65251e..000af74f282fa 100644 --- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -156,8 +156,9 @@ public function validate($value, Constraint $constraint) } // Calculate a checksum. "X" equals 10. - $checkSum = 'X' === $canonical{7} || 'x' === $canonical{7} - ? 10 + $checkSum = 'X' === $canonical{7} + || 'x' === $canonical{7} + ? 10 : $canonical{7}; for ($i = 0; $i < 7; ++$i) { diff --git a/src/Symfony/Component/Validator/Constraints/Traverse.php b/src/Symfony/Component/Validator/Constraints/Traverse.php index 4abae6c67ab34..5811ad770ad6f 100644 --- a/src/Symfony/Component/Validator/Constraints/Traverse.php +++ b/src/Symfony/Component/Validator/Constraints/Traverse.php @@ -18,6 +18,7 @@ * @Annotation * * @since 2.5 + * * @author Bernhard Schussek */ class Traverse extends Constraint diff --git a/src/Symfony/Component/Validator/Constraints/Uuid.php b/src/Symfony/Component/Validator/Constraints/Uuid.php index 83627800791c4..2deecbadd61c9 100644 --- a/src/Symfony/Component/Validator/Constraints/Uuid.php +++ b/src/Symfony/Component/Validator/Constraints/Uuid.php @@ -45,14 +45,14 @@ class Uuid extends Constraint const V5_SHA1 = 5; /** - * Message to display when validation fails + * Message to display when validation fails. * * @var string */ public $message = 'This is not a valid UUID.'; /** - * Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122 + * Strict mode only allows UUIDs that meet the formal definition and formatting per RFC 4122. * * Set this to `false` to allow legacy formats with different dash positioning or wrapping characters * @@ -61,7 +61,7 @@ class Uuid extends Constraint public $strict = true; /** - * Array of allowed versions (see version constants above) + * Array of allowed versions (see version constants above). * * All UUID versions are allowed by default * diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index 39f92fbc6d2a4..722bcc947d2f4 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -28,6 +28,7 @@ * The context used and created by {@link ExecutionContextFactory}. * * @since 2.5 + * * @author Bernhard Schussek * * @see ExecutionContextInterface diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php b/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php index d94a806201ce4..f4f01d926e0f7 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php @@ -18,6 +18,7 @@ * Creates new {@link ExecutionContext} instances. * * @since 2.5 + * * @author Bernhard Schussek * * @internal You should not instantiate or use this class. Code against diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php b/src/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php index f0ee00174f7c3..e4af667d2da6a 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php @@ -20,6 +20,7 @@ * that is passed through the validation run. * * @since 2.5 + * * @author Bernhard Schussek */ interface ExecutionContextFactoryInterface diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php index 486520442552a..2ef80b66f041a 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php @@ -57,6 +57,7 @@ * results later on. * * @since 2.5 + * * @author Bernhard Schussek */ interface ExecutionContextInterface extends LegacyExecutionContextInterface diff --git a/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php b/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php index 4d5be451d91dd..f52b359fb39ca 100644 --- a/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php @@ -21,6 +21,7 @@ * An execution context that is compatible with the legacy API (< 2.5). * * @since 2.5 + * * @author Bernhard Schussek * * @deprecated since version 2.5, to be removed in 3.0. diff --git a/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php b/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php index 9e8498a6b9da9..c110644e99c1b 100644 --- a/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php +++ b/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php @@ -23,6 +23,7 @@ * Implemented for backward compatibility with Symfony < 2.5. * * @since 2.5 + * * @author Bernhard Schussek * * @deprecated since version 2.5, to be removed in 3.0. diff --git a/src/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php b/src/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php index c6ece50b70062..97cc5ffe5d92a 100644 --- a/src/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php +++ b/src/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php @@ -13,6 +13,7 @@ /** * @since 2.5 + * * @author Bernhard Schussek */ class UnsupportedMetadataException extends InvalidArgumentException diff --git a/src/Symfony/Component/Validator/Mapping/CascadingStrategy.php b/src/Symfony/Component/Validator/Mapping/CascadingStrategy.php index ff2853f4e0415..2b97bdd4ca90a 100644 --- a/src/Symfony/Component/Validator/Mapping/CascadingStrategy.php +++ b/src/Symfony/Component/Validator/Mapping/CascadingStrategy.php @@ -28,6 +28,7 @@ * implemented as bit mask in order to allow future extensions. * * @since 2.5 + * * @author Bernhard Schussek * * @see TraversalStrategy diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php b/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php index bb76c2c01b4cf..577440d61d8c7 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php @@ -25,6 +25,7 @@ * should be traversed or not. * * @since 2.5 + * * @author Bernhard Schussek * * @see MetadataInterface diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index 208dfceeb65f3..6c5c277ed8dc4 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -41,21 +41,21 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface { /** - * The loader for loading the class metadata + * The loader for loading the class metadata. * * @var LoaderInterface|null */ protected $loader; /** - * The cache for caching class metadata + * The cache for caching class metadata. * * @var CacheInterface|null */ protected $cache; /** - * The loaded metadata, indexed by class name + * The loaded metadata, indexed by class name. * * @var ClassMetadata[] */ diff --git a/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php b/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php index 58736e251181e..6e55e771dd1aa 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php @@ -17,6 +17,7 @@ * Returns {@link \Symfony\Component\Validator\Mapping\MetadataInterface} instances for values. * * @since 2.5 + * * @author Bernhard Schussek */ interface MetadataFactoryInterface extends LegacyMetadataFactoryInterface diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index cc0e54d3619e8..3459074fcabf7 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -24,6 +24,7 @@ * This class supports serialization and cloning. * * @since 2.5 + * * @author Bernhard Schussek */ class GenericMetadata implements MetadataInterface diff --git a/src/Symfony/Component/Validator/Mapping/MetadataInterface.php b/src/Symfony/Component/Validator/Mapping/MetadataInterface.php index fda1dbbbb40a0..991962ceafd2d 100644 --- a/src/Symfony/Component/Validator/Mapping/MetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/MetadataInterface.php @@ -24,6 +24,7 @@ * traversed or not. * * @since 2.5 + * * @author Bernhard Schussek * * @see CascadingStrategy diff --git a/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php b/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php index 79e2c799de602..8a77aa83faba5 100644 --- a/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php @@ -25,6 +25,7 @@ * objects should be traversed or not. * * @since 2.5 + * * @author Bernhard Schussek * * @see MetadataInterface diff --git a/src/Symfony/Component/Validator/Mapping/TraversalStrategy.php b/src/Symfony/Component/Validator/Mapping/TraversalStrategy.php index 450a3ecc0a0a8..ae76857aa443f 100644 --- a/src/Symfony/Component/Validator/Mapping/TraversalStrategy.php +++ b/src/Symfony/Component/Validator/Mapping/TraversalStrategy.php @@ -24,6 +24,7 @@ * The traversal strategy is ignored for arrays. Arrays are always iterated. * * @since 2.1 + * * @author Bernhard Schussek * * @see CascadingStrategy diff --git a/src/Symfony/Component/Validator/PropertyMetadataInterface.php b/src/Symfony/Component/Validator/PropertyMetadataInterface.php index 20af8a993bcda..46e7c692c85ca 100644 --- a/src/Symfony/Component/Validator/PropertyMetadataInterface.php +++ b/src/Symfony/Component/Validator/PropertyMetadataInterface.php @@ -23,7 +23,6 @@ * @author Bernhard Schussek * * @see MetadataInterface - * * @deprecated since version 2.5, to be removed in 3.0. * Use {@link Mapping\PropertyMetadataInterface} instead. */ diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf index 63eecc0e19e79..a58f5b8d8c660 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf @@ -175,7 +175,7 @@ 画像の高さが小さすぎます({{ height }}ピクセル)。{{ min_height }}ピクセル以上にしてください。 - This value should be the user current password. + This value should be the user's current password. ユーザーの現在のパスワードでなければなりません。 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf index 0237a308acd5f..d5b57031b9f69 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf @@ -175,7 +175,7 @@ ความสูงของภาพไม่ได้ขนาด ({{ height }}px) อนุญาตให้สูงอย่างน้อยที่สุด {{ min_height }}px - This value should be the user current password. + This value should be the user's current password. ค่านี้ควรจะเป็นรหัสผ่านปัจจุบันของผู้ใช้ diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php index 21cb4611aa75a..eab15ed3bb848 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php @@ -33,6 +33,7 @@ public function getDefaultOption() /** * @since 2.6 + * * @author Bernhard Schussek */ class CompositeTest extends \PHPUnit_Framework_TestCase diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 1f66de2aa95dd..c2220bab71e3c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -18,13 +18,6 @@ class CountryValidatorTest extends AbstractConstraintValidatorTest { - protected function setUp() - { - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - protected function getApiVersion() { return Validation::API_VERSION_2_5; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index c59fc638f70f6..b0ed4f0192e66 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -18,13 +18,6 @@ class CurrencyValidatorTest extends AbstractConstraintValidatorTest { - protected function setUp() - { - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - protected function getApiVersion() { return Validation::API_VERSION_2_5; @@ -72,6 +65,8 @@ public function testValidCurrencies($currency) **/ public function testValidCurrenciesWithCountrySpecificLocale($currency) { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('en_GB'); $this->validator->validate($currency, new Currency()); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 742c2027c5b7f..62cbdbf02f673 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -179,7 +179,7 @@ public function testFailingExpressionAtNestedPropertyLevel() /** * When validatePropertyValue() is called with a class name - * https://github.com/symfony/symfony/pull/11498 + * https://github.com/symfony/symfony/pull/11498. */ public function testSucceedingExpressionAtPropertyLevelWithoutRoot() { @@ -196,7 +196,7 @@ public function testSucceedingExpressionAtPropertyLevelWithoutRoot() /** * When validatePropertyValue() is called with a class name - * https://github.com/symfony/symfony/pull/11498 + * https://github.com/symfony/symfony/pull/11498. */ public function testFailingExpressionAtPropertyLevelWithoutRoot() { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 176b49f494387..686b62b0911b5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -247,17 +247,17 @@ public function provideBinaryFormatTests() array(11, 10, false, '11', '10', 'bytes'), // round(size) == 1.01kB, limit == 1kB - array(ceil(1000*1.01), 1000, null, '1.01', '1', 'kB'), - array(ceil(1000*1.01), '1k', null, '1.01', '1', 'kB'), - array(ceil(1024*1.01), '1Ki', null, '1.01', '1', 'KiB'), + array(ceil(1000 * 1.01), 1000, null, '1.01', '1', 'kB'), + array(ceil(1000 * 1.01), '1k', null, '1.01', '1', 'kB'), + array(ceil(1024 * 1.01), '1Ki', null, '1.01', '1', 'KiB'), - array(ceil(1024*1.01), 1024, true, '1.01', '1', 'KiB'), - array(ceil(1024*1.01*1000), '1024k', true, '1010', '1000', 'KiB'), - array(ceil(1024*1.01), '1Ki', true, '1.01', '1', 'KiB'), + array(ceil(1024 * 1.01), 1024, true, '1.01', '1', 'KiB'), + array(ceil(1024 * 1.01 * 1000), '1024k', true, '1010', '1000', 'KiB'), + array(ceil(1024 * 1.01), '1Ki', true, '1.01', '1', 'KiB'), - array(ceil(1000*1.01), 1000, false, '1.01', '1', 'kB'), - array(ceil(1000*1.01), '1k', false, '1.01', '1', 'kB'), - array(ceil(1024*1.01*10), '10Ki', false, '10.34', '10.24', 'kB'), + array(ceil(1000 * 1.01), 1000, false, '1.01', '1', 'kB'), + array(ceil(1000 * 1.01), '1k', false, '1.01', '1', 'kB'), + array(ceil(1024 * 1.01 * 10), '10Ki', false, '10.34', '10.24', 'kB'), ); } @@ -266,7 +266,7 @@ public function provideBinaryFormatTests() */ public function testBinaryFormat($bytesWritten, $limit, $binaryFormat, $sizeAsString, $limitAsString, $suffix) { - fseek($this->file, $bytesWritten-1, SEEK_SET); + fseek($this->file, $bytesWritten - 1, SEEK_SET); fwrite($this->file, '0'); fclose($this->file); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index ab9839a238968..e9deb11de4943 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -57,8 +57,8 @@ public function getValidIbans() array('CH9300762011623852957'), // Switzerland without spaces array('CH93 0076 2011 6238 5295 7'), // Switzerland with multiple spaces - //Country list - //http://www.rbs.co.uk/corporate/international/g0/guide-to-international-business/regulatory-information/iban/iban-example.ashx + // Country list + // http://www.rbs.co.uk/corporate/international/g0/guide-to-international-business/regulatory-information/iban/iban-example.ashx array('AL47 2121 1009 0000 0002 3569 8741'), //Albania array('AD12 0001 2030 2003 5910 0100'), //Andorra @@ -114,14 +114,17 @@ public function getValidIbans() array('TN59 1000 6035 1835 9847 8831'), //Tunisia array('TR33 0006 1005 1978 6457 8413 26'), //Turkey array('AE07 0331 2345 6789 0123 456'), //UAE - array('GB 12 CPBK 0892 9965 0449 91'), //United Kingdom + array('GB12 CPBK 0892 9965 0449 91'), //United Kingdom //Extended country list //http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html + // http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf array('AO06000600000100037131174'), //Angola array('AZ21NABZ00000000137010001944'), //Azerbaijan array('BH29BMAG1299123456BH00'), //Bahrain array('BJ11B00610100400271101192591'), //Benin + array('BR9700360305000010009795493P1'), // Brazil + array('BR1800000000141455123924100C2'), // Brazil array('VG96VPVG0000012345678901'), //British Virgin Islands array('BF1030134020015400945000643'), //Burkina Faso array('BI43201011067444'), //Burundi @@ -135,6 +138,7 @@ public function getValidIbans() array('IR580540105180021273113007'), //Iran array('IL620108000000099999999'), //Israel array('CI05A00060174100178530011852'), //Ivory Coast + array('JO94CBJO0010000000000131000302'), // Jordan array('KZ176010251000042993'), //Kazakhstan array('KW74NBOK0000000000001000372151'), //Kuwait array('LB30099900000001001925579115'), //Lebanon @@ -144,9 +148,12 @@ public function getValidIbans() array('MU17BOMM0101101030300200000MUR'), //Mauritius array('MZ59000100000011834194157'), //Mozambique array('PS92PALS000000000400123456702'), //Palestinian Territory + array('QA58DOHB00001234567890ABCDEFG'), //Qatar + array('XK051212012345678906'), //Republic of Kosovo array('PT50000200000163099310355'), //Sao Tome and Principe array('SA0380000000608010167519'), //Saudi Arabia array('SN12K00100152000025690007542'), //Senegal + array('TL380080012345678910157'), //Timor-Leste array('TN5914207207100707129648'), //Tunisia array('TR330006100519786457841326'), //Turkey array('AE260211000000230064016'), //United Arab Emirates @@ -154,9 +161,268 @@ public function getValidIbans() } /** - * @dataProvider getInvalidIbans + * @dataProvider getIbansWithInvalidFormat */ - public function testInvalidIbans($iban, $code) + public function testIbansWithInvalidFormat($iban) + { + $this->assertViolationRaised($iban, Iban::INVALID_FORMAT_ERROR); + } + + public function getIbansWithInvalidFormat() + { + return array( + array('AL47 2121 1009 0000 0002 3569 874'), //Albania + array('AD12 0001 2030 2003 5910 010'), //Andorra + array('AT61 1904 3002 3457 320'), //Austria + array('AZ21 NABZ 0000 0000 1370 1000 194'), //Azerbaijan + array('AZ21 N1BZ 0000 0000 1370 1000 1944'), //Azerbaijan + array('BH67 BMAG 0000 1299 1234 5'), //Bahrain + array('BH67 B2AG 0000 1299 1234 56'), //Bahrain + array('BE62 5100 0754 7061 2'), //Belgium + array('BA39 1290 0794 0102 8494 4'), //Bosnia and Herzegovina + array('BG80 BNBG 9661 1020 3456 7'), //Bulgaria + array('BG80 B2BG 9661 1020 3456 78'), //Bulgaria + array('HR12 1001 0051 8630 0016 01'), //Croatia + array('CY17 0020 0128 0000 0012 0052 7600 1'), //Cyprus + array('CZ65 0800 0000 1920 0014 5399 1'), //Czech Republic + array('DK50 0040 0440 1162 431'), //Denmark + array('EE38 2200 2210 2014 5685 1'), //Estonia + array('FO97 5432 0388 8999 441'), //Faroe Islands + array('FI21 1234 5600 0007 851'), //Finland + array('FR14 2004 1010 0505 0001 3M02 6061'), //France + array('GE29 NB00 0000 0101 9049 171'), //Georgia + array('DE89 3704 0044 0532 0130 001'), //Germany + array('GI75 NWBK 0000 0000 7099 4531'), //Gibraltar + array('GR16 0110 1250 0000 0001 2300 6951'), //Greece + array('GL56 0444 9876 5432 101'), //Greenland + array('HU42 1177 3016 1111 1018 0000 0000 1'), //Hungary + array('IS14 0159 2600 7654 5510 7303 391'), //Iceland + array('IE29 AIBK 9311 5212 3456 781'), //Ireland + array('IL62 0108 0000 0009 9999 9991'), //Israel + array('IT40 S054 2811 1010 0000 0123 4561'), //Italy + array('LV80 BANK 0000 4351 9500 11'), //Latvia + array('LB62 0999 0000 0001 0019 0122 9114 1'), //Lebanon + array('LI21 0881 0000 2324 013A A1'), //Liechtenstein + array('LT12 1000 0111 0100 1000 1'), //Lithuania + array('LU28 0019 4006 4475 0000 1'), //Luxembourg + array('MK072 5012 0000 0589 84 1'), //Macedonia + array('MT84 MALT 0110 0001 2345 MTLC AST0 01SA'), //Malta + array('MU17 BOMM 0101 1010 3030 0200 000M URA'), //Mauritius + array('MD24 AG00 0225 1000 1310 4168 1'), //Moldova + array('MC93 2005 2222 1001 1223 3M44 5551'), //Monaco + array('ME25 5050 0001 2345 6789 511'), //Montenegro + array('NL39 RABO 0300 0652 641'), //Netherlands + array('NO93 8601 1117 9471'), //Norway + array('PK36 SCBL 0000 0011 2345 6702 1'), //Pakistan + array('PL60 1020 1026 0000 0422 7020 1111 1'), //Poland + array('PT50 0002 0123 1234 5678 9015 41'), //Portugal + array('RO49 AAAA 1B31 0075 9384 0000 1'), //Romania + array('SM86 U032 2509 8000 0000 0270 1001'), //San Marino + array('SA03 8000 0000 6080 1016 7519 1'), //Saudi Arabia + array('RS35 2600 0560 1001 6113 791'), //Serbia + array('SK31 1200 0000 1987 4263 7541 1'), //Slovak Republic + array('SI56 1910 0000 0123 4381'), //Slovenia + array('ES80 2310 0001 1800 0001 2345 1'), //Spain + array('SE35 5000 0000 0549 1000 0003 1'), //Sweden + array('CH93 0076 2011 6238 5295 71'), //Switzerland + array('TN59 1000 6035 1835 9847 8831 1'), //Tunisia + array('TR33 0006 1005 1978 6457 8413 261'), //Turkey + array('AE07 0331 2345 6789 0123 4561'), //UAE + array('GB12 CPBK 0892 9965 0449 911'), //United Kingdom + + //Extended country list + array('AO060006000001000371311741'), //Angola + array('AZ21NABZ000000001370100019441'), //Azerbaijan + array('BH29BMAG1299123456BH001'), //Bahrain + array('BJ11B006101004002711011925911'), //Benin + array('BR9700360305000010009795493P11'), // Brazil + array('BR1800000000141455123924100C21'), // Brazil + array('VG96VPVG00000123456789011'), //British Virgin Islands + array('BF10301340200154009450006431'), //Burkina Faso + array('BI432010110674441'), //Burundi + array('CM21100030010005000006053061'), //Cameroon + array('CV640003000045470691101761'), //Cape Verde + array('FR76300070001100099700049421'), //Central African Republic + array('CG52300110002021512345678901'), //Congo + array('CR05152020010262840661'), //Costa Rica + array('DO28BAGR000000012124536113241'), //Dominican Republic + array('GT82TRAJ010200000012100296901'), //Guatemala + array('IR5805401051800212731130071'), //Iran + array('IL6201080000000999999991'), //Israel + array('CI05A000601741001785300118521'), //Ivory Coast + array('JO94CBJO00100000000001310003021'), // Jordan + array('KZ1760102510000429931'), //Kazakhstan + array('KW74NBOK00000000000010003721511'), //Kuwait + array('LB300999000000010019255791151'), //Lebanon + array('MG46000050300101019140160561'), //Madagascar + array('ML03D008901700010021200004471'), //Mali + array('MR13000120000100000020373721'), //Mauritania + array('MU17BOMM0101101030300200000MUR1'), //Mauritius + array('MZ590001000000118341941571'), //Mozambique + array('PS92PALS0000000004001234567021'), //Palestinian Territory + array('QA58DOHB00001234567890ABCDEFG1'), //Qatar + array('XK0512120123456789061'), //Republic of Kosovo + array('PT500002000001630993103551'), //Sao Tome and Principe + array('SA03800000006080101675191'), //Saudi Arabia + array('SN12K001001520000256900075421'), //Senegal + array('TL3800800123456789101571'), //Timor-Leste + array('TN59142072071007071296481'), //Tunisia + array('TR3300061005197864578413261'), //Turkey + array('AE2602110000002300640161'), //United Arab Emirates + ); + } + + /** + * @dataProvider getIbansWithValidFormatButIncorrectChecksum + */ + public function testIbansWithValidFormatButIncorrectChecksum($iban) + { + $this->assertViolationRaised($iban, Iban::CHECKSUM_FAILED_ERROR); + } + + public function getIbansWithValidFormatButIncorrectChecksum() + { + return array( + array('AL47 2121 1009 0000 0002 3569 8742'), //Albania + array('AD12 0001 2030 2003 5910 0101'), //Andorra + array('AT61 1904 3002 3457 3202'), //Austria + array('AZ21 NABZ 0000 0000 1370 1000 1945'), //Azerbaijan + array('BH67 BMAG 0000 1299 1234 57'), //Bahrain + array('BE62 5100 0754 7062'), //Belgium + array('BA39 1290 0794 0102 8495'), //Bosnia and Herzegovina + array('BG80 BNBG 9661 1020 3456 79'), //Bulgaria + array('HR12 1001 0051 8630 0016 1'), //Croatia + array('CY17 0020 0128 0000 0012 0052 7601'), //Cyprus + array('CZ65 0800 0000 1920 0014 5398'), //Czech Republic + array('DK50 0040 0440 1162 44'), //Denmark + array('EE38 2200 2210 2014 5684'), //Estonia + array('FO97 5432 0388 8999 43'), //Faroe Islands + array('FI21 1234 5600 0007 84'), //Finland + array('FR14 2004 1010 0505 0001 3M02 605'), //France + array('GE29 NB00 0000 0101 9049 16'), //Georgia + array('DE89 3704 0044 0532 0130 01'), //Germany + array('GI75 NWBK 0000 0000 7099 452'), //Gibraltar + array('GR16 0110 1250 0000 0001 2300 694'), //Greece + array('GL56 0444 9876 5432 11'), //Greenland + array('HU42 1177 3016 1111 1018 0000 0001'), //Hungary + array('IS14 0159 2600 7654 5510 7303 38'), //Iceland + array('IE29 AIBK 9311 5212 3456 79'), //Ireland + array('IL62 0108 0000 0009 9999 998'), //Israel + array('IT40 S054 2811 1010 0000 0123 457'), //Italy + array('LV80 BANK 0000 4351 9500 2'), //Latvia + array('LB62 0999 0000 0001 0019 0122 9115'), //Lebanon + array('LI21 0881 0000 2324 013A B'), //Liechtenstein + array('LT12 1000 0111 0100 1001'), //Lithuania + array('LU28 0019 4006 4475 0001'), //Luxembourg + array('MK072 5012 0000 0589 85'), //Macedonia + array('MT84 MALT 0110 0001 2345 MTLC AST0 01T'), //Malta + array('MU17 BOMM 0101 1010 3030 0200 000M UP'), //Mauritius + array('MD24 AG00 0225 1000 1310 4169'), //Moldova + array('MC93 2005 2222 1001 1223 3M44 554'), //Monaco + array('ME25 5050 0001 2345 6789 52'), //Montenegro + array('NL39 RABO 0300 0652 65'), //Netherlands + array('NO93 8601 1117 948'), //Norway + array('PK36 SCBL 0000 0011 2345 6703'), //Pakistan + array('PL60 1020 1026 0000 0422 7020 1112'), //Poland + array('PT50 0002 0123 1234 5678 9015 5'), //Portugal + array('RO49 AAAA 1B31 0075 9384 0001'), //Romania + array('SM86 U032 2509 8000 0000 0270 101'), //San Marino + array('SA03 8000 0000 6080 1016 7518'), //Saudi Arabia + array('RS35 2600 0560 1001 6113 78'), //Serbia + array('SK31 1200 0000 1987 4263 7542'), //Slovak Republic + array('SI56 1910 0000 0123 439'), //Slovenia + array('ES80 2310 0001 1800 0001 2346'), //Spain + array('SE35 5000 0000 0549 1000 0004'), //Sweden + array('CH93 0076 2011 6238 5295 8'), //Switzerland + array('TN59 1000 6035 1835 9847 8832'), //Tunisia + array('TR33 0006 1005 1978 6457 8413 27'), //Turkey + array('AE07 0331 2345 6789 0123 457'), //UAE + array('GB12 CPBK 0892 9965 0449 92'), //United Kingdom + + //Extended country list + array('AO06000600000100037131175'), //Angola + array('AZ21NABZ00000000137010001945'), //Azerbaijan + array('BH29BMAG1299123456BH01'), //Bahrain + array('BJ11B00610100400271101192592'), //Benin + array('BR9700360305000010009795493P2'), // Brazil + array('BR1800000000141455123924100C3'), // Brazil + array('VG96VPVG0000012345678902'), //British Virgin Islands + array('BF1030134020015400945000644'), //Burkina Faso + array('BI43201011067445'), //Burundi + array('CM2110003001000500000605307'), //Cameroon + array('CV64000300004547069110177'), //Cape Verde + array('FR7630007000110009970004943'), //Central African Republic + array('CG5230011000202151234567891'), //Congo + array('CR0515202001026284067'), //Costa Rica + array('DO28BAGR00000001212453611325'), //Dominican Republic + array('GT82TRAJ01020000001210029691'), //Guatemala + array('IR580540105180021273113008'), //Iran + array('IL620108000000099999998'), //Israel + array('CI05A00060174100178530011853'), //Ivory Coast + array('JO94CBJO0010000000000131000303'), // Jordan + array('KZ176010251000042994'), //Kazakhstan + array('KW74NBOK0000000000001000372152'), //Kuwait + array('LB30099900000001001925579116'), //Lebanon + array('MG4600005030010101914016057'), //Madagascar + array('ML03D00890170001002120000448'), //Mali + array('MR1300012000010000002037373'), //Mauritania + array('MU17BOMM0101101030300200000MUP'), //Mauritius + array('MZ59000100000011834194158'), //Mozambique + array('PS92PALS000000000400123456703'), //Palestinian Territory + array('QA58DOHB00001234567890ABCDEFH'), //Qatar + array('XK051212012345678907'), //Republic of Kosovo + array('PT50000200000163099310356'), //Sao Tome and Principe + array('SA0380000000608010167518'), //Saudi Arabia + array('SN12K00100152000025690007543'), //Senegal + array('TL380080012345678910158'), //Timor-Leste + array('TN5914207207100707129649'), //Tunisia + array('TR330006100519786457841327'), //Turkey + array('AE260211000000230064017'), //United Arab Emirates + ); + } + + /** + * @dataProvider getUnsupportedCountryCodes + */ + public function testIbansWithUnsupportedCountryCode($countryCode) + { + $this->assertViolationRaised($countryCode.'260211000000230064016', Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR); + } + + public function getUnsupportedCountryCodes() + { + return array( + array('AG'), + array('AI'), + array('AQ'), + array('AS'), + array('AW'), + ); + } + + public function testIbansWithInvalidCharacters() + { + $this->assertViolationRaised('CH930076201162385295]', Iban::INVALID_CHARACTERS_ERROR); + } + + /** + * @dataProvider getIbansWithInvalidCountryCode + */ + public function testIbansWithInvalidCountryCode($iban) + { + $this->assertViolationRaised($iban, Iban::INVALID_COUNTRY_CODE_ERROR); + } + + public function getIbansWithInvalidCountryCode() + { + return array( + array('0750447346'), + array('2X0750447346'), + array('A20750447346'), + ); + } + + private function assertViolationRaised($iban, $code) { $constraint = new Iban(array( 'message' => 'myMessage', @@ -169,25 +435,4 @@ public function testInvalidIbans($iban, $code) ->setCode($code) ->assertRaised(); } - - public function getInvalidIbans() - { - return array( - array('CH93 0076 2011 6238 5295', Iban::CHECKSUM_FAILED_ERROR), - array('CH930076201162385295', Iban::CHECKSUM_FAILED_ERROR), - array('GB29 RBOS 6016 1331 9268 19', Iban::CHECKSUM_FAILED_ERROR), - array('CH930072011623852957', Iban::CHECKSUM_FAILED_ERROR), - array('NL39 RASO 0300 0652 64', Iban::CHECKSUM_FAILED_ERROR), - array('NO93 8601117 947', Iban::CHECKSUM_FAILED_ERROR), - array('CY170020 128 0000 0012 0052 7600', Iban::CHECKSUM_FAILED_ERROR), - array('foo', Iban::TOO_SHORT_ERROR), - array('123', Iban::TOO_SHORT_ERROR), - array('0750447346', Iban::INVALID_COUNTRY_CODE_ERROR), - array('CH930076201162385295]', Iban::INVALID_CHARACTERS_ERROR), - - //Ibans with lower case values are invalid - array('Ae260211000000230064016', Iban::INVALID_CASE_ERROR), - array('ae260211000000230064016', Iban::INVALID_CASE_ERROR), - ); - } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 56824b785bdbd..530627d7cdb0e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -28,13 +28,6 @@ protected function createValidator() return new LanguageValidator(); } - protected function setUp() - { - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - public function testNullIsValid() { $this->validator->validate(null, new Language()); @@ -103,6 +96,8 @@ public function getInvalidLanguages() public function testValidateUsingCountrySpecificLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('fr_FR'); $existingLanguage = 'en'; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index ad27a74e2aa70..53b779618a8ad 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; use Symfony\Component\Validator\Validation; @@ -28,13 +27,6 @@ protected function createValidator() return new LocaleValidator(); } - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - public function testNullIsValid() { $this->validator->validate(null, new Locale()); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 8634ac5ed67b6..a238b1754aa03 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -162,7 +162,7 @@ public function testMemberMetadatas() $this->metadata->addPropertyConstraint('firstName', new ConstraintA()); $this->assertTrue($this->metadata->hasPropertyMetadata('firstName')); - $this->assertFalse($this->metadata->hasPropertyMetadata('non_existant_field')); + $this->assertFalse($this->metadata->hasPropertyMetadata('non_existent_field')); } public function testMergeConstraintsKeepsPrivateMembersSeparate() diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php index 12c8d87f2ca5b..a2da68f9f1d30 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php @@ -30,6 +30,7 @@ * Verifies that a validator satisfies the API of Symfony 2.5+. * * @since 2.5 + * * @author Bernhard Schussek */ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest @@ -108,7 +109,7 @@ public function testGroupSequenceAbortsAfterFailedGroup() $sequence = new GroupSequence(array('Group 1', 'Group 2', 'Group 3')); $violations = $this->validator->validate($entity, new Valid(), $sequence); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message 1', $violations[0]->getMessage()); } @@ -138,7 +139,7 @@ public function testGroupSequenceIncludesReferences() $sequence = new GroupSequence(array('Group 1', 'Entity')); $violations = $this->validator->validate($entity, new Valid(), $sequence); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Reference violation 1', $violations[0]->getMessage()); } @@ -157,7 +158,7 @@ public function testValidateInSeparateContext() ->validate($value->reference, new Valid(), 'Group') ; - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $test->assertCount(1, $violations); $test->assertSame('Message value', $violations[0]->getMessage()); $test->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -197,7 +198,7 @@ public function testValidateInSeparateContext() $violations = $this->validator->validate($entity, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $test->assertSame('Separate violation', $violations[0]->getMessage()); } @@ -254,7 +255,7 @@ public function testValidateInContext() $violations = $this->validator->validate($entity, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -318,7 +319,7 @@ public function testValidateArrayInContext() $violations = $this->validator->validate($entity, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -357,7 +358,7 @@ public function testTraverseTraversableByDefault() $violations = $this->validate($traversable, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -389,7 +390,7 @@ public function testTraversalEnabledOnClass() $violations = $this->validate($traversable, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } @@ -414,7 +415,7 @@ public function testTraversalDisabledOnClass() $violations = $this->validate($traversable, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -452,7 +453,7 @@ public function testReferenceTraversalDisabledOnClass() $violations = $this->validate($entity, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -480,7 +481,7 @@ public function testReferenceTraversalEnabledOnReferenceDisabledOnClass() $violations = $this->validate($entity, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -508,7 +509,7 @@ public function testReferenceTraversalDisabledOnReferenceEnabledOnClass() $violations = $this->validate($entity, new Valid(), 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -529,7 +530,7 @@ public function testAddCustomizedViolation() $violations = $this->validator->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -611,7 +612,7 @@ public function testNoDuplicateValidationIfClassConstraintInMultipleGroups() $violations = $this->validator->validate($entity, new Valid(), array('Group 1', 'Group 2')); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } @@ -630,7 +631,7 @@ public function testNoDuplicateValidationIfPropertyConstraintInMultipleGroups() $violations = $this->validator->validate($entity, new Valid(), array('Group 1', 'Group 2')); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php index 5f4167dcd8849..22af86e3deb32 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php @@ -24,6 +24,7 @@ * Verifies that a validator satisfies the API of Symfony < 2.5. * * @since 2.5 + * * @author Bernhard Schussek */ abstract class AbstractLegacyApiTest extends AbstractValidatorTest @@ -160,7 +161,7 @@ public function testValidateInContext() $violations = $this->validator->validate($entity, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -218,7 +219,7 @@ public function testValidateArrayInContext() $violations = $this->validator->validate($entity, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -248,7 +249,7 @@ public function testAddCustomizedViolation() $violations = $this->validator->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php index 69c025d4594ee..678a3252a5a0b 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php @@ -24,6 +24,7 @@ /** * @since 2.5 + * * @author Bernhard Schussek */ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase @@ -92,7 +93,7 @@ public function testValidate() $violations = $this->validate('Bernhard', $constraint, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -129,7 +130,7 @@ public function testClassConstraint() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -169,7 +170,7 @@ public function testPropertyConstraint() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -209,7 +210,7 @@ public function testGetterConstraint() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -247,7 +248,7 @@ public function testArray() $violations = $this->validate($array, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -285,7 +286,7 @@ public function testRecursiveArray() $violations = $this->validate($array, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -323,7 +324,7 @@ public function testTraversable() $violations = $this->validate($traversable, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -363,7 +364,7 @@ public function testRecursiveTraversable() $violations = $this->validate($traversable, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -402,7 +403,7 @@ public function testReferenceClassConstraint() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -444,7 +445,7 @@ public function testReferencePropertyConstraint() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -486,7 +487,7 @@ public function testReferenceGetterConstraint() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -507,7 +508,7 @@ public function testsIgnoreNullReference() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -551,7 +552,7 @@ public function testArrayReference() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -591,7 +592,7 @@ public function testRecursiveArrayReference() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -619,7 +620,7 @@ public function testArrayTraversalCannotBeDisabled() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } @@ -639,7 +640,7 @@ public function testRecursiveArrayTraversalCannotBeDisabled() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } @@ -652,7 +653,7 @@ public function testIgnoreScalarsDuringArrayTraversal() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -665,7 +666,7 @@ public function testIgnoreNullDuringArrayTraversal() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -696,7 +697,7 @@ public function testTraversableReference() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -725,7 +726,7 @@ public function testDisableTraversableTraversal() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(0, $violations); } @@ -775,7 +776,7 @@ public function testEnableRecursiveTraversableTraversal() $violations = $this->validate($entity, null, 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -824,7 +825,7 @@ public function testValidateProperty() $violations = $this->validateProperty($entity, 'firstName', 'Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -853,7 +854,7 @@ public function testLegacyValidatePropertyFailsIfPropertiesNotSupported() } /** - * https://github.com/symfony/symfony/issues/11604 + * https://github.com/symfony/symfony/issues/11604. */ public function testValidatePropertyWithoutConstraints() { @@ -904,7 +905,7 @@ public function testValidatePropertyValue() 'Group' ); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -955,7 +956,7 @@ public function testValidatePropertyValueWithClassName() 'Group' ); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Message value', $violations[0]->getMessage()); $this->assertSame('Message %param%', $violations[0]->getMessageTemplate()); @@ -984,7 +985,7 @@ public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported() } /** - * https://github.com/symfony/symfony/issues/11604 + * https://github.com/symfony/symfony/issues/11604. */ public function testValidatePropertyValueWithoutConstraints() { @@ -1010,7 +1011,7 @@ public function testValidateObjectOnlyOncePerGroup() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } @@ -1030,7 +1031,7 @@ public function testValidateDifferentObjectsSeparately() $violations = $this->validate($entity); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(2, $violations); } @@ -1053,7 +1054,7 @@ public function testValidateSingleGroup() $violations = $this->validate($entity, null, 'Group 2'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); } @@ -1076,7 +1077,7 @@ public function testValidateMultipleGroups() $violations = $this->validate($entity, null, array('Group 1', 'Group 2')); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(2, $violations); } @@ -1109,7 +1110,7 @@ public function testReplaceDefaultGroupByGroupSequenceObject() $violations = $this->validate($entity, null, 'Default'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); } @@ -1143,7 +1144,7 @@ public function testReplaceDefaultGroupByGroupSequenceArray() $violations = $this->validate($entity, null, 'Default'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); } @@ -1175,7 +1176,7 @@ public function testPropagateDefaultGroupToReferenceWhenReplacingDefaultGroup() $violations = $this->validate($entity, null, 'Default'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Violation in Default group', $violations[0]->getMessage()); } @@ -1205,7 +1206,7 @@ public function testValidateCustomGroupWhenDefaultGroupWasReplaced() $violations = $this->validate($entity, null, 'Other Group'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Violation in other group', $violations[0]->getMessage()); } @@ -1241,7 +1242,7 @@ public function testReplaceDefaultGroupWithObjectFromGroupSequenceProvider() $violations = $this->validate($entity, null, 'Default'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); } @@ -1277,7 +1278,7 @@ public function testReplaceDefaultGroupWithArrayFromGroupSequenceProvider() $violations = $this->validate($entity, null, 'Default'); - /** @var ConstraintViolationInterface[] $violations */ + /* @var ConstraintViolationInterface[] $violations */ $this->assertCount(1, $violations); $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); } diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index 88e8b3b82689d..fbc863157d9af 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Validator\Tests; -use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\ValidatorBuilder; use Symfony\Component\Validator\ValidatorBuilderInterface; diff --git a/src/Symfony/Component/Validator/Validation.php b/src/Symfony/Component/Validator/Validation.php index a03d21584bc9d..1693f7311add4 100644 --- a/src/Symfony/Component/Validator/Validation.php +++ b/src/Symfony/Component/Validator/Validation.php @@ -20,6 +20,7 @@ final class Validation { /** * The Validator API provided by Symfony 2.4 and older. + * * @deprecated use API_VERSION_2_5_BC instead. */ const API_VERSION_2_4 = 1; diff --git a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php index 767f89585f950..048d6c7545f84 100644 --- a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php @@ -18,6 +18,7 @@ * A validator in a specific execution context. * * @since 2.5 + * * @author Bernhard Schussek */ interface ContextualValidatorInterface diff --git a/src/Symfony/Component/Validator/Validator/LegacyValidator.php b/src/Symfony/Component/Validator/Validator/LegacyValidator.php index 0b0934bd3e253..e35f4c91401b3 100644 --- a/src/Symfony/Component/Validator/Validator/LegacyValidator.php +++ b/src/Symfony/Component/Validator/Validator/LegacyValidator.php @@ -17,11 +17,11 @@ * A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+. * * @since 2.5 + * * @author Bernhard Schussek * * @see \Symfony\Component\Validator\ValidatorInterface * @see \Symfony\Component\Validator\Validator\ValidatorInterface - * * @deprecated since version 2.5, to be removed in 3.0. */ class LegacyValidator extends RecursiveValidator diff --git a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php index 2582bf65c85c4..3aafa34ea09cc 100644 --- a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php @@ -20,6 +20,7 @@ * Validates PHP values against constraints. * * @since 2.5 + * * @author Bernhard Schussek */ interface ValidatorInterface extends MetadataFactoryInterface diff --git a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php index cc0007770578b..e15fb7aa14e67 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -180,7 +180,6 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) * * @see Validation::API_VERSION_2_5 * @see Validation::API_VERSION_2_5_BC - * * @deprecated since version 2.7, to be removed in 3.0. */ public function setApiVersion($apiVersion); diff --git a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php index b752c397b8805..d7d3877aed283 100644 --- a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php +++ b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php @@ -21,6 +21,7 @@ * Default implementation of {@link ConstraintViolationBuilderInterface}. * * @since 2.5 + * * @author Bernhard Schussek * * @internal You should not instantiate or use this class. Code against diff --git a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php index e0d8d22c91de1..e02d61b432d13 100644 --- a/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php +++ b/src/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php @@ -20,6 +20,7 @@ * execution context. * * @since 2.5 + * * @author Bernhard Schussek */ interface ConstraintViolationBuilderInterface diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php index d9a7b8fab5584..8452590d63dad 100644 --- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php @@ -42,7 +42,7 @@ class ExceptionCaster public static function castError(\Error $e, array $a, Stub $stub, $isNested, $filter = 0) { - return $e instanceof \Exception ? $a : self::filterExceptionArray($a, "\0Error\0", $filter); + return self::filterExceptionArray($a, "\0Error\0", $filter); } public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0) diff --git a/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php b/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php new file mode 100644 index 0000000000000..17b86456beab4 --- /dev/null +++ b/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts pqsql resources to array representation. + * + * @author Nicolas Grekas + */ +class PgSqlCaster +{ + private static $paramCodes = array( + 'server_encoding', + 'client_encoding', + 'is_superuser', + 'session_authorization', + 'DateStyle', + 'TimeZone', + 'IntervalStyle', + 'integer_datetimes', + 'application_name', + 'standard_conforming_strings', + ); + + private static $transactionStatus = array( + PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE', + PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE', + PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS', + PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR', + PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN', + ); + + private static $resultStatus = array( + PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY', + PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK', + PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK', + PGSQL_COPY_OUT => 'PGSQL_COPY_OUT', + PGSQL_COPY_IN => 'PGSQL_COPY_IN', + PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE', + PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR', + PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR', + ); + + private static $diagCodes = array( + 'severity' => PGSQL_DIAG_SEVERITY, + 'sqlstate' => PGSQL_DIAG_SQLSTATE, + 'message' => PGSQL_DIAG_MESSAGE_PRIMARY, + 'detail' => PGSQL_DIAG_MESSAGE_DETAIL, + 'hint' => PGSQL_DIAG_MESSAGE_HINT, + 'statement position' => PGSQL_DIAG_STATEMENT_POSITION, + 'internal position' => PGSQL_DIAG_INTERNAL_POSITION, + 'internal query' => PGSQL_DIAG_INTERNAL_QUERY, + 'context' => PGSQL_DIAG_CONTEXT, + 'file' => PGSQL_DIAG_SOURCE_FILE, + 'line' => PGSQL_DIAG_SOURCE_LINE, + 'function' => PGSQL_DIAG_SOURCE_FUNCTION, + ); + + public static function castLargeObject($lo, array $a, Stub $stub, $isNested) + { + $a['seek position'] = pg_lo_tell($lo); + + return $a; + } + + public static function castLink($link, array $a, Stub $stub, $isNested) + { + $a['status'] = pg_connection_status($link); + $a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']); + $a['busy'] = pg_connection_busy($link); + + $a['transaction'] = pg_transaction_status($link); + if (isset(self::$transactionStatus[$a['transaction']])) { + $a['transaction'] = new ConstStub(self::$transactionStatus[$a['transaction']], $a['transaction']); + } + + $a['pid'] = pg_get_pid($link); + $a['last error'] = pg_last_error($link); + $a['last notice'] = pg_last_notice($link); + $a['host'] = pg_host($link); + $a['port'] = pg_port($link); + $a['dbname'] = pg_dbname($link); + $a['options'] = pg_options($link); + $a['version'] = pg_version($link); + + foreach (self::$paramCodes as $v) { + if (false !== $s = pg_parameter_status($link, $v)) { + $a['param'][$v] = $s; + } + } + + $a['param']['client_encoding'] = pg_client_encoding($link); + + return $a; + } + + public static function castResult($result, array $a, Stub $stub, $isNested) + { + $a['num rows'] = pg_num_rows($result); + $a['status'] = pg_result_status($result); + if (isset(self::$resultStatus[$a['status']])) { + $a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']); + } + $a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING); + + if (-1 === $a['num rows']) { + foreach (self::$diagCodes as $k => $v) { + $a['error'][$k] = pg_result_error_field($result, $v); + } + } + + $a['affected rows'] = pg_affected_rows($result); + $a['last OID'] = pg_last_oid($result); + + $fields = pg_num_fields($result); + + for ($i = 0; $i < $fields; ++$i) { + $field = array( + 'name' => pg_field_name($result, $i), + 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), + 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), + 'nullable' => (bool) pg_field_is_null($result, $i), + 'storage' => pg_field_size($result, $i).' bytes', + 'display' => pg_field_prtlen($result, $i).' chars', + ); + if (' (OID: )' === $field['table']) { + $field['table'] = null; + } + if ('-1 bytes' === $field['storage']) { + $field['storage'] = 'variable size'; + } elseif ('1 bytes' === $field['storage']) { + $field['storage'] = '1 byte'; + } + if ('1 chars' === $field['display']) { + $field['display'] = '1 char'; + } + $a['fields'][] = $field; + } + + return $a; + } +} diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 6ef2ebf7bd078..0bf91c8204aee 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -130,7 +130,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra if ($v = $c->getStaticVariables()) { foreach ($v as $k => &$v) { - $a[$prefix.'use']['$'.$k] =& $v; + $a[$prefix.'use']['$'.$k] = &$v; } unset($v); } @@ -219,7 +219,7 @@ public static function castZendExtension(\ReflectionZendExtension $c, array $a, private static function addExtra(&$a, \Reflector $c) { - $a =& $a[Caster::PREFIX_VIRTUAL.'extra']; + $a = &$a[Caster::PREFIX_VIRTUAL.'extra']; if (method_exists($c, 'getFileName') && $m = $c->getFileName()) { $a['file'] = $m; diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index c19cf06dd4f7c..b376c8d394ff1 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -98,6 +98,10 @@ abstract class AbstractCloner implements ClonerInterface ':dba persistent' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba', ':gd' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castGd', ':mysql link' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castMysqlLink', + ':pgsql large object' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castLargeObject', + ':pgsql link' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castLink', + ':pgsql link persistent' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castLink', + ':pgsql result' => 'Symfony\Component\VarDumper\Caster\PgSqlCaster::castResult', ':process' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castProcess', ':stream' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castStream', ':stream-context' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castStreamContext', diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 4699e19182f8a..51309c662b500 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -77,7 +77,7 @@ protected function doClone($var) $zval['type'] = gettype($v); } if ($zval['zval_isref']) { - $queue[$i][$k] =& $stub; // Break hard references to make $queue completely + $queue[$i][$k] = &$stub; // Break hard references to make $queue completely unset($stub); // independent from the original structure if (isset($hardRefs[$zval['zval_hash']])) { $queue[$i][$k] = $useExt ? ($v = $hardRefs[$zval['zval_hash']]) : ($step[$k] = $v); @@ -130,7 +130,7 @@ protected function doClone($var) unset($v[$gid]); $a = array(); foreach ($v as $gk => &$gv) { - $a[$gk] =& $gv; + $a[$gk] = &$gv; } } else { $a = $v; @@ -210,7 +210,7 @@ protected function doClone($var) $step[$k] = new Stub(); $step[$k]->value = $stub; $h = spl_object_hash($step[$k]); - $queue[$i][$k] = $hardRefs[$h] =& $step[$k]; + $queue[$i][$k] = $hardRefs[$h] = &$step[$k]; $values[$h] = $v; } $queue[$i][$k]->handle = ++$refs; @@ -249,7 +249,7 @@ protected function doClone($var) $step[$k] = $queue[$i][$k] = new Stub(); $step[$k]->value = $v; $h = spl_object_hash($step[$k]); - $hardRefs[$h] =& $step[$k]; + $hardRefs[$h] = &$step[$k]; $values[$h] = $v; } $queue[$i][$k]->handle = ++$refs; diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index abd1e076981ac..0fcc7e26bb36a 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -32,7 +32,7 @@ public function testReflectionCaster() constants: array:3 [ "IS_IMPLICIT_ABSTRACT" => 16 "IS_EXPLICIT_ABSTRACT" => 32 - "IS_FINAL" => 64 + "IS_FINAL" => %d ] properties: array:%d [ "name" => ReflectionProperty { diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 311ef18a376f0..ad7ae498ff1ab 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -115,6 +115,9 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap); } } + if ($isRef) { + $this->refs[$isRef] = end($data); + } } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); @@ -227,6 +230,9 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data[$key] = $value; } } + if ($isRef) { + $this->refs[$isRef] = $data[$key]; + } } else { // multiple documents are not supported if ('---' === $this->currentLine) { @@ -284,10 +290,6 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine); } - - if ($isRef) { - $this->refs[$isRef] = end($data); - } } if (isset($mbEncoding)) { @@ -356,7 +358,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) return; } - if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) { + if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) { // the previous line contained a dash but no item content, this line is a sequence item with the same indentation // and therefore no nested list or mapping $this->moveToPreviousLine(); diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml index f8501ddc29646..d98810256ec21 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml @@ -21,7 +21,7 @@ ruby: | test: Leading Document Separator todo: true brief: > - You can explicity give an opening + You can explicitly give an opening document separator to your YAML stream. yaml: | --- diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml index fd9910174dade..4b67d341008e7 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml @@ -33,6 +33,17 @@ yaml: | isit: tested head: <<: [ *foo , *dong , *foo2 ] + taz: &taz + a: Steve + w: + p: 1234 + nested: + <<: *taz + d: Doug + w: &nestedref + p: 12345 + z: + <<: *nestedref php: | array( 'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'), @@ -41,5 +52,7 @@ php: | 'foo2' => array('a' => 'Ballmer'), 'ding' => array('fi', 'fei', 'fo', 'fam'), 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'), - 'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam') + 'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam'), + 'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)), + 'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)) ) diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 0776e4fa8dfbf..522d77053deac 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -293,8 +293,8 @@ public function getTestsForParseWithMapObjects() array('{ foo : bar, bar : foo, false : false, null : null, integer : 12 }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)), array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')), array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')), - array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', "bar\"" => 'foo: bar')), - array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', "bar: " => 'foo: bar')), + array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', 'bar"' => 'foo: bar')), + array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', 'bar: ' => 'foo: bar')), // nested sequences and mappings array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))), diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index 93206f923352f..1b5e5ec2dc590 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -24,6 +24,7 @@ class Unescaper * must be converted to that encoding. * * @deprecated since version 2.5, to be removed in 3.0 + * * @internal */ const ENCODING = 'UTF-8'; From ab13ed4f491a41b2001b26df3c52e979c1469fb7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 1 Sep 2015 17:52:18 +0200 Subject: [PATCH 126/133] fixed composer.json --- src/Symfony/Component/Security/composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index e323fc70d3ffd..aeda867f03741 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -1,4 +1,3 @@ -<<<<<<< Local Changes { "name": "symfony/security", "type": "library", @@ -57,5 +56,3 @@ } } } -======= ->>>>>>> External Changes From 3f0ba473641dc2340d5ffcc81e725fe5581a6368 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Tue, 4 Aug 2015 14:52:22 +0200 Subject: [PATCH 127/133] Add choice_label_attr --- .../Factory/CachingFactoryDecorator.php | 7 +++--- .../Factory/ChoiceListFactoryInterface.php | 4 +++- .../Factory/DefaultChoiceListFactory.php | 23 ++++++++++++------- .../Factory/PropertyAccessDecorator.php | 14 +++++++++-- .../Form/ChoiceList/View/ChoiceView.php | 19 +++++++++++---- .../Form/Extension/Core/Type/ChoiceType.php | 6 ++++- 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php index 0692781f40ee4..79587c2535fa1 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php @@ -181,11 +181,11 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul /** * {@inheritdoc} */ - public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null) + public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null, $labelAttr = null) { // The input is not validated on purpose. This way, the decorated // factory may decide which input to accept and which not. - $hash = self::generateHash(array($list, $preferredChoices, $label, $index, $groupBy, $attr)); + $hash = self::generateHash(array($list, $preferredChoices, $label, $index, $groupBy, $attr, $labelAttr)); if (!isset($this->views[$hash])) { $this->views[$hash] = $this->decoratedFactory->createView( @@ -194,7 +194,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $label, $index, $groupBy, - $attr + $attr, + $labelAttr ); } diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php b/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php index 7933dd91d48d7..ead6db545ba36 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php @@ -112,8 +112,10 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul * group names * @param null|array|callable $attr The callable generating the * HTML attributes + * @param null|array|callable $labelAttr The callable generating the + * label HTML attributes * * @return ChoiceListView The choice list view */ - public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null); + public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null, $labelAttr = null); } diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index 9e54fa0857f9e..e20b4cd7d472f 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -59,13 +59,13 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul /** * {@inheritdoc} */ - public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null) + public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null, $labelAttr = null) { // Backwards compatibility if ($list instanceof LegacyChoiceListAdapter && empty($preferredChoices) - && null === $label && null === $index && null === $groupBy && null === $attr) { - $mapToNonLegacyChoiceView = function (LegacyChoiceView &$choiceView) { - $choiceView = new ChoiceView($choiceView->data, $choiceView->value, $choiceView->label); + && null === $label && null === $index && null === $groupBy && null === $attr && null === $labelAttr) { + $mapToNonLegacyChoiceView = function (LegacyChoiceView $choiceView) { + return new ChoiceView($choiceView->data, $choiceView->value, $choiceView->label); }; $adaptedList = $list->getAdaptedList(); @@ -107,6 +107,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $keys, $index, $attr, + $labelAttr, $preferredChoices, $preferredViews, $otherViews @@ -121,6 +122,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $keys, $index, $attr, + $labelAttr, $preferredChoices, $preferredViews, $otherViews @@ -144,7 +146,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, return new ChoiceListView($otherViews, $preferredViews); } - private static function addChoiceView($choice, $value, $label, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews) + private static function addChoiceView($choice, $value, $label, $keys, &$index, $attr, $labelAttr, $isPreferred, &$preferredViews, &$otherViews) { // $value may be an integer or a string, since it's stored in the array // keys. We want to guarantee it's a string though. @@ -158,7 +160,8 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $ null === $label ? (string) $key : (string) call_user_func($label, $choice, $key, $value), // The attributes may be a callable or a mapping from choice indices // to nested arrays - is_callable($attr) ? call_user_func($attr, $choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array()) + is_callable($attr) ? call_user_func($attr, $choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array()), + is_callable($labelAttr) ? call_user_func($labelAttr, $choice, $key, $value) : (isset($labelAttr[$key]) ? $labelAttr[$key] : array()) ); // $isPreferred may be null if no choices are preferred @@ -169,7 +172,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $ } } - private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews) + private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $keys, &$index, $attr, $labelAttr, $isPreferred, &$preferredViews, &$otherViews) { foreach ($groupBy as $key => $value) { // Add the contents of groups to new ChoiceGroupView instances @@ -184,6 +187,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key $keys, $index, $attr, + $labelAttr, $isPreferred, $preferredViewsForGroup, $otherViewsForGroup @@ -208,6 +212,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key $keys, $index, $attr, + $labelAttr, $isPreferred, $preferredViews, $otherViews @@ -215,7 +220,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key } } - private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews) + private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label, $keys, &$index, $attr, $labelAttr, $isPreferred, &$preferredViews, &$otherViews) { $groupLabel = call_user_func($groupBy, $choice, $keys[$value], $value); @@ -228,6 +233,7 @@ private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label $keys, $index, $attr, + $labelAttr, $isPreferred, $preferredViews, $otherViews @@ -252,6 +258,7 @@ private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label $keys, $index, $attr, + $labelAttr, $isPreferred, $preferredViews[$groupLabel]->choices, $otherViews[$groupLabel]->choices diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php index 87a364a5f4d55..f45d5ef0fcb06 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php @@ -166,7 +166,7 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul * * @return ChoiceListView The choice list view */ - public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null) + public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null, $labelAttr = null) { $accessor = $this->propertyAccessor; @@ -229,6 +229,16 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, }; } - return $this->decoratedFactory->createView($list, $preferredChoices, $label, $index, $groupBy, $attr); + if (is_string($labelAttr)) { + $labelAttr = new PropertyPath($labelAttr); + } + + if ($labelAttr instanceof PropertyPath) { + $labelAttr = function ($choice) use ($accessor, $labelAttr) { + return $accessor->getValue($choice, $labelAttr); + }; + } + + return $this->decoratedFactory->createView($list, $preferredChoices, $label, $index, $groupBy, $attr, $labelAttr); } } diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php index 6e79d413cc019..36fe2c648859a 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php @@ -75,18 +75,27 @@ class ChoiceView extends LegacyChoiceView */ public $attr; + /** + * Additional attributes for labels HTML tag. + * + * @var array + */ + public $labelAttr; + /** * Creates a new choice view. * - * @param mixed $data The original choice - * @param string $value The view representation of the choice - * @param string $label The label displayed to humans - * @param array $attr Additional attributes for the HTML tag + * @param mixed $data The original choice + * @param string $value The view representation of the choice + * @param string $label The label displayed to humans + * @param array $attr Additional attributes for the HTML tag + * @param array $labelAttr Additional attributes for labels HTML tag */ - public function __construct($data, $value, $label, array $attr = array()) + public function __construct($data, $value, $label, array $attr = array(), array $labelAttr = array()) { parent::__construct($data, $value, $label); $this->attr = $attr; + $this->labelAttr = $labelAttr; } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 66444659d4315..a1207839bb924 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -325,6 +325,7 @@ public function configureOptions(OptionsResolver $resolver) 'choice_name' => null, 'choice_value' => null, 'choice_attr' => null, + 'choice_label_attr' => null, 'preferred_choices' => array(), 'group_by' => null, 'empty_data' => $emptyData, @@ -353,6 +354,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('choice_name', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('choice_value', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('choice_attr', array('null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); + $resolver->setAllowedTypes('choice_label_attr', array('null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('preferred_choices', array('array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('group_by', array('null', 'array', '\Traversable', 'string', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); } @@ -427,6 +429,7 @@ private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $ch 'value' => $choiceView->value, 'label' => $choiceView->label, 'attr' => $choiceView->attr, + 'label_attr' => $choiceView->labelAttr, 'translation_domain' => $options['translation_domain'], 'block_name' => 'entry', ); @@ -459,7 +462,8 @@ private function createChoiceListView(ChoiceListInterface $choiceList, array $op $options['choice_label'], $options['choice_name'], $options['group_by'], - $options['choice_attr'] + $options['choice_attr'], + $options['choice_label_attr'] ); } } From 383dabf19620088b171882a98e046bc9a492f620 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Tue, 4 Aug 2015 14:52:32 +0200 Subject: [PATCH 128/133] add tests --- .../Factory/CachingFactoryDecoratorTest.php | 72 +++++ .../Factory/DefaultChoiceListFactoryTest.php | 257 ++++++++++++++++-- .../Factory/PropertyAccessDecoratorTest.php | 44 +++ 3 files changed, 348 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index 9855c4a708d67..f19cb5d8a34a7 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -598,6 +598,78 @@ public function testCreateViewDifferentAttributesClosure() $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); } + public function testCreateViewSameLabelAttributes() + { + $labelAttr = array('class' => 'foobar'); + $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $view = new \stdClass(); + + $this->decoratedFactory->expects($this->once()) + ->method('createView') + ->with($list, null, null, null, null, null, $labelAttr) + ->will($this->returnValue($view)); + + $this->assertSame($view, $this->factory->createView($list, null, null, null, null, null, $labelAttr)); + $this->assertSame($view, $this->factory->createView($list, null, null, null, null, null, $labelAttr)); + } + + public function testCreateViewDifferentLabelAttributes() + { + $labelAttr1 = array('class' => 'foobar1'); + $labelAttr2 = array('class' => 'foobar2'); + $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $view1 = new \stdClass(); + $view2 = new \stdClass(); + + $this->decoratedFactory->expects($this->at(0)) + ->method('createView') + ->with($list, null, null, null, null, null, $labelAttr1) + ->will($this->returnValue($view1)); + $this->decoratedFactory->expects($this->at(1)) + ->method('createView') + ->with($list, null, null, null, null, null, $labelAttr2) + ->will($this->returnValue($view2)); + + $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, null, $labelAttr1)); + $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, null, $labelAttr2)); + } + + public function testCreateViewSameLabelAttributesClosure() + { + $labelAttr = function () {}; + $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $view = new \stdClass(); + + $this->decoratedFactory->expects($this->once()) + ->method('createView') + ->with($list, null, null, null, null, $labelAttr) + ->will($this->returnValue($view)); + + $this->assertSame($view, $this->factory->createView($list, null, null, null, null, null, $labelAttr)); + $this->assertSame($view, $this->factory->createView($list, null, null, null, null, null, $labelAttr)); + } + + public function testCreateViewDifferentLabelAttributesClosure() + { + $labelAttr1 = function () {}; + $labelAttr2 = function () {}; + $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + $view1 = new \stdClass(); + $view2 = new \stdClass(); + + $this->decoratedFactory->expects($this->at(0)) + ->method('createView') + ->with($list, null, null, null, null, null, $labelAttr1) + ->will($this->returnValue($view1)); + $this->decoratedFactory->expects($this->at(1)) + ->method('createView') + ->with($list, null, null, null, null, null, $labelAttr2) + ->will($this->returnValue($view2)); + + $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, null, $labelAttr1)); + $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, null, $labelAttr2)); + } + public function provideSameChoices() { $object = (object) array('foo' => 'bar'); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index 1738aaff0ff3c..debf0ea827441 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -31,6 +31,10 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase private $obj4; + private $obj5; + + private $obj6; + private $list; /** @@ -50,6 +54,8 @@ public function getScalarValue($choice) case 'b': return 'b'; case 'c': return '1'; case 'd': return '2'; + case 'e': return '0.1'; + case 'f': return '0.2'; } } @@ -73,26 +79,35 @@ public function getAttr($object) return $object->attr; } + public function getLabelAttr($object) + { + return $object->labelAttr; + } + public function getGroup($object) { - return $this->obj1 === $object || $this->obj2 === $object ? 'Group 1' : 'Group 2'; + return $this->obj1 === $object || $this->obj2 === $object ? 'Group 1' : ($this->obj3 === $object || $this->obj4 === $object ? 'Group 2' : 'Group 3'); } public function getGroupAsObject($object) { return $this->obj1 === $object || $this->obj2 === $object ? new DefaultChoiceListFactoryTest_Castable('Group 1') - : new DefaultChoiceListFactoryTest_Castable('Group 2'); + : ($this->obj3 === $object || $this->obj4 === $object + ? new DefaultChoiceListFactoryTest_Castable('Group 2') + : new DefaultChoiceListFactoryTest_Castable('Group 3')); } protected function setUp() { - $this->obj1 = (object) array('label' => 'A', 'index' => 'w', 'value' => 'a', 'preferred' => false, 'group' => 'Group 1', 'attr' => array()); - $this->obj2 = (object) array('label' => 'B', 'index' => 'x', 'value' => 'b', 'preferred' => true, 'group' => 'Group 1', 'attr' => array('attr1' => 'value1')); - $this->obj3 = (object) array('label' => 'C', 'index' => 'y', 'value' => 1, 'preferred' => true, 'group' => 'Group 2', 'attr' => array('attr2' => 'value2')); - $this->obj4 = (object) array('label' => 'D', 'index' => 'z', 'value' => 2, 'preferred' => false, 'group' => 'Group 2', 'attr' => array()); + $this->obj1 = (object) array('label' => 'A', 'index' => 'w', 'value' => 'a', 'preferred' => false, 'group' => 'Group 1', 'attr' => array(), 'labelAttr' => array()); + $this->obj2 = (object) array('label' => 'B', 'index' => 'x', 'value' => 'b', 'preferred' => true, 'group' => 'Group 1', 'attr' => array('attr1' => 'value1'), 'labelAttr' => array()); + $this->obj3 = (object) array('label' => 'C', 'index' => 'y', 'value' => 1, 'preferred' => true, 'group' => 'Group 2', 'attr' => array('attr2' => 'value2'), 'labelAttr' => array()); + $this->obj4 = (object) array('label' => 'D', 'index' => 'z', 'value' => 2, 'preferred' => false, 'group' => 'Group 2', 'attr' => array(), 'labelAttr' => array()); + $this->obj5 = (object) array('label' => 'E', 'index' => 'u', 'value' => 0.1, 'preferred' => true, 'group' => 'Group 3', 'attr' => array('attr1' => 'value1'), 'labelAttr' => array('labelAttr1' => 'labelValue1')); + $this->obj6 = (object) array('label' => 'F', 'index' => 'v', 'value' => 0.2, 'preferred' => false, 'group' => 'Group 3', 'attr' => array(), 'labelAttr' => array('labelAttr2' => 'labelValue2')); $this->list = new ArrayChoiceList( - array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4) + array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj5, 'F' => $this->obj6) ); $this->factory = new DefaultChoiceListFactory(); } @@ -108,7 +123,7 @@ public function testCreateFromChoicesEmpty() public function testCreateFromChoicesFlat() { $list = $this->factory->createListFromChoices( - array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4) + array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj4, 'F' => $this->obj6) ); $this->assertObjectListWithGeneratedValues($list); @@ -117,7 +132,7 @@ public function testCreateFromChoicesFlat() public function testCreateFromChoicesFlatTraversable() { $list = $this->factory->createListFromChoices( - new \ArrayIterator(array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4)) + new \ArrayIterator(array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj5, 'F' => $this->obj6)) ); $this->assertObjectListWithGeneratedValues($list); @@ -126,7 +141,7 @@ public function testCreateFromChoicesFlatTraversable() public function testCreateFromChoicesFlatValuesAsCallable() { $list = $this->factory->createListFromChoices( - array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4), + array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj5, 'F' => $this->obj6), array($this, 'getValue') ); @@ -136,7 +151,7 @@ public function testCreateFromChoicesFlatValuesAsCallable() public function testCreateFromChoicesFlatValuesAsClosure() { $list = $this->factory->createListFromChoices( - array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4), + array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj5, 'F' => $this->obj6), function ($object) { return $object->value; } ); @@ -149,6 +164,7 @@ public function testCreateFromChoicesGrouped() array( 'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2), 'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4), + 'Group 3' => array('E' => $this->obj5, 'F' => $this->obj6), ) ); @@ -159,9 +175,10 @@ public function testCreateFromChoicesGroupedTraversable() { $list = $this->factory->createListFromChoices( new \ArrayIterator(array( - 'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2), - 'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4), - )) + 'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2), + 'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4), + 'Group 3' => array('E' => $this->obj5, 'F' => $this->obj6), + )) ); $this->assertObjectListWithGeneratedValues($list); @@ -173,6 +190,7 @@ public function testCreateFromChoicesGroupedValuesAsCallable() array( 'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2), 'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4), + 'Group 3' => array('E' => $this->obj5, 'F' => $this->obj6), ), array($this, 'getValue') ); @@ -186,6 +204,7 @@ public function testCreateFromChoicesGroupedValuesAsClosure() array( 'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2), 'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4), + 'Group 3' => array('E' => $this->obj5, 'F' => $this->obj6), ), function ($object) { return $object->value; } ); @@ -204,7 +223,7 @@ public function testCreateFromFlippedChoicesEmpty() public function testCreateFromFlippedChoicesFlat() { $list = $this->factory->createListFromFlippedChoices( - array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D') + array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', 'e' => 'E', 'f' => 'F') ); $this->assertScalarListWithChoiceValues($list); @@ -213,7 +232,7 @@ public function testCreateFromFlippedChoicesFlat() public function testCreateFromFlippedChoicesFlatTraversable() { $list = $this->factory->createListFromFlippedChoices( - new \ArrayIterator(array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D')) + new \ArrayIterator(array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', 'e' => 'E', 'f' => 'F')) ); $this->assertScalarListWithChoiceValues($list); @@ -222,7 +241,7 @@ public function testCreateFromFlippedChoicesFlatTraversable() public function testCreateFromFlippedChoicesFlatValuesAsCallable() { $list = $this->factory->createListFromFlippedChoices( - array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'), + array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', 'e' => 'E', 'f' => 'F'), array($this, 'getScalarValue') ); @@ -232,13 +251,15 @@ public function testCreateFromFlippedChoicesFlatValuesAsCallable() public function testCreateFromFlippedChoicesFlatValuesAsClosure() { $list = $this->factory->createListFromFlippedChoices( - array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'), + array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', 'e' => 'E', 'f' => 'F'), function ($choice) { switch ($choice) { case 'a': return 'a'; case 'b': return 'b'; case 'c': return '1'; case 'd': return '2'; + case 'e': return '0.1'; + case 'f': return '0.2'; } } ); @@ -252,6 +273,7 @@ public function testCreateFromFlippedChoicesGrouped() array( 'Group 1' => array('a' => 'A', 'b' => 'B'), 'Group 2' => array('c' => 'C', 'd' => 'D'), + 'Group 3' => array('e' => 'E', 'f' => 'F'), ) ); @@ -262,9 +284,10 @@ public function testCreateFromFlippedChoicesGroupedTraversable() { $list = $this->factory->createListFromFlippedChoices( new \ArrayIterator(array( - 'Group 1' => array('a' => 'A', 'b' => 'B'), - 'Group 2' => array('c' => 'C', 'd' => 'D'), - )) + 'Group 1' => array('a' => 'A', 'b' => 'B'), + 'Group 2' => array('c' => 'C', 'd' => 'D'), + 'Group 3' => array('e' => 'E', 'f' => 'F'), + )) ); $this->assertScalarListWithChoiceValues($list); @@ -276,6 +299,7 @@ public function testCreateFromFlippedChoicesGroupedValuesAsCallable() array( 'Group 1' => array('a' => 'A', 'b' => 'B'), 'Group 2' => array('c' => 'C', 'd' => 'D'), + 'Group 3' => array('e' => 'E', 'f' => 'F'), ), array($this, 'getScalarValue') ); @@ -289,6 +313,7 @@ public function testCreateFromFlippedChoicesGroupedValuesAsClosure() array( 'Group 1' => array('a' => 'A', 'b' => 'B'), 'Group 2' => array('c' => 'C', 'd' => 'D'), + 'Group 3' => array('e' => 'E', 'f' => 'F'), ), function ($choice) { switch ($choice) { @@ -296,6 +321,8 @@ function ($choice) { case 'b': return 'b'; case 'c': return '1'; case 'd': return '2'; + case 'e': return '0.1'; + case 'f': return '0.2'; } } ); @@ -332,6 +359,8 @@ public function testCreateViewFlat() 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D'), + 4 => new ChoiceView($this->obj5, '4', 'E'), + 5 => new ChoiceView($this->obj6, '5', 'F'), ), array() ), $view); } @@ -359,6 +388,8 @@ public function testCreateViewFlatPreferredChoicesEmptyArray() 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D'), + 4 => new ChoiceView($this->obj5, '4', 'E'), + 5 => new ChoiceView($this->obj6, '5', 'F'), ), array() ), $view); } @@ -734,6 +765,113 @@ function ($object, $key, $value) { $this->assertFlatViewWithAttr($view); } + public function testCreateViewFlatLabelAttrAsArray() + { + $view = $this->factory->createView( + $this->list, + array($this->obj5, $this->obj6), + null, // label + null, // index + null, // group + null, // attr + array( + 'E' => array('labelAttr1' => 'labelValue1'), + 'F' => array('labelAttr2' => 'labelValue2'), + ) + ); + + $this->assertFlatViewWithLabelAttr($view); + } + + public function testCreateViewFlatLabelAttrEmpty() + { + $view = $this->factory->createView( + $this->list, + array($this->obj5, $this->obj6), + null, // label + null, // index + null, // group + null, // attr + array() + ); + + $this->assertFlatView($view); + } + + public function testCreateViewFlatLabelAttrAsCallable() + { + $view = $this->factory->createView( + $this->list, + array($this->obj5, $this->obj6), + null, // label + null, // index + null, // group + null, // attr + array($this, 'getLabelAttr') + ); + + $this->assertFlatViewWithLabelAttr($view); + } + + public function testCreateViewFlatLabelAttrAsClosure() + { + $view = $this->factory->createView( + $this->list, + array($this->obj5, $this->obj6), + null, // label + null, // index + null, // group + null, // attr + function ($object) { + return $object->labelAttr; + } + ); + + $this->assertFlatViewWithLabelAttr($view); + } + + public function testCreateViewFlatLabelAttrClosureReceivesKey() + { + $view = $this->factory->createView( + $this->list, + array($this->obj5, $this->obj6), + null, // label + null, // index + null, // group + null, // attr + function ($object, $key) { + switch ($key) { + case 'E': return array('labelAttr1' => 'labelValue1'); + case 'F': return array('labelAttr2' => 'labelValue2'); + default: return array(); + } + } + ); + + $this->assertFlatViewWithLabelAttr($view); + } + + public function testCreateViewFlatLabelAttrClosureReceivesValue() + { + $view = $this->factory->createView( + $this->list, + array($this->obj5, $this->obj6), + null, // label + null, // index + null, // group + null, // attr + function ($object, $key, $value) { + switch ($value) { + case '4': return array('labelAttr1' => 'labelValue1'); + case '5': return array('labelAttr2' => 'labelValue2'); + default: return array(); + } + } + ); + + $this->assertFlatViewWithLabelAttr($view); + } + /** * @group legacy */ @@ -790,13 +928,15 @@ public function testCreateViewForNestedLegacyChoiceList() private function assertScalarListWithChoiceValues(ChoiceListInterface $list) { - $this->assertSame(array('a', 'b', 'c', 'd'), $list->getValues()); + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $list->getValues()); $this->assertSame(array( 'a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', + 'e' => 'e', + 'f' => 'f', ), $list->getChoices()); $this->assertSame(array( @@ -804,18 +944,22 @@ private function assertScalarListWithChoiceValues(ChoiceListInterface $list) 'b' => 'B', 'c' => 'C', 'd' => 'D', + 'e' => 'E', + 'f' => 'F', ), $list->getOriginalKeys()); } private function assertObjectListWithGeneratedValues(ChoiceListInterface $list) { - $this->assertSame(array('0', '1', '2', '3'), $list->getValues()); + $this->assertSame(array('0', '1', '2', '3', '4', 5), $list->getValues()); $this->assertSame(array( 0 => $this->obj1, 1 => $this->obj2, 2 => $this->obj3, 3 => $this->obj4, + 4 => $this->obj5, + 5 => $this->obj6, ), $list->getChoices()); $this->assertSame(array( @@ -823,18 +967,22 @@ private function assertObjectListWithGeneratedValues(ChoiceListInterface $list) 1 => 'B', 2 => 'C', 3 => 'D', + 4 => 'E', + 5 => 'F', ), $list->getOriginalKeys()); } private function assertScalarListWithCustomValues(ChoiceListInterface $list) { - $this->assertSame(array('a', 'b', '1', '2'), $list->getValues()); + $this->assertSame(array('a', 'b', '1', '2', '0.1', '0.2'), $list->getValues()); $this->assertSame(array( 'a' => 'a', 'b' => 'b', 1 => 'c', 2 => 'd', + '0.1' => 'e', + '0.2' => 'f' ), $list->getChoices()); $this->assertSame(array( @@ -842,18 +990,22 @@ private function assertScalarListWithCustomValues(ChoiceListInterface $list) 'b' => 'B', 1 => 'C', 2 => 'D', + '0.1' => 'E', + '0.2' => 'F', ), $list->getOriginalKeys()); } private function assertObjectListWithCustomValues(ChoiceListInterface $list) { - $this->assertSame(array('a', 'b', '1', '2'), $list->getValues()); + $this->assertSame(array('a', 'b', '1', '2', '0.1', '0.2'), $list->getValues()); $this->assertSame(array( 'a' => $this->obj1, 'b' => $this->obj2, 1 => $this->obj3, 2 => $this->obj4, + '0.1' => $this->obj5, + '0.2' => $this->obj6, ), $list->getChoices()); $this->assertSame(array( @@ -861,6 +1013,8 @@ private function assertObjectListWithCustomValues(ChoiceListInterface $list) 'b' => 'B', 1 => 'C', 2 => 'D', + '0.1' => 'E', + '0.2' => 'F' ), $list->getOriginalKeys()); } @@ -873,6 +1027,9 @@ private function assertFlatView($view) ), array( 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), + ), array( + 4 => new ChoiceView($this->obj5, '4', 'E'), + 5 => new ChoiceView($this->obj6, '5', 'F'), ) ), $view); } @@ -886,6 +1043,9 @@ private function assertFlatViewWithCustomIndices($view) ), array( 'x' => new ChoiceView($this->obj2, '1', 'B'), 'y' => new ChoiceView($this->obj3, '2', 'C'), + ), array( + 'u' => new ChoiceView($this->obj5, '4', 'E'), + 'v' => new ChoiceView($this->obj6, '5', 'F'), ) ), $view); } @@ -913,6 +1073,44 @@ private function assertFlatViewWithAttr($view) ), $view); } + private function assertFlatViewWithLabelAttr($view) + { + $this->assertEquals(new ChoiceListView( + array( + 0 => new ChoiceView($this->obj1, '0', 'A'), + 3 => new ChoiceView($this->obj4, '3', 'D'), + ), array( + 1 => new ChoiceView( + $this->obj2, + '1', + 'B', + array('attr1' => 'value1') + ), + 2 => new ChoiceView( + $this->obj3, + '2', + 'C', + array('attr2' => 'value2') + ), + ), array( + 4 => new ChoiceView( + $this->obj5, + '4', + 'E', + array('attr1' => 'value1'), + array('labelAttr1' => 'labelValue1') + ), + 5 => new ChoiceView( + $this->obj6, + '5', + 'F', + array(), + array('labelAttr2' => 'labelValue2') + ) + ) + ), $view); + } + private function assertGroupedView($view) { $this->assertEquals(new ChoiceListView( @@ -930,6 +1128,15 @@ private function assertGroupedView($view) 'Group 1', array(1 => new ChoiceView($this->obj2, '1', 'B')) ), + 'Group 3' => new ChoiceGroupView( + 'Group 3', + array(5 => new ChoiceView($this->obj6, '5', 'F')) + ), + ), array( + 'Group 3' => new ChoiceGroupView( + 'Group 3', + array(4 => new ChoiceView($this->obj5, '4', 'E')) + ), 'Group 2' => new ChoiceGroupView( 'Group 2', array(2 => new ChoiceView($this->obj3, '2', 'C')) diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 311db477b1993..6cde8305ca272 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -365,4 +365,48 @@ public function testCreateViewAttrAsPropertyPathInstance() new PropertyPath('property') )); } + + public function testCreateViewLabelAttrAsPropertyPath() + { + $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + + $this->decoratedFactory->expects($this->once()) + ->method('createView') + ->with($list, null, null, null, null, null, $this->isInstanceOf('\Closure')) + ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr, $labelAttr) { + return $labelAttr((object) array('property' => 'labelAttr')); + })); + + $this->assertSame('labelAttr', $this->factory->createView( + $list, + null, // preferred choices + null, // label + null, // index + null, // groups + null, // attr + 'property' + )); + } + + public function testCreateViewLabelAttrAsPropertyPathInstance() + { + $list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface'); + + $this->decoratedFactory->expects($this->once()) + ->method('createView') + ->with($list, null, null, null, null, null, $this->isInstanceOf('\Closure')) + ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $labelAttr) { + return $labelAttr((object) array('property' => 'labelAttr')); + })); + + $this->assertSame('labelAttr', $this->factory->createView( + $list, + null, // preferred choices + null, // label + null, // index + null, // groups + null, // attr + new PropertyPath('property') + )); + } } From 95561e61b06af4208519cefba5207cac16609783 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Tue, 4 Aug 2015 15:11:58 +0200 Subject: [PATCH 129/133] cs fix for fatbot.io --- .../ChoiceList/Factory/DefaultChoiceListFactoryTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index debf0ea827441..bc1b8bbfb6a6f 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -982,7 +982,7 @@ private function assertScalarListWithCustomValues(ChoiceListInterface $list) 1 => 'c', 2 => 'd', '0.1' => 'e', - '0.2' => 'f' + '0.2' => 'f', ), $list->getChoices()); $this->assertSame(array( @@ -1014,7 +1014,7 @@ private function assertObjectListWithCustomValues(ChoiceListInterface $list) 1 => 'C', 2 => 'D', '0.1' => 'E', - '0.2' => 'F' + '0.2' => 'F', ), $list->getOriginalKeys()); } @@ -1106,7 +1106,7 @@ private function assertFlatViewWithLabelAttr($view) 'F', array(), array('labelAttr2' => 'labelValue2') - ) + ), ) ), $view); } From 242296af53cd8d962339fe018f9d7be04ad7ad39 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Wed, 26 Aug 2015 14:50:44 +0200 Subject: [PATCH 130/133] Fix tests --- .../Factory/CachingFactoryDecoratorTest.php | 2 +- .../Factory/DefaultChoiceListFactoryTest.php | 152 +++++++++--------- .../Factory/PropertyAccessDecoratorTest.php | 2 +- 3 files changed, 81 insertions(+), 75 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index f19cb5d8a34a7..d1c9f41b29bd1 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -642,7 +642,7 @@ public function testCreateViewSameLabelAttributesClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') - ->with($list, null, null, null, null, $labelAttr) + ->with($list, null, null, null, null, null, $labelAttr) ->will($this->returnValue($view)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, null, $labelAttr)); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index bc1b8bbfb6a6f..48278819e0e26 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -71,7 +71,7 @@ public function getFormIndex($object) public function isPreferred($object) { - return $this->obj2 === $object || $this->obj3 === $object; + return $this->obj2 === $object || $this->obj3 === $object || $this->obj5 === $object; } public function getAttr($object) @@ -104,8 +104,8 @@ protected function setUp() $this->obj2 = (object) array('label' => 'B', 'index' => 'x', 'value' => 'b', 'preferred' => true, 'group' => 'Group 1', 'attr' => array('attr1' => 'value1'), 'labelAttr' => array()); $this->obj3 = (object) array('label' => 'C', 'index' => 'y', 'value' => 1, 'preferred' => true, 'group' => 'Group 2', 'attr' => array('attr2' => 'value2'), 'labelAttr' => array()); $this->obj4 = (object) array('label' => 'D', 'index' => 'z', 'value' => 2, 'preferred' => false, 'group' => 'Group 2', 'attr' => array(), 'labelAttr' => array()); - $this->obj5 = (object) array('label' => 'E', 'index' => 'u', 'value' => 0.1, 'preferred' => true, 'group' => 'Group 3', 'attr' => array('attr1' => 'value1'), 'labelAttr' => array('labelAttr1' => 'labelValue1')); - $this->obj6 = (object) array('label' => 'F', 'index' => 'v', 'value' => 0.2, 'preferred' => false, 'group' => 'Group 3', 'attr' => array(), 'labelAttr' => array('labelAttr2' => 'labelValue2')); + $this->obj5 = (object) array('label' => 'E', 'index' => 'u', 'value' => '0.1', 'preferred' => true, 'group' => 'Group 3', 'attr' => array('attr1' => 'value1'), 'labelAttr' => array('labelAttr1' => 'labelValue1')); + $this->obj6 = (object) array('label' => 'F', 'index' => 'v', 'value' => '0.2', 'preferred' => false, 'group' => 'Group 3', 'attr' => array(), 'labelAttr' => array('labelAttr2' => 'labelValue2')); $this->list = new ArrayChoiceList( array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj5, 'F' => $this->obj6) ); @@ -123,7 +123,7 @@ public function testCreateFromChoicesEmpty() public function testCreateFromChoicesFlat() { $list = $this->factory->createListFromChoices( - array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj4, 'F' => $this->obj6) + array('A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3, 'D' => $this->obj4, 'E' => $this->obj5, 'F' => $this->obj6) ); $this->assertObjectListWithGeneratedValues($list); @@ -369,7 +369,7 @@ public function testCreateViewFlatPreferredChoices() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3) + array($this->obj2, $this->obj3, $this->obj5) ); $this->assertFlatView($view); @@ -408,11 +408,12 @@ public function testCreateViewFlatPreferredChoicesAsClosure() { $obj2 = $this->obj2; $obj3 = $this->obj3; + $obj5 = $this->obj5; $view = $this->factory->createView( $this->list, - function ($object) use ($obj2, $obj3) { - return $obj2 === $object || $obj3 === $object; + function ($object) use ($obj2, $obj3, $obj5) { + return $obj2 === $object || $obj3 === $object || $obj5 === $object; } ); @@ -424,7 +425,7 @@ public function testCreateViewFlatPreferredChoicesClosureReceivesKey() $view = $this->factory->createView( $this->list, function ($object, $key) { - return 'B' === $key || 'C' === $key; + return 'B' === $key || 'C' === $key || 'E' === $key; } ); @@ -436,7 +437,7 @@ public function testCreateViewFlatPreferredChoicesClosureReceivesValue() $view = $this->factory->createView( $this->list, function ($object, $key, $value) { - return '1' === $value || '2' === $value; + return '1' === $value || '2' === $value || '4' === $value; } ); @@ -447,7 +448,7 @@ public function testCreateViewFlatLabelAsCallable() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), array($this, 'getLabel') ); @@ -458,7 +459,7 @@ public function testCreateViewFlatLabelAsClosure() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), function ($object) { return $object->label; } @@ -471,7 +472,7 @@ public function testCreateViewFlatLabelClosureReceivesKey() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), function ($object, $key) { return $key; } @@ -484,13 +485,15 @@ public function testCreateViewFlatLabelClosureReceivesValue() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), function ($object, $key, $value) { switch ($value) { case '0': return 'A'; case '1': return 'B'; case '2': return 'C'; case '3': return 'D'; + case '4': return 'E'; + case '5': return 'F'; } } ); @@ -502,7 +505,7 @@ public function testCreateViewFlatIndexAsCallable() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label array($this, 'getFormIndex') ); @@ -514,7 +517,7 @@ public function testCreateViewFlatIndexAsClosure() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label function ($object) { return $object->index; @@ -528,7 +531,7 @@ public function testCreateViewFlatIndexClosureReceivesKey() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label function ($object, $key) { switch ($key) { @@ -536,6 +539,8 @@ function ($object, $key) { case 'B': return 'x'; case 'C': return 'y'; case 'D': return 'z'; + case 'E': return 'u'; + case 'F': return 'v'; } } ); @@ -547,7 +552,7 @@ public function testCreateViewFlatIndexClosureReceivesValue() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label function ($object, $key, $value) { switch ($value) { @@ -555,6 +560,8 @@ function ($object, $key, $value) { case '1': return 'x'; case '2': return 'y'; case '3': return 'z'; + case '4': return 'u'; + case '5': return 'v'; } } ); @@ -567,11 +574,12 @@ public function testCreateViewFlatGroupByOriginalStructure() $list = new ArrayChoiceList(array( 'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2), 'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4), + 'Group 3' => array('E' => $this->obj5, 'F' => $this->obj6), )); $view = $this->factory->createView( $list, - array($this->obj2, $this->obj3) + array($this->obj2, $this->obj3, $this->obj5) ); $this->assertGroupedView($view); @@ -581,7 +589,7 @@ public function testCreateViewFlatGroupByEmpty() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index array() // ignored @@ -594,7 +602,7 @@ public function testCreateViewFlatGroupByAsCallable() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index array($this, 'getGroup') @@ -607,7 +615,7 @@ public function testCreateViewFlatGroupByObjectThatCanBeCastToString() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index array($this, 'getGroupAsObject') @@ -620,14 +628,16 @@ public function testCreateViewFlatGroupByAsClosure() { $obj1 = $this->obj1; $obj2 = $this->obj2; + $obj3 = $this->obj3; + $obj4 = $this->obj4; $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index - function ($object) use ($obj1, $obj2) { - return $obj1 === $object || $obj2 === $object ? 'Group 1' : 'Group 2'; + function ($object) use ($obj1, $obj2, $obj3, $obj4) { + return $obj1 === $object || $obj2 === $object ? 'Group 1' : ($obj3 === $object || $obj4 === $object ? 'Group 2' : 'Group 3'); } ); @@ -638,11 +648,11 @@ public function testCreateViewFlatGroupByClosureReceivesKey() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index function ($object, $key) { - return 'A' === $key || 'B' === $key ? 'Group 1' : 'Group 2'; + return 'A' === $key || 'B' === $key ? 'Group 1' : ('C' === $key || 'D' === $key ? 'Group 2' : 'Group 3'); } ); @@ -653,11 +663,11 @@ public function testCreateViewFlatGroupByClosureReceivesValue() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index function ($object, $key, $value) { - return '0' === $value || '1' === $value ? 'Group 1' : 'Group 2'; + return '0' === $value || '1' === $value ? 'Group 1' : ('2' === $value || '3' === $value ? 'Group 2' : 'Group 3'); } ); @@ -668,13 +678,14 @@ public function testCreateViewFlatAttrAsArray() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group array( 'B' => array('attr1' => 'value1'), 'C' => array('attr2' => 'value2'), + 'E' => array('attr1' => 'value1'), ) ); @@ -685,7 +696,7 @@ public function testCreateViewFlatAttrEmpty() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -699,7 +710,7 @@ public function testCreateViewFlatAttrAsCallable() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -713,7 +724,7 @@ public function testCreateViewFlatAttrAsClosure() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -729,7 +740,7 @@ public function testCreateViewFlatAttrClosureReceivesKey() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -737,6 +748,7 @@ function ($object, $key) { switch ($key) { case 'B': return array('attr1' => 'value1'); case 'C': return array('attr2' => 'value2'); + case 'E': return array('attr1' => 'value1'); default: return array(); } } @@ -749,7 +761,7 @@ public function testCreateViewFlatAttrClosureReceivesValue() { $view = $this->factory->createView( $this->list, - array($this->obj2, $this->obj3), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -757,6 +769,7 @@ function ($object, $key, $value) { switch ($value) { case '1': return array('attr1' => 'value1'); case '2': return array('attr2' => 'value2'); + case '4': return array('attr1' => 'value1'); default: return array(); } } @@ -769,7 +782,7 @@ public function testCreateViewFlatLabelAttrAsArray() { $view = $this->factory->createView( $this->list, - array($this->obj5, $this->obj6), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -787,7 +800,7 @@ public function testCreateViewFlatLabelAttrEmpty() { $view = $this->factory->createView( $this->list, - array($this->obj5, $this->obj6), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -802,7 +815,7 @@ public function testCreateViewFlatLabelAttrAsCallable() { $view = $this->factory->createView( $this->list, - array($this->obj5, $this->obj6), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -817,7 +830,7 @@ public function testCreateViewFlatLabelAttrAsClosure() { $view = $this->factory->createView( $this->list, - array($this->obj5, $this->obj6), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -834,7 +847,7 @@ public function testCreateViewFlatLabelAttrClosureReceivesKey() { $view = $this->factory->createView( $this->list, - array($this->obj5, $this->obj6), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -855,7 +868,7 @@ public function testCreateViewFlatLabelAttrClosureReceivesValue() { $view = $this->factory->createView( $this->list, - array($this->obj5, $this->obj6), + array($this->obj2, $this->obj3, $this->obj5), null, // label null, // index null, // group @@ -951,7 +964,7 @@ private function assertScalarListWithChoiceValues(ChoiceListInterface $list) private function assertObjectListWithGeneratedValues(ChoiceListInterface $list) { - $this->assertSame(array('0', '1', '2', '3', '4', 5), $list->getValues()); + $this->assertSame(array('0', '1', '2', '3', '4', '5'), $list->getValues()); $this->assertSame(array( 0 => $this->obj1, @@ -1024,12 +1037,11 @@ private function assertFlatView($view) array( 0 => new ChoiceView($this->obj1, '0', 'A'), 3 => new ChoiceView($this->obj4, '3', 'D'), + 5 => new ChoiceView($this->obj6, '5', 'F'), ), array( 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), - ), array( 4 => new ChoiceView($this->obj5, '4', 'E'), - 5 => new ChoiceView($this->obj6, '5', 'F'), ) ), $view); } @@ -1040,12 +1052,11 @@ private function assertFlatViewWithCustomIndices($view) array( 'w' => new ChoiceView($this->obj1, '0', 'A'), 'z' => new ChoiceView($this->obj4, '3', 'D'), + 'v' => new ChoiceView($this->obj6, '5', 'F'), ), array( 'x' => new ChoiceView($this->obj2, '1', 'B'), 'y' => new ChoiceView($this->obj3, '2', 'C'), - ), array( 'u' => new ChoiceView($this->obj5, '4', 'E'), - 'v' => new ChoiceView($this->obj6, '5', 'F'), ) ), $view); } @@ -1056,6 +1067,7 @@ private function assertFlatViewWithAttr($view) array( 0 => new ChoiceView($this->obj1, '0', 'A'), 3 => new ChoiceView($this->obj4, '3', 'D'), + 5 => new ChoiceView($this->obj6, '5', 'F'), ), array( 1 => new ChoiceView( $this->obj2, @@ -1069,6 +1081,12 @@ private function assertFlatViewWithAttr($view) 'C', array('attr2' => 'value2') ), + 4 => new ChoiceView( + $this->obj5, + '4', + 'E', + array('attr1' => 'value1') + ), ) ), $view); } @@ -1079,33 +1097,22 @@ private function assertFlatViewWithLabelAttr($view) array( 0 => new ChoiceView($this->obj1, '0', 'A'), 3 => new ChoiceView($this->obj4, '3', 'D'), - ), array( - 1 => new ChoiceView( - $this->obj2, - '1', - 'B', - array('attr1' => 'value1') - ), - 2 => new ChoiceView( - $this->obj3, - '2', - 'C', - array('attr2' => 'value2') + 5 => new ChoiceView( + $this->obj6, + '5', + 'F', + array(), + array('labelAttr2' => 'labelValue2') ), ), array( + 1 => new ChoiceView($this->obj2, '1', 'B'), + 2 => new ChoiceView($this->obj3, '2', 'C'), 4 => new ChoiceView( $this->obj5, '4', 'E', - array('attr1' => 'value1'), - array('labelAttr1' => 'labelValue1') - ), - 5 => new ChoiceView( - $this->obj6, - '5', - 'F', array(), - array('labelAttr2' => 'labelValue2') + array('labelAttr1' => 'labelValue1') ), ) ), $view); @@ -1123,24 +1130,23 @@ private function assertGroupedView($view) 'Group 2', array(3 => new ChoiceView($this->obj4, '3', 'D')) ), - ), array( - 'Group 1' => new ChoiceGroupView( - 'Group 1', - array(1 => new ChoiceView($this->obj2, '1', 'B')) - ), 'Group 3' => new ChoiceGroupView( 'Group 3', array(5 => new ChoiceView($this->obj6, '5', 'F')) ), ), array( - 'Group 3' => new ChoiceGroupView( - 'Group 3', - array(4 => new ChoiceView($this->obj5, '4', 'E')) + 'Group 1' => new ChoiceGroupView( + 'Group 1', + array(1 => new ChoiceView($this->obj2, '1', 'B')) ), 'Group 2' => new ChoiceGroupView( 'Group 2', array(2 => new ChoiceView($this->obj3, '2', 'C')) ), + 'Group 3' => new ChoiceGroupView( + 'Group 3', + array(4 => new ChoiceView($this->obj5, '4', 'E')) + ), ) ), $view); } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 6cde8305ca272..014f9462e43a5 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -395,7 +395,7 @@ public function testCreateViewLabelAttrAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $labelAttr) { + ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr, $labelAttr) { return $labelAttr((object) array('property' => 'labelAttr')); })); From 3db5644cb4587d5304b877bdbc47beaa714dfdbd Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Thu, 27 Aug 2015 11:10:08 +0200 Subject: [PATCH 131/133] Revert "Handle conflict in DefaultChoiceListFactory" This reverts commit 2807562296ef5fcff65e7ea11a38c7f807f9b6f4, reversing changes made to 99f5757585dd77a6e4e07f0ad1e86f28c20f0dad. --- .../ChoiceList/Factory/DefaultChoiceListFactory.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index e20b4cd7d472f..acfa2d560644a 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -70,12 +70,10 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, $adaptedList = $list->getAdaptedList(); - $remainingViews = $adaptedList->getRemainingViews(); - $preferredViews = $adaptedList->getPreferredViews(); - array_walk_recursive($remainingViews, $mapToNonLegacyChoiceView); - array_walk_recursive($preferredViews, $mapToNonLegacyChoiceView); - - return new ChoiceListView($remainingViews, $preferredViews); + return new ChoiceListView( + array_map($mapToNonLegacyChoiceView, $adaptedList->getRemainingViews()), + array_map($mapToNonLegacyChoiceView, $adaptedList->getPreferredViews()) + ); } $preferredViews = array(); From b556a3c3d6ce7b6a6442dc0678c104f7f0dfdb8d Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Tue, 1 Sep 2015 18:14:29 +0200 Subject: [PATCH 132/133] rebase --- .gitignore | 2 ++ .../FrameworkExtensionTest.php | 14 ++++++++ .../Tests/ClassMapGeneratorTest.php | 6 ++++ src/Symfony/Component/Form/AbstractType.php | 26 ++++++++++++++ ...NumberToLocalizedStringTransformerTest.php | 5 +++ .../Form/Tests/Fixtures/FBooType.php~HEAD | 18 ++++++++++ .../Form/Tests/Fixtures/FBooType.php~rebasing | 18 ++++++++++ .../Tests/Dumper/XliffFileDumperTest.php | 35 +++++++++++++++++++ 8 files changed, 124 insertions(+) create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing diff --git a/.gitignore b/.gitignore index 0f504231b6e95..9301a95d6e2d4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ composer.phar package.tar /packages.json /.phpunit + +src/Symfony/Component/Security/Acl/Exception/Exception.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 1f2f80d41bf1b..24fe785df1168 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -498,6 +498,20 @@ public function testSerializerServiceIsNotRegisteredWhenDisabled() $this->assertFalse($container->hasDefinition('serializer')); } + public function testSerializerServiceIsRegisteredWhenEnabled() + { + $container = $this->createContainerFromFile('serializer_enabled'); + + $this->assertTrue($container->hasDefinition('serializer')); + } + + public function testSerializerServiceIsNotRegisteredWhenDisabled() + { + $container = $this->createContainerFromFile('serializer_disabled'); + + $this->assertFalse($container->hasDefinition('serializer')); + } + protected function createContainer(array $data = array()) { return new ContainerBuilder(new ParameterBag(array_merge(array( diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index db8b29dbeb3ab..d03ec17e130c8 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -118,6 +118,12 @@ public function getTestCreateMapTests() )); } + if (PHP_VERSION_ID >= 50500) { + $data[] = array(__DIR__.'/Fixtures/php5.5', array( + 'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php', + )); + } + return $data; } diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component/Form/AbstractType.php index 709efa34f5661..267e4f7d89aa2 100644 --- a/src/Symfony/Component/Form/AbstractType.php +++ b/src/Symfony/Component/Form/AbstractType.php @@ -73,6 +73,32 @@ public function getBlockPrefix() return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn); } + /** + * {@inheritdoc} + */ + public function getName() + { + // As of Symfony 2.8, the name defaults to the fully-qualified class name + return get_class($this); + } + + /** + * Returns the prefix of the template block name for this type. + * + * The block prefixes default to the underscored short class name with + * the "Type" suffix removed (e.g. "UserProfileType" => "user_profile"). + * + * @return string The prefix of the template block name + */ + public function getBlockPrefix() + { + $fqcn = get_class($this); + $name = $this->getName(); + + // For BC: Use the name as block prefix if one is set + return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn); + } + /** * {@inheritdoc} */ 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 8f23af510ad91..6d6ddcde20876 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -92,6 +92,11 @@ public function testTransformWithScale() public function transformWithRoundingProvider() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + return array( // towards positive infinity (1.6 -> 2, -1.6 -> -1) array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_CEILING), diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD new file mode 100644 index 0000000000000..fd9ca41dfbc85 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class FBooType extends AbstractType +{ +} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing new file mode 100644 index 0000000000000..fd9ca41dfbc85 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; + +class FBooType extends AbstractType +{ +} diff --git a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php index d2cbf4668dee4..00b7e80b4b760 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php @@ -86,4 +86,39 @@ public function testDumpWithTargetAttributesMetadata() unlink($this->tempDir.'/messages.en_US.xlf'); } + + public function testTargetAttributesMetadataIsSetInFile() + { + $catalogue = new MessageCatalogue('en_US'); + $catalogue->add(array( + 'foo' => 'bar', + )); + $catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation'))); + + $tempDir = sys_get_temp_dir(); + $dumper = new XliffFileDumper(); + $dumper->dump($catalogue, array('path' => $tempDir, 'default_locale' => 'fr_FR')); + + $content = << + + + + + foo + bar + + + + + +EOT; + + $this->assertEquals( + $content, + file_get_contents($tempDir.'/messages.en_US.xlf') + ); + + unlink($tempDir.'/messages.en_US.xlf'); + } } From b65653418e2857bd63594ecf9bf46458ddc0b852 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Tue, 1 Sep 2015 18:20:38 +0200 Subject: [PATCH 133/133] Revert "rebase" This reverts commit b556a3c3d6ce7b6a6442dc0678c104f7f0dfdb8d. --- .gitignore | 2 -- .../FrameworkExtensionTest.php | 14 -------- .../Tests/ClassMapGeneratorTest.php | 6 ---- src/Symfony/Component/Form/AbstractType.php | 26 -------------- ...NumberToLocalizedStringTransformerTest.php | 5 --- .../Form/Tests/Fixtures/FBooType.php~HEAD | 18 ---------- .../Form/Tests/Fixtures/FBooType.php~rebasing | 18 ---------- .../Tests/Dumper/XliffFileDumperTest.php | 35 ------------------- 8 files changed, 124 deletions(-) delete mode 100644 src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD delete mode 100644 src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing diff --git a/.gitignore b/.gitignore index 9301a95d6e2d4..0f504231b6e95 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,3 @@ composer.phar package.tar /packages.json /.phpunit - -src/Symfony/Component/Security/Acl/Exception/Exception.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 24fe785df1168..1f2f80d41bf1b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -498,20 +498,6 @@ public function testSerializerServiceIsNotRegisteredWhenDisabled() $this->assertFalse($container->hasDefinition('serializer')); } - public function testSerializerServiceIsRegisteredWhenEnabled() - { - $container = $this->createContainerFromFile('serializer_enabled'); - - $this->assertTrue($container->hasDefinition('serializer')); - } - - public function testSerializerServiceIsNotRegisteredWhenDisabled() - { - $container = $this->createContainerFromFile('serializer_disabled'); - - $this->assertFalse($container->hasDefinition('serializer')); - } - protected function createContainer(array $data = array()) { return new ContainerBuilder(new ParameterBag(array_merge(array( diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index d03ec17e130c8..db8b29dbeb3ab 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -118,12 +118,6 @@ public function getTestCreateMapTests() )); } - if (PHP_VERSION_ID >= 50500) { - $data[] = array(__DIR__.'/Fixtures/php5.5', array( - 'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php', - )); - } - return $data; } diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component/Form/AbstractType.php index 267e4f7d89aa2..709efa34f5661 100644 --- a/src/Symfony/Component/Form/AbstractType.php +++ b/src/Symfony/Component/Form/AbstractType.php @@ -73,32 +73,6 @@ public function getBlockPrefix() return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn); } - /** - * {@inheritdoc} - */ - public function getName() - { - // As of Symfony 2.8, the name defaults to the fully-qualified class name - return get_class($this); - } - - /** - * Returns the prefix of the template block name for this type. - * - * The block prefixes default to the underscored short class name with - * the "Type" suffix removed (e.g. "UserProfileType" => "user_profile"). - * - * @return string The prefix of the template block name - */ - public function getBlockPrefix() - { - $fqcn = get_class($this); - $name = $this->getName(); - - // For BC: Use the name as block prefix if one is set - return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn); - } - /** * {@inheritdoc} */ 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 6d6ddcde20876..8f23af510ad91 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -92,11 +92,6 @@ public function testTransformWithScale() public function transformWithRoundingProvider() { - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - return array( // towards positive infinity (1.6 -> 2, -1.6 -> -1) array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_CEILING), diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD deleted file mode 100644 index fd9ca41dfbc85..0000000000000 --- a/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~HEAD +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractType; - -class FBooType extends AbstractType -{ -} diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing b/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing deleted file mode 100644 index fd9ca41dfbc85..0000000000000 --- a/src/Symfony/Component/Form/Tests/Fixtures/FBooType.php~rebasing +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractType; - -class FBooType extends AbstractType -{ -} diff --git a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php index 00b7e80b4b760..d2cbf4668dee4 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php @@ -86,39 +86,4 @@ public function testDumpWithTargetAttributesMetadata() unlink($this->tempDir.'/messages.en_US.xlf'); } - - public function testTargetAttributesMetadataIsSetInFile() - { - $catalogue = new MessageCatalogue('en_US'); - $catalogue->add(array( - 'foo' => 'bar', - )); - $catalogue->setMetadata('foo', array('target-attributes' => array('state' => 'needs-translation'))); - - $tempDir = sys_get_temp_dir(); - $dumper = new XliffFileDumper(); - $dumper->dump($catalogue, array('path' => $tempDir, 'default_locale' => 'fr_FR')); - - $content = << - - - - - foo - bar - - - - - -EOT; - - $this->assertEquals( - $content, - file_get_contents($tempDir.'/messages.en_US.xlf') - ); - - unlink($tempDir.'/messages.en_US.xlf'); - } }