diff --git a/composer.json b/composer.json index 74cff7ff4a4e38edea6ebc3408c0e38376cf2d1d..dfdad5d4cafdbe71b5cd685b3515ba33cfb2a5ce 100644 --- a/composer.json +++ b/composer.json @@ -6,16 +6,16 @@ "require": { "php": ">=5.4.2", "sdboyer/gliph": "0.1.*", - "symfony/class-loader": "2.4.*", - "symfony/css-selector": "2.4.*", - "symfony/dependency-injection": "2.4.*", - "symfony/event-dispatcher": "2.4.*", - "symfony/http-foundation": "2.4.*", - "symfony/http-kernel": "2.4.*", - "symfony/routing": "2.4.*", + "symfony/class-loader": "2.5.*", + "symfony/css-selector": "2.5.*", + "symfony/dependency-injection": "2.5.*", + "symfony/event-dispatcher": "2.5.*", + "symfony/http-foundation": "2.5.*", + "symfony/http-kernel": "2.5.*", + "symfony/routing": "2.5.*", "symfony/serializer": "2.5.*", - "symfony/validator": "2.4.*", - "symfony/yaml": "dev-master#e49a47d60348665261f6e279ba383241deb73cab", + "symfony/validator": "2.5.*", + "symfony/yaml": "2.5.*", "twig/twig": "1.15.*", "doctrine/common": "dev-master#a45d110f71c323e29f41eb0696fa230e3fa1b1b5", "doctrine/annotations": "1.2.*", diff --git a/composer.lock b/composer.lock index a40cb4920733f13a17bdf58da5bb6bfc65116288..a14fe822abd43162947acc65e62b0a1aa83457c2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9b3b0c6ca08a325572fdeb2865e85c0a", + "hash": "5dca82e6d2f23a408795c33590f41c8d", "packages": [ { "name": "doctrine/annotations", @@ -1574,17 +1574,17 @@ }, { "name": "symfony/class-loader", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader.git", - "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c" + "reference": "432561f655123b003b32f370ca812fed9a9340c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/6a2ebedbc780130f07b3a15363743d08eb46820c", - "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/432561f655123b003b32f370ca812fed9a9340c6", + "reference": "432561f655123b003b32f370ca812fed9a9340c6", "shasum": "" }, "require": { @@ -1596,7 +1596,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1609,32 +1609,32 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony ClassLoader Component", "homepage": "http://symfony.com", - "time": "2013-11-26 16:40:27" + "time": "2014-09-22 09:14:18" }, { "name": "symfony/css-selector", - "version": "v2.4.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "479a5b409723f596ffc3b5178034e4d76ce615b3" + "reference": "caf5ecc3face1f22884fb74b8edab65ac5ba9976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/479a5b409723f596ffc3b5178034e4d76ce615b3", - "reference": "479a5b409723f596ffc3b5178034e4d76ce615b3", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/caf5ecc3face1f22884fb74b8edab65ac5ba9976", + "reference": "caf5ecc3face1f22884fb74b8edab65ac5ba9976", "shasum": "" }, "require": { @@ -1643,7 +1643,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1656,12 +1656,6 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" @@ -1669,25 +1663,29 @@ { "name": "Jean-François Simon", "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony CssSelector Component", "homepage": "http://symfony.com", - "time": "2014-04-18 20:37:09" + "time": "2014-09-22 09:14:18" }, { "name": "symfony/debug", - "version": "v2.3.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Debug", "source": { "type": "git", "url": "https://github.com/symfony/Debug.git", - "reference": "729f6d19cfc401c4942e43fcc1059103bd6df130" + "reference": "4a3dd4ef3fc0cee2fd9faaae12bd7af43afcf648" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Debug/zipball/729f6d19cfc401c4942e43fcc1059103bd6df130", - "reference": "729f6d19cfc401c4942e43fcc1059103bd6df130", + "url": "https://api.github.com/repos/symfony/Debug/zipball/4a3dd4ef3fc0cee2fd9faaae12bd7af43afcf648", + "reference": "4a3dd4ef3fc0cee2fd9faaae12bd7af43afcf648", "shasum": "" }, "require": { @@ -1698,14 +1696,13 @@ "symfony/http-kernel": "~2.1" }, "suggest": { - "symfony/class-loader": "", "symfony/http-foundation": "", "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1718,32 +1715,32 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Debug Component", "homepage": "http://symfony.com", - "time": "2013-08-08 14:16:10" + "time": "2014-09-28 15:22:14" }, { "name": "symfony/dependency-injection", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c" + "reference": "1f01a64c9047909e40700a14ee34e8c446300618" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/7e5bde3a607dde1f8ddef5180759068ad53d259c", - "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/1f01a64c9047909e40700a14ee34e8c446300618", + "reference": "1f01a64c9047909e40700a14ee34e8c446300618", "shasum": "" }, "require": { @@ -1762,7 +1759,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1775,39 +1772,42 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2014-01-01 09:02:49" + "time": "2014-09-27 08:35:39" }, { "name": "symfony/event-dispatcher", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46", + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "~2.0" + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.0,<2.6.0", + "symfony/stopwatch": "~2.2" }, "suggest": { "symfony/dependency-injection": "", @@ -1816,7 +1816,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1829,41 +1829,44 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-12-28 08:12:03" + "time": "2014-09-28 15:56:11" }, { "name": "symfony/http-foundation", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" + "reference": "650e115af152d7a5e857d01c2cdb9a22809de9b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/650e115af152d7a5e857d01c2cdb9a22809de9b4", + "reference": "650e115af152d7a5e857d01c2cdb9a22809de9b4", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/expression-language": "~2.4" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1879,40 +1882,40 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:10:50" + "time": "2014-09-25 09:52:29" }, { "name": "symfony/http-kernel", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4" + "reference": "6a3595611229def14d5e644f060cf372235532ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4", - "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/6a3595611229def14d5e644f060cf372235532ec", + "reference": "6a3595611229def14d5e644f060cf372235532ec", "shasum": "" }, "require": { "php": ">=5.3.3", "psr/log": "~1.0", - "symfony/debug": "~2.3", - "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": "~2.4" + "symfony/debug": "~2.5", + "symfony/event-dispatcher": "~2.5", + "symfony/http-foundation": "~2.5" }, "require-dev": { "symfony/browser-kit": "~2.2", @@ -1920,6 +1923,7 @@ "symfony/config": "~2.0", "symfony/console": "~2.2", "symfony/dependency-injection": "~2.0", + "symfony/expression-language": "~2.4", "symfony/finder": "~2.0", "symfony/process": "~2.0", "symfony/routing": "~2.2", @@ -1937,7 +1941,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1950,32 +1954,32 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:12:11" + "time": "2014-09-28 17:33:53" }, { "name": "symfony/process", - "version": "v2.3.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b" + "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", - "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", + "url": "https://api.github.com/repos/symfony/Process/zipball/8a1ec96c4e519cee0fb971ea48a1eb7369dda54b", + "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b", "shasum": "" }, "require": { @@ -1984,7 +1988,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -1997,90 +2001,32 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "http://symfony.com", - "time": "2013-08-22 06:42:25" - }, - { - "name": "symfony/property-access", - "version": "v2.4.1", - "target-dir": "Symfony/Component/PropertyAccess", - "source": { - "type": "git", - "url": "https://github.com/symfony/PropertyAccess.git", - "reference": "274951234150e303c83099a2429be6be35629fe9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/274951234150e303c83099a2429be6be35629fe9", - "reference": "274951234150e303c83099a2429be6be35629fe9", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\PropertyAccess\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ + }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" } ], - "description": "Symfony PropertyAccess Component", + "description": "Symfony Process Component", "homepage": "http://symfony.com", - "keywords": [ - "access", - "array", - "extraction", - "index", - "injection", - "object", - "property", - "property path", - "reflection" - ], - "time": "2013-11-13 21:30:16" + "time": "2014-09-23 05:25:11" }, { "name": "symfony/routing", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" + "reference": "9bc38fe72e0eff61611e7cd4df3accbce20b1d36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", + "url": "https://api.github.com/repos/symfony/Routing/zipball/9bc38fe72e0eff61611e7cd4df3accbce20b1d36", + "reference": "9bc38fe72e0eff61611e7cd4df3accbce20b1d36", "shasum": "" }, "require": { @@ -2091,6 +2037,7 @@ "psr/log": "~1.0", "symfony/config": "~2.2", "symfony/expression-language": "~2.4", + "symfony/http-foundation": "~2.3", "symfony/yaml": "~2.0" }, "suggest": { @@ -2102,7 +2049,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2115,13 +2062,13 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Routing Component", @@ -2132,21 +2079,21 @@ "uri", "url" ], - "time": "2014-01-05 02:10:50" + "time": "2014-09-22 15:28:36" }, { "name": "symfony/serializer", - "version": "v2.5.2", + "version": "v2.5.5", "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", "url": "https://github.com/symfony/Serializer.git", - "reference": "33185b290310ab1fd8283fb8ed2a434cdb88b9b9" + "reference": "a95c0471682778da2e02169fb2644d3b08d4470f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Serializer/zipball/33185b290310ab1fd8283fb8ed2a434cdb88b9b9", - "reference": "33185b290310ab1fd8283fb8ed2a434cdb88b9b9", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/a95c0471682778da2e02169fb2644d3b08d4470f", + "reference": "a95c0471682778da2e02169fb2644d3b08d4470f", "shasum": "" }, "require": { @@ -2168,34 +2115,32 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Serializer Component", "homepage": "http://symfony.com", - "time": "2014-07-09 09:05:48" + "time": "2014-09-22 09:14:18" }, { "name": "symfony/translation", - "version": "v2.3.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "65f888291f0896ad492f9abc6dc05c998373aded" + "reference": "170c0d895616e1a6a35681ffb0b9e339f58ab928" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/65f888291f0896ad492f9abc6dc05c998373aded", - "reference": "65f888291f0896ad492f9abc6dc05c998373aded", + "url": "https://api.github.com/repos/symfony/Translation/zipball/170c0d895616e1a6a35681ffb0b9e339f58ab928", + "reference": "170c0d895616e1a6a35681ffb0b9e339f58ab928", "shasum": "" }, "require": { @@ -2203,6 +2148,7 @@ }, "require-dev": { "symfony/config": "~2.0", + "symfony/intl": "~2.3", "symfony/yaml": "~2.2" }, "suggest": { @@ -2212,7 +2158,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2225,59 +2171,64 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2013-08-26 05:49:51" + "time": "2014-09-23 05:25:11" }, { "name": "symfony/validator", - "version": "v2.4.1", + "version": "v2.5.5", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730" + "reference": "64f61505843ca5e6c647244f5a4b6812c1279427" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/7ea4e53f8d68bf3ae9cca28765d49d7930618730", - "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730", + "url": "https://api.github.com/repos/symfony/Validator/zipball/64f61505843ca5e6c647244f5a4b6812c1279427", + "reference": "64f61505843ca5e6c647244f5a4b6812c1279427", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/property-access": "~2.2", "symfony/translation": "~2.0" }, "require-dev": { "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0", + "egulias/email-validator": "~1.0", "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", "symfony/http-foundation": "~2.1", "symfony/intl": "~2.3", + "symfony/property-access": "~2.2", "symfony/yaml": "~2.0" }, "suggest": { "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader", + "doctrine/cache": "For using the default cached annotation reader and metadata cache.", + "egulias/email-validator": "Strict (RFC compliant) email validation", "symfony/config": "", + "symfony/expression-language": "For using the 2.4 Expression validator", "symfony/http-foundation": "", "symfony/intl": "", + "symfony/property-access": "For using the 2.4 Validator API", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2290,32 +2241,32 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-09-28 15:22:14" }, { "name": "symfony/yaml", - "version": "dev-master", + "version": "v2.5.5", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "e49a47d60348665261f6e279ba383241deb73cab" + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/e49a47d60348665261f6e279ba383241deb73cab", - "reference": "e49a47d60348665261f6e279ba383241deb73cab", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", "shasum": "" }, "require": { @@ -2337,20 +2288,18 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-02-24 16:21:51" + "time": "2014-09-22 09:14:18" }, { "name": "twig/twig", @@ -2534,15 +2483,10 @@ "time": "2013-06-12 19:46:58" } ], - "packages-dev": [ - - ], - "aliases": [ - - ], + "packages-dev": [], + "aliases": [], "minimum-stability": "stable", "stability-flags": { - "symfony/yaml": 20, "doctrine/common": 20, "kriswallsmith/assetic": 15, "phpunit/phpunit-mock-objects": 20 @@ -2551,7 +2495,5 @@ "platform": { "php": ">=5.4.2" }, - "platform-dev": [ - - ] + "platform-dev": [] } diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 99cc3067b4ef0fe2f4c575e5951e2752b6d756c1..9206d237d3da48d9350b11bfa75aea716f08227d 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -15,8 +15,8 @@ use Drupal\Core\TypedData\Validation\MetadataFactory; use Drupal\Core\Validation\ConstraintManager; use Drupal\Core\Validation\DrupalTranslator; -use Symfony\Component\Validator\ValidatorInterface; use Symfony\Component\Validator\Validation; +use Symfony\Component\Validator\Validator\ValidatorInterface; /** * Manages data type plugins. @@ -298,7 +298,7 @@ public function getPropertyInstance(TypedDataInterface $object, $property_name, /** * Sets the validator for validating typed data. * - * @param \Symfony\Component\Validator\ValidatorInterface $validator + * @param \Symfony\Component\Validator\Validator\ValidatorInterface $validator * The validator object to set. */ public function setValidator(ValidatorInterface $validator) { @@ -308,7 +308,7 @@ public function setValidator(ValidatorInterface $validator) { /** * Gets the validator for validating typed data. * - * @return \Symfony\Component\Validator\ValidatorInterface + * @return \Symfony\Component\Validator\Validator\ValidatorInterface * The validator object. */ public function getValidator() { @@ -316,6 +316,7 @@ public function getValidator() { $this->validator = Validation::createValidatorBuilder() ->setMetadataFactory(new MetadataFactory()) ->setTranslator(new DrupalTranslator()) + ->setApiVersion(Validation::API_VERSION_2_4) ->getValidator(); } return $this->validator; diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index a2b46d307287fa16bc6881f67ccaa8aef4c58870..458c0bc8ceb2d2e679e8f6df9bd6d1cfa09a67a4 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -101,7 +101,7 @@ public function registerDefinitions() { )); $this->discovery->setDefinition('Email', array( 'label' => new TranslationWrapper('Email'), - 'class' => '\Symfony\Component\Validator\Constraints\Email', + 'class' => '\Drupal\Core\Validation\Plugin\Validation\Constraint\EmailConstraint', 'type' => array('string'), )); } diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php new file mode 100644 index 0000000000000000000000000000000000000000..905d1b63847cf912703d655b533fa1ec284e11ab --- /dev/null +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php @@ -0,0 +1,32 @@ +<?php + +/** + * @file + * Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\EmailConstraint. + */ + +namespace Drupal\Core\Validation\Plugin\Validation\Constraint; + +use Symfony\Component\Validator\Constraints\Email; + +/** + * Count constraint. + * + * Overrides the symfony constraint to use the strict setting. + * + * @Plugin( + * id = "Email", + * label = @Translation("Email", context = "Validation") + * ) + */ +class EmailConstraint extends Email { + + public $strict = TRUE; + + /** + * {@inheritdoc} + */ + public function validatedBy() { + return '\Symfony\Component\Validator\Constraints\EmailValidator'; + } +} diff --git a/core/vendor/composer/autoload_namespaces.php b/core/vendor/composer/autoload_namespaces.php index e506f986e14b000d7219111672915a761cafafac..50cec5732beb7d3c06044ebc851e7c4de2a01eb1 100644 --- a/core/vendor/composer/autoload_namespaces.php +++ b/core/vendor/composer/autoload_namespaces.php @@ -16,7 +16,6 @@ 'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'), 'Symfony\\Component\\Serializer\\' => array($vendorDir . '/symfony/serializer'), 'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'), - 'Symfony\\Component\\PropertyAccess\\' => array($vendorDir . '/symfony/property-access'), 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), 'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'), 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 168a4ae4e7ec838f1a07f24d7d4d789319a58b63..63b28ad31f9df88675024167b76a90658c549bd5 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -501,170 +501,6 @@ "string" ] }, - { - "name": "symfony/debug", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Debug", - "source": { - "type": "git", - "url": "https://github.com/symfony/Debug.git", - "reference": "729f6d19cfc401c4942e43fcc1059103bd6df130" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Debug/zipball/729f6d19cfc401c4942e43fcc1059103bd6df130", - "reference": "729f6d19cfc401c4942e43fcc1059103bd6df130", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/http-foundation": "~2.1", - "symfony/http-kernel": "~2.1" - }, - "suggest": { - "symfony/class-loader": "", - "symfony/http-foundation": "", - "symfony/http-kernel": "" - }, - "time": "2013-08-08 14:16:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Debug\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/translation", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Translation", - "source": { - "type": "git", - "url": "https://github.com/symfony/Translation.git", - "reference": "65f888291f0896ad492f9abc6dc05c998373aded" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/65f888291f0896ad492f9abc6dc05c998373aded", - "reference": "65f888291f0896ad492f9abc6dc05c998373aded", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/config": "~2.0", - "symfony/yaml": "~2.2" - }, - "suggest": { - "symfony/config": "", - "symfony/yaml": "" - }, - "time": "2013-08-26 05:49:51", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Translation\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Translation Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/process", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Process", - "source": { - "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", - "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "time": "2013-08-22 06:42:25", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Process\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "http://symfony.com" - }, { "name": "sdboyer/gliph", "version": "0.1.4", @@ -843,1349 +679,1443 @@ ] }, { - "name": "symfony/class-loader", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/ClassLoader", + "name": "easyrdf/easyrdf", + "version": "0.8.0", + "version_normalized": "0.8.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/ClassLoader.git", - "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c" + "url": "https://github.com/njh/easyrdf.git", + "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/6a2ebedbc780130f07b3a15363743d08eb46820c", - "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c", + "url": "https://api.github.com/repos/njh/easyrdf/zipball/3e43ab7274004e9f4192e06b9fc147781e1f85c2", + "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.2.8" + }, + "replace": { + "njh/easyrdf": "self.version" }, "require-dev": { - "symfony/finder": "~2.0" + "phpunit/phpunit": ">=3.5.15", + "sami/sami": "dev-master", + "squizlabs/php_codesniffer": ">=1.4.3" }, - "time": "2013-11-26 16:40:27", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } + "suggest": { + "ml/json-ld": "dev-master" }, + "time": "2013-12-30 22:31:37", + "type": "library", "installation-source": "dist", "autoload": { "psr-0": { - "Symfony\\Component\\ClassLoader\\": "" + "EasyRdf_": "lib/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Nicholas Humfrey", + "email": "njh@aelius.com", + "homepage": "http://www.aelius.com/njh/", + "role": "Developer" } ], - "description": "Symfony ClassLoader Component", - "homepage": "http://symfony.com" + "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", + "homepage": "http://www.easyrdf.org/", + "keywords": [ + "Linked Data", + "RDF", + "Semantic Web", + "Turtle", + "rdfa", + "sparql" + ] }, { - "name": "symfony/dependency-injection", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/DependencyInjection", + "name": "sebastian/version", + "version": "1.0.3", + "version_normalized": "1.0.3.0", "source": { "type": "git", - "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c" + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/7e5bde3a607dde1f8ddef5180759068ad53d259c", - "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", "shasum": "" }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/config": "~2.2", - "symfony/expression-language": "~2.4", - "symfony/yaml": "~2.0" - }, - "suggest": { - "symfony/config": "", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "time": "2014-01-01 09:02:49", + "time": "2014-03-07 15:35:33", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\DependencyInjection\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Symfony DependencyInjection Component", - "homepage": "http://symfony.com" + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version" }, { - "name": "symfony/http-foundation", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/HttpFoundation", + "name": "sebastian/exporter", + "version": "1.0.1", + "version_normalized": "1.0.1.0", "source": { "type": "git", - "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2014-01-05 02:10:50", - "type": "library", + "require-dev": { + "phpunit/phpunit": "4.0.*@dev" + }, + "time": "2014-02-16 08:26:31", + "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "1.0.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\HttpFoundation\\": "" - }, "classmap": [ - "Symfony/Component/HttpFoundation/Resources/stubs" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" }, { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net", + "role": "Lead" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" } ], - "description": "Symfony HttpFoundation Component", - "homepage": "http://symfony.com" + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ] }, { - "name": "symfony/event-dispatcher", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/EventDispatcher", + "name": "sebastian/environment", + "version": "1.0.0", + "version_normalized": "1.0.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "~2.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" + "phpunit/phpunit": "4.0.*@dev" }, - "time": "2013-12-28 08:12:03", + "time": "2014-02-18 16:17:19", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "1.0.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com" + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ] }, { - "name": "symfony/http-kernel", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/HttpKernel", + "name": "sebastian/diff", + "version": "1.1.0", + "version_normalized": "1.1.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/HttpKernel.git", - "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4" + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4", - "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", "shasum": "" }, "require": { - "php": ">=5.3.3", - "psr/log": "~1.0", - "symfony/debug": "~2.3", - "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": "~2.4" - }, - "require-dev": { - "symfony/browser-kit": "~2.2", - "symfony/class-loader": "~2.1", - "symfony/config": "~2.0", - "symfony/console": "~2.2", - "symfony/dependency-injection": "~2.0", - "symfony/finder": "~2.0", - "symfony/process": "~2.0", - "symfony/routing": "~2.2", - "symfony/stopwatch": "~2.2", - "symfony/templating": "~2.2" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/class-loader": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "" + "php": ">=5.3.3" }, - "time": "2014-01-05 02:12:11", + "time": "2013-08-03 16:46:33", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "1.1-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\HttpKernel\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" }, { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" } ], - "description": "Symfony HttpKernel Component", - "homepage": "http://symfony.com" + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ] }, { - "name": "symfony/routing", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/Routing", + "name": "sebastian/comparator", + "version": "1.0.0", + "version_normalized": "1.0.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/Routing.git", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "sebastian/diff": "~1.1", + "sebastian/exporter": "~1.0" }, "require-dev": { - "doctrine/annotations": "~1.0", - "psr/log": "~1.0", - "symfony/config": "~2.2", - "symfony/expression-language": "~2.4", - "symfony/yaml": "~2.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/expression-language": "For using expression matching", - "symfony/yaml": "For using the YAML loader" + "phpunit/phpunit": "~4.1" }, - "time": "2014-01-05 02:10:50", + "time": "2014-05-02 07:05:58", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "1.0.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\Routing\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" }, { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" } ], - "description": "Symfony Routing Component", - "homepage": "http://symfony.com", + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", "keywords": [ - "router", - "routing", - "uri", - "url" + "comparator", + "compare", + "equality" ] }, { - "name": "symfony/property-access", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/PropertyAccess", + "name": "phpunit/php-text-template", + "version": "1.2.0", + "version_normalized": "1.2.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/PropertyAccess.git", - "reference": "274951234150e303c83099a2429be6be35629fe9" + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/274951234150e303c83099a2429be6be35629fe9", - "reference": "274951234150e303c83099a2429be6be35629fe9", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-11-13 21:30:16", + "time": "2014-01-30 17:20:04", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\PropertyAccess\\": "" - } + "classmap": [ + "Text/" + ] }, "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" } ], - "description": "Symfony PropertyAccess Component", - "homepage": "http://symfony.com", + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", "keywords": [ - "access", - "array", - "extraction", - "index", - "injection", - "object", - "property", - "property path", - "reflection" + "template" ] }, { - "name": "symfony/validator", - "version": "v2.4.1", - "version_normalized": "2.4.1.0", - "target-dir": "Symfony/Component/Validator", + "name": "phpunit/php-timer", + "version": "1.0.5", + "version_normalized": "1.0.5.0", "source": { "type": "git", - "url": "https://github.com/symfony/Validator.git", - "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730" + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/7ea4e53f8d68bf3ae9cca28765d49d7930618730", - "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/property-access": "~2.2", - "symfony/translation": "~2.0" + "php": ">=5.3.3" }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/cache": "~1.0", - "symfony/config": "~2.2", - "symfony/http-foundation": "~2.1", - "symfony/intl": "~2.3", - "symfony/yaml": "~2.0" + "time": "2013-08-02 07:42:54", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "PHP/" + ] }, - "suggest": { - "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader", - "symfony/config": "", - "symfony/http-foundation": "", - "symfony/intl": "", - "symfony/yaml": "" + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ] + }, + { + "name": "phpunit/php-token-stream", + "version": "1.2.2", + "version_normalized": "1.2.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" }, - "time": "2014-01-01 08:14:50", + "time": "2014-03-03 05:10:30", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "1.2-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\Validator\\": "" - } + "classmap": [ + "PHP/" + ] }, "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" } ], - "description": "Symfony Validator Component", - "homepage": "http://symfony.com" + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ] }, { - "name": "easyrdf/easyrdf", - "version": "0.8.0", - "version_normalized": "0.8.0.0", + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "version_normalized": "1.3.4.0", "source": { "type": "git", - "url": "https://github.com/njh/easyrdf.git", - "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/njh/easyrdf/zipball/3e43ab7274004e9f4192e06b9fc147781e1f85c2", - "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", "shasum": "" }, "require": { - "php": ">=5.2.8" + "php": ">=5.3.3" }, - "replace": { - "njh/easyrdf": "self.version" + "time": "2013-10-10 15:34:57", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ] + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.8", + "version_normalized": "2.0.8.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "58401826c8cfc8fd689b60026e91c337df374bca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/58401826c8cfc8fd689b60026e91c337df374bca", + "reference": "58401826c8cfc8fd689b60026e91c337df374bca", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-text-template": "~1.2.0", + "phpunit/php-token-stream": "~1.2.2", + "sebastian/environment": "~1.0.0", + "sebastian/version": "~1.0.3" }, "require-dev": { - "phpunit/phpunit": ">=3.5.15", - "sami/sami": "dev-master", - "squizlabs/php_codesniffer": ">=1.4.3" + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4.0.14" }, "suggest": { - "ml/json-ld": "dev-master" + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" }, - "time": "2013-12-30 22:31:37", + "time": "2014-05-26 14:55:24", "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "installation-source": "dist", "autoload": { - "psr-0": { - "EasyRdf_": "lib/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], "license": [ "BSD-3-Clause" ], "authors": [ { - "name": "Nicholas Humfrey", - "email": "njh@aelius.com", - "homepage": "http://www.aelius.com/njh/", - "role": "Developer" + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" } ], - "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", - "homepage": "http://www.easyrdf.org/", + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", "keywords": [ - "Linked Data", - "RDF", - "Semantic Web", - "Turtle", - "rdfa", - "sparql" + "coverage", + "testing", + "xunit" ] }, { - "name": "symfony/yaml", - "version": "dev-master", - "version_normalized": "9999999-dev", - "target-dir": "Symfony/Component/Yaml", + "name": "phpunit/phpunit", + "version": "4.1.3", + "version_normalized": "4.1.3.0", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "e49a47d60348665261f6e279ba383241deb73cab" + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/e49a47d60348665261f6e279ba383241deb73cab", - "reference": "e49a47d60348665261f6e279ba383241deb73cab", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/939cb801b3b2aa253aedd0b279f40bb8f35cec91", + "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91", "shasum": "" }, "require": { - "php": ">=5.3.3" + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.1", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.0", + "sebastian/exporter": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" }, - "time": "2014-02-24 16:21:51", + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "time": "2014-06-11 14:15:47", + "bin": [ + "phpunit" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "4.1.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com" + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ] }, { - "name": "symfony/css-selector", - "version": "v2.4.4", - "version_normalized": "2.4.4.0", - "target-dir": "Symfony/Component/CssSelector", + "name": "phpunit/phpunit-mock-objects", + "version": "dev-master", + "version_normalized": "9999999-dev", "source": { "type": "git", - "url": "https://github.com/symfony/CssSelector.git", - "reference": "479a5b409723f596ffc3b5178034e4d76ce615b3" + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/479a5b409723f596ffc3b5178034e4d76ce615b3", - "reference": "479a5b409723f596ffc3b5178034e4d76ce615b3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/32f97c9198be565b6051983c70dc8d8e758725f4", + "reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" }, - "time": "2014-04-18 20:37:09", + "require-dev": { + "phpunit/phpunit": "4.3.*@dev" + }, + "suggest": { + "ext-soap": "*" + }, + "time": "2014-06-12 07:22:27", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.3.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "Symfony\\Component\\CssSelector\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Jean-François Simon", - "email": "jeanfrancois.simon@sensiolabs.com" + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" } ], - "description": "Symfony CssSelector Component", - "homepage": "http://symfony.com" + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ] }, { - "name": "sebastian/version", - "version": "1.0.3", - "version_normalized": "1.0.3.0", + "name": "mikey179/vfsStream", + "version": "v1.3.0", + "version_normalized": "1.3.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + "url": "https://github.com/mikey179/vfsStream.git", + "reference": "8571f349567e02af1b7efc0fc4e3a4a1c98e664e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", - "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/8571f349567e02af1b7efc0fc4e3a4a1c98e664e", + "reference": "8571f349567e02af1b7efc0fc4e3a4a1c98e664e", "shasum": "" }, - "time": "2014-03-07 15:35:33", + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" + }, + "time": "2014-07-21 20:15:54", "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" - ] + "psr-0": { + "org\\bovigo\\vfs\\": "src/main/php" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } + "BSD" ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version" + "homepage": "http://vfs.bovigo.org/" }, { - "name": "sebastian/exporter", - "version": "1.0.1", - "version_normalized": "1.0.1.0", + "name": "guzzlehttp/streams", + "version": "1.5.1", + "version_normalized": "1.5.1.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" + "url": "https://github.com/guzzle/streams.git", + "reference": "fb0d1ee29987c2bdc59867bffaade6fc88c2675f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "url": "https://api.github.com/repos/guzzle/streams/zipball/fb0d1ee29987c2bdc59867bffaade6fc88c2675f", + "reference": "fb0d1ee29987c2bdc59867bffaade6fc88c2675f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "4.0.*@dev" + "phpunit/phpunit": "~4.0" }, - "time": "2014-02-16 08:26:31", + "time": "2014-08-10 23:57:01", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.5-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" + "psr-4": { + "GuzzleHttp\\Stream\\": "src/" + }, + "files": [ + "src/functions.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net", - "role": "Lead" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" } ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", + "description": "Provides a simple abstraction over streams of data (Guzzle 4+)", + "homepage": "http://guzzlephp.org/", "keywords": [ - "export", - "exporter" + "Guzzle", + "stream" ] }, { - "name": "sebastian/environment", - "version": "1.0.0", - "version_normalized": "1.0.0.0", + "name": "guzzlehttp/guzzle", + "version": "4.1.7", + "version_normalized": "4.1.7.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" + "url": "https://github.com/guzzle/guzzle.git", + "reference": "448f2c2076cf0fb756230611491c4f7ecb735a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/448f2c2076cf0fb756230611491c4f7ecb735a29", + "reference": "448f2c2076cf0fb756230611491c4f7ecb735a29", "shasum": "" }, "require": { - "php": ">=5.3.3" + "ext-json": "*", + "guzzlehttp/streams": "~1.4", + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "4.0.*@dev" + "ext-curl": "*", + "phpunit/phpunit": "~4.0", + "psr/log": "~1.0" }, - "time": "2014-02-18 16:17:19", + "suggest": { + "ext-curl": "Guzzle will use specific adapters if cURL is present" + }, + "time": "2014-08-08 01:30:43", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "4.1-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" } ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "homepage": "http://guzzlephp.org/", "keywords": [ - "Xdebug", - "environment", - "hhvm" + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" ] }, { - "name": "sebastian/diff", - "version": "1.1.0", - "version_normalized": "1.1.0.0", + "name": "symfony-cmf/routing", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "target-dir": "Symfony/Cmf/Component/Routing", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" + "url": "https://github.com/symfony-cmf/Routing.git", + "reference": "c67258b875eef3cb08009bf1428499d0f01ce5e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/c67258b875eef3cb08009bf1428499d0f01ce5e7", + "reference": "c67258b875eef3cb08009bf1428499d0f01ce5e7", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "psr/log": "~1.0", + "symfony/http-kernel": "~2.2", + "symfony/routing": "~2.2" }, - "time": "2013-08-03 16:46:33", + "require-dev": { + "symfony/config": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1" + }, + "time": "2014-05-08 19:37:14", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.2-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" - ] + "psr-0": { + "Symfony\\Cmf\\Component\\Routing": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" + "name": "Symfony CMF Community", + "homepage": "https://github.com/symfony-cmf/Routing/contributors" } ], - "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", + "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", + "homepage": "http://cmf.symfony.com", "keywords": [ - "diff" + "database", + "routing" ] }, { - "name": "sebastian/comparator", - "version": "1.0.0", - "version_normalized": "1.0.0.0", + "name": "stack/builder", + "version": "v1.0.2", + "version_normalized": "1.0.2.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" + "url": "https://github.com/stackphp/builder.git", + "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "url": "https://api.github.com/repos/stackphp/builder/zipball/b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", + "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.1", - "sebastian/exporter": "~1.0" + "php": ">=5.3.0", + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" }, "require-dev": { - "phpunit/phpunit": "~4.1" + "silex/silex": "~1.0" }, - "time": "2014-05-02 07:05:58", + "time": "2014-01-28 19:42:24", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.0-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" - ] + "psr-0": { + "Stack": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" + "name": "Igor Wiedler", + "email": "igor@wiedler.ch", + "homepage": "http://wiedler.ch/igor/" } ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "description": "Builder for stack middlewares based on HttpKernelInterface.", "keywords": [ - "comparator", - "compare", - "equality" + "stack" ] }, { - "name": "phpunit/php-text-template", - "version": "1.2.0", + "name": "doctrine/annotations", + "version": "v1.2.0", "version_normalized": "1.2.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "url": "https://github.com/doctrine/annotations.git", + "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", + "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", "shasum": "" }, "require": { - "php": ">=5.3.3" + "doctrine/lexer": "1.*", + "php": ">=5.3.2" }, - "time": "2014-01-30 17:20:04", + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" + }, + "time": "2014-07-06 15:52:21", "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, "installation-source": "dist", "autoload": { - "classmap": [ - "Text/" - ] + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" } ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", "keywords": [ - "template" + "annotations", + "docblock", + "parser" ] }, { - "name": "phpunit/php-timer", - "version": "1.0.5", - "version_normalized": "1.0.5.0", + "name": "egulias/email-validator", + "version": "1.2.2", + "version_normalized": "1.2.2.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "39b451bb2bb0655d83d82a38a0bba7189298cfc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/39b451bb2bb0655d83d82a38a0bba7189298cfc5", + "reference": "39b451bb2bb0655d83d82a38a0bba7189298cfc5", "shasum": "" }, "require": { - "php": ">=5.3.3" + "doctrine/lexer": "~1.0", + "php": ">= 5.3.3" }, - "time": "2013-08-02 07:42:54", + "require-dev": { + "satooshi/php-coveralls": "dev-master" + }, + "time": "2014-09-01 22:35:48", "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "installation-source": "dist", "autoload": { - "classmap": [ - "PHP/" - ] + "psr-0": { + "Egulias\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Eduardo Gulias Davis" } ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", + "description": "A library for validating emails", + "homepage": "https://github.com/egulias/EmailValidator", "keywords": [ - "timer" + "email", + "validation", + "validator" ] }, { - "name": "phpunit/php-token-stream", - "version": "1.2.2", - "version_normalized": "1.2.2.0", + "name": "symfony/class-loader", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + "url": "https://github.com/symfony/ClassLoader.git", + "reference": "432561f655123b003b32f370ca812fed9a9340c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", - "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/432561f655123b003b32f370ca812fed9a9340c6", + "reference": "432561f655123b003b32f370ca812fed9a9340c6", "shasum": "" }, "require": { - "ext-tokenizer": "*", "php": ">=5.3.3" }, - "time": "2014-03-03 05:10:30", + "require-dev": { + "symfony/finder": "~2.0" + }, + "time": "2014-09-22 09:14:18", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "PHP/" - ] + "psr-0": { + "Symfony\\Component\\ClassLoader\\": "" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ] + "description": "Symfony ClassLoader Component", + "homepage": "http://symfony.com" }, { - "name": "phpunit/php-file-iterator", - "version": "1.3.4", - "version_normalized": "1.3.4.0", + "name": "symfony/css-selector", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "url": "https://github.com/symfony/CssSelector.git", + "reference": "caf5ecc3face1f22884fb74b8edab65ac5ba9976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/caf5ecc3face1f22884fb74b8edab65ac5ba9976", + "reference": "caf5ecc3face1f22884fb74b8edab65ac5ba9976", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-10-10 15:34:57", + "time": "2014-09-22 09:14:18", "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, "installation-source": "dist", "autoload": { - "classmap": [ - "File/" - ] + "psr-0": { + "Symfony\\Component\\CssSelector\\": "" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ] + "description": "Symfony CssSelector Component", + "homepage": "http://symfony.com" }, { - "name": "phpunit/php-code-coverage", - "version": "2.0.8", - "version_normalized": "2.0.8.0", + "name": "symfony/dependency-injection", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "58401826c8cfc8fd689b60026e91c337df374bca" + "url": "https://github.com/symfony/DependencyInjection.git", + "reference": "1f01a64c9047909e40700a14ee34e8c446300618" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/58401826c8cfc8fd689b60026e91c337df374bca", - "reference": "58401826c8cfc8fd689b60026e91c337df374bca", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/1f01a64c9047909e40700a14ee34e8c446300618", + "reference": "1f01a64c9047909e40700a14ee34e8c446300618", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3.1", - "phpunit/php-text-template": "~1.2.0", - "phpunit/php-token-stream": "~1.2.2", - "sebastian/environment": "~1.0.0", - "sebastian/version": "~1.0.3" + "php": ">=5.3.3" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4.0.14" + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/yaml": "~2.0" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" }, - "time": "2014-05-26 14:55:24", + "time": "2014-09-27 08:35:39", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" - ] + "psr-0": { + "Symfony\\Component\\DependencyInjection\\": "" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ] + "description": "Symfony DependencyInjection Component", + "homepage": "http://symfony.com" }, { - "name": "phpunit/phpunit", - "version": "4.1.3", - "version_normalized": "4.1.3.0", + "name": "symfony/debug", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Debug", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91" + "url": "https://github.com/symfony/Debug.git", + "reference": "4a3dd4ef3fc0cee2fd9faaae12bd7af43afcf648" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/939cb801b3b2aa253aedd0b279f40bb8f35cec91", - "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91", + "url": "https://api.github.com/repos/symfony/Debug/zipball/4a3dd4ef3fc0cee2fd9faaae12bd7af43afcf648", + "reference": "4a3dd4ef3fc0cee2fd9faaae12bd7af43afcf648", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.1", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.1", - "sebastian/comparator": "~1.0", - "sebastian/diff": "~1.1", - "sebastian/environment": "~1.0", - "sebastian/exporter": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.0" + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" }, "suggest": { - "phpunit/php-invoker": "~1.1" + "symfony/http-foundation": "", + "symfony/http-kernel": "" }, - "time": "2014-06-11 14:15:47", - "bin": [ - "phpunit" - ], + "time": "2014-09-28 15:22:14", "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1.x-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { - "classmap": [ - "src/" - ] + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "The PHP Unit Testing framework.", - "homepage": "http://www.phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ] + "description": "Symfony Debug Component", + "homepage": "http://symfony.com" }, { - "name": "phpunit/phpunit-mock-objects", - "version": "dev-master", - "version_normalized": "9999999-dev", + "name": "symfony/http-foundation", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2" + "url": "https://github.com/symfony/HttpFoundation.git", + "reference": "650e115af152d7a5e857d01c2cdb9a22809de9b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/32f97c9198be565b6051983c70dc8d8e758725f4", - "reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/650e115af152d7a5e857d01c2cdb9a22809de9b4", + "reference": "650e115af152d7a5e857d01c2cdb9a22809de9b4", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "4.3.*@dev" + "symfony/expression-language": "~2.4" }, - "suggest": { - "ext-soap": "*" - }, - "time": "2014-06-12 07:22:27", + "time": "2014-09-25 09:52:29", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation\\": "" + }, "classmap": [ - "src/" + "Symfony/Component/HttpFoundation/Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ] + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com" }, { - "name": "symfony/serializer", - "version": "v2.5.2", - "version_normalized": "2.5.2.0", - "target-dir": "Symfony/Component/Serializer", + "name": "symfony/event-dispatcher", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", - "url": "https://github.com/symfony/Serializer.git", - "reference": "33185b290310ab1fd8283fb8ed2a434cdb88b9b9" + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Serializer/zipball/33185b290310ab1fd8283fb8ed2a434cdb88b9b9", - "reference": "33185b290310ab1fd8283fb8ed2a434cdb88b9b9", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46", + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2014-07-09 09:05:48", + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.0,<2.6.0", + "symfony/stopwatch": "~2.2" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "time": "2014-09-28 15:56:11", "type": "library", "extra": { "branch-alias": { @@ -2195,7 +2125,7 @@ "installation-source": "dist", "autoload": { "psr-0": { - "Symfony\\Component\\Serializer\\": "" + "Symfony\\Component\\EventDispatcher\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2203,96 +2133,137 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Symfony Serializer Component", + "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com" }, { - "name": "mikey179/vfsStream", - "version": "v1.3.0", - "version_normalized": "1.3.0.0", + "name": "symfony/http-kernel", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", - "url": "https://github.com/mikey179/vfsStream.git", - "reference": "8571f349567e02af1b7efc0fc4e3a4a1c98e664e" + "url": "https://github.com/symfony/HttpKernel.git", + "reference": "6a3595611229def14d5e644f060cf372235532ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/8571f349567e02af1b7efc0fc4e3a4a1c98e664e", - "reference": "8571f349567e02af1b7efc0fc4e3a4a1c98e664e", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/6a3595611229def14d5e644f060cf372235532ec", + "reference": "6a3595611229def14d5e644f060cf372235532ec", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=5.3.3", + "psr/log": "~1.0", + "symfony/debug": "~2.5", + "symfony/event-dispatcher": "~2.5", + "symfony/http-foundation": "~2.5" }, "require-dev": { - "phpunit/phpunit": "~4.1" + "symfony/browser-kit": "~2.2", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.0", + "symfony/console": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/expression-language": "~2.4", + "symfony/finder": "~2.0", + "symfony/process": "~2.0", + "symfony/routing": "~2.2", + "symfony/stopwatch": "~2.2", + "symfony/templating": "~2.2" }, - "time": "2014-07-21 20:15:54", + "suggest": { + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" + }, + "time": "2014-09-28 17:33:53", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "org\\bovigo\\vfs\\": "src/main/php" + "Symfony\\Component\\HttpKernel\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD" + "MIT" ], - "homepage": "http://vfs.bovigo.org/" + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "http://symfony.com" }, { - "name": "guzzlehttp/streams", - "version": "1.5.1", - "version_normalized": "1.5.1.0", + "name": "symfony/routing", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Routing", "source": { "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "fb0d1ee29987c2bdc59867bffaade6fc88c2675f" + "url": "https://github.com/symfony/Routing.git", + "reference": "9bc38fe72e0eff61611e7cd4df3accbce20b1d36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/fb0d1ee29987c2bdc59867bffaade6fc88c2675f", - "reference": "fb0d1ee29987c2bdc59867bffaade6fc88c2675f", + "url": "https://api.github.com/repos/symfony/Routing/zipball/9bc38fe72e0eff61611e7cd4df3accbce20b1d36", + "reference": "9bc38fe72e0eff61611e7cd4df3accbce20b1d36", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "doctrine/annotations": "~1.0", + "psr/log": "~1.0", + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/http-foundation": "~2.3", + "symfony/yaml": "~2.0" }, - "time": "2014-08-10 23:57:01", + "suggest": { + "doctrine/annotations": "For using the annotation loader", + "symfony/config": "For using the all-in-one router or any loader", + "symfony/expression-language": "For using expression matching", + "symfony/yaml": "For using the YAML loader" + }, + "time": "2014-09-22 15:28:36", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { - "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - }, - "files": [ - "src/functions.php" - ] + "psr-0": { + "Symfony\\Component\\Routing\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2300,61 +2271,54 @@ ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Provides a simple abstraction over streams of data (Guzzle 4+)", - "homepage": "http://guzzlephp.org/", + "description": "Symfony Routing Component", + "homepage": "http://symfony.com", "keywords": [ - "Guzzle", - "stream" + "router", + "routing", + "uri", + "url" ] }, { - "name": "guzzlehttp/guzzle", - "version": "4.1.7", - "version_normalized": "4.1.7.0", + "name": "symfony/serializer", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "448f2c2076cf0fb756230611491c4f7ecb735a29" + "url": "https://github.com/symfony/Serializer.git", + "reference": "a95c0471682778da2e02169fb2644d3b08d4470f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/448f2c2076cf0fb756230611491c4f7ecb735a29", - "reference": "448f2c2076cf0fb756230611491c4f7ecb735a29", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/a95c0471682778da2e02169fb2644d3b08d4470f", + "reference": "a95c0471682778da2e02169fb2644d3b08d4470f", "shasum": "" }, "require": { - "ext-json": "*", - "guzzlehttp/streams": "~1.4", - "php": ">=5.4.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" + "php": ">=5.3.3" }, - "time": "2014-08-08 01:30:43", + "time": "2014-09-22 09:14:18", "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions.php" - ] + "psr-0": { + "Symfony\\Component\\Serializer\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2362,64 +2326,56 @@ ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ] + "description": "Symfony Serializer Component", + "homepage": "http://symfony.com" }, { - "name": "symfony-cmf/routing", - "version": "1.2.0", - "version_normalized": "1.2.0.0", - "target-dir": "Symfony/Cmf/Component/Routing", + "name": "symfony/translation", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Translation", "source": { "type": "git", - "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "c67258b875eef3cb08009bf1428499d0f01ce5e7" + "url": "https://github.com/symfony/Translation.git", + "reference": "170c0d895616e1a6a35681ffb0b9e339f58ab928" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/c67258b875eef3cb08009bf1428499d0f01ce5e7", - "reference": "c67258b875eef3cb08009bf1428499d0f01ce5e7", + "url": "https://api.github.com/repos/symfony/Translation/zipball/170c0d895616e1a6a35681ffb0b9e339f58ab928", + "reference": "170c0d895616e1a6a35681ffb0b9e339f58ab928", "shasum": "" }, "require": { - "php": ">=5.3.3", - "psr/log": "~1.0", - "symfony/http-kernel": "~2.2", - "symfony/routing": "~2.2" + "php": ">=5.3.3" }, "require-dev": { - "symfony/config": "~2.2", - "symfony/dependency-injection": "~2.0", - "symfony/event-dispatcher": "~2.1" + "symfony/config": "~2.0", + "symfony/intl": "~2.3", + "symfony/yaml": "~2.2" }, "suggest": { - "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1" + "symfony/config": "", + "symfony/yaml": "" }, - "time": "2014-05-08 19:37:14", + "time": "2014-09-23 05:25:11", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Symfony\\Cmf\\Component\\Routing": "" + "Symfony\\Component\\Translation\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2428,51 +2384,70 @@ ], "authors": [ { - "name": "Symfony CMF Community", - "homepage": "https://github.com/symfony-cmf/Routing/contributors" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", - "homepage": "http://cmf.symfony.com", - "keywords": [ - "database", - "routing" - ] + "description": "Symfony Translation Component", + "homepage": "http://symfony.com" }, { - "name": "stack/builder", - "version": "v1.0.2", - "version_normalized": "1.0.2.0", + "name": "symfony/validator", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Validator", "source": { "type": "git", - "url": "https://github.com/stackphp/builder.git", - "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7" + "url": "https://github.com/symfony/Validator.git", + "reference": "64f61505843ca5e6c647244f5a4b6812c1279427" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stackphp/builder/zipball/b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", - "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", + "url": "https://api.github.com/repos/symfony/Validator/zipball/64f61505843ca5e6c647244f5a4b6812c1279427", + "reference": "64f61505843ca5e6c647244f5a4b6812c1279427", "shasum": "" }, "require": { - "php": ">=5.3.0", - "symfony/http-foundation": "~2.1", - "symfony/http-kernel": "~2.1" + "php": ">=5.3.3", + "symfony/translation": "~2.0" }, "require-dev": { - "silex/silex": "~1.0" + "doctrine/annotations": "~1.0", + "doctrine/cache": "~1.0", + "egulias/email-validator": "~1.0", + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/http-foundation": "~2.1", + "symfony/intl": "~2.3", + "symfony/property-access": "~2.2", + "symfony/yaml": "~2.0" }, - "time": "2014-01-28 19:42:24", + "suggest": { + "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", + "doctrine/cache": "For using the default cached annotation reader and metadata cache.", + "egulias/email-validator": "Strict (RFC compliant) email validation", + "symfony/config": "", + "symfony/expression-language": "For using the 2.4 Expression validator", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/property-access": "For using the 2.4 Validator API", + "symfony/yaml": "" + }, + "time": "2014-09-28 15:22:14", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Stack": "src" + "Symfony\\Component\\Validator\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2481,50 +2456,47 @@ ], "authors": [ { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch", - "homepage": "http://wiedler.ch/igor/" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Builder for stack middlewares based on HttpKernelInterface.", - "keywords": [ - "stack" - ] + "description": "Symfony Validator Component", + "homepage": "http://symfony.com" }, { - "name": "doctrine/annotations", - "version": "v1.2.0", - "version_normalized": "1.2.0.0", + "name": "symfony/yaml", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd" + "url": "https://github.com/symfony/Yaml.git", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", - "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", "shasum": "" }, "require": { - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" + "php": ">=5.3.3" }, - "time": "2014-07-06 15:52:21", + "time": "2014-09-22 09:14:18", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" + "Symfony\\Component\\Yaml\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2533,72 +2505,47 @@ ], "authors": [ { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": "Creator" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" }, { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ] + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com" }, { - "name": "egulias/email-validator", - "version": "1.2.2", - "version_normalized": "1.2.2.0", + "name": "symfony/process", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "target-dir": "Symfony/Component/Process", "source": { "type": "git", - "url": "https://github.com/egulias/EmailValidator.git", - "reference": "39b451bb2bb0655d83d82a38a0bba7189298cfc5" + "url": "https://github.com/symfony/Process.git", + "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/39b451bb2bb0655d83d82a38a0bba7189298cfc5", - "reference": "39b451bb2bb0655d83d82a38a0bba7189298cfc5", + "url": "https://api.github.com/repos/symfony/Process/zipball/8a1ec96c4e519cee0fb971ea48a1eb7369dda54b", + "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b", "shasum": "" }, "require": { - "doctrine/lexer": "~1.0", - "php": ">= 5.3.3" - }, - "require-dev": { - "satooshi/php-coveralls": "dev-master" + "php": ">=5.3.3" }, - "time": "2014-09-01 22:35:48", + "time": "2014-09-23 05:25:11", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.5-dev" } }, "installation-source": "dist", "autoload": { "psr-0": { - "Egulias\\": "src/" + "Symfony\\Component\\Process\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2607,15 +2554,15 @@ ], "authors": [ { - "name": "Eduardo Gulias Davis" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], - "description": "A library for validating emails", - "homepage": "https://github.com/egulias/EmailValidator", - "keywords": [ - "email", - "validation", - "validator" - ] + "description": "Symfony Process Component", + "homepage": "http://symfony.com" } ] diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php index c4c156f7030a6ccd13fb0acb39b1388005abb3c8..513362a50301e2ac500852d0702e166841d9635d 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php @@ -15,7 +15,7 @@ * ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3. * * It expects an object implementing a findFile method to find the file. This - * allow using it as a wrapper around the other loaders of the component (the + * allows using it as a wrapper around the other loaders of the component (the * ClassLoader and the UniversalClassLoader for instance) but also around any * other autoloader following this convention (the Composer one for instance) * @@ -46,7 +46,7 @@ class ApcClassLoader /** * The class loader object being decorated. * - * @var \Symfony\Component\ClassLoader\ClassLoader + * @var object * A class loader object that implements the findFile() method. */ protected $decorated; @@ -79,7 +79,7 @@ public function __construct($prefix, $decorated) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -99,7 +99,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { @@ -133,5 +133,4 @@ public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } - } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php index b2be33ad88ec1d9ee8c7322d32a6be0055bedb61..0ee9322f8433fcea9b0579fa30f1627140e17573 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -28,8 +28,8 @@ class ClassCollectionLoader * @param array $classes An array of classes to load * @param string $cacheDir A cache directory * @param string $name The cache name prefix - * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not - * @param Boolean $adaptive Whether to remove already declared classes or not + * @param bool $autoReload Whether to flush the cache when the cache is stale or not + * @param bool $adaptive Whether to remove already declared classes or not * @param string $extension File extension of the resulting file * * @throws \InvalidArgumentException When class can't be loaded @@ -200,7 +200,7 @@ public static function fixNamespaceDeclarations($source) */ public static function enableTokenizer($bool) { - self::$useTokenizer = (Boolean) $bool; + self::$useTokenizer = (bool) $bool; } /** diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php index 00de5b980bdd0ea32501fc826ef1304d183cec6e..1a5e3554354106e3fd7ade5bf19e9f83a7c08291 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php @@ -103,7 +103,7 @@ public function addPrefix($prefix, $paths) /** * Turns on searching the include for class files. * - * @param Boolean $useIncludePath + * @param bool $useIncludePath */ public function setUseIncludePath($useIncludePath) { @@ -114,7 +114,7 @@ public function setUseIncludePath($useIncludePath) * Can be used to check if the autoloader uses the include path to check * for classes. * - * @return Boolean + * @return bool */ public function getUseIncludePath() { @@ -124,7 +124,7 @@ public function getUseIncludePath() /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -144,7 +144,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php index 59c99d0f1b75d0832a67e91c1aedbbb1bbe08789..efc95ec8be94c2ca4761a78a7422a8f17e5116b8 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,6 +11,10 @@ namespace Symfony\Component\ClassLoader; +if (!defined('T_TRAIT')) { + define('T_TRAIT', 0); +} + /** * ClassMapGenerator * @@ -67,7 +71,6 @@ public static function createMap($dir) foreach ($classes as $class) { $map[$class] = $path; } - } return $map; @@ -84,7 +87,6 @@ private static function findClasses($path) { $contents = file_get_contents($path); $tokens = token_get_all($contents); - $T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT; $classes = array(); @@ -111,7 +113,7 @@ private static function findClasses($path) break; case T_CLASS: case T_INTERFACE: - case $T_TRAIT: + case T_TRAIT: // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugClassLoader.php index 8edd4c1999fa768f0ce40ec2112e47307e538f47..9294bda76d78da09a31fe56924914722af09524e 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -98,7 +98,7 @@ public function findFile($class) * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded * * @throws \RuntimeException */ diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php index 96c6290fc23093ce0a7b7c3f381269c6efa63bb9..678f4e8b2aba667f4346d07f389cf8bdcc0abdd9 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php @@ -48,7 +48,7 @@ public static function enable() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClass($class) { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/LICENSE b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/LICENSE +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php index 82010a77aebba261e947e66c4e080b5553828c87..7557b0ddf3a2bf966759279f4fb7f8a6c823afa0 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/MapClassLoader.php @@ -33,7 +33,7 @@ public function __construct(array $map) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Psr4ClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Psr4ClassLoader.php new file mode 100644 index 0000000000000000000000000000000000000000..1c0c37e09887e72823dc8eb35cdf0376ae0a6ed5 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Psr4ClassLoader.php @@ -0,0 +1,94 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader; + +/** + * A PSR-4 compatible class loader. + * + * See http://www.php-fig.org/psr/psr-4/ + * + * @author Alexander M. Turek <me@derrabus.de> + */ +class Psr4ClassLoader +{ + /** + * @var array + */ + private $prefixes = array(); + + /** + * @param string $prefix + * @param string $baseDir + */ + public function addPrefix($prefix, $baseDir) + { + $prefix = trim($prefix, '\\').'\\'; + $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; + $this->prefixes[] = array($prefix, $baseDir); + } + + /** + * @param string $class + * + * @return string|null + */ + public function findFile($class) + { + $class = ltrim($class, '\\'); + + foreach ($this->prefixes as $current) { + list($currentPrefix, $currentBaseDir) = $current; + if (0 === strpos($class, $currentPrefix)) { + $classWithoutPrefix = substr($class, strlen($currentPrefix)); + $file = $currentBaseDir.str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php'; + if (file_exists($file)) { + return $file; + } + } + } + } + + /** + * @param string $class + * + * @return bool + */ + public function loadClass($class) + { + $file = $this->findFile($class); + if (null !== $file) { + require $file; + + return true; + } + + return false; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Removes this instance from the registered autoloaders. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php index 9a7acfd7167c482bb0dc2a911f8b7bacc79d0196..9755256c79a4ded3453d90e8c70b543b12130437 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php @@ -55,15 +55,13 @@ public function testLoadClass($className, $testClassName, $message) $this->assertTrue(class_exists($className), $message); } - public function getLoadClassTests() - { - return array( - array('\\Apc\\Namespaced\\Foo', '\\Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'), + public function getLoadClassTests() + { + return array( + array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'), array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'), - array('\\Apc\\Namespaced\\Bar', '\\Apc\\Namespaced\\Bar', '->loadClass() loads Apc\Namespaced\Bar class with a leading slash'), - array('Apc_Pearlike_Bar', '\\Apc_Pearlike_Bar', '->loadClass() loads Apc_Pearlike_Bar class with a leading slash'), ); - } + } /** * @dataProvider getLoadClassFromFallbackTests @@ -79,15 +77,15 @@ public function testLoadClassFromFallback($className, $testClassName, $message) $this->assertTrue(class_exists($className), $message); } - public function getLoadClassFromFallbackTests() - { - return array( - array('\\Apc\\Namespaced\\Baz', '\\Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'), + public function getLoadClassFromFallbackTests() + { + return array( + array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'), array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'), - array('\\Apc\\Namespaced\\FooBar', '\\Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'), + array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'), array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'), ); - } + } /** * @dataProvider getLoadClassNamespaceCollisionTests @@ -102,15 +100,15 @@ public function testLoadClassNamespaceCollision($namespaces, $className, $messag $this->assertTrue(class_exists($className), $message); } - public function getLoadClassNamespaceCollisionTests() - { - return array( + public function getLoadClassNamespaceCollisionTests() + { + return array( array( array( 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', ), - '\Apc\NamespaceCollision\A\Foo', + 'Apc\NamespaceCollision\A\Foo', '->loadClass() loads NamespaceCollision\A\Foo from alpha.', ), array( @@ -118,7 +116,7 @@ public function getLoadClassNamespaceCollisionTests() 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', ), - '\Apc\NamespaceCollision\A\Bar', + 'Apc\NamespaceCollision\A\Bar', '->loadClass() loads NamespaceCollision\A\Bar from alpha.', ), array( @@ -126,7 +124,7 @@ public function getLoadClassNamespaceCollisionTests() 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', ), - '\Apc\NamespaceCollision\A\B\Foo', + 'Apc\NamespaceCollision\A\B\Foo', '->loadClass() loads NamespaceCollision\A\B\Foo from beta.', ), array( @@ -134,11 +132,11 @@ public function getLoadClassNamespaceCollisionTests() 'Apc\\NamespaceCollision\\A\\B' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/beta', 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', ), - '\Apc\NamespaceCollision\A\B\Bar', + 'Apc\NamespaceCollision\A\B\Bar', '->loadClass() loads NamespaceCollision\A\B\Bar from beta.', ), ); - } + } /** * @dataProvider getLoadClassPrefixCollisionTests @@ -152,9 +150,9 @@ public function testLoadClassPrefixCollision($prefixes, $className, $message) $this->assertTrue(class_exists($className), $message); } - public function getLoadClassPrefixCollisionTests() - { - return array( + public function getLoadClassPrefixCollisionTests() + { + return array( array( array( 'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', @@ -188,5 +186,5 @@ public function getLoadClassPrefixCollisionTests() '->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.', ), ); - } + } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index b8600fc54ed7b4567dc88cce8c11394da3cae6b3..35617e363ea481fb0ba81feb6526a9cc5edc4303 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -76,7 +76,7 @@ public function getTestCreateMapTests() 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', 'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php', - ) + ), ), array(__DIR__.'/Fixtures/beta/NamespaceCollision', array( 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php index dff891dcb79a6dca068c1aa8ad58127c114ada61..b0f9425950f44c0acbcb5f9d17ca24db24bcf73c 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php @@ -2,4 +2,6 @@ namespace ClassesWithParents; -class A extends B {} +class A extends B +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php index 196bf7a2d31b44c39beac08177ee882a3716b750..22c751a7e5da417ec561ff22db0c3d7ecbf1e82b 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php @@ -2,4 +2,6 @@ namespace ClassesWithParents; -class B implements CInterface {} +class B implements CInterface +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php index 26fabbd96e2d29a45b81eec123e73e93764b463e..c63cef9233eb158c9f4240706c332a67160fc3b2 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php @@ -13,5 +13,4 @@ class SomeClass extends SomeParent implements SomeInterface { - } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php index 09d7a8f35a436f80dc8153e099057be01cc8f05d..1fe5e09aa1f50b6f0c4fd39d03441807f326a17a 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php @@ -13,5 +13,4 @@ interface SomeInterface { - } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php index 5a859a94607fbf810d5546c248be5e027ece239d..ce2f9fc6c478ce420407b3e3a61b9fd5bb6a44c4 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php @@ -13,5 +13,4 @@ abstract class SomeParent { - } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php index d19e07fc11a5e50a9b0b0d39e1fbe57d97a024ce..7db8cd3b67ccc101199cd572baace913570d0ade 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php @@ -1,14 +1,24 @@ <?php namespace { - class A {} + class A + { + } } namespace Alpha { - class A {} - class B {} + class A + { + } + class B + { + } } namespace Beta { - class A {} - class B {} + class A + { + } + class B + { + } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/sameNsMultipleClasses.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/sameNsMultipleClasses.php index d5ef5e5aa25716c24a1ca0b36c85c128fd5f7f27..b34b9dd28be776567868cd2cca59641f33f3f4f7 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/sameNsMultipleClasses.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/sameNsMultipleClasses.php @@ -11,5 +11,9 @@ namespace Foo\Bar; -class A {} -class B {} +class A +{ +} +class B +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/deps/traits.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/deps/traits.php index a5537ac92fa82608f57f054b7453f560f4a6342f..82b30a6f9d0b932d0b5b1d8ddba5c6ec06f64174 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/deps/traits.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/deps/traits.php @@ -1,7 +1,8 @@ <?php trait TD -{} +{ +} trait TZ { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Class_With_Underscores.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Class_With_Underscores.php new file mode 100644 index 0000000000000000000000000000000000000000..ce9b8ea323fd7ca0f05e180e2e5ccb52822a7bc2 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Class_With_Underscores.php @@ -0,0 +1,7 @@ +<?php + +namespace Acme\DemoLib; + +class Class_With_Underscores +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Foo.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Foo.php new file mode 100644 index 0000000000000000000000000000000000000000..8ba6f837e6bc9f1f719fd9569229e42d718f7fa5 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Foo.php @@ -0,0 +1,7 @@ +<?php + +namespace Acme\DemoLib; + +class Foo +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Class_With_Underscores.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Class_With_Underscores.php new file mode 100644 index 0000000000000000000000000000000000000000..e18bb0f1119bce42d47b3c1a28b8784225ac5b52 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Class_With_Underscores.php @@ -0,0 +1,7 @@ +<?php + +namespace Acme\DemoLib\Lets\Go\Deeper; + +class Class_With_Underscores +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Foo.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Foo.php new file mode 100644 index 0000000000000000000000000000000000000000..53ead9f427228431d28c33b95929b97962709522 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Fixtures/psr-4/Lets/Go/Deeper/Foo.php @@ -0,0 +1,7 @@ +<?php + +namespace Acme\DemoLib\Lets\Go\Deeper; + +class Foo +{ +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Psr4ClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Psr4ClassLoaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..21a7afbd6e75ba8c99bfe592765f774838704051 --- /dev/null +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/Psr4ClassLoaderTest.php @@ -0,0 +1,71 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\ClassLoader\Tests; + +use Symfony\Component\ClassLoader\Psr4ClassLoader; + +class Psr4ClassLoaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @param string $className + * @dataProvider getLoadClassTests + */ + public function testLoadClass($className) + { + $loader = new Psr4ClassLoader(); + $loader->addPrefix( + 'Acme\\DemoLib', + __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4' + ); + $loader->loadClass($className); + $this->assertTrue(class_exists($className), sprintf('loadClass() should load %s', $className)); + } + + /** + * @return array + */ + public function getLoadClassTests() + { + return array( + array('Acme\\DemoLib\\Foo'), + array('Acme\\DemoLib\\Class_With_Underscores'), + array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Foo'), + array('Acme\\DemoLib\\Lets\\Go\\Deeper\\Class_With_Underscores'), + ); + } + + /** + * @param string $className + * @dataProvider getLoadNonexistentClassTests + */ + public function testLoadNonexistentClass($className) + { + $loader = new Psr4ClassLoader(); + $loader->addPrefix( + 'Acme\\DemoLib', + __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'psr-4' + ); + $loader->loadClass($className); + $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className)); + } + + /** + * @return array + */ + public function getLoadNonexistentClassTests() + { + return array( + array('Acme\\DemoLib\\I_Do_Not_Exist'), + array('UnknownVendor\\SomeLib\\I_Do_Not_Exist'), + ); + } +} diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php index 734af7430c59ff0a93157aeed0a128c60962cd37..8a3149f3198815f788dc22315a4e8794ca51d391 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php @@ -70,7 +70,7 @@ class UniversalClassLoader * Turns on searching the include for class files. Allows easy loading * of installed PEAR packages * - * @param Boolean $useIncludePath + * @param bool $useIncludePath */ public function useIncludePath($useIncludePath) { @@ -81,7 +81,7 @@ public function useIncludePath($useIncludePath) * Can be used to check if the autoloader uses the include path to check * for classes. * - * @return Boolean + * @return bool */ public function getUseIncludePath() { @@ -229,7 +229,7 @@ public function registerPrefix($prefix, $paths) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not * * @api */ @@ -243,7 +243,7 @@ public function register($prepend = false) * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { @@ -287,7 +287,6 @@ public function findFile($class) return $file; } } - } else { // PEAR-like class name $normalizedClass = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php index 3d09fa99f90571f4baa0d495157283281a47850f..c88e74bc95db16a0dad469758e52d7793837561b 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php @@ -76,7 +76,7 @@ public function __construct($prefix, $decorated) /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -96,7 +96,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php index 31bb00684b6bb403b393c1afa270eb936a93c897..30096bc83f1403cfac12fc9499ec61ac782bb718 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php @@ -12,7 +12,7 @@ namespace Symfony\Component\ClassLoader; /** - * XcacheClassLoader implements a wrapping autoloader cached in Xcache for PHP 5.3. + * XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3. * * It expects an object implementing a findFile method to find the file. This * allows using it as a wrapper around the other loaders of the component (the @@ -43,37 +43,41 @@ class XcacheClassLoader { private $prefix; - private $classFinder; + + /** + * @var object A class loader object that implements the findFile() method + */ + private $decorated; /** * Constructor. * - * @param string $prefix A prefix to create a namespace in Xcache - * @param object $classFinder An object that implements findFile() method. + * @param string $prefix The XCache namespace prefix to use. + * @param object $decorated A class loader object that implements the findFile() method. * * @throws \RuntimeException * @throws \InvalidArgumentException * * @api */ - public function __construct($prefix, $classFinder) + public function __construct($prefix, $decorated) { - if (!extension_loaded('Xcache')) { - throw new \RuntimeException('Unable to use XcacheClassLoader as Xcache is not enabled.'); + if (!extension_loaded('xcache')) { + throw new \RuntimeException('Unable to use XcacheClassLoader as XCache is not enabled.'); } - if (!method_exists($classFinder, 'findFile')) { + if (!method_exists($decorated, 'findFile')) { throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); } $this->prefix = $prefix; - $this->classFinder = $classFinder; + $this->decorated = $decorated; } /** * Registers this instance as an autoloader. * - * @param Boolean $prepend Whether to prepend the autoloader or not + * @param bool $prepend Whether to prepend the autoloader or not */ public function register($prepend = false) { @@ -93,7 +97,7 @@ public function unregister() * * @param string $class The name of the class * - * @return Boolean|null True, if loaded + * @return bool|null True, if loaded */ public function loadClass($class) { @@ -116,9 +120,18 @@ public function findFile($class) if (xcache_isset($this->prefix.$class)) { $file = xcache_get($this->prefix.$class); } else { - xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class)); + $file = $this->decorated->findFile($class); + xcache_set($this->prefix.$class, $file); } return $file; } + + /** + * Passes through all unknown calls onto the decorated object. + */ + public function __call($method, $args) + { + return call_user_func_array(array($this->decorated, $method), $args); + } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json index b28f4f55cb269344ee728494bc931d7562d0695f..84ce6a0a633a7c9ea8ca7d628a35e06c930b16f2 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/composer.json @@ -28,7 +28,7 @@ "target-dir": "Symfony/Component/ClassLoader", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist index 0d29c115323ee301ceb6dcc73613fa960658a673..3602188f09af78285d3e169a8cbcef1ac3131673 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php index 6c7c3be583ba8c8b869c68e6647713770f7cb91a..c622383e841a2f6325f686a94b06ac802c886d93 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php @@ -96,7 +96,7 @@ public static function parseSeries(array $tokens) return array( $first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1, - isset($split[1]) && $split[1] ? $int($split[1]) : 0 + isset($split[1]) && $split[1] ? $int($split[1]) : 0, ); } diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php index db352334f0a2415fd273be89fb4617fe129d75db..bb9653ce01636470e2b49c95bb4fb976bb60ea6b 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php @@ -41,7 +41,7 @@ public function parse($source) // 4 => string 'ab6bd_field' (length=11) if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?\.([\w-]+)$/i', trim($source), $matches)) { return array( - new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])) + new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])), ); } diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php index 95d7d5f91174f9cb04a0bb03c2ab4d84cdea4ac1..28c7d296f1b78b758028521208fff150c684dcd3 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php @@ -41,7 +41,7 @@ public function parse($source) // 4 => string 'ab6bd_field' (length=11) if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?#([\w-]+)$/i', trim($source), $matches)) { return array( - new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])) + new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])), ); } diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php index c90fc1044d3a9c5d43e29f190ddd6b21b27fad16..76386c937141fa92d26f5e9e3137993dded484d7 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php @@ -65,14 +65,18 @@ public function escapeUnicodeAndNewLine($value) */ private function replaceUnicodeSequences($value) { - return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function (array $match) { - $code = $match[1]; + return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) { + $c = hexdec($match[1]); - if (bin2hex($code) > 0xFFFD) { - $code = '\\FFFD'; + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } - - return mb_convert_encoding(pack('H*', $code), 'UTF-8', 'UCS-2BE'); }, $value); } } diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md index 623649bedbb23678cbac55434b43d1468e5366a3..fae1d4bc9a4535c2796fecc71b78849ad6e46ba8 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md @@ -35,7 +35,7 @@ Resources This component is a port of the Python lxml library, which is copyright Infrae and distributed under the BSD license. -Current code is a port of https://github.com/SimonSapin/cssselect@v0.7.1 +Current code is a port of https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1 You can run the unit tests with the following command: diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php index 65ab287770f27ac4f87790caec74246e0ccaffe4..22312659429a4aed674e4876cb72771ad6b159ba 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php @@ -24,6 +24,8 @@ interface ExtensionInterface /** * Returns node translators. * + * These callables will receive the node as first argument and the translator as second argument. + * * @return callable[] */ public function getNodeTranslators(); diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php index f86f2b967266adae658206a1bb1fabbd4b2065be..d71baaa96bcd3c0cf58960c97ba0cabd4674bb30 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -29,11 +29,6 @@ class NodeExtension extends AbstractExtension const ATTRIBUTE_NAME_IN_LOWER_CASE = 2; const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4; - /** - * @var Translator - */ - private $translator; - /** * @var int */ @@ -42,12 +37,10 @@ class NodeExtension extends AbstractExtension /** * Constructor. * - * @param Translator $translator - * @param int $flags + * @param int $flags */ - public function __construct(Translator $translator, $flags = 0) + public function __construct($flags = 0) { - $this->translator = $translator; $this->flags = $flags; } @@ -100,33 +93,36 @@ public function getNodeTranslators() /** * @param Node\SelectorNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateSelector(Node\SelectorNode $node) + public function translateSelector(Node\SelectorNode $node, Translator $translator) { - return $this->translator->nodeToXPath($node->getTree()); + return $translator->nodeToXPath($node->getTree()); } /** * @param Node\CombinedSelectorNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateCombinedSelector(Node\CombinedSelectorNode $node) + public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator) { - return $this->translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); + return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); } /** * @param Node\NegationNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateNegation(Node\NegationNode $node) + public function translateNegation(Node\NegationNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); - $subXpath = $this->translator->nodeToXPath($node->getSubSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); + $subXpath = $translator->nodeToXPath($node->getSubSelector()); $subXpath->addNameTest(); if ($subXpath->getCondition()) { @@ -138,34 +134,37 @@ public function translateNegation(Node\NegationNode $node) /** * @param Node\FunctionNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateFunction(Node\FunctionNode $node) + public function translateFunction(Node\FunctionNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addFunction($xpath, $node); + return $translator->addFunction($xpath, $node); } /** * @param Node\PseudoNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translatePseudo(Node\PseudoNode $node) + public function translatePseudo(Node\PseudoNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addPseudoClass($xpath, $node->getIdentifier()); + return $translator->addPseudoClass($xpath, $node->getIdentifier()); } /** * @param Node\AttributeNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateAttribute(Node\AttributeNode $node) + public function translateAttribute(Node\AttributeNode $node, Translator $translator) { $name = $node->getAttribute(); $safe = $this->isSafeName($name); @@ -181,37 +180,39 @@ public function translateAttribute(Node\AttributeNode $node) $attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name)); $value = $node->getValue(); - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) { $value = strtolower($value); } - return $this->translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); + return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); } /** * @param Node\ClassNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateClass(Node\ClassNode $node) + public function translateClass(Node\ClassNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); + return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); } /** * @param Node\HashNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateHash(Node\HashNode $node) + public function translateHash(Node\HashNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); + return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); } /** diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php index 5a8eb99017a1b58149f267319c5ae939f736beac..4676677ea48847e13c7cc5f6ee7c163071b4b22b 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php @@ -76,7 +76,7 @@ public function __construct(ParserInterface $parser = null) $this->mainParser = $parser ?: new Parser(); $this - ->registerExtension(new Extension\NodeExtension($this)) + ->registerExtension(new Extension\NodeExtension()) ->registerExtension(new Extension\CombinationExtension()) ->registerExtension(new Extension\FunctionExtension()) ->registerExtension(new Extension\PseudoClassExtension()) @@ -207,7 +207,7 @@ public function nodeToXPath(NodeInterface $node) throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName())); } - return call_user_func($this->nodeTranslators[$node->getNodeName()], $node); + return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this); } /** diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json index 1ab133f3181456690bab77bfa0180f66c4ff0a99..5b4231d7947574057015b85e85f7170a5c44c30d 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist index a19dc00b348f1a680903cfaf34ecea5a77633084..3eb0a1ece0c367b75a78fa6c5f55634e2762c173 100644 --- a/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist +++ b/core/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md b/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md index 2ad5ce695c365de387b93840161bb613c17b4cf0..776468fb7a59e057aa5dddfa3be4bfc9b4b6eb61 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md @@ -1,6 +1,19 @@ CHANGELOG ========= +2.5.0 +----- + +* added ExceptionHandler::setHandler() +* added UndefinedMethodFatalErrorHandler +* deprecated DummyException + +2.4.0 +----- + + * added a DebugClassLoader able to wrap any autoloader providing a findFile method + * improved error messages for not found classes and functions + 2.3.0 ----- diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php index 2e36805ca3c6a6b3c7b880932205b40893c7ca7f..e0710c59e677010a667e208ad8dce0c21feccd84 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Debug.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Debug; -use Symfony\Component\ClassLoader\DebugClassLoader; - /** * Registers all the debug tools. * @@ -30,8 +28,8 @@ class Debug * If the Symfony ClassLoader component is available, a special * class loader is also registered. * - * @param integer $errorReportingLevel The level of error reporting you want - * @param Boolean $displayErrors Whether to display errors (for development) or just log them (for production) + * @param int $errorReportingLevel The level of error reporting you want + * @param bool $displayErrors Whether to display errors (for development) or just log them (for production) */ public static function enable($errorReportingLevel = null, $displayErrors = true) { @@ -51,8 +49,6 @@ public static function enable($errorReportingLevel = null, $displayErrors = true ini_set('display_errors', 1); } - if (class_exists('Symfony\Component\ClassLoader\DebugClassLoader')) { - DebugClassLoader::enable(); - } + DebugClassLoader::enable(); } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php b/core/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php new file mode 100644 index 0000000000000000000000000000000000000000..4a02e616cce8928688938a0e9d5d6ac36e1951ce --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php @@ -0,0 +1,226 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +/** + * Autoloader checking if the class is really defined in the file found. + * + * The ClassLoader will wrap all registered autoloaders + * and will throw an exception if a file is found but does + * not declare the class. + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Christophe Coevoet <stof@notk.org> + * @author Nicolas Grekas <p@tchwork.com> + * + * @api + */ +class DebugClassLoader +{ + private $classLoader; + private $isFinder; + private $wasFinder; + private static $caseCheck; + + /** + * Constructor. + * + * @param callable|object $classLoader + * + * @api + * @deprecated since 2.5, passing an object is deprecated and support for it will be removed in 3.0 + */ + public function __construct($classLoader) + { + $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile'); + + if ($this->wasFinder) { + $this->classLoader = array($classLoader, 'loadClass'); + $this->isFinder = true; + } else { + $this->classLoader = $classLoader; + $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile'); + } + + if (!isset(self::$caseCheck)) { + self::$caseCheck = false !== stripos(PHP_OS, 'win') ? (false !== stripos(PHP_OS, 'darwin') ? 2 : 1) : 0; + } + } + + /** + * Gets the wrapped class loader. + * + * @return callable|object a class loader + * + * @deprecated since 2.5, returning an object is deprecated and support for it will be removed in 3.0 + */ + public function getClassLoader() + { + if ($this->wasFinder) { + return $this->classLoader[0]; + } else { + return $this->classLoader; + } + } + + /** + * Wraps all autoloaders + */ + public static function enable() + { + // Ensures we don't hit https://bugs.php.net/42098 + class_exists(__NAMESPACE__.'\ErrorHandler', true); + + if (!is_array($functions = spl_autoload_functions())) { + return; + } + + foreach ($functions as $function) { + spl_autoload_unregister($function); + } + + foreach ($functions as $function) { + if (!is_array($function) || !$function[0] instanceof self) { + $function = array(new static($function), 'loadClass'); + } + + spl_autoload_register($function); + } + } + + /** + * Disables the wrapping. + */ + public static function disable() + { + if (!is_array($functions = spl_autoload_functions())) { + return; + } + + foreach ($functions as $function) { + spl_autoload_unregister($function); + } + + foreach ($functions as $function) { + if (is_array($function) && $function[0] instanceof self) { + $function = $function[0]->getClassLoader(); + } + + spl_autoload_register($function); + } + } + + /** + * Finds a file by class name + * + * @param string $class A class name to resolve to file + * + * @return string|null + * + * @deprecated Deprecated since 2.5, to be removed in 3.0. + */ + public function findFile($class) + { + if ($this->wasFinder) { + return $this->classLoader[0]->findFile($class); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * + * @return bool|null True, if loaded + * + * @throws \RuntimeException + */ + public function loadClass($class) + { + ErrorHandler::stackErrors(); + + try { + if ($this->isFinder) { + if ($file = $this->classLoader[0]->findFile($class)) { + require $file; + } + } else { + call_user_func($this->classLoader, $class); + $file = false; + } + } catch (\Exception $e) { + ErrorHandler::unstackErrors(); + + throw $e; + } + + ErrorHandler::unstackErrors(); + + $exists = class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + + if ('\\' === $class[0]) { + $class = substr($class, 1); + } + + if ($exists) { + $refl = new \ReflectionClass($class); + $name = $refl->getName(); + + if ($name !== $class && 0 === strcasecmp($name, $class)) { + throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name)); + } + } + + if ($file) { + if (!$exists) { + 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)); + } + + 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)) { + $tail = $tail[0]; + $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; + } + } + closedir($h); + } + chdir($cwd); + } + + if ( 0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true) + && 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false) + ) { + throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real)); + } + } + + return true; + } + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php index 52fd7a50f7d5517eeab4df3b0333cd22257b631e..b0699f34a870cb79d44b0e175a6d02a34df1cd0d 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php @@ -11,15 +11,22 @@ namespace Symfony\Component\Debug; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\Exception\ContextErrorException; +use Psr\Log\LogLevel; use Psr\Log\LoggerInterface; +use Symfony\Component\Debug\Exception\ContextErrorException; +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\Exception\OutOfMemoryException; +use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; +use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; +use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; +use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface; /** * ErrorHandler. * * @author Fabien Potencier <fabien@symfony.com> * @author Konstantin Myakshin <koc-dp@yandex.ru> + * @author Nicolas Grekas <p@tchwork.com> */ class ErrorHandler { @@ -38,7 +45,7 @@ class ErrorHandler E_ERROR => 'Error', E_CORE_ERROR => 'Core Error', E_COMPILE_ERROR => 'Compile Error', - E_PARSE => 'Parse', + E_PARSE => 'Parse Error', ); private $level; @@ -52,13 +59,17 @@ class ErrorHandler */ private static $loggers = array(); + private static $stackedErrors = array(); + + private static $stackedErrorLevels = array(); + /** * Registers the error handler. * - * @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) - * @param Boolean $displayErrors Display errors (for dev environment) or just log they (production usage) + * @param int $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) + * @param bool $displayErrors Display errors (for dev environment) or just log them (production usage) * - * @return The registered error handler + * @return ErrorHandler The registered error handler */ public static function register($level = null, $displayErrors = true) { @@ -74,98 +85,285 @@ public static function register($level = null, $displayErrors = true) return $handler; } + /** + * Sets the level at which the conversion to Exception is done. + * + * @param int|null $level The level (null to use the error_reporting() value and 0 to disable) + */ public function setLevel($level) { $this->level = null === $level ? error_reporting() : $level; } + /** + * Sets the display_errors flag value. + * + * @param int $displayErrors The display_errors flag value + */ public function setDisplayErrors($displayErrors) { $this->displayErrors = $displayErrors; } + /** + * Sets a logger for the given channel. + * + * @param LoggerInterface $logger A logger interface + * @param string $channel The channel associated with the logger (deprecation, emergency or scream) + */ public static function setLogger(LoggerInterface $logger, $channel = 'deprecation') { self::$loggers[$channel] = $logger; } /** - * @throws ContextErrorException When error_reporting returns error + * @throws \ErrorException When error_reporting returns error */ public function handle($level, $message, $file = 'unknown', $line = 0, $context = array()) { - if (0 === $this->level) { - return false; - } - if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) { if (isset(self::$loggers['deprecation'])) { - if (version_compare(PHP_VERSION, '5.4', '<')) { - $stack = array_map( - function ($row) { - unset($row['args']); - - return $row; - }, - array_slice(debug_backtrace(false), 0, 10) - ); + if (self::$stackedErrorLevels) { + self::$stackedErrors[] = func_get_args(); } else { - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); + if (version_compare(PHP_VERSION, '5.4', '<')) { + $stack = array_map( + function ($row) { + unset($row['args']); + + return $row; + }, + array_slice(debug_backtrace(false), 0, 10) + ); + } else { + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); + } + + self::$loggers['deprecation']->warning($message, array('type' => self::TYPE_DEPRECATION, 'stack' => $stack)); } - self::$loggers['deprecation']->warning($message, array('type' => self::TYPE_DEPRECATION, 'stack' => $stack)); + return true; + } + } elseif ($this->displayErrors && error_reporting() & $level && $this->level & $level) { + if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && is_array($context)) { + $c = $context; // Whatever the signature of the method, + unset($c['GLOBALS'], $context); // $context is always a reference in 5.3 + $context = $c; } - return true; - } + $exception = sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line); + if ($context && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { + // Checking for class existence is a work around for https://bugs.php.net/42098 + $exception = new ContextErrorException($exception, 0, $level, $file, $line, $context); + } else { + $exception = new \ErrorException($exception, 0, $level, $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. - if ($this->displayErrors && error_reporting() & $level && $this->level & $level) { - // make sure the ContextErrorException class is loaded (https://bugs.php.net/bug.php?id=65322) - if (!class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { - require __DIR__.'/Exception/ContextErrorException.php'; + $exception->errorHandlerCanary = new ErrorHandlerCanary(); } - throw new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context); + throw $exception; + } + + if (isset(self::$loggers['scream']) && !(error_reporting() & $level)) { + if (self::$stackedErrorLevels) { + self::$stackedErrors[] = func_get_args(); + } else { + switch ($level) { + case E_USER_ERROR: + case E_RECOVERABLE_ERROR: + $logLevel = LogLevel::ERROR; + break; + + case E_WARNING: + case E_USER_WARNING: + $logLevel = LogLevel::WARNING; + break; + + default: + $logLevel = LogLevel::NOTICE; + break; + } + + self::$loggers['scream']->log($logLevel, $message, array( + 'type' => $level, + 'file' => $file, + 'line' => $line, + 'scream' => error_reporting(), + )); + } } return false; } + /** + * Configure the error handler for delayed handling. + * Ensures also that non-catchable fatal errors are never silenced. + * + * As shown by http://bugs.php.net/42098 and http://bugs.php.net/60724 + * PHP has a compile stage where it behaves unusually. To workaround it, + * we plug an error handler that only stacks errors for later. + * + * The most important feature of this is to prevent + * autoloading until unstackErrors() is called. + */ + public static function stackErrors() + { + self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); + } + + /** + * Unstacks stacked errors and forwards to the regular handler + */ + public static function unstackErrors() + { + $level = array_pop(self::$stackedErrorLevels); + + if (null !== $level) { + $e = error_reporting($level); + if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) { + // If the user changed the error level, do not overwrite it + error_reporting($e); + } + } + + if (empty(self::$stackedErrorLevels)) { + $errors = self::$stackedErrors; + self::$stackedErrors = array(); + + $errorHandler = set_error_handler('var_dump'); + restore_error_handler(); + + if ($errorHandler) { + foreach ($errors as $e) { + call_user_func_array($errorHandler, $e); + } + } + } + } + public function handleFatal() { - if (null === $error = error_get_last()) { - return; + $this->reservedMemory = ''; + gc_collect_cycles(); + $error = error_get_last(); + + // get current exception handler + $exceptionHandler = set_exception_handler('var_dump'); + restore_exception_handler(); + + try { + while (self::$stackedErrorLevels) { + static::unstackErrors(); + } + } catch (\Exception $exception) { + if ($exceptionHandler) { + call_user_func($exceptionHandler, $exception); + + return; + } + + if ($this->displayErrors) { + ini_set('display_errors', 1); + } + + throw $exception; } - unset($this->reservedMemory); - $type = $error['type']; - if (0 === $this->level || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) { + if (!$error || !$this->level || !($error['type'] & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE))) { return; } if (isset(self::$loggers['emergency'])) { $fatal = array( - 'type' => $type, + 'type' => $error['type'], 'file' => $error['file'], 'line' => $error['line'], ); - self::$loggers['emergency']->emerg($error['message'], $fatal); + self::$loggers['emergency']->emergency($error['message'], $fatal); } - if (!$this->displayErrors) { - return; + if ($this->displayErrors && $exceptionHandler) { + $this->handleFatalError($exceptionHandler, $error); } + } - // get current exception handler - $exceptionHandler = set_exception_handler(function() {}); - restore_exception_handler(); + /** + * Gets the fatal error handlers. + * + * Override this method if you want to define more fatal error handlers. + * + * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface + */ + protected function getFatalErrorHandlers() + { + return array( + new UndefinedFunctionFatalErrorHandler(), + new UndefinedMethodFatalErrorHandler(), + new ClassNotFoundFatalErrorHandler(), + ); + } + + private function handleFatalError($exceptionHandler, array $error) + { + // Let PHP handle any further error + set_error_handler('var_dump', 0); + ini_set('display_errors', 1); + + $level = isset($this->levels[$error['type']]) ? $this->levels[$error['type']] : $error['type']; + $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); + if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) { + $exception = new OutOfMemoryException($message, 0, $error['type'], $error['file'], $error['line'], 3, false); + } else { + $exception = new FatalErrorException($message, 0, $error['type'], $error['file'], $error['line'], 3, true); + + foreach ($this->getFatalErrorHandlers() as $handler) { + if ($e = $handler->handleError($error, $exception)) { + $exception = $e; + break; + } + } + } + + try { + call_user_func($exceptionHandler, $exception); + } catch (\Exception $e) { + // The handler failed. Let PHP handle that now. + throw $exception; + } + } +} - if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { - $level = isset($this->levels[$type]) ? $this->levels[$type] : $type; - $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); - $exception = new FatalErrorException($message, 0, $type, $error['file'], $error['line']); - $exceptionHandler[0]->handle($exception); +/** + * Private class used to work around https://bugs.php.net/54275 + * + * @author Nicolas Grekas <p@tchwork.com> + * + * @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/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php new file mode 100644 index 0000000000000000000000000000000000000000..b91bf46631bbb482943988927889dd7fc6d7ab1d --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php @@ -0,0 +1,33 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Class (or Trait or Interface) Not Found Exception. + * + * @author Konstanton Myakshin <koc-dp@yandex.ru> + */ +class ClassNotFoundException extends FatalErrorException +{ + public function __construct($message, \ErrorException $previous) + { + parent::__construct( + $message, + $previous->getCode(), + $previous->getSeverity(), + $previous->getFile(), + $previous->getLine(), + $previous->getPrevious() + ); + $this->setTrace($previous->getTrace()); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php index ea27922808532fe1df586ac8d5c141308cab2de4..54f0198f1b2f87334c26d157c19c20514bcb83ea 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php @@ -27,7 +27,7 @@ public function __construct($message, $code, $severity, $filename, $lineno, $con } /** - * @return array Array of variables that existed when the exception occured + * @return array Array of variables that existed when the exception occurred */ public function getContext() { diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchPropertyException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php similarity index 55% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchPropertyException.php rename to core/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php index 1c7eda5f83839b3e7eb0860e5698ce21602d013a..967e033777322ad5b0c8f763ed068860180dcf43 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchPropertyException.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Debug\Exception; /** - * Thrown when a property cannot be found. + * @author Fabien Potencier <fabien@symfony.com> * - * @author Bernhard Schussek <bschussek@gmail.com> + * @deprecated since version 2.5, to be removed in 3.0. */ -class NoSuchPropertyException extends AccessException +class DummyException extends \ErrorException { } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php index bf37ef809857fb90fcd597b1e65d5cdea27bee44..d5b58468c9c6d61f5da98762550277e68c9def8e 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php @@ -14,8 +14,58 @@ /** * Fatal Error Exception. * + * @author Fabien Potencier <fabien@symfony.com> * @author Konstanton Myakshin <koc-dp@yandex.ru> + * @author Nicolas Grekas <p@tchwork.com> */ class FatalErrorException extends \ErrorException { + public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true) + { + parent::__construct($message, $code, $severity, $filename, $lineno); + + if (null !== $traceOffset) { + if (function_exists('xdebug_get_function_stack')) { + $trace = xdebug_get_function_stack(); + if (0 < $traceOffset) { + array_splice($trace, -$traceOffset); + } + + foreach ($trace as &$frame) { + if (!isset($frame['type'])) { + // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 + if (isset($frame['class'])) { + $frame['type'] = '::'; + } + } elseif ('dynamic' === $frame['type']) { + $frame['type'] = '->'; + } elseif ('static' === $frame['type']) { + $frame['type'] = '::'; + } + + // XDebug also has a different name for the parameters array + if (!$traceArgs) { + unset($frame['params'], $frame['args']); + } elseif (isset($frame['params']) && !isset($frame['args'])) { + $frame['args'] = $frame['params']; + unset($frame['params']); + } + } + + unset($frame); + $trace = array_reverse($trace); + } else { + $trace = array(); + } + + $this->setTrace($trace); + } + } + + protected function setTrace($trace) + { + $traceReflector = new \ReflectionProperty('Exception', 'trace'); + $traceReflector->setAccessible(true); + $traceReflector->setValue($this, $trace); + } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php index 4f0e815f9706264d1fbc24099fc0320fd2ff1450..eb49d4609fdf6fb0f1200483cc8dec9f86c8aed2 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php @@ -172,36 +172,7 @@ public function getTrace() public function setTraceFromException(\Exception $exception) { - $trace = $exception->getTrace(); - - if ($exception instanceof FatalErrorException) { - if (function_exists('xdebug_get_function_stack')) { - $trace = array_slice(array_reverse(xdebug_get_function_stack()), 4); - - foreach ($trace as $i => $frame) { - // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 - if (!isset($frame['type'])) { - $trace[$i]['type'] = '??'; - } - - if ('dynamic' === $trace[$i]['type']) { - $trace[$i]['type'] = '->'; - } elseif ('static' === $trace[$i]['type']) { - $trace[$i]['type'] = '::'; - } - - // XDebug also has a different name for the parameters array - if (isset($frame['params']) && !isset($frame['args'])) { - $trace[$i]['args'] = $frame['params']; - unset($trace[$i]['params']); - } - } - } else { - $trace = array_slice(array_reverse($trace), 1); - } - } - - $this->setTrace($trace, $exception->getFile(), $exception->getLine()); + $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine()); } public function setTrace($trace, $file, $line) @@ -249,7 +220,7 @@ private function flattenArgs($args, $level = 0) if ($level > 10) { $result[$key] = array('array', '*DEEP NESTED ARRAY*'); } else { - $result[$key] = array('array', $this->flattenArgs($value, ++$level)); + $result[$key] = array('array', $this->flattenArgs($value, $level + 1)); } } elseif (null === $value) { $result[$key] = array('null', null); diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchIndexException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php similarity index 54% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchIndexException.php rename to core/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php index 597b9904a22a0c6dcb837a86de62526e411f2601..fec19798364502d573e47c17da34290db2c43a4a 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchIndexException.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Debug\Exception; /** - * Thrown when an index cannot be found. + * Out of memory exception. * - * @author Stéphane Escandell <stephane.escandell@gmail.com> + * @author Nicolas Grekas <p@tchwork.com> */ -class NoSuchIndexException extends AccessException +class OutOfMemoryException extends FatalErrorException { } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php new file mode 100644 index 0000000000000000000000000000000000000000..a66ae2a3879c99778d464618c92c60dfb39b47bb --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php @@ -0,0 +1,33 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Undefined Function Exception. + * + * @author Konstanton Myakshin <koc-dp@yandex.ru> + */ +class UndefinedFunctionException extends FatalErrorException +{ + public function __construct($message, \ErrorException $previous) + { + parent::__construct( + $message, + $previous->getCode(), + $previous->getSeverity(), + $previous->getFile(), + $previous->getLine(), + $previous->getPrevious() + ); + $this->setTrace($previous->getTrace()); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php new file mode 100644 index 0000000000000000000000000000000000000000..350dc3187f47541b28c5d46301690a4832566288 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php @@ -0,0 +1,33 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Undefined Method Exception. + * + * @author Grégoire Pineau <lyrixx@lyrixx.info> + */ +class UndefinedMethodException extends FatalErrorException +{ + public function __construct($message, \ErrorException $previous) + { + parent::__construct( + $message, + $previous->getCode(), + $previous->getSeverity(), + $previous->getFile(), + $previous->getLine(), + $previous->getPrevious() + ); + $this->setTrace($previous->getTrace()); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php index cd781b56097749293c9a8ff24a72e20a6eccd44f..6c12979d6e0cd841d14946782b001afbf84766c6 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php @@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Debug\Exception\FlattenException; +use Symfony\Component\Debug\Exception\OutOfMemoryException; if (!defined('ENT_SUBSTITUTE')) { define('ENT_SUBSTITUTE', 8); @@ -28,11 +29,15 @@ * available, the Response content is always HTML. * * @author Fabien Potencier <fabien@symfony.com> + * @author Nicolas Grekas <p@tchwork.com> */ class ExceptionHandler { private $debug; private $charset; + private $handler; + private $caughtBuffer; + private $caughtLength; public function __construct($debug = true, $charset = 'UTF-8') { @@ -43,7 +48,7 @@ public function __construct($debug = true, $charset = 'UTF-8') /** * Registers the exception handler. * - * @param Boolean $debug + * @param bool $debug * * @return ExceptionHandler The registered exception handler */ @@ -56,6 +61,65 @@ public static function register($debug = true) return $handler; } + /** + * Sets a user exception handler. + * + * @param callable $handler An handler that will be called on Exception + * + * @return callable|null The previous exception handler if any + */ + public function setHandler($handler) + { + if (null !== $handler && !is_callable($handler)) { + throw new \LogicException('The exception handler must be a valid PHP callable.'); + } + $old = $this->handler; + $this->handler = $handler; + + return $old; + } + + /** + * Sends a response for the given Exception. + * + * To be as fail-safe as possible, the exception is first handled + * by our simple exception handler, then by the user exception handler. + * The latter takes precedence and any output from the former is cancelled, + * if and only if nothing bad happens in this handling path. + */ + public function handle(\Exception $exception) + { + if (null === $this->handler || $exception instanceof OutOfMemoryException) { + $this->failSafeHandle($exception); + + return; + } + + $caughtLength = $this->caughtLength = 0; + + ob_start(array($this, 'catchOutput')); + $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')); + echo $this->caughtBuffer; + $caughtLength = ob_get_length(); + } + $this->caughtBuffer = null; + + try { + call_user_func($this->handler, $exception); + $this->caughtLength = $caughtLength; + } catch (\Exception $e) { + if (!$caughtLength) { + // All handlers failed. Let PHP handle that now. + throw $exception; + } + } + } + /** * Sends a response for the given Exception. * @@ -63,15 +127,15 @@ public static function register($debug = true) * this method will use it to create and send the response. If not, * it will fallback to plain PHP functions. * - * @param \Exception $exception An \Exception instance - * * @see sendPhpResponse * @see createResponse */ - public function handle(\Exception $exception) + private function failSafeHandle(\Exception $exception) { - if (class_exists('Symfony\Component\HttpFoundation\Response')) { - $this->createResponse($exception)->send(); + if (class_exists('Symfony\Component\HttpFoundation\Response', false)) { + $response = $this->createResponse($exception); + $response->sendHeaders(); + $response->sendContent(); } else { $this->sendPhpResponse($exception); } @@ -91,9 +155,11 @@ public function sendPhpResponse($exception) $exception = FlattenException::create($exception); } - header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); - foreach ($exception->getHeaders() as $name => $value) { - header($name.': '.$value, false); + if (!headers_sent()) { + header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); + foreach ($exception->getHeaders() as $name => $value) { + header($name.': '.$value, false); + } } echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); @@ -313,4 +379,30 @@ private function formatArgs(array $args) return implode(', ', $result); } + + /** + * @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/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php new file mode 100644 index 0000000000000000000000000000000000000000..2d543ed2b4d645af0cbc1c069049c7adea8a4af7 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -0,0 +1,202 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\ClassNotFoundException; +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\DebugClassLoader; +use Composer\Autoload\ClassLoader as ComposerClassLoader; +use Symfony\Component\ClassLoader as SymfonyClassLoader; + +/** + * ErrorHandler for classes that do not exist. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handleError(array $error, FatalErrorException $exception) + { + $messageLen = strlen($error['message']); + $notFoundSuffix = '\' not found'; + $notFoundSuffixLen = strlen($notFoundSuffix); + if ($notFoundSuffixLen > $messageLen) { + return; + } + + if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { + return; + } + + foreach (array('class', 'interface', 'trait') as $typeName) { + $prefix = ucfirst($typeName).' \''; + $prefixLen = strlen($prefix); + if (0 !== strpos($error['message'], $prefix)) { + continue; + } + + $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); + if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) { + $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1); + $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex); + $message = sprintf( + 'Attempted to load %s "%s" from namespace "%s" in %s line %d. Do you need to "use" it from another namespace?', + $typeName, + $className, + $namespacePrefix, + $error['file'], + $error['line'] + ); + } else { + $className = $fullyQualifiedClassName; + $message = sprintf( + 'Attempted to load %s "%s" from the global namespace in %s line %d. Did you forget a use statement for this %s?', + $typeName, + $className, + $error['file'], + $error['line'], + $typeName + ); + } + + if ($classes = $this->getClassCandidates($className)) { + $message .= sprintf(' Perhaps you need to add a use statement for one of the following: %s.', implode(', ', $classes)); + } + + return new ClassNotFoundException($message, $exception); + } + } + + /** + * Tries to guess the full namespace for a given class name. + * + * By default, it looks for PSR-0 classes registered via a Symfony or a Composer + * autoloader (that should cover all common cases). + * + * @param string $class A class name (without its namespace) + * + * @return array An array of possible fully qualified class names + */ + private function getClassCandidates($class) + { + if (!is_array($functions = spl_autoload_functions())) { + return array(); + } + + // find Symfony and Composer autoloaders + $classes = array(); + foreach ($functions as $function) { + if (!is_array($function)) { + continue; + } + + // get class loaders wrapped by DebugClassLoader + if ($function[0] instanceof DebugClassLoader) { + $function = $function[0]->getClassLoader(); + + // Since 2.5, returning an object from DebugClassLoader::getClassLoader() is @deprecated + if (is_object($function)) { + $function = array($function); + } + + if (!is_array($function)) { + continue; + } + } + + if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) { + foreach ($function[0]->getPrefixes() as $prefix => $paths) { + foreach ($paths as $path) { + $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix)); + } + } + } + } + + return $classes; + } + + /** + * @param string $path + * @param string $class + * @param string $prefix + * + * @return array + */ + private function findClassInPath($path, $class, $prefix) + { + if (!$path = realpath($path)) { + return array(); + } + + $classes = array(); + $filename = $class.'.php'; + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { + if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) { + $classes[] = $class; + } + } + + return $classes; + } + + /** + * @param string $path + * @param string $file + * @param string $prefix + * + * @return string|null + */ + private function convertFileToClass($path, $file, $prefix) + { + $candidates = array( + // namespaced class + $namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file), + // namespaced class (with target dir) + $namespacedClassTargetDir = $prefix.str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file), + // PEAR class + str_replace('\\', '_', $namespacedClass), + // PEAR class (with target dir) + str_replace('\\', '_', $namespacedClassTargetDir), + ); + + // We cannot use the autoloader here as most of them use require; but if the class + // is not found, the new autoloader call will require the file again leading to a + // "cannot redeclare class" error. + foreach ($candidates as $candidate) { + if ($this->classExists($candidate)) { + return $candidate; + } + } + + require_once $file; + + foreach ($candidates as $candidate) { + if ($this->classExists($candidate)) { + return $candidate; + } + } + } + + /** + * @param string $class + * + * @return bool + */ + private function classExists($class) + { + return class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..6b87eb30a126e406b82bd8b493ac81506fbea805 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php @@ -0,0 +1,32 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; + +/** + * Attempts to convert fatal errors to exceptions. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +interface FatalErrorHandlerInterface +{ + /** + * Attempts to convert an error into an exception. + * + * @param array $error An array as returned by error_get_last() + * @param FatalErrorException $exception A FatalErrorException instance + * + * @return FatalErrorException|null A FatalErrorException instance if the class is able to convert the error, null otherwise + */ + public function handleError(array $error, FatalErrorException $exception); +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php new file mode 100644 index 0000000000000000000000000000000000000000..f460c66f8e2029f401d52b43089973838e987219 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @@ -0,0 +1,91 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\UndefinedFunctionException; +use Symfony\Component\Debug\Exception\FatalErrorException; + +/** + * ErrorHandler for undefined functions. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handleError(array $error, FatalErrorException $exception) + { + $messageLen = strlen($error['message']); + $notFoundSuffix = '()'; + $notFoundSuffixLen = strlen($notFoundSuffix); + if ($notFoundSuffixLen > $messageLen) { + return; + } + + if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { + return; + } + + $prefix = 'Call to undefined function '; + $prefixLen = strlen($prefix); + if (0 !== strpos($error['message'], $prefix)) { + return; + } + + $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); + if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) { + $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1); + $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex); + $message = sprintf( + 'Attempted to call function "%s" from namespace "%s" in %s line %d.', + $functionName, + $namespacePrefix, + $error['file'], + $error['line'] + ); + } else { + $functionName = $fullyQualifiedFunctionName; + $message = sprintf( + 'Attempted to call function "%s" from the global namespace in %s line %d.', + $functionName, + $error['file'], + $error['line'] + ); + } + + $candidates = array(); + foreach (get_defined_functions() as $type => $definedFunctionNames) { + foreach ($definedFunctionNames as $definedFunctionName) { + if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) { + $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1); + } else { + $definedFunctionNameBasename = $definedFunctionName; + } + + if ($definedFunctionNameBasename === $functionName) { + $candidates[] = '\\'.$definedFunctionName; + } + } + } + + if ($candidates) { + sort($candidates); + $message .= ' Did you mean to call: '.implode(', ', array_map(function ($val) { + return '"'.$val.'"'; + }, $candidates)).'?'; + } + + return new UndefinedFunctionException($message, $exception); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php new file mode 100644 index 0000000000000000000000000000000000000000..7cc55c6b06f5a7fa8196977862c17ecab00ee84b --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -0,0 +1,54 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\Exception\UndefinedMethodException; + +/** + * ErrorHandler for undefined methods. + * + * @author Grégoire Pineau <lyrixx@lyrixx.info> + */ +class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handleError(array $error, FatalErrorException $exception) + { + preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); + if (!$matches) { + return; + } + + $className = $matches[1]; + $methodName = $matches[2]; + + $message = sprintf('Attempted to call method "%s" on class "%s" in %s line %d.', $methodName, $className, $error['file'], $error['line']); + + $candidates = array(); + foreach (get_class_methods($className) as $definedMethodName) { + $lev = levenshtein($methodName, $definedMethodName); + if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) { + $candidates[] = $definedMethodName; + } + } + + if ($candidates) { + sort($candidates); + $message .= sprintf(' Did you mean to call: "%s"?', implode('", "', $candidates)); + } + + return new UndefinedMethodException($message, $exception); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE b/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..396cc98ee9b756bc9c90ff33e59dee33c7e30919 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -0,0 +1,190 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests; + +use Symfony\Component\Debug\DebugClassLoader; +use Symfony\Component\Debug\ErrorHandler; +use Symfony\Component\Debug\Exception\ContextErrorException; + +class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var int Error reporting level before running tests. + */ + private $errorReporting; + + private $loader; + + protected function setUp() + { + $this->errorReporting = error_reporting(E_ALL | E_STRICT); + $this->loader = new ClassLoader(); + spl_autoload_register(array($this->loader, 'loadClass'), true, true); + DebugClassLoader::enable(); + } + + protected function tearDown() + { + DebugClassLoader::disable(); + spl_autoload_unregister(array($this->loader, 'loadClass')); + error_reporting($this->errorReporting); + } + + public function testIdempotence() + { + DebugClassLoader::enable(); + + $functions = spl_autoload_functions(); + foreach ($functions as $function) { + if (is_array($function) && $function[0] instanceof DebugClassLoader) { + $reflClass = new \ReflectionClass($function[0]); + $reflProp = $reflClass->getProperty('classLoader'); + $reflProp->setAccessible(true); + + $this->assertNotInstanceOf('Symfony\Component\Debug\DebugClassLoader', $reflProp->getValue($function[0])); + + return; + } + } + + $this->fail('DebugClassLoader did not register'); + } + + public function testUnsilencing() + { + ob_start(); + $bak = array( + ini_set('log_errors', 0), + ini_set('display_errors', 1), + ); + + // See below: this will fail with parse error + // but this should not be @-silenced. + @class_exists(__NAMESPACE__.'\TestingUnsilencing', true); + + ini_set('log_errors', $bak[0]); + ini_set('display_errors', $bak[1]); + $output = ob_get_clean(); + + $this->assertStringMatchesFormat('%aParse error%a', $output); + } + + public function testStacking() + { + // the ContextErrorException must not be loaded to test the workaround + // for https://bugs.php.net/65322. + if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) { + $this->markTestSkipped('The ContextErrorException class is already loaded.'); + } + + ErrorHandler::register(); + + try { + // Trigger autoloading + E_STRICT at compile time + // which in turn triggers $errorHandler->handle() + // that again triggers autoloading for ContextErrorException. + // Error stacking works around the bug above and everything is fine. + + eval(' + namespace '.__NAMESPACE__.'; + class ChildTestingStacking extends TestingStacking { function foo($bar) {} } + '); + $this->fail('ContextErrorException expected'); + } catch (\ErrorException $exception) { + // if an exception is thrown, the test passed + restore_error_handler(); + restore_exception_handler(); + $this->assertEquals(E_STRICT, $exception->getSeverity()); + $this->assertStringStartsWith(__FILE__, $exception->getFile()); + $this->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage()); + } catch (\Exception $e) { + restore_error_handler(); + restore_exception_handler(); + + throw $e; + } + } + + /** + * @expectedException \RuntimeException + */ + public function testNameCaseMismatch() + { + class_exists(__NAMESPACE__.'\TestingCaseMismatch', true); + } + + /** + * @expectedException \RuntimeException + */ + public function testFileCaseMismatch() + { + if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) { + $this->markTestSkipped('Can only be run on case insensitive filesystems'); + } + + class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true); + } + + /** + * @expectedException \RuntimeException + */ + public function testPsr4CaseMismatch() + { + class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true); + } + + public function testNotPsr0() + { + $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\NotPSR0', true)); + } + + public function testNotPsr0Bis() + { + $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\NotPSR0bis', true)); + } + + public function testClassAlias() + { + $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\ClassAlias', true)); + } +} + +class ClassLoader +{ + public function loadClass($class) + { + } + + public function getClassMap() + { + return array(__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php'); + } + + public function findFile($class) + { + if (__NAMESPACE__.'\TestingUnsilencing' === $class) { + eval('-- parse error --'); + } elseif (__NAMESPACE__.'\TestingStacking' === $class) { + eval('namespace '.__NAMESPACE__.'; class TestingStacking { function foo() {} }'); + } elseif (__NAMESPACE__.'\TestingCaseMismatch' === $class) { + eval('namespace '.__NAMESPACE__.'; class TestingCaseMisMatch {}'); + } elseif (__NAMESPACE__.'\Fixtures\CaseMismatch' === $class) { + return __DIR__.'/Fixtures/CaseMismatch.php'; + } elseif (__NAMESPACE__.'\Fixtures\Psr4CaseMismatch' === $class) { + return __DIR__.'/Fixtures/psr4/Psr4CaseMismatch.php'; + } elseif (__NAMESPACE__.'\Fixtures\NotPSR0' === $class) { + return __DIR__.'/Fixtures/reallyNotPsr0.php'; + } elseif (__NAMESPACE__.'\Fixtures\NotPSR0bis' === $class) { + return __DIR__.'/Fixtures/notPsr0Bis.php'; + } + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 24c422fe54c8d94168d04ad287f3f43e115314b3..603e0d59ae53c11d92e6c08d66a1e97db5fb3915 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Debug\Tests; use Symfony\Component\Debug\ErrorHandler; +use Symfony\Component\Debug\Exception\ContextErrorException; /** * ErrorHandlerTest @@ -20,99 +21,229 @@ */ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase { - public function testCompileTimeError() + /** + * @var int Error reporting level before running tests. + */ + protected $errorReporting; + + /** + * @var string Display errors setting before running tests. + */ + protected $displayErrors; + + public function setUp() { - // the ContextErrorException must not be loaded for this test to work - if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) { - $this->markTestSkipped('The ContextErrorException class is already loaded.'); - } - - $handler = ErrorHandler::register(E_ALL | E_STRICT); - $displayErrors = ini_get('display_errors'); + $this->errorReporting = error_reporting(E_ALL | E_STRICT); + $this->displayErrors = ini_get('display_errors'); ini_set('display_errors', '1'); + } + + public function tearDown() + { + ini_set('display_errors', $this->displayErrors); + error_reporting($this->errorReporting); + } + + public function testNotice() + { + ErrorHandler::register(); try { - // trigger compile time error - eval(<<<'PHP' -class _BaseCompileTimeError { function foo() {} } -class _CompileTimeError extends _BaseCompileTimeError { function foo($invalid) {} } -PHP - ); - } catch(\Exception $e) { + self::triggerNotice($this); + $this->fail('ContextErrorException expected'); + } catch (ContextErrorException $exception) { // if an exception is thrown, the test passed + restore_error_handler(); + $this->assertEquals(E_NOTICE, $exception->getSeverity()); + $this->assertEquals(__FILE__, $exception->getFile()); + $this->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); + $this->assertArrayHasKey('foobar', $exception->getContext()); + + $trace = $exception->getTrace(); + $this->assertEquals(__FILE__, $trace[0]['file']); + $this->assertEquals('Symfony\Component\Debug\ErrorHandler', $trace[0]['class']); + $this->assertEquals('handle', $trace[0]['function']); + $this->assertEquals('->', $trace[0]['type']); + + $this->assertEquals(__FILE__, $trace[1]['file']); + $this->assertEquals(__CLASS__, $trace[1]['class']); + $this->assertEquals('triggerNotice', $trace[1]['function']); + $this->assertEquals('::', $trace[1]['type']); + + $this->assertEquals(__CLASS__, $trace[2]['class']); + $this->assertEquals('testNotice', $trace[2]['function']); + $this->assertEquals('->', $trace[2]['type']); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; } - ini_set('display_errors', $displayErrors); restore_error_handler(); } + // dummy function to test trace in error handler. + private static function triggerNotice($that) + { + // dummy variable to check for in error handler. + $foobar = 123; + $that->assertSame('', $foo.$foo.$bar); + } + public function testConstruct() { - $handler = ErrorHandler::register(3); + try { + $handler = ErrorHandler::register(3); - $level = new \ReflectionProperty($handler, 'level'); - $level->setAccessible(true); + $level = new \ReflectionProperty($handler, 'level'); + $level->setAccessible(true); - $this->assertEquals(3, $level->getValue($handler)); + $this->assertEquals(3, $level->getValue($handler)); - restore_error_handler(); + restore_error_handler(); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; + } } public function testHandle() { - $handler = ErrorHandler::register(0); - $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo')); + try { + $handler = ErrorHandler::register(0); + $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array())); - restore_error_handler(); + restore_error_handler(); - $handler = ErrorHandler::register(3); - $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo')); + $handler = ErrorHandler::register(3); + $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, array())); - restore_error_handler(); + restore_error_handler(); - $handler = ErrorHandler::register(3); - try { - $handler->handle(111, 'foo', 'foo.php', 12, 'foo'); - } catch (\ErrorException $e) { - $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); - $this->assertSame(111, $e->getSeverity()); - $this->assertSame('foo.php', $e->getFile()); - $this->assertSame(12, $e->getLine()); - } + $handler = ErrorHandler::register(3); + try { + $handler->handle(111, 'foo', 'foo.php', 12, array()); + } catch (\ErrorException $e) { + $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); + $this->assertSame(111, $e->getSeverity()); + $this->assertSame('foo.php', $e->getFile()); + $this->assertSame(12, $e->getLine()); + } - restore_error_handler(); + restore_error_handler(); - $handler = ErrorHandler::register(E_USER_DEPRECATED); - $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); + $handler = ErrorHandler::register(E_USER_DEPRECATED); + $this->assertFalse($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); - restore_error_handler(); + restore_error_handler(); - $handler = ErrorHandler::register(E_DEPRECATED); - $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); + $handler = ErrorHandler::register(E_DEPRECATED); + $this->assertFalse($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, array())); - restore_error_handler(); + restore_error_handler(); + + $logger = $this->getMock('Psr\Log\LoggerInterface'); + + $that = $this; + $warnArgCheck = function ($message, $context) use ($that) { + $that->assertEquals('foo', $message); + $that->assertArrayHasKey('type', $context); + $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION); + $that->assertArrayHasKey('stack', $context); + $that->assertInternalType('array', $context['stack']); + }; + + $logger + ->expects($this->once()) + ->method('warning') + ->will($this->returnCallback($warnArgCheck)) + ; - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $handler = ErrorHandler::register(E_USER_DEPRECATED); + $handler->setLogger($logger); + $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); - $that = $this; - $warnArgCheck = function($message, $context) use ($that) { - $that->assertEquals('foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION); - $that->assertArrayHasKey('stack', $context); - $that->assertInternalType('array', $context['stack']); - }; + restore_error_handler(); - $logger - ->expects($this->once()) - ->method('warning') - ->will($this->returnCallback($warnArgCheck)) - ; + $logger = $this->getMock('Psr\Log\LoggerInterface'); - $handler = ErrorHandler::register(E_USER_DEPRECATED); - $handler->setLogger($logger); - $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'); + $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); + }; + + $logger + ->expects($this->once()) + ->method('log') + ->will($this->returnCallback($logArgCheck)) + ; + + $handler = ErrorHandler::register(E_NOTICE); + $handler->setLogger($logger, 'scream'); + unset($undefVar); + @$undefVar++; + + restore_error_handler(); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; + } + } + + /** + * @dataProvider provideFatalErrorHandlersData + */ + public function testFatalErrorHandlers($error, $class, $translatedMessage) + { + $handler = new ErrorHandler(); + $exceptionHandler = new MockExceptionHandler(); + + $m = new \ReflectionMethod($handler, 'handleFatalError'); + $m->setAccessible(true); + $m->invoke($handler, array($exceptionHandler, 'handle'), $error); restore_error_handler(); + $this->assertInstanceof($class, $exceptionHandler->e); + // class names are case insensitive and PHP/HHVM do not return the same + $this->assertSame(strtolower($translatedMessage), strtolower($exceptionHandler->e->getMessage())); + $this->assertSame($error['type'], $exceptionHandler->e->getSeverity()); + $this->assertSame($error['file'], $exceptionHandler->e->getFile()); + $this->assertSame($error['line'], $exceptionHandler->e->getLine()); + } + + public function provideFatalErrorHandlersData() + { + return array( + // undefined function + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function test_namespaced_function_again()', + ), + 'Symfony\Component\Debug\Exception\UndefinedFunctionException', + 'Attempted to call function "test_namespaced_function_again" from the global namespace in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\test_namespaced_function_again"?', + ), + // class not found + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'WhizBangFactory\' not found', + ), + 'Symfony\Component\Debug\Exception\ClassNotFoundException', + 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?', + ), + ); } } + +function test_namespaced_function_again() +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php index 4a1d99e816a149189b1156821dae7d741a9dbb88..0c0f42d80b5142cb8cab9cfda4f9bf9d4fc0d3de 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php @@ -113,8 +113,7 @@ public function testFlattenHttpException(\Exception $exception, $statusCode) $this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.'); $this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.'); - $this->assertEquals(get_class($exception), $flattened->getClass(), 'The class is set to the class of the original exception'); - + $this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception'); } /** @@ -160,13 +159,13 @@ public function testToArray(\Exception $exception, $statusCode) $this->assertEquals(array( array( - 'message'=> 'test', - 'class'=>'Exception', - 'trace'=>array(array( + 'message' => 'test', + 'class' => 'Exception', + 'trace' => array(array( 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', 'file' => 'foo.php', 'line' => 123, - 'args' => array() + 'args' => array(), )), - ) + ), ), $flattened->toArray()); } @@ -202,7 +201,7 @@ public function testSetTraceIncompleteClass() 'line' => 123, 'function' => 'test', 'args' => array( - unserialize('O:14:"BogusTestClass":0:{}') + unserialize('O:14:"BogusTestClass":0:{}'), ), ), ), @@ -211,9 +210,9 @@ public function testSetTraceIncompleteClass() $this->assertEquals(array( array( - 'message'=> 'test', - 'class'=>'Exception', - 'trace'=>array( + 'message' => 'test', + 'class' => 'Exception', + 'trace' => array( array( 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', 'file' => 'foo.php', 'line' => 123, @@ -224,12 +223,12 @@ public function testSetTraceIncompleteClass() 'file' => __FILE__, 'line' => 123, 'args' => array( array( - 'incomplete-object', 'BogusTestClass' + 'incomplete-object', 'BogusTestClass', ), ), - ) + ), ), - ) + ), ), $flattened->toArray()); } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index f187e2d09929dde0ee094266d1c16dd267c521fd..b202b8f1dec22c1a2c5a9e086e1bf59c6af55678 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -17,13 +17,6 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testDebug() { $handler = new ExceptionHandler(false); @@ -64,6 +57,6 @@ public function testHeaders() public function testNestedExceptions() { $handler = new ExceptionHandler(true); - $response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar'))); + $response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar'))); } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..be6c74af9c1d0da87114537f67df253b31b8df26 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -0,0 +1,105 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; + +class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideClassNotFoundData + */ + public function testClassNotFound($error, $translatedMessage) + { + $handler = new ClassNotFoundFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + $this->assertSame($translatedMessage, $exception->getMessage()); + $this->assertSame($error['type'], $exception->getSeverity()); + $this->assertSame($error['file'], $exception->getFile()); + $this->assertSame($error['line'], $exception->getLine()); + } + + public function provideClassNotFoundData() + { + return array( + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'WhizBangFactory\' not found', + ), + 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found', + ), + 'Attempted to load class "WhizBangFactory" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'UndefinedFunctionException\' not found', + ), + 'Attempted to load class "UndefinedFunctionException" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony\Component\Debug\Exception\UndefinedFunctionException.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'PEARClass\' not found', + ), + 'Attempted to load class "PEARClass" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony_Component_Debug_Tests_Fixtures_PEARClass.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', + ), + 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\Component\Debug\Exception\UndefinedFunctionException.', + ), + ); + } + + public function testCannotRedeclareClass() + { + if (!file_exists(__DIR__.'/../FIXTURES/REQUIREDTWICE.PHP')) { + $this->markTestSkipped('Can only be run on case insensitive filesystems'); + } + + require_once __DIR__.'/../FIXTURES/REQUIREDTWICE.PHP'; + + $error = array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'Foo\\Bar\\RequiredTwice\' not found', + ); + + $handler = new ClassNotFoundFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..27d50ff86f5834547b9b7ac15cfb8af2317e0f5c --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php @@ -0,0 +1,80 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; + +class UndefinedFunctionFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideUndefinedFunctionData + */ + public function testUndefinedFunction($error, $translatedMessage) + { + $handler = new UndefinedFunctionFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception); + // class names are case insensitive and PHP/HHVM do not return the same + $this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage())); + $this->assertSame($error['type'], $exception->getSeverity()); + $this->assertSame($error['file'], $exception->getFile()); + $this->assertSame($error['line'], $exception->getLine()); + } + + public function provideUndefinedFunctionData() + { + return array( + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function test_namespaced_function()', + ), + 'Attempted to call function "test_namespaced_function" from the global namespace in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function"?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()', + ), + 'Attempted to call function "test_namespaced_function" from namespace "Foo\\Bar\\Baz" in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function"?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function foo()', + ), + 'Attempted to call function "foo" from the global namespace in foo.php line 12.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function Foo\\Bar\\Baz\\foo()', + ), + 'Attempted to call function "foo" from namespace "Foo\Bar\Baz" in foo.php line 12.', + ), + ); + } +} + +function test_namespaced_function() +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8e1893c15f07e27b2dcb7745e082b40c408c7040 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -0,0 +1,66 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; + +class UndefinedMethodFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideUndefinedMethodData + */ + public function testUndefinedMethod($error, $translatedMessage) + { + $handler = new UndefinedMethodFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception); + $this->assertSame($translatedMessage, $exception->getMessage()); + $this->assertSame($error['type'], $exception->getSeverity()); + $this->assertSame($error['file'], $exception->getFile()); + $this->assertSame($error['line'], $exception->getLine()); + } + + public function provideUndefinedMethodData() + { + return array( + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined method SplObjectStorage::what()', + ), + 'Attempted to call method "what" on class "SplObjectStorage" in foo.php line 12.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined method SplObjectStorage::walid()', + ), + 'Attempted to call method "walid" on class "SplObjectStorage" in foo.php line 12. Did you mean to call: "valid"?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined method SplObjectStorage::offsetFet()', + ), + 'Attempted to call method "offsetFet" on class "SplObjectStorage" in foo.php line 12. Did you mean to call: "offsetGet", "offsetSet", "offsetUnset"?', + ), + ); + } +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php new file mode 100644 index 0000000000000000000000000000000000000000..9d6dbaa7124feba20de910abbff2abd49c833650 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php @@ -0,0 +1,3 @@ +<?php + +class_alias('Symfony\Component\Debug\Tests\Fixtures\NotPSR0bis', 'Symfony\Component\Debug\Tests\Fixtures\ClassAlias'); diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php new file mode 100644 index 0000000000000000000000000000000000000000..39f228182e0fac756ac32a559b87c0a8d27de9ae --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php @@ -0,0 +1,5 @@ +<?php + +class Symfony_Component_Debug_Tests_Fixtures_PEARClass +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/RequiredTwice.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/RequiredTwice.php new file mode 100644 index 0000000000000000000000000000000000000000..3c42d67b8a94d8d41086ff1df37033f98cc50e6a --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/RequiredTwice.php @@ -0,0 +1,7 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +class RequiredTwice +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/casemismatch.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/casemismatch.php new file mode 100644 index 0000000000000000000000000000000000000000..691d660fd1d5b8d7e367b73eb1243c5d05a4a48a --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/casemismatch.php @@ -0,0 +1,7 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +class CaseMismatch +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/notPsr0Bis.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/notPsr0Bis.php new file mode 100644 index 0000000000000000000000000000000000000000..4cf526719a6e67772a5cb6341240af869a6f80f0 --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/notPsr0Bis.php @@ -0,0 +1,7 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +class NotPSR0bis +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/psr4/Psr4CaseMismatch.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/psr4/Psr4CaseMismatch.php new file mode 100644 index 0000000000000000000000000000000000000000..ec48dd22b4999740f606972241278208b2da9aed --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/psr4/Psr4CaseMismatch.php @@ -0,0 +1,7 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +class PSR4CaseMismatch +{ +} diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/reallyNotPsr0.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/reallyNotPsr0.php new file mode 100644 index 0000000000000000000000000000000000000000..8554725aa8b3b6605d75899c0496c10876cc4aab --- /dev/null +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/reallyNotPsr0.php @@ -0,0 +1,7 @@ +<?php + +namespace Symfony\Component\Debug\Tests\Fixtures; + +class NotPSR0 +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/AccessException.php b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/MockExceptionHandler.php similarity index 51% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/AccessException.php rename to core/vendor/symfony/debug/Symfony/Component/Debug/Tests/MockExceptionHandler.php index b3a854646efce5d600db7b1cc5c65d38b31248ac..a85d2d15e7131e290c3dc6e1972ad8707567125c 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/AccessException.php +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/Tests/MockExceptionHandler.php @@ -9,13 +9,16 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Debug\Tests; -/** - * Thrown when a property path is not available. - * - * @author Stéphane Escandell <stephane.escandell@gmail.com> - */ -class AccessException extends RuntimeException +use Symfony\Component\Debug\ExceptionHandler; + +class MockExceptionHandler extends Exceptionhandler { + public $e; + + public function handle(\Exception $e) + { + $this->e = $e; + } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json b/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json index 35b170a3c0e173cc2be2cf2b646be2e3ca6f8ecb..b9cd2d340a36315b69459f17a27f7f84a010af4e 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/composer.json @@ -24,8 +24,7 @@ }, "suggest": { "symfony/http-foundation": "", - "symfony/http-kernel": "", - "symfony/class-loader": "" + "symfony/http-kernel": "" }, "autoload": { "psr-0": { "Symfony\\Component\\Debug\\": "" } @@ -34,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist b/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist index 8bab165e1053733b678c32a8a2fe1e767c584065..2a8cb8143e1a635b0ceb5fc192d0c05154eff433 100644 --- a/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist +++ b/core/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Alias.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Alias.php index fd75578cdb9c8e2d3c3f5de130921b1207016235..021b0c650e8a249e5a182e89604dcf1f973e06be 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Alias.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Alias.php @@ -23,7 +23,7 @@ class Alias * Constructor. * * @param string $id Alias identifier - * @param Boolean $public If this alias is public + * @param bool $public If this alias is public * * @api */ @@ -36,7 +36,7 @@ public function __construct($id, $public = true) /** * Checks if this DI Alias should be public or not. * - * @return Boolean + * @return bool * * @api */ @@ -48,13 +48,13 @@ public function isPublic() /** * Sets if this Alias is public. * - * @param Boolean $boolean If this Alias should be public + * @param bool $boolean If this Alias should be public * * @api */ public function setPublic($boolean) { - $this->public = (Boolean) $boolean; + $this->public = (bool) $boolean; } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md index 9a41e85705514b5a1970ff0bb2ad477a59745eca..5a88e34e47d50c7b88bde2cd6221a736db1c1e8f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +2.5.0 +----- + +* added DecoratorServicePass and a way to override a service definition (Definition::setDecoratedService()) +* deprecated SimpleXMLElement class. + 2.4.0 ----- diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index f7aa471dd8a34b074efa68fa01a39246028a990f..f488052596a907db91af11b23a3026a8bb496440 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -36,15 +36,15 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface /** * Constructor. * - * @param Boolean $onlyConstructorArguments Sets this Service Reference pass to ignore method calls + * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls */ public function __construct($onlyConstructorArguments = false) { - $this->onlyConstructorArguments = (Boolean) $onlyConstructorArguments; + $this->onlyConstructorArguments = (bool) $onlyConstructorArguments; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function setRepeatedPass(RepeatedPass $repeatedPass) { @@ -69,7 +69,11 @@ public function process(ContainerBuilder $container) $this->currentId = $id; $this->currentDefinition = $definition; + $this->processArguments($definition->getArguments()); + if ($definition->getFactoryService()) { + $this->processArguments(array(new Reference($definition->getFactoryService()))); + } if (!$this->onlyConstructorArguments) { $this->processArguments($definition->getMethodCalls()); @@ -132,7 +136,7 @@ private function getDefinitionId($id) } if (!$this->container->hasDefinition($id)) { - return null; + return; } return $id; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php index 9351b11b39dcf6a59cebeaa62d3d62e45e39f737..aa11d38da175f710347d1e726b13eb31577ec3a5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php @@ -159,7 +159,7 @@ private function validateScope(Reference $reference, Definition $definition = nu private function getDefinition($id) { if (!$this->container->hasDefinition($id)) { - return null; + return; } return $this->container->getDefinition($id); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php new file mode 100644 index 0000000000000000000000000000000000000000..dea9f030ef51be0b5a44e82040cd2e20bd01d89c --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php @@ -0,0 +1,54 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Alias; + +/** + * Overwrites a service but keeps the overridden one. + * + * @author Christophe Coevoet <stof@notk.org> + * @author Fabien Potencier <fabien@symfony.com> + */ +class DecoratorServicePass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + foreach ($container->getDefinitions() as $id => $definition) { + if (!$decorated = $definition->getDecoratedService()) { + continue; + } + $definition->setDecoratedService(null); + + list ($inner, $renamedId) = $decorated; + if (!$renamedId) { + $renamedId = $id.'.inner'; + } + + // we create a new alias/service for the service we are replacing + // to be able to reference it in the new one + if ($container->hasAlias($inner)) { + $alias = $container->getAlias($inner); + $public = $alias->isPublic(); + $container->setAlias($renamedId, new Alias((string) $alias, false)); + } else { + $definition = $container->getDefinition($inner); + $public = $definition->isPublic(); + $definition->setPublic(false); + $container->setDefinition($renamedId, $definition); + } + + $container->setAlias($inner, new Alias($id, $public)); + } + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index ba1688f5e86752f8ad816b43e8ed7d338e36f996..d2d3599046456ff8858488316375dc8cae395aea 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -30,7 +30,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface private $currentId; /** - * {@inheritDoc} + * {@inheritdoc} */ public function setRepeatedPass(RepeatedPass $repeatedPass) { @@ -62,6 +62,11 @@ public function process(ContainerBuilder $container) $definition->setProperties( $this->inlineArguments($container, $definition->getProperties()) ); + + $configurator = $this->inlineArguments($container, array($definition->getConfigurator())); + $definition->setConfigurator( + $configurator[0] + ); } } @@ -109,7 +114,7 @@ private function inlineArguments(ContainerBuilder $container, array $arguments) * @param string $id * @param Definition $definition * - * @return Boolean If the definition is inlineable + * @return bool If the definition is inlineable */ private function isInlineableDefinition(ContainerBuilder $container, $id, Definition $definition) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php index 7573084c36c39c5a21410a9d4be46506f2727cae..92a98870403eb793fe110f490fd9205552f72c25 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php @@ -22,7 +22,7 @@ class MergeExtensionConfigurationPass implements CompilerPassInterface { /** - * {@inheritDoc} + * {@inheritdoc} */ public function process(ContainerBuilder $container) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index ac395db22e9a27e810f65f9aea3beebf953122c1..bcef41052b9bce42c3ab89dc428bfd5717ab2b5f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -46,6 +46,7 @@ public function __construct() $this->optimizationPasses = array( new ResolveDefinitionTemplatesPass(), + new DecoratorServicePass(), new ResolveParameterPlaceHoldersPass(), new CheckDefinitionValidityPass(), new ResolveReferencesToAliasesPass(), diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php index 0c7be667a19c09cf900ff00546dddb481577a7e0..9e18a9ebde062f54c303be7ed31ab2a5a5385a5b 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php @@ -23,7 +23,7 @@ class RemoveUnusedDefinitionsPass implements RepeatablePassInterface private $repeatedPass; /** - * {@inheritDoc} + * {@inheritdoc} */ public function setRepeatedPass(RepeatedPass $repeatedPass) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php index 6073abe69d66c9960fabbd91c125046d4720bcca..9b7db4032418a359c16929249a58a597035cef1d 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php @@ -22,7 +22,7 @@ class RepeatedPass implements CompilerPassInterface { /** - * @var Boolean + * @var bool */ private $repeat = false; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php index 4699ac34148e2c2e89a07cbd99d009de46f99f5e..4527840e73f0bd2654788f7954b448300ec006c6 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php @@ -127,7 +127,7 @@ private function resolveDefinition($id, DefinitionDecorator $definition) throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k)); } - $index = (integer) substr($k, strlen('index_')); + $index = (int) substr($k, strlen('index_')); $def->replaceArgument($index, $v); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php index 93d5806036bde56771e718a0390a9981de578f6a..83aef9b2c6456b95417cdf7c295fa84c30eb94e0 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php @@ -70,7 +70,7 @@ public function process(ContainerBuilder $container) * Processes arguments to determine invalid references. * * @param array $arguments An array of Reference objects - * @param Boolean $inMethodCall + * @param bool $inMethodCall * * @return array * diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php index 1de14fa62f96b90303a376d6ec0978017188f6df..dc9a1a00eadc826a56c5f822d521ded79b0d73c5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php @@ -33,7 +33,7 @@ class ServiceReferenceGraph * * @param string $id Id to check * - * @return Boolean + * @return bool */ public function hasNode($id) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php index 283f6de5ba0ef7d014b10579a5963424aa87825a..cc7288e8edccd8c37a6e7b489fb286e36a4b3b4c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php @@ -63,7 +63,7 @@ public function addOutEdge(ServiceReferenceGraphEdge $edge) /** * Checks if the value of this node is an Alias. * - * @return Boolean True if the value is an Alias instance + * @return bool True if the value is an Alias instance */ public function isAlias() { @@ -73,7 +73,7 @@ public function isAlias() /** * Checks if the value of this node is a Definition. * - * @return Boolean True if the value is a Definition instance + * @return bool True if the value is a Definition instance */ public function isDefinition() { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php index c4d8f16f32ee6ce891102aedee35f644c6465e16..3308d9f29ace9bf5ab945a774a0190695f431051 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php @@ -110,7 +110,7 @@ public function compile() /** * Returns true if the container parameter bag are frozen. * - * @return Boolean true if the container parameter bag are frozen, false otherwise + * @return bool true if the container parameter bag are frozen, false otherwise * * @api */ @@ -152,7 +152,7 @@ public function getParameter($name) * * @param string $name The parameter name * - * @return Boolean The presence of parameter in container + * @return bool The presence of parameter in container * * @api */ @@ -197,6 +197,12 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) $id = strtolower($id); + if ('service_container' === $id) { + // BC: 'service_container' is no longer a self-reference but always + // $this, so ignore this call. + // @todo Throw InvalidArgumentException in next major release. + return; + } if (self::SCOPE_CONTAINER !== $scope) { if (!isset($this->scopedServices[$scope])) { throw new RuntimeException(sprintf('You cannot set service "%s" of inactive scope.', $id)); @@ -225,7 +231,7 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) * * @param string $id The service identifier * - * @return Boolean true if the service is defined, false otherwise + * @return bool true if the service is defined, false otherwise * * @api */ @@ -233,6 +239,10 @@ public function has($id) { $id = strtolower($id); + if ('service_container' === $id) { + return true; + } + return isset($this->services[$id]) || array_key_exists($id, $this->services) || isset($this->aliases[$id]) @@ -247,13 +257,14 @@ public function has($id) * with a get{$id}Service() method, the former has always precedence. * * @param string $id The service identifier - * @param integer $invalidBehavior The behavior when the service does not exist + * @param int $invalidBehavior The behavior when the service does not exist * * @return object The associated service * - * @throws InvalidArgumentException if the service is not defined + * @throws InvalidArgumentException if the service is not defined * @throws ServiceCircularReferenceException When a circular reference is detected - * @throws ServiceNotFoundException When the service is not defined + * @throws ServiceNotFoundException When the service is not defined + * @throws \Exception if an exception has been thrown when the service has been resolved * * @see Reference * @@ -269,6 +280,9 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE if ($strtolower) { $id = strtolower($id); } + if ('service_container' === $id) { + return $this; + } if (isset($this->aliases[$id])) { $id = $this->aliases[$id]; } @@ -303,7 +317,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE throw new ServiceNotFoundException($id, null, null, $alternatives); } - return null; + return; } $this->loading[$id] = true; @@ -318,7 +332,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE } if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; + return; } throw $e; @@ -334,12 +348,18 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE * * @param string $id The service identifier * - * @return Boolean true if service has already been initialized, false otherwise + * @return bool true if service has already been initialized, false otherwise */ public function initialized($id) { $id = strtolower($id); + if ('service_container' === $id) { + // BC: 'service_container' was a synthetic service previously. + // @todo Change to false in next major release. + return true; + } + return isset($this->services[$id]) || array_key_exists($id, $this->services); } @@ -357,6 +377,7 @@ public function getServiceIds() $ids[] = self::underscore($match[1]); } } + $ids[] = 'service_container'; return array_unique(array_merge($ids, array_keys($this->services))); } @@ -491,7 +512,7 @@ public function addScope(ScopeInterface $scope) * * @param string $name The name of the scope * - * @return Boolean + * @return bool * * @api */ @@ -507,7 +528,7 @@ public function hasScope($name) * * @param string $name * - * @return Boolean + * @return bool * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php index 0e07ec6b159b12285ca9e77abc4e47bbd13e5639..c06b622da7d80bd3ff2578daaa0a7feb776eba0c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -90,17 +90,17 @@ class ContainerBuilder extends Container implements TaggedContainerInterface * If you are not using the loaders and therefore don't want * to depend on the Config component, set this flag to false. * - * @param Boolean $track true if you want to track resources, false otherwise + * @param bool $track true if you want to track resources, false otherwise */ public function setResourceTracking($track) { - $this->trackResources = (Boolean) $track; + $this->trackResources = (bool) $track; } /** * Checks if resources are tracked. * - * @return Boolean true if resources are tracked, false otherwise + * @return bool true if resources are tracked, false otherwise */ public function isTrackingResources() { @@ -174,7 +174,7 @@ public function getExtensions() * * @param string $name The name of the extension * - * @return Boolean If the extension exists + * @return bool If the extension exists * * @api */ @@ -428,7 +428,7 @@ public function removeDefinition($id) * * @param string $id The service identifier * - * @return Boolean true if the service is defined, false otherwise + * @return bool true if the service is defined, false otherwise * * @api */ @@ -443,7 +443,7 @@ public function has($id) * Gets a service. * * @param string $id The service identifier - * @param integer $invalidBehavior The behavior when the service does not exist + * @param int $invalidBehavior The behavior when the service does not exist * * @return object The associated service * @@ -460,51 +460,45 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV { $id = strtolower($id); + if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) { + return $service; + } + + if (isset($this->loading[$id])) { + throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); + } + + if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) { + return $this->get($this->aliasDefinitions[$id]); + } + try { - return parent::get($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); - } catch (InactiveScopeException $e) { + $definition = $this->getDefinition($id); + } catch (InvalidArgumentException $e) { if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; + return; } throw $e; - } catch (InvalidArgumentException $e) { - if (isset($this->loading[$id])) { - throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); - } + } - if (!$this->hasDefinition($id) && isset($this->aliasDefinitions[$id])) { - return $this->get($this->aliasDefinitions[$id]); - } + $this->loading[$id] = true; - try { - $definition = $this->getDefinition($id); - } catch (InvalidArgumentException $e) { - if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; - } + try { + $service = $this->createService($definition, $id); + } catch (\Exception $e) { + unset($this->loading[$id]); - throw $e; + if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { + return; } - $this->loading[$id] = true; - - try { - $service = $this->createService($definition, $id); - } catch (\Exception $e) { - unset($this->loading[$id]); - - if ($e instanceof InactiveScopeException && self::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { - return null; - } - - throw $e; - } + throw $e; + } - unset($this->loading[$id]); + unset($this->loading[$id]); - return $service; - } + return $service; } /** @@ -715,7 +709,7 @@ public function removeAlias($alias) * * @param string $id The service identifier * - * @return Boolean true if the alias exists, false otherwise + * @return bool true if the alias exists, false otherwise * * @api */ @@ -845,7 +839,7 @@ public function setDefinition($id, Definition $definition) * * @param string $id The service identifier * - * @return Boolean true if the service definition exists, false otherwise + * @return bool true if the service definition exists, false otherwise * * @api */ @@ -903,7 +897,7 @@ public function findDefinition($id) * * @param Definition $definition A service definition instance * @param string $id The service identifier - * @param Boolean $tryProxy Whether to try proxying the service with a lazy proxy + * @param bool $tryProxy Whether to try proxying the service with a lazy proxy * * @return object The service described by the service definition * diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php index 1951ae7b939c92e5dbae80f59b8c2f96e64d9ca2..77ee42b57cbe01247cef4ff41c9674ec8bc7ab83 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -65,7 +65,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE * * @param string $id The service identifier * - * @return Boolean true if the service is defined, false otherwise + * @return bool true if the service is defined, false otherwise * * @api */ @@ -89,7 +89,7 @@ public function getParameter($name); * * @param string $name The parameter name * - * @return Boolean The presence of parameter in container + * @return bool The presence of parameter in container * * @api */ @@ -137,7 +137,7 @@ public function addScope(ScopeInterface $scope); * * @param string $name * - * @return Boolean + * @return bool * * @api */ @@ -150,7 +150,7 @@ public function hasScope($name); * * @param string $name * - * @return Boolean + * @return bool * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php index 428fee27c3a21d1bb781be40b25a26d85bf0dfd6..f83c069c6390626c971f3b315a4f52004b68825c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php @@ -38,6 +38,7 @@ class Definition private $abstract = false; private $synchronized = false; private $lazy = false; + private $decoratedService; protected $arguments; @@ -100,6 +101,41 @@ public function setFactoryMethod($factoryMethod) return $this; } + /** + * Sets the service that this service is decorating. + * + * @param null|string $id The decorated service id, use null to remove decoration + * @param null|string $renamedId The new decorated service id + * + * @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) + { + if ($renamedId && $id == $renamedId) { + throw new \InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); + } + + if (null === $id) { + $this->decoratedService = null; + } else { + $this->decoratedService = array($id, $renamedId); + } + + return $this; + } + + /** + * 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 + */ + public function getDecoratedService() + { + return $this->decoratedService; + } + /** * Gets the factory method. * @@ -231,7 +267,7 @@ public function addArgument($argument) /** * Sets a specific argument * - * @param integer $index + * @param int $index * @param mixed $argument * * @return Definition The current instance @@ -266,7 +302,7 @@ public function getArguments() /** * Gets an argument to pass to the service constructor/factory method. * - * @param integer $index + * @param int $index * * @return mixed The argument value * @@ -350,7 +386,7 @@ public function removeMethodCall($method) * * @param string $method The method name to search for * - * @return Boolean + * @return bool * * @api */ @@ -441,7 +477,7 @@ public function addTag($name, array $attributes = array()) * * @param string $name * - * @return Boolean + * @return bool * * @api */ @@ -539,7 +575,7 @@ public function getScope() /** * Sets the visibility of this service. * - * @param Boolean $boolean + * @param bool $boolean * * @return Definition The current instance * @@ -547,7 +583,7 @@ public function getScope() */ public function setPublic($boolean) { - $this->public = (Boolean) $boolean; + $this->public = (bool) $boolean; return $this; } @@ -555,7 +591,7 @@ public function setPublic($boolean) /** * Whether this service is public facing * - * @return Boolean + * @return bool * * @api */ @@ -567,7 +603,7 @@ public function isPublic() /** * Sets the synchronized flag of this service. * - * @param Boolean $boolean + * @param bool $boolean * * @return Definition The current instance * @@ -575,7 +611,7 @@ public function isPublic() */ public function setSynchronized($boolean) { - $this->synchronized = (Boolean) $boolean; + $this->synchronized = (bool) $boolean; return $this; } @@ -583,7 +619,7 @@ public function setSynchronized($boolean) /** * Whether this service is synchronized. * - * @return Boolean + * @return bool * * @api */ @@ -595,13 +631,13 @@ public function isSynchronized() /** * Sets the lazy flag of this service. * - * @param Boolean $lazy + * @param bool $lazy * * @return Definition The current instance */ public function setLazy($lazy) { - $this->lazy = (Boolean) $lazy; + $this->lazy = (bool) $lazy; return $this; } @@ -609,7 +645,7 @@ public function setLazy($lazy) /** * Whether this service is lazy. * - * @return Boolean + * @return bool */ public function isLazy() { @@ -620,7 +656,7 @@ public function isLazy() * Sets whether this definition is synthetic, that is not constructed by the * container, but dynamically injected. * - * @param Boolean $boolean + * @param bool $boolean * * @return Definition the current instance * @@ -628,7 +664,7 @@ public function isLazy() */ public function setSynthetic($boolean) { - $this->synthetic = (Boolean) $boolean; + $this->synthetic = (bool) $boolean; return $this; } @@ -637,7 +673,7 @@ public function setSynthetic($boolean) * Whether this definition is synthetic, that is not constructed by the * container, but dynamically injected. * - * @return Boolean + * @return bool * * @api */ @@ -650,7 +686,7 @@ public function isSynthetic() * Whether this definition is abstract, that means it merely serves as a * template for other definitions. * - * @param Boolean $boolean + * @param bool $boolean * * @return Definition the current instance * @@ -658,7 +694,7 @@ public function isSynthetic() */ public function setAbstract($boolean) { - $this->abstract = (Boolean) $boolean; + $this->abstract = (bool) $boolean; return $this; } @@ -667,7 +703,7 @@ public function setAbstract($boolean) * Whether this definition is abstract, that means it merely serves as a * template for other definitions. * - * @return Boolean + * @return bool * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php index b7eed8c564d4d0d582c4c90cc24ec6cad9becdae..497c394dffedf13e2d78be1e8a1b2df94617df78 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -65,7 +65,7 @@ public function getChanges() } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -77,7 +77,7 @@ public function setClass($class) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -89,7 +89,7 @@ public function setFactoryClass($class) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -101,7 +101,7 @@ public function setFactoryMethod($method) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -113,7 +113,7 @@ public function setFactoryService($service) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -125,7 +125,7 @@ public function setConfigurator($callable) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -137,7 +137,7 @@ public function setFile($file) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -149,7 +149,7 @@ public function setPublic($boolean) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -166,7 +166,7 @@ public function setLazy($boolean) * If replaceArgument() has been used to replace an argument, this method * will return the replacement value. * - * @param integer $index + * @param int $index * * @return mixed The argument value * @@ -197,7 +197,7 @@ public function getArgument($index) * certain conventions when you want to overwrite the arguments of the * parent definition, otherwise your arguments will only be appended. * - * @param integer $index + * @param int $index * @param mixed $value * * @return DefinitionDecorator the current instance diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index 4499e5231074a48797db0483dea3dd9987cce49a..d9325c957d0b767e257c251dc03a3b57dbcb1ba0 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -12,11 +12,13 @@ namespace Symfony\Component\DependencyInjection\Dumper; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\DependencyInjection\Scope; /** * GraphvizDumper dumps a service container as a graphviz file. @@ -123,7 +125,7 @@ private function addEdges() * * @param string $id The service id used to find edges * @param array $arguments An array of arguments - * @param Boolean $required + * @param bool $required * @param string $name * * @return array An array of edges @@ -164,8 +166,14 @@ private function findNodes() $container = $this->cloneContainer(); foreach ($container->getDefinitions() as $id => $definition) { - $nodes[$id] = array('class' => str_replace('\\', '\\\\', $this->container->getParameterBag()->resolveValue($definition->getClass())), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted'))); + $className = $definition->getClass(); + try { + $className = $this->container->getParameterBag()->resolveValue($className); + } catch (ParameterNotFoundException $e) { + } + + $nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted'))); $container->setDefinition($id, new Definition('stdClass')); } @@ -193,8 +201,8 @@ private function cloneContainer() $container->setDefinitions($this->container->getDefinitions()); $container->setAliases($this->container->getAliases()); $container->setResources($this->container->getResources()); - foreach ($this->container->getScopes() as $scope) { - $container->addScope($scope); + foreach ($this->container->getScopes() as $scope => $parentScope) { + $container->addScope(new Scope($scope, $parentScope)); } foreach ($this->container->getExtensions() as $extension) { $container->registerExtension($extension); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 7be1fe2ece19304c63faefd3c2f7d971d68fa429..7ab109b21c436f52e072f2e556d653ed30aab086 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -61,7 +61,7 @@ class PhpDumper extends Dumper private $proxyDumper; /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -69,7 +69,7 @@ public function __construct(ContainerBuilder $container) { parent::__construct($container); - $this->inlinedDefinitions = new \SplObjectStorage; + $this->inlinedDefinitions = new \SplObjectStorage(); } /** @@ -159,6 +159,7 @@ private function addServiceLocalTempVariables($cId, $definition) $this->getServiceCallsFromArguments($iDefinition->getArguments(), $calls, $behavior); $this->getServiceCallsFromArguments($iDefinition->getMethodCalls(), $calls, $behavior); $this->getServiceCallsFromArguments($iDefinition->getProperties(), $calls, $behavior); + $this->getServiceCallsFromArguments(array($iDefinition->getConfigurator()), $calls, $behavior); } $code = ''; @@ -201,7 +202,7 @@ private function addProxyClasses() $code = ''; foreach ($definitions as $definition) { - $code .= "\n" . $this->getProxyDumper()->getProxyCode($definition); + $code .= "\n".$this->getProxyDumper()->getProxyCode($definition); } return $code; @@ -372,7 +373,7 @@ private function addServiceInstance($id, $definition) * @param string $id * @param Definition $definition * - * @return Boolean + * @return bool */ private function isSimpleInstance($id, $definition) { @@ -428,7 +429,10 @@ private function addServiceProperties($id, $definition, $variableName = 'instanc * * @param string $id * @param Definition $definition + * * @return string + * + * @throws ServiceCircularReferenceException when the container contains a circular reference */ private function addServiceInlinedDefinitionsSetup($id, $definition) { @@ -481,8 +485,15 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta } if (is_array($callable)) { - if ($callable[0] instanceof Reference) { - return sprintf(" %s->%s(\$%s);\n", $this->getServiceCall((string) $callable[0]), $callable[1], $variableName); + if ($callable[0] instanceof Reference + || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) { + return sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); + } + + $class = $this->dumpValue($callable[0]); + // If the class is a string we can optimize call_user_func away + if (strpos($class, "'") === 0) { + return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName); } return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); @@ -510,7 +521,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' : "\\".$class, $class); } elseif ($definition->getFactoryClass()) { $return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod()); } elseif ($definition->getFactoryService()) { @@ -549,7 +560,7 @@ private function addService($id, $definition) if ($definition->isLazy()) { $lazyInitialization = '$lazyLoad = true'; - $lazyInitializationDoc = "\n * @param boolean \$lazyLoad whether to try lazy-loading the service with a proxy\n *"; + $lazyInitializationDoc = "\n * @param bool \$lazyLoad whether to try lazy-loading the service with a proxy\n *"; } else { $lazyInitialization = ''; $lazyInitializationDoc = ''; @@ -632,6 +643,8 @@ private function addServices() * * @param string $id A service identifier * @param Definition $definition A Definition instance + * + * @return string|null */ private function addServiceSynchronizer($id, Definition $definition) { @@ -689,6 +702,13 @@ private function addNewInstance($id, Definition $definition, $return, $instantia if (null !== $definition->getFactoryMethod()) { if (null !== $definition->getFactoryClass()) { + $class = $this->dumpValue($definition->getFactoryClass()); + + // If the class is a string we can optimize call_user_func away + if (strpos($class, "'") === 0) { + return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $definition->getFactoryMethod(), $arguments ? implode(', ', $arguments) : ''); + } + return sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : ''); } @@ -703,7 +723,7 @@ private function addNewInstance($id, Definition $definition, $return, $instantia return sprintf(" \$class = %s;\n\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments)); } - return sprintf(" $return{$instantiation}new \\%s(%s);\n", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments)); + return sprintf(" $return{$instantiation}new %s(%s);\n", $this->dumpLiteralClass($class), implode(', ', $arguments)); } /** @@ -788,6 +808,8 @@ private function addFrozenConstructor() { $code = <<<EOF + private \$parameters; + /** * Constructor. */ @@ -846,7 +868,7 @@ private function addMethodMap() $code .= ' '.var_export($id, true).' => '.var_export('get'.$this->camelize($id).'Service', true).",\n"; } - return $code . " );\n"; + return $code." );\n"; } /** @@ -874,7 +896,7 @@ private function addAliases() $code .= ' '.var_export($alias, true).' => '.var_export($id, true).",\n"; } - return $code . " );\n"; + return $code." );\n"; } /** @@ -927,7 +949,7 @@ public function setParameter(\$name, \$value) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getParameterBag() { @@ -962,7 +984,7 @@ protected function getDefaultParameters() * * @param array $parameters * @param string $path - * @param integer $indent + * @param int $indent * * @return string * @@ -1072,7 +1094,8 @@ private function getInlinedDefinitions(Definition $definition) $definitions = array_merge( $this->getDefinitionsFromArguments($definition->getArguments()), $this->getDefinitionsFromArguments($definition->getMethodCalls()), - $this->getDefinitionsFromArguments($definition->getProperties()) + $this->getDefinitionsFromArguments($definition->getProperties()), + $this->getDefinitionsFromArguments(array($definition->getConfigurator())) ); $this->inlinedDefinitions->offsetSet($definition, $definitions); @@ -1113,10 +1136,10 @@ private function getDefinitionsFromArguments(array $arguments) * * @param string $id * @param array $arguments - * @param Boolean $deep + * @param bool $deep * @param array $visited * - * @return Boolean + * @return bool */ private function hasReference($id, array $arguments, $deep = false, array $visited = array()) { @@ -1151,7 +1174,7 @@ private function hasReference($id, array $arguments, $deep = false, array $visit * Dumps values. * * @param array $value - * @param Boolean $interpolate + * @param bool $interpolate * * @return string * @@ -1207,7 +1230,7 @@ private function dumpValue($value, $interpolate = true) return $this->getServiceCall((string) $value, $value); } elseif ($value instanceof Expression) { - return $this->getExpressionLanguage()->compile((string) $value, array('container')); + return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container')); } elseif ($value instanceof Parameter) { return $this->dumpParameter($value); } elseif (true === $interpolate && is_string($value)) { @@ -1232,6 +1255,18 @@ private function dumpValue($value, $interpolate = true) } } + /** + * Dumps a string to a literal (aka PHP Code) class value. + * + * @param string $class + * + * @return string + */ + private function dumpLiteralClass($class) + { + return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1); + } + /** * Dumps a parameter * diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 31bec31b22456e8c84a638abe0d90602343dc769..e3a533eed2783c2a0cf6dcfc481e9c5febcc3be1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -120,6 +120,9 @@ private function addService($definition, $id, \DOMElement $parent) if ($definition->getFactoryMethod()) { $service->setAttribute('factory-method', $definition->getFactoryMethod()); } + if ($definition->getFactoryClass()) { + $service->setAttribute('factory-class', $definition->getFactoryClass()); + } if ($definition->getFactoryService()) { $service->setAttribute('factory-service', $definition->getFactoryService()); } @@ -138,6 +141,13 @@ private function addService($definition, $id, \DOMElement $parent) if ($definition->isLazy()) { $service->setAttribute('lazy', 'true'); } + if (null !== $decorated = $definition->getDecoratedService()) { + list ($decorated, $renamedId) = $decorated; + $service->setAttribute('decorates', $decorated); + if (null !== $renamedId) { + $service->setAttribute('decoration-inner-name', $renamedId); + } + } foreach ($definition->getTags() as $name => $tags) { foreach ($tags as $attributes) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index b4748545dc2a7b446583f58b186ea51f826e0248..613620c2333ab134e9c71f648427ef731e4763b7 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -139,6 +139,14 @@ private function addService($id, $definition) $code .= sprintf(" scope: %s\n", $scope); } + if (null !== $decorated = $definition->getDecoratedService()) { + list ($decorated, $renamedId) = $decorated; + $code .= sprintf(" decorates: %s\n", $decorated); + if (null !== $renamedId) { + $code .= sprintf(" decoration_inner_name: %s\n", $renamedId); + } + } + if ($callable = $definition->getConfigurator()) { if (is_array($callable)) { if ($callable[0] instanceof Reference) { @@ -283,7 +291,7 @@ private function getExpressionCall($expression) * Prepares parameters. * * @param array $parameters - * @param Boolean $escape + * @param bool $escape * * @return array */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php index 6fcd9018dc761bb2e7a54af5e592b104bb4e26e9..51bff080124e2f79190254e429a73bd5c17b858e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php @@ -24,7 +24,7 @@ interface ConfigurationExtensionInterface /** * Returns extension configuration * - * @param array $config $config An array of configuration values + * @param array $config An array of configuration values * @param ContainerBuilder $container A ContainerBuilder instance * * @return ConfigurationInterface|null The configuration or null diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php index a39fe37ed4f08d0d9c985e985c53dedbe09161f1..0ebe4e484ae5d060c4ad29d013b875110ace535c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -78,7 +78,7 @@ public function getAlias() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getConfiguration(array $config, ContainerBuilder $container) { @@ -96,8 +96,6 @@ public function getConfiguration(array $config, ContainerBuilder $container) return $configuration; } } - - return null; } final protected function processConfiguration(ConfigurationInterface $configuration, array $configs) @@ -111,7 +109,7 @@ final protected function processConfiguration(ConfigurationInterface $configurat * @param ContainerBuilder $container * @param array $config * - * @return Boolean Whether the configuration is enabled + * @return bool Whether the configuration is enabled * * @throws InvalidArgumentException When the config is not enableable */ @@ -121,6 +119,6 @@ protected function isConfigEnabled(ContainerBuilder $container, array $config) throw new InvalidArgumentException("The config array has no 'enabled' key."); } - return (Boolean) $container->getParameterBag()->resolveValue($config['enabled']); + return (bool) $container->getParameterBag()->resolveValue($config['enabled']); } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php index 34d6cada9a7a88121b391e20766e3513f52c3623..f0853fe01e5716261776d26e2b8b0c78115f16a7 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php @@ -25,9 +25,8 @@ interface IntrospectableContainerInterface extends ContainerInterface * * @param string $id * - * @return Boolean true if the service has been initialized, false otherwise + * @return bool true if the service has been initialized, false otherwise * */ public function initialized($id); - } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LICENSE b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LICENSE +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php index 6495df2813db1f0ba962f3ffb8db31c441baed25..cad9320039b14d918e07ea7897cc5cd1b73c3186 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\Definition; /** - * {@inheritDoc} + * {@inheritdoc} * * Noop proxy instantiator - simply produces the real service instead of a proxy instance. * @@ -24,7 +24,7 @@ class RealServiceInstantiator implements InstantiatorInterface { /** - * {@inheritDoc} + * {@inheritdoc} */ public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php index 83a2909fc2c7a5bee36a21136fa1650bb52cd7fb..30911d3a5e83af4a4e3bc09ad3753e668f912567 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php @@ -21,7 +21,7 @@ class NullDumper implements DumperInterface { /** - * {@inheritDoc} + * {@inheritdoc} */ public function isProxyCandidate(Definition $definition) { @@ -29,7 +29,7 @@ public function isProxyCandidate(Definition $definition) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getProxyFactoryCode(Definition $definition, $id) { @@ -37,7 +37,7 @@ public function getProxyFactoryCode(Definition $definition, $id) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getProxyCode(Definition $definition) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php index 775a3525d83402650b3d0306a8f4ddff14d531d2..30cbe0ebaf99eab085279ba2f5c29d15709cac9c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php @@ -52,7 +52,7 @@ public function load($closure, $type = null) * @param mixed $resource A resource * @param string $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php index e4b99f60d93fd922056dafa7ca50eb73bf490df9..189eaa5fde155eda2ace59f063804e277cf2458c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php @@ -53,7 +53,7 @@ public function load($file, $type = null) * @param mixed $resource A resource * @param string $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php index e866a29f7067a7958ac9e75a7878f97eca68632f..f3139ad70a827a110cdb668d1ac5bcfc2fdfe25b 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php @@ -48,7 +48,7 @@ public function load($file, $type = null) * @param mixed $resource A resource * @param string $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 9b2d46d28ef276e780a81e846351af6d07d583b7..32d2bb19ba40eaea550d5a340387a1878ed1047e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -18,9 +18,9 @@ use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\SimpleXMLElement; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\ExpressionLanguage\Expression; /** * XmlFileLoader loads XML files service definitions. @@ -29,6 +29,8 @@ */ class XmlFileLoader extends FileLoader { + const NS = 'http://symfony.com/schema/dic/services'; + /** * Loads an XML file. * @@ -39,8 +41,7 @@ public function load($file, $type = null) { $path = $this->locator->locate($file); - $xml = $this->parseFile($path); - $xml->registerXPathNamespace('container', 'http://symfony.com/schema/dic/services'); + $xml = $this->parseFileToDOM($path); $this->container->addResource(new FileResource($path)); @@ -66,7 +67,7 @@ public function load($file, $type = null) * @param mixed $resource A resource * @param string $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { @@ -76,140 +77,150 @@ public function supports($resource, $type = null) /** * Parses parameters * - * @param SimpleXMLElement $xml - * @param string $file + * @param \DOMDocument $xml + * @param string $file */ - private function parseParameters(SimpleXMLElement $xml, $file) + private function parseParameters(\DOMDocument $xml, $file) { - if (!$xml->parameters) { - return; + if ($parameters = $this->getChildren($xml->documentElement, 'parameters')) { + $this->container->getParameterBag()->add($this->getArgumentsAsPhp($parameters[0], 'parameter')); } - - $this->container->getParameterBag()->add($xml->parameters->getArgumentsAsPhp('parameter')); } /** * Parses imports * - * @param SimpleXMLElement $xml - * @param string $file + * @param \DOMDocument $xml + * @param string $file */ - private function parseImports(SimpleXMLElement $xml, $file) + private function parseImports(\DOMDocument $xml, $file) { - if (false === $imports = $xml->xpath('//container:imports/container:import')) { + $xpath = new \DOMXPath($xml); + $xpath->registerNamespace('container', self::NS); + + if (false === $imports = $xpath->query('//container:imports/container:import')) { return; } foreach ($imports as $import) { $this->setCurrentDir(dirname($file)); - $this->import((string) $import['resource'], null, (Boolean) $import->getAttributeAsPhp('ignore-errors'), $file); + $this->import($import->getAttribute('resource'), null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file); } } /** * Parses multiple definitions * - * @param SimpleXMLElement $xml - * @param string $file + * @param \DOMDocument $xml + * @param string $file */ - private function parseDefinitions(SimpleXMLElement $xml, $file) + private function parseDefinitions(\DOMDocument $xml, $file) { - if (false === $services = $xml->xpath('//container:services/container:service')) { + $xpath = new \DOMXPath($xml); + $xpath->registerNamespace('container', self::NS); + + if (false === $services = $xpath->query('//container:services/container:service')) { return; } foreach ($services as $service) { - $this->parseDefinition((string) $service['id'], $service, $file); + $this->parseDefinition((string) $service->getAttribute('id'), $service, $file); } } /** * Parses an individual Definition * - * @param string $id - * @param SimpleXMLElement $service - * @param string $file + * @param string $id + * @param \DOMElement $service + * @param string $file */ - private function parseDefinition($id, $service, $file) + private function parseDefinition($id, \DOMElement $service, $file) { - if ((string) $service['alias']) { + if ($alias = $service->getAttribute('alias')) { $public = true; - if (isset($service['public'])) { - $public = $service->getAttributeAsPhp('public'); + if ($publicAttr = $service->getAttribute('public')) { + $public = XmlUtils::phpize($publicAttr); } - $this->container->setAlias($id, new Alias((string) $service['alias'], $public)); + $this->container->setAlias($id, new Alias($alias, $public)); return; } - if (isset($service['parent'])) { - $definition = new DefinitionDecorator((string) $service['parent']); + if ($parent = $service->getAttribute('parent')) { + $definition = new DefinitionDecorator($parent); } else { $definition = new Definition(); } foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'synchronized', 'lazy', 'abstract') as $key) { - if (isset($service[$key])) { + if ($value = $service->getAttribute($key)) { $method = 'set'.str_replace('-', '', $key); - $definition->$method((string) $service->getAttributeAsPhp($key)); + $definition->$method(XmlUtils::phpize($value)); } } - if ($service->file) { - $definition->setFile((string) $service->file); + if ($files = $this->getChildren($service, 'file')) { + $definition->setFile($files[0]->nodeValue); } - $definition->setArguments($service->getArgumentsAsPhp('argument')); - $definition->setProperties($service->getArgumentsAsPhp('property')); + $definition->setArguments($this->getArgumentsAsPhp($service, 'argument')); + $definition->setProperties($this->getArgumentsAsPhp($service, 'property')); - if (isset($service->configurator)) { - if (isset($service->configurator['function'])) { - $definition->setConfigurator((string) $service->configurator['function']); + if ($configurators = $this->getChildren($service, 'configurator')) { + $configurator = $configurators[0]; + if ($function = $configurator->getAttribute('function')) { + $definition->setConfigurator($function); } else { - if (isset($service->configurator['service'])) { - $class = new Reference((string) $service->configurator['service'], ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false); + if ($childService = $configurator->getAttribute('service')) { + $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false); } else { - $class = (string) $service->configurator['class']; + $class = $configurator->getAttribute('class'); } - $definition->setConfigurator(array($class, (string) $service->configurator['method'])); + $definition->setConfigurator(array($class, $configurator->getAttribute('method'))); } } - foreach ($service->call as $call) { - $definition->addMethodCall((string) $call['method'], $call->getArgumentsAsPhp('argument')); + foreach ($this->getChildren($service, 'call') as $call) { + $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument')); } - foreach ($service->tag as $tag) { + foreach ($this->getChildren($service, 'tag') as $tag) { $parameters = array(); - foreach ($tag->attributes() as $name => $value) { + foreach ($tag->attributes as $name => $node) { if ('name' === $name) { continue; } if (false !== strpos($name, '-') && false === strpos($name, '_') && !array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) { - $parameters[$normalizedName] = SimpleXMLElement::phpize($value); + $parameters[$normalizedName] = XmlUtils::phpize($node->nodeValue); } // keep not normalized key for BC too - $parameters[$name] = SimpleXMLElement::phpize($value); + $parameters[$name] = XmlUtils::phpize($node->nodeValue); } - $definition->addTag((string) $tag['name'], $parameters); + $definition->addTag($tag->getAttribute('name'), $parameters); + } + + if ($value = $service->getAttribute('decorates')) { + $renameId = $service->hasAttribute('decoration-inner-name') ? $service->getAttribute('decoration-inner-name') : null; + $definition->setDecoratedService($value, $renameId); } $this->container->setDefinition($id, $definition); } /** - * Parses a XML file. + * Parses a XML file to a \DOMDocument * * @param string $file Path to a file * - * @return SimpleXMLElement + * @return \DOMDocument * * @throws InvalidArgumentException When loading of XML file returns error */ - protected function parseFile($file) + private function parseFileToDOM($file) { try { $dom = XmlUtils::loadFile($file, array($this, 'validateSchema')); @@ -219,61 +230,162 @@ protected function parseFile($file) $this->validateExtensions($dom, $file); - return simplexml_import_dom($dom, 'Symfony\\Component\\DependencyInjection\\SimpleXMLElement'); + return $dom; } /** * Processes anonymous services * - * @param SimpleXMLElement $xml - * @param string $file + * @param \DOMDocument $xml + * @param string $file */ - private function processAnonymousServices(SimpleXMLElement $xml, $file) + private function processAnonymousServices(\DOMDocument $xml, $file) { $definitions = array(); $count = 0; + $xpath = new \DOMXPath($xml); + $xpath->registerNamespace('container', self::NS); + // anonymous services as arguments/properties - if (false !== $nodes = $xml->xpath('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]')) { + if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]')) { foreach ($nodes as $node) { // give it a unique name $id = sprintf('%s_%d', hash('sha256', $file), ++$count); - $node['id'] = $id; + $node->setAttribute('id', $id); - $definitions[$id] = array($node->service, $file, false); - $node->service['id'] = $id; + if ($services = $this->getChildren($node, 'service')) { + $definitions[$id] = array($services[0], $file, false); + $services[0]->setAttribute('id', $id); + } } } // anonymous services "in the wild" - if (false !== $nodes = $xml->xpath('//container:services/container:service[not(@id)]')) { + if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) { foreach ($nodes as $node) { // give it a unique name $id = sprintf('%s_%d', hash('sha256', $file), ++$count); - $node['id'] = $id; + $node->setAttribute('id', $id); - $definitions[$id] = array($node, $file, true); - $node->service['id'] = $id; + if ($services = $this->getChildren($node, 'service')) { + $definitions[$id] = array($node, $file, true); + $services[0]->setAttribute('id', $id); + } } } // resolve definitions krsort($definitions); foreach ($definitions as $id => $def) { + list($domElement, $file, $wild) = $def; + // anonymous services are always private - $def[0]['public'] = false; + // we could not use the constant false here, because of XML parsing + $domElement->setAttribute('public', 'false'); + + $this->parseDefinition($id, $domElement, $file); + + if (true === $wild) { + $tmpDomElement = new \DOMElement('_services', null, self::NS); + $domElement->parentNode->replaceChild($tmpDomElement, $domElement); + $tmpDomElement->setAttribute('id', $id); + } else { + $domElement->parentNode->removeChild($domElement); + } + } + } - $this->parseDefinition($id, $def[0], $def[1]); + /** + * Returns arguments as valid php types. + * + * @param \DOMElement $node + * @param string $name + * @param bool $lowercase + * + * @return mixed + */ + private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true) + { + $arguments = array(); + foreach ($this->getChildren($node, $name) as $arg) { + if ($arg->hasAttribute('name')) { + $arg->setAttribute('key', $arg->getAttribute('name')); + } - $oNode = dom_import_simplexml($def[0]); - if (true === $def[2]) { - $nNode = new \DOMElement('_services'); - $oNode->parentNode->replaceChild($nNode, $oNode); - $nNode->setAttribute('id', $id); + if (!$arg->hasAttribute('key')) { + $key = !$arguments ? 0 : max(array_keys($arguments)) + 1; } else { - $oNode->parentNode->removeChild($oNode); + $key = $arg->getAttribute('key'); + } + + // parameter keys are case insensitive + if ('parameter' == $name && $lowercase) { + $key = strtolower($key); + } + + // this is used by DefinitionDecorator to overwrite a specific + // argument of the parent definition + if ($arg->hasAttribute('index')) { + $key = 'index_'.$arg->getAttribute('index'); + } + + switch ($arg->getAttribute('type')) { + case 'service': + $onInvalid = $arg->getAttribute('on-invalid'); + $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + if ('ignore' == $onInvalid) { + $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + } elseif ('null' == $onInvalid) { + $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; + } + + if ($strict = $arg->getAttribute('strict')) { + $strict = XmlUtils::phpize($strict); + } else { + $strict = true; + } + + $arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior, $strict); + break; + case 'expression': + $arguments[$key] = new Expression($arg->nodeValue); + break; + case 'collection': + $arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false); + break; + case 'string': + $arguments[$key] = $arg->nodeValue; + break; + case 'constant': + $arguments[$key] = constant($arg->nodeValue); + break; + default: + $arguments[$key] = XmlUtils::phpize($arg->nodeValue); + } + } + + return $arguments; + } + + /** + * Get child elements by name + * + * @param \DOMNode $node + * @param mixed $name + * + * @return array + */ + private function getChildren(\DOMNode $node, $name) + { + $children = array(); + foreach ($node->childNodes as $child) { + if ($child instanceof \DOMElement && $child->localName === $name && $child->namespaceURI === self::NS) { + $children[] = $child; } } + + return $children; } /** @@ -281,7 +393,7 @@ private function processAnonymousServices(SimpleXMLElement $xml, $file) * * @param \DOMDocument $dom * - * @return Boolean + * @return bool * * @throws RuntimeException When extension references a non-existent XSD file */ @@ -380,12 +492,12 @@ private function validateExtensions(\DOMDocument $dom, $file) /** * Loads from an extension. * - * @param SimpleXMLElement $xml + * @param \DOMDocument $xml */ - private function loadFromExtensions(SimpleXMLElement $xml) + private function loadFromExtensions(\DOMDocument $xml) { - foreach (dom_import_simplexml($xml)->childNodes as $node) { - if (!$node instanceof \DOMElement || $node->namespaceURI === 'http://symfony.com/schema/dic/services') { + foreach ($xml->documentElement->childNodes as $node) { + if (!$node instanceof \DOMElement || $node->namespaceURI === self::NS) { continue; } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index e081be5c2abd732bdf64e7765530c6069213d9cc..39bdf9488724347c68e0ca3c0a16c67f76ce89cf 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -52,10 +52,14 @@ public function load($file, $type = null) } // imports - $this->parseImports($content, $file); + $this->parseImports($content, $path); // parameters if (isset($content['parameters'])) { + if (!is_array($content['parameters'])) { + throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $file)); + } + foreach ($content['parameters'] as $key => $value) { $this->container->setParameter($key, $this->resolveServices($value)); } @@ -74,7 +78,7 @@ public function load($file, $type = null) * @param mixed $resource A resource * @param string $type The resource type * - * @return Boolean true if this class supports the given resource, false otherwise + * @return bool true if this class supports the given resource, false otherwise */ public function supports($resource, $type = null) { @@ -93,9 +97,17 @@ private function parseImports($content, $file) return; } + if (!is_array($content['imports'])) { + throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file)); + } + foreach ($content['imports'] as $import) { + if (!is_array($import)) { + throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file)); + } + $this->setCurrentDir(dirname($file)); - $this->import($import['resource'], null, isset($import['ignore_errors']) ? (Boolean) $import['ignore_errors'] : false, $file); + $this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file); } } @@ -111,6 +123,10 @@ private function parseDefinitions($content, $file) return; } + if (!is_array($content['services'])) { + throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file)); + } + foreach ($content['services'] as $id => $service) { $this->parseDefinition($id, $service, $file); } @@ -131,8 +147,14 @@ private function parseDefinition($id, $service, $file) $this->container->setAlias($id, substr($service, 1)); return; - } elseif (isset($service['alias'])) { - $public = !array_key_exists('public', $service) || (Boolean) $service['public']; + } + + if (!is_array($service)) { + throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but %s found for service "%s" in %s. Check your YAML syntax.', gettype($service), $id, $file)); + } + + if (isset($service['alias'])) { + $public = !array_key_exists('public', $service) || (bool) $service['public']; $this->container->setAlias($id, new Alias($service['alias'], $public)); return; @@ -205,6 +227,10 @@ private function parseDefinition($id, $service, $file) } if (isset($service['calls'])) { + if (!is_array($service['calls'])) { + throw new InvalidArgumentException(sprintf('Parameter "calls" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + } + foreach ($service['calls'] as $call) { $args = isset($call[1]) ? $this->resolveServices($call[1]) : array(); $definition->addMethodCall($call[0], $args); @@ -213,10 +239,14 @@ private function parseDefinition($id, $service, $file) if (isset($service['tags'])) { if (!is_array($service['tags'])) { - throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s.', $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); } foreach ($service['tags'] as $tag) { + if (!is_array($tag)) { + throw new InvalidArgumentException(sprintf('A "tags" entry must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + } + if (!isset($tag['name'])) { throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file)); } @@ -226,7 +256,7 @@ private function parseDefinition($id, $service, $file) foreach ($tag as $attribute => $value) { if (!is_scalar($value) && null !== $value) { - throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s.', $id, $name, $attribute, $file)); + throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s. Check your YAML syntax.', $id, $name, $attribute, $file)); } } @@ -234,6 +264,11 @@ 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); + } + $this->container->setDefinition($id, $definition); } @@ -243,6 +278,8 @@ private function parseDefinition($id, $service, $file) * @param string $file * * @return array The file content + * + * @throws InvalidArgumentException when the given file is not a local file or when it does not exist */ protected function loadFile($file) { @@ -278,7 +315,7 @@ private function validate($content, $file) } if (!is_array($content)) { - throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); + throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); } foreach (array_keys($content) as $namespace) { @@ -304,9 +341,9 @@ private function validate($content, $file) /** * Resolves services. * - * @param string $value + * @param string|array $value * - * @return Reference + * @return array|string|Reference */ private function resolveServices($value) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd index f7b578767bb5ad8abd8eca329ba2d1f74002fd46..54a4544ad50d36407e1116f73efea3e76b6187ef 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd @@ -94,6 +94,8 @@ <xsd:attribute name="factory-service" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="parent" type="xsd:string" /> + <xsd:attribute name="decorates" type="xsd:string" /> + <xsd:attribute name="decoration-inner-name" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="tag"> @@ -156,7 +158,6 @@ <xsd:simpleType name="parameter_type"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="collection" /> - <xsd:enumeration value="service" /> <xsd:enumeration value="string" /> <xsd:enumeration value="constant" /> </xsd:restriction> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php index 9664b134ef803f35d83918211961f67bcb1410df..dc936a0bd6718b425671c07822849d3362a545cf 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php @@ -41,7 +41,7 @@ public function __construct(array $parameters = array()) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -51,7 +51,7 @@ public function clear() } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ @@ -61,7 +61,7 @@ public function add(array $parameters) } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index dabd1c6215673ca199709ae0c4269e7768d4b0aa..1a339e56c032bf7df26fed6e2b985b0f0ef06d09 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -127,7 +127,7 @@ public function set($name, $value) * * @param string $name The parameter name * - * @return Boolean true if the parameter name is defined, false otherwise + * @return bool true if the parameter name is defined, false otherwise * * @api */ @@ -264,7 +264,7 @@ public function isResolved() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function escapeValue($value) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index a26d6aee1724631675ecb108e3985c9f6d1285c6..990f33a18fb023644b0dbda2e9b6393ece93d5cd 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -75,7 +75,7 @@ public function set($name, $value); * * @param string $name The parameter name * - * @return Boolean true if the parameter name is defined, false otherwise + * @return bool true if the parameter name is defined, false otherwise * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Reference.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Reference.php index 725747055c1dfa8b8b04f31513e9a22b46a23dc9..d9de9f3904a08165a0e9566e12d3f88587fb638c 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Reference.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Reference.php @@ -29,7 +29,7 @@ class Reference * * @param string $id The service identifier * @param int $invalidBehavior The behavior when the service does not exist - * @param Boolean $strict Sets how this reference is validated + * @param bool $strict Sets how this reference is validated * * @see Container */ @@ -63,7 +63,7 @@ public function getInvalidBehavior() /** * Returns true when this Reference is strict * - * @return Boolean + * @return bool */ public function isStrict() { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/SimpleXMLElement.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/SimpleXMLElement.php index db855f66d1e89e19ea7d09c929df47296f5c70b7..15f3544fed439548a486b991a59227615c93f5fe 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/SimpleXMLElement.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/SimpleXMLElement.php @@ -18,6 +18,8 @@ * SimpleXMLElement class. * * @author Fabien Potencier <fabien@symfony.com> + * + * @deprecated Deprecated since version 2.5, to be removed in 3.0. */ class SimpleXMLElement extends \SimpleXMLElement { @@ -37,7 +39,7 @@ public function getAttributeAsPhp($name) * Returns arguments as valid PHP types. * * @param string $name - * @param Boolean $lowercase + * @param bool $lowercase * * @return mixed */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php index c99659e5a67f6eb74e094104f9831ceac4918916..00322a22d0037519ce507d69bd7bc5502575c953 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php @@ -97,6 +97,26 @@ public function testProcessDoesNotSaveDuplicateReferences() $this->assertCount(2, $graph->getNode('a')->getInEdges()); } + public function testProcessDetectsFactoryReferences() + { + $container = new ContainerBuilder(); + + $container + ->register('foo', 'stdClass') + ->setFactoryClass('stdClass') + ->setFactoryMethod('getInstance'); + + $container + ->register('bar', 'stdClass') + ->setFactoryService('foo') + ->setFactoryMethod('getInstance'); + + $graph = $this->process($container); + + $this->assertTrue($graph->hasNode('foo')); + $this->assertCount(1, $graph->getNode('foo')->getInEdges()); + } + protected function process(ContainerBuilder $container) { $pass = new RepeatedPass(array(new AnalyzeServiceReferencesPass())); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index 085bc519b73eb5ea1c50efe655b2a2afcd4e075b..8183014c5b0e5f2c75794b98b99f6f89a6e69144 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -48,6 +48,26 @@ public function testProcessWithAliases() $this->process($container); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + */ + public function testProcessWithFactory() + { + $container = new ContainerBuilder(); + + $container + ->register('a', 'stdClass') + ->setFactoryService('b') + ->setFactoryMethod('getInstance'); + + $container + ->register('b', 'stdClass') + ->setFactoryService('a') + ->setFactoryMethod('getInstance'); + + $this->process($container); + } + /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ @@ -61,6 +81,25 @@ public function testProcessDetectsIndirectCircularReference() $this->process($container); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + */ + public function testProcessDetectsIndirectCircularReferenceWithFactory() + { + $container = new ContainerBuilder(); + + $container->register('a')->addArgument(new Reference('b')); + + $container + ->register('b', 'stdClass') + ->setFactoryService('c') + ->setFactoryMethod('getInstance'); + + $container->register('c')->addArgument(new Reference('a')); + + $this->process($container); + } + /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e17961ac99db119f478e02f66bc741683966cbac --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php @@ -0,0 +1,81 @@ +<?php + +namespace Symfony\Component\DependencyInjection\Tests\Compiler; + +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass; + +class DecoratorServicePassTest extends \PHPUnit_Framework_TestCase +{ + public function testProcessWithoutAlias() + { + $container = new ContainerBuilder(); + $fooDefinition = $container + ->register('foo') + ->setPublic(false) + ; + $fooExtendedDefinition = $container + ->register('foo.extended') + ->setPublic(true) + ->setDecoratedService('foo') + ; + $barDefinition = $container + ->register('bar') + ->setPublic(true) + ; + $barExtendedDefinition = $container + ->register('bar.extended') + ->setPublic(true) + ->setDecoratedService('bar', 'bar.yoo') + ; + + $this->process($container); + + $this->assertEquals('foo.extended', $container->getAlias('foo')); + $this->assertFalse($container->getAlias('foo')->isPublic()); + + $this->assertEquals('bar.extended', $container->getAlias('bar')); + $this->assertTrue($container->getAlias('bar')->isPublic()); + + $this->assertSame($fooDefinition, $container->getDefinition('foo.extended.inner')); + $this->assertFalse($container->getDefinition('foo.extended.inner')->isPublic()); + + $this->assertSame($barDefinition, $container->getDefinition('bar.yoo')); + $this->assertFalse($container->getDefinition('bar.yoo')->isPublic()); + + $this->assertNull($fooExtendedDefinition->getDecoratedService()); + $this->assertNull($barExtendedDefinition->getDecoratedService()); + } + + public function testProcessWithAlias() + { + $container = new ContainerBuilder(); + $container + ->register('foo') + ->setPublic(true) + ; + $container->setAlias('foo.alias', new Alias('foo', false)); + $fooExtendedDefinition = $container + ->register('foo.extended') + ->setPublic(true) + ->setDecoratedService('foo.alias') + ; + + $this->process($container); + + $this->assertEquals('foo.extended', $container->getAlias('foo.alias')); + $this->assertFalse($container->getAlias('foo.alias')->isPublic()); + + $this->assertEquals('foo', $container->getAlias('foo.extended.inner')); + $this->assertFalse($container->getAlias('foo.extended.inner')->isPublic()); + + $this->assertNull($fooExtendedDefinition->getDecoratedService()); + } + + protected function process(ContainerBuilder $container) + { + $repeatedPass = new DecoratorServicePass(); + $repeatedPass->process($container); + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php index d7e55214a9366e1a0c82eb51d27cd170fea71b76..b3e451c551c43da26b790a5abf48e65f06ae35ac 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php @@ -81,6 +81,33 @@ public function testProcessWorksWithInlinedDefinitions() $this->assertTrue($container->hasDefinition('bar')); } + public function testProcessWontRemovePrivateFactory() + { + $container = new ContainerBuilder(); + + $container + ->register('foo', 'stdClass') + ->setFactoryClass('stdClass') + ->setFactoryMethod('getInstance') + ->setPublic(false); + + $container + ->register('bar', 'stdClass') + ->setFactoryService('foo') + ->setFactoryMethod('getInstance') + ->setPublic(false); + + $container + ->register('foobar') + ->addArgument(new Reference('bar')); + + $this->process($container); + + $this->assertTrue($container->hasDefinition('foo')); + $this->assertTrue($container->hasDefinition('bar')); + $this->assertTrue($container->hasDefinition('foobar')); + } + protected function process(ContainerBuilder $container) { $repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new RemoveUnusedDefinitionsPass())); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index dd08c97c114ecc85440d8dba490e36c2b5bfef7b..714a07b768181e4b68dbc7b8d0ce6418d9f3cef5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -40,7 +41,7 @@ public function testDefinitions() { $builder = new ContainerBuilder(); $definitions = array( - 'foo' => new Definition('FooClass'), + 'foo' => new Definition('Bar\FooClass'), 'bar' => new Definition('BarClass'), ); $builder->setDefinitions($definitions); @@ -69,7 +70,7 @@ public function testDefinitions() public function testRegister() { $builder = new ContainerBuilder(); - $builder->register('foo', 'FooClass'); + $builder->register('foo', 'Bar\FooClass'); $this->assertTrue($builder->hasDefinition('foo'), '->register() registers a new service definition'); $this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $builder->getDefinition('foo'), '->register() returns the newly created Definition instance'); } @@ -81,7 +82,7 @@ public function testHas() { $builder = new ContainerBuilder(); $this->assertFalse($builder->has('foo'), '->has() returns false if the service does not exist'); - $builder->register('foo', 'FooClass'); + $builder->register('foo', 'Bar\FooClass'); $this->assertTrue($builder->has('foo'), '->has() returns true if a service definition exists'); $builder->set('bar', new \stdClass()); $this->assertTrue($builder->has('bar'), '->has() returns true if a service exists'); @@ -152,6 +153,16 @@ public function testGetReturnsNullOnInactiveScope() $this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE)); } + /** + * @covers Symfony\Component\DependencyInjection\ContainerBuilder::get + */ + public function testGetReturnsNullOnInactiveScopeWhenServiceIsCreatedByAMethod() + { + $builder = new ProjectContainer(); + + $this->assertNull($builder->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds */ @@ -259,11 +270,11 @@ public function testAddGetCompilerPass() public function testCreateService() { $builder = new ContainerBuilder(); - $builder->register('foo1', 'FooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); - $this->assertInstanceOf('\FooClass', $builder->get('foo1'), '->createService() requires the file defined by the service definition'); - $builder->register('foo2', 'FooClass')->setFile(__DIR__.'/Fixtures/includes/%file%.php'); + $builder->register('foo1', 'Bar\FooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); + $this->assertInstanceOf('\Bar\FooClass', $builder->get('foo1'), '->createService() requires the file defined by the service definition'); + $builder->register('foo2', 'Bar\FooClass')->setFile(__DIR__.'/Fixtures/includes/%file%.php'); $builder->setParameter('file', 'foo'); - $this->assertInstanceOf('\FooClass', $builder->get('foo2'), '->createService() replaces parameters in the file provided by the service definition'); + $this->assertInstanceOf('\Bar\FooClass', $builder->get('foo2'), '->createService() replaces parameters in the file provided by the service definition'); } /** @@ -273,13 +284,13 @@ public function testCreateProxyWithRealServiceInstantiator() { $builder = new ContainerBuilder(); - $builder->register('foo1', 'FooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); + $builder->register('foo1', 'Bar\FooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); $builder->getDefinition('foo1')->setLazy(true); $foo1 = $builder->get('foo1'); $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls'); - $this->assertSame('FooClass', get_class($foo1)); + $this->assertSame('Bar\FooClass', get_class($foo1)); } /** @@ -300,7 +311,7 @@ public function testCreateServiceArguments() { $builder = new ContainerBuilder(); $builder->register('bar', 'stdClass'); - $builder->register('foo1', 'FooClass')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'), '%%unescape_it%%')); + $builder->register('foo1', 'Bar\FooClass')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'), '%%unescape_it%%')); $builder->setParameter('value', 'bar'); $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar'), '%unescape_it%'), $builder->get('foo1')->arguments, '->createService() replaces parameters and service references in the arguments provided by the service definition'); } @@ -312,7 +323,7 @@ public function testCreateServiceFactoryMethod() { $builder = new ContainerBuilder(); $builder->register('bar', 'stdClass'); - $builder->register('foo1', 'FooClass')->setFactoryClass('FooClass')->setFactoryMethod('getInstance')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); + $builder->register('foo1', 'Bar\FooClass')->setFactoryClass('Bar\FooClass')->setFactoryMethod('getInstance')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); $builder->setParameter('value', 'bar'); $this->assertTrue($builder->get('foo1')->called, '->createService() calls the factory method to create the service instance'); $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar')), $builder->get('foo1')->arguments, '->createService() passes the arguments to the factory method'); @@ -337,7 +348,7 @@ public function testCreateServiceMethodCalls() { $builder = new ContainerBuilder(); $builder->register('bar', 'stdClass'); - $builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%value%', new Reference('bar')))); + $builder->register('foo1', 'Bar\FooClass')->addMethodCall('setBar', array(array('%value%', new Reference('bar')))); $builder->setParameter('value', 'bar'); $this->assertEquals(array('bar', $builder->get('bar')), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments'); } @@ -348,23 +359,23 @@ public function testCreateServiceMethodCalls() public function testCreateServiceConfigurator() { $builder = new ContainerBuilder(); - $builder->register('foo1', 'FooClass')->setConfigurator('sc_configure'); + $builder->register('foo1', 'Bar\FooClass')->setConfigurator('sc_configure'); $this->assertTrue($builder->get('foo1')->configured, '->createService() calls the configurator'); - $builder->register('foo2', 'FooClass')->setConfigurator(array('%class%', 'configureStatic')); + $builder->register('foo2', 'Bar\FooClass')->setConfigurator(array('%class%', 'configureStatic')); $builder->setParameter('class', 'BazClass'); $this->assertTrue($builder->get('foo2')->configured, '->createService() calls the configurator'); $builder->register('baz', 'BazClass'); - $builder->register('foo3', 'FooClass')->setConfigurator(array(new Reference('baz'), 'configure')); + $builder->register('foo3', 'Bar\FooClass')->setConfigurator(array(new Reference('baz'), 'configure')); $this->assertTrue($builder->get('foo3')->configured, '->createService() calls the configurator'); - $builder->register('foo4', 'FooClass')->setConfigurator('foo'); + $builder->register('foo4', 'Bar\FooClass')->setConfigurator('foo'); try { $builder->get('foo4'); $this->fail('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); } catch (\InvalidArgumentException $e) { - $this->assertEquals('The configure callable for class "FooClass" is not a callable.', $e->getMessage(), '->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); + $this->assertEquals('The configure callable for class "Bar\FooClass" is not a callable.', $e->getMessage(), '->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); } } @@ -375,7 +386,7 @@ public function testCreateServiceConfigurator() public function testCreateSyntheticService() { $builder = new ContainerBuilder(); - $builder->register('foo', 'FooClass')->setSynthetic(true); + $builder->register('foo', 'Bar\FooClass')->setSynthetic(true); $builder->get('foo'); } @@ -384,7 +395,7 @@ public function testCreateServiceWithExpression() $builder = new ContainerBuilder(); $builder->setParameter('bar', 'bar'); $builder->register('bar', 'BarClass'); - $builder->register('foo', 'FooClass')->addArgument(array('foo' => new Expression('service("bar").foo ~ parameter("bar")'))); + $builder->register('foo', 'Bar\FooClass')->addArgument(array('foo' => new Expression('service("bar").foo ~ parameter("bar")'))); $this->assertEquals('foobar', $builder->get('foo')->arguments['foo']); } @@ -394,7 +405,7 @@ public function testCreateServiceWithExpression() public function testResolveServices() { $builder = new ContainerBuilder(); - $builder->register('foo', 'FooClass'); + $builder->register('foo', 'Bar\FooClass'); $this->assertEquals($builder->get('foo'), $builder->resolveServices(new Reference('foo')), '->resolveServices() resolves service references to service instances'); $this->assertEquals(array('foo' => array('foo', $builder->get('foo'))), $builder->resolveServices(array('foo' => array('foo', new Reference('foo')))), '->resolveServices() resolves service references to service instances in nested arrays'); $this->assertEquals($builder->get('foo'), $builder->resolveServices(new Expression('service("foo")')), '->resolveServices() resolves expressions'); @@ -427,7 +438,7 @@ public function testMerge() $container = new ContainerBuilder(); $container->setResourceTracking(false); - $container->register('foo', 'FooClass'); + $container->register('foo', 'Bar\FooClass'); $container->register('bar', 'BarClass'); $config = new ContainerBuilder(); $config->setDefinition('baz', new Definition('BazClass')); @@ -441,7 +452,7 @@ public function testMerge() $container = new ContainerBuilder(); $container->setResourceTracking(false); - $container->register('foo', 'FooClass'); + $container->register('foo', 'Bar\FooClass'); $config->setDefinition('foo', new Definition('BazClass')); $container->merge($config); $this->assertEquals('BazClass', $container->getDefinition('foo')->getClass(), '->merge() overrides already defined services'); @@ -466,7 +477,7 @@ public function testfindTaggedServiceIds() { $builder = new ContainerBuilder(); $builder - ->register('foo', 'FooClass') + ->register('foo', 'Bar\FooClass') ->addTag('foo', array('foo' => 'foo')) ->addTag('bar', array('bar' => 'bar')) ->addTag('foo', array('foofoo' => 'foofoo')) @@ -475,7 +486,7 @@ public function testfindTaggedServiceIds() 'foo' => array( array('foo' => 'foo'), array('foofoo' => 'foofoo'), - ) + ), ), '->findTaggedServiceIds() returns an array of service ids and its tag attributes'); $this->assertEquals(array(), $builder->findTaggedServiceIds('foobar'), '->findTaggedServiceIds() returns an empty array if there is annotated services'); } @@ -486,7 +497,7 @@ public function testfindTaggedServiceIds() public function testFindDefinition() { $container = new ContainerBuilder(); - $container->setDefinition('foo', $definition = new Definition('FooClass')); + $container->setDefinition('foo', $definition = new Definition('Bar\FooClass')); $container->setAlias('bar', 'foo'); $container->setAlias('foobar', 'bar'); $this->assertEquals($definition, $container->findDefinition('foobar'), '->findDefinition() returns a Definition'); @@ -641,7 +652,7 @@ public function testPrivateServiceUser() $container->addDefinitions(array( 'bar' => $fooDefinition, - 'bar_user' => $fooUserDefinition + 'bar_user' => $fooUserDefinition, )); $container->compile(); @@ -790,8 +801,18 @@ public function testLazyLoadedService() } } - $this->assertEquals(true, $classInList); + $this->assertTrue($classInList); } } -class FooClass {} +class FooClass +{ +} + +class ProjectContainer extends ContainerBuilder +{ + public function getFoobazService() + { + throw new InactiveScopeException('foo', 'request'); + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index e145c7a10c1aa5b983f21625a472291f77c19a72..314f3e61f12569becafca6b80b3c85d05bffdc19 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -228,7 +228,6 @@ public function testGetThrowServiceNotFoundException() public function testGetCircularReference() { - $sc = new ProjectServiceContainer(); try { $sc->get('circular'); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index 4ffd7c079267a81178db7bfa5c8cc50e4d7ee7ca..9b4cf21ff90c7a669adc76815c74aedaae334932 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -62,6 +62,26 @@ public function testSetGetClass() $this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name'); } + public function testSetGetDecoratedService() + { + $def = new Definition('stdClass'); + $this->assertNull($def->getDecoratedService()); + $def->setDecoratedService('foo', 'foo.renamed'); + $this->assertEquals(array('foo', 'foo.renamed'), $def->getDecoratedService()); + $def->setDecoratedService(null); + $this->assertNull($def->getDecoratedService()); + + $def = new Definition('stdClass'); + $def->setDecoratedService('foo'); + $this->assertEquals(array('foo', null), $def->getDecoratedService()); + $def->setDecoratedService(null); + $this->assertNull($def->getDecoratedService()); + + $def = new Definition('stdClass'); + $this->setExpectedException('InvalidArgumentException', 'The decorated service inner name for "foo" must be different than the service name itself.'); + $def->setDecoratedService('foo', 'foo'); + } + /** * @covers Symfony\Component\DependencyInjection\Definition::setArguments * @covers Symfony\Component\DependencyInjection\Definition::getArguments diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php index 0dc1ce8de150d3fbb5e301b642a28a553cb238f3..8c7bf5ab26e4ad22688d6d63b4d40859c9ac99e9 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php @@ -62,4 +62,19 @@ public function testDumpWithFrozenCustomClassContainer() $dumper = new GraphvizDumper($container); $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services14.dot')), $dumper->dump(), '->dump() dumps services'); } + + public function testDumpWithUnresolvedParameter() + { + $container = include self::$fixturesPath.'/containers/container17.php'; + $dumper = new GraphvizDumper($container); + + $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services17.dot')), $dumper->dump(), '->dump() dumps services'); + } + + public function testDumpWithScopes() + { + $container = include self::$fixturesPath.'/containers/container18.php'; + $dumper = new GraphvizDumper($container); + $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services18.dot')), $dumper->dump(), '->dump() dumps services'); + } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 98b05d2501ee06522e751f26478042dd981e342e..231ab773460a5c0994ccf742a5cf9f9f97257ce1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -62,7 +62,7 @@ public function testDumpOptimizationString() 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', - '\'\'.' =>'concatenation from the start key', + '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => "string1%some_string%string2", 'optimize concatenation with empty string' => "string1%empty_value%string2", 'optimize concatenation from the start' => '%empty_value%start', @@ -140,7 +140,7 @@ public function testAliases() eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Aliases'))); $container = new \Symfony_DI_PhpDumper_Test_Aliases(); - $container->set('foo', $foo = new \stdClass); + $container->set('foo', $foo = new \stdClass()); $this->assertSame($foo, $container->get('foo')); $this->assertSame($foo, $container->get('alias_for_foo')); $this->assertSame($foo, $container->get('alias_for_alias')); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 9ec3438db26bb01c6a722820ce5694bba03a2f36..d3116b0a30f3e788df7fc67baa83c96d56474f7e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -66,7 +66,7 @@ public function testAddService() public function testDumpAnonymousServices() { - include self::$fixturesPath.'/containers/container11.php'; + $container = include self::$fixturesPath.'/containers/container11.php'; $dumper = new XmlDumper($container); $this->assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\"?> <container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\"> @@ -87,7 +87,7 @@ public function testDumpAnonymousServices() public function testDumpEntities() { - include self::$fixturesPath.'/containers/container12.php'; + $container = include self::$fixturesPath.'/containers/container12.php'; $dumper = new XmlDumper($container); $this->assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\"?> <container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\"> @@ -100,4 +100,35 @@ public function testDumpEntities() </container> ", $dumper->dump()); } + + /** + * @dataProvider provideDecoratedServicesData + */ + public function testDumpDecoratedServices($expectedXmlDump, $container) + { + $dumper = new XmlDumper($container); + $this->assertEquals($expectedXmlDump, $dumper->dump()); + } + + public function provideDecoratedServicesData() + { + $fixturesPath = realpath(__DIR__.'/../Fixtures/'); + + return array( + array("<?xml version=\"1.0\" encoding=\"utf-8\"?> +<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\"> + <services> + <service id=\"foo\" class=\"FooClass\Foo\" decorates=\"bar\" decoration-inner-name=\"bar.woozy\"/> + </services> +</container> +", include $fixturesPath.'/containers/container15.php'), + array("<?xml version=\"1.0\" encoding=\"utf-8\"?> +<container xmlns=\"http://symfony.com/schema/dic/services\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd\"> + <services> + <service id=\"foo\" class=\"FooClass\Foo\" decorates=\"bar\"/> + </services> +</container> +", include $fixturesPath.'/containers/container16.php'), + ); + } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index e35bbd5d3c8ad8fd75bb82a162bc221e804647db..e7f19a6e94dc991e5742741b5d3125b175e7fff9 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -54,7 +54,7 @@ public function getResolvedEnabledFixtures() { return array( array(true), - array(false) + array(false), ); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container15.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container15.php new file mode 100644 index 0000000000000000000000000000000000000000..bb41ea3c4f17586ddffd0519f3523a3ec4fea7f0 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container15.php @@ -0,0 +1,11 @@ +<?php + +use Symfony\Component\DependencyInjection\ContainerBuilder; + +$container = new ContainerBuilder(); +$container + ->register('foo', 'FooClass\\Foo') + ->setDecoratedService('bar', 'bar.woozy') +; + +return $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container16.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container16.php new file mode 100644 index 0000000000000000000000000000000000000000..67b4d353db4d2dc12bcdd6518320f8d2c8337dea --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container16.php @@ -0,0 +1,11 @@ +<?php + +use Symfony\Component\DependencyInjection\ContainerBuilder; + +$container = new ContainerBuilder(); +$container + ->register('foo', 'FooClass\\Foo') + ->setDecoratedService('bar') +; + +return $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container17.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container17.php new file mode 100644 index 0000000000000000000000000000000000000000..d902ec2a3930627fe5faa02a4d8ab6cf7ed88a3f --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container17.php @@ -0,0 +1,10 @@ +<?php + +use Symfony\Component\DependencyInjection\ContainerBuilder; + +$container = new ContainerBuilder(); +$container + ->register('foo', '%foo.class%') +; + +return $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php new file mode 100644 index 0000000000000000000000000000000000000000..0248ed462722e9bef990e71040d355908f34e559 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php @@ -0,0 +1,14 @@ +<?php + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Scope; + +$container = new ContainerBuilder(); +$container->addScope(new Scope('request')); +$container-> + register('foo', 'FooClass')-> + setScope('request') +; +$container->compile(); + +return $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php index 19882c0211c3e6cd3288d794e3600023e22791ac..5565def1e8954c83edd488da9429d46be46d30a1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php @@ -10,10 +10,10 @@ $container = new ContainerBuilder(); $container-> - register('foo', 'FooClass')-> + register('foo', 'Bar\FooClass')-> addTag('foo', array('foo' => 'foo'))-> addTag('foo', array('bar' => 'bar'))-> - setFactoryClass('FooClass')-> + setFactoryClass('Bar\\FooClass')-> setFactoryMethod('getInstance')-> setArguments(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%'), true, new Reference('service_container')))-> setProperties(array('foo' => 'bar', 'moo' => new Reference('foo.baz'), 'qux' => array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%')))-> @@ -22,7 +22,7 @@ setConfigurator('sc_configure') ; $container-> - register('bar', 'FooClass')-> + register('bar', 'Bar\FooClass')-> setArguments(array('foo', new Reference('foo.baz'), new Parameter('foo_bar')))-> setScope('container')-> setConfigurator(array(new Reference('foo.baz'), 'configure')) @@ -40,19 +40,19 @@ $container->getParameterBag()->clear(); $container->getParameterBag()->add(array( 'baz_class' => 'BazClass', - 'foo_class' => 'FooClass', + 'foo_class' => 'Bar\FooClass', 'foo' => 'bar', )); $container->setAlias('alias_for_foo', 'foo'); $container->setAlias('alias_for_alias', 'alias_for_foo'); $container-> - register('method_call1', 'FooClass')-> + register('method_call1', 'Bar\FooClass')-> setFile(realpath(__DIR__.'/../includes/foo.php'))-> addMethodCall('setBar', array(new Reference('foo')))-> addMethodCall('setBar', array(new Reference('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)))-> addMethodCall('setBar', array(new Reference('foo3', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))-> addMethodCall('setBar', array(new Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))-> - addMethodCall('setBar', array(new Expression('service("foo").foo() ~ parameter("foo")'))) + addMethodCall('setBar', array(new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")'))) ; $container-> register('factory_service', 'Bar')-> @@ -83,5 +83,25 @@ ->register('depends_on_request', 'stdClass') ->addMethodCall('setRequest', array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))) ; +$container + ->register('configurator_service', 'ConfClass') + ->setPublic(false) + ->addMethodCall('setFoo', array(new Reference('baz'))) +; +$container + ->register('configured_service', 'stdClass') + ->setConfigurator(array(new Reference('configurator_service'), 'configureStdClass')) +; +$container + ->register('decorated', 'stdClass') +; +$container + ->register('decorator_service', 'stdClass') + ->setDecoratedService('decorated') +; +$container + ->register('decorator_service_with_name', 'stdClass') + ->setDecoratedService('decorated', 'decorated.pif-pouf') +; return $container; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot new file mode 100644 index 0000000000000000000000000000000000000000..a6d04bf5a097f8ddc9d129245b421efb356ca94d --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot @@ -0,0 +1,8 @@ +digraph sc { + ratio="compress" + node [fontsize="11" fontname="Arial" shape="record"]; + edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + + node_foo [label="foo\n%foo.class%\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot new file mode 100644 index 0000000000000000000000000000000000000000..4fbcceef3614d7e25f54a5b13d204f806ad4b8fc --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot @@ -0,0 +1,8 @@ +digraph sc { + ratio="compress" + node [fontsize="11" fontname="Arial" shape="record"]; + edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + + node_foo [label="foo\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot index cb006641d0b132f3cae39b264ac778ac7d67d30e..6bf53e56b65d5c9c2935726d08ab2617c814b214 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot @@ -3,17 +3,22 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; - node_foo [label="foo (alias_for_foo)\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_bar [label="bar\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_foo [label="foo (alias_for_foo)\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_bar [label="bar\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo_baz [label="foo.baz\nBazClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_foo_bar [label="foo_bar\nFooClass\n", shape=record, fillcolor="#eeeeee", style="dotted"]; - node_method_call1 [label="method_call1\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_foo_bar [label="foo_bar\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="dotted"]; + node_method_call1 [label="method_call1\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_factory_service [label="factory_service\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo_with_inline [label="foo_with_inline\nFoo\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_inlined [label="inlined\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_baz [label="baz\nBaz\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_request [label="request\nRequest\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_depends_on_request [label="depends_on_request\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_configurator_service [label="configurator_service\nConfClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_configured_service [label="configured_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_decorated [label="decorated\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_decorator_service [label="decorator_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_decorator_service_with_name [label="decorator_service_with_name\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"]; node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"]; @@ -31,4 +36,5 @@ digraph sc { node_inlined -> node_baz [label="setBaz()" style="dashed"]; node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"]; node_depends_on_request -> node_request [label="setRequest()" style="dashed"]; + node_configurator_service -> node_baz [label="setFoo()" style="dashed"]; } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php index 81ff7aa6feb31f76723723863a534ef95683e87f..c9f80102687174aa893aa71403d8e8a007c0f135 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php @@ -36,6 +36,5 @@ public function getAlias() public function getConfiguration(array $config, ContainerBuilder $container) { - return null; } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php index 180bb384a3de6d4c1c26eb535635299c0394808d..55968aff923c4553c35027860ab5b5cf15ee2033 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php @@ -1,5 +1,7 @@ <?php +namespace Bar; + class FooClass { public $foo, $moo; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index d1f9c0d1664cb1dbfd0511ec6942d5ec7a28f954..2ccd9a07e49b2f735a7c51db2096041d56a4cd79 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -16,6 +16,8 @@ */ class ProjectServiceContainer extends Container { + private $parameters; + /** * Constructor. */ @@ -44,7 +46,7 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getTestService() { @@ -84,7 +86,7 @@ public function setParameter($name, $value) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getParameterBag() { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 3fafcf175735160a7862840b730ab625cb44fc68..8fe63d70567b2d92dff952c8a46f53cde812024f 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -25,6 +25,11 @@ public function __construct() $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', + 'configurator_service' => 'getConfiguratorServiceService', + 'configured_service' => 'getConfiguredServiceService', + 'decorated' => 'getDecoratedService', + 'decorator_service' => 'getDecoratorServiceService', + 'decorator_service_with_name' => 'getDecoratorServiceWithNameService', 'depends_on_request' => 'getDependsOnRequestService', 'factory_service' => 'getFactoryServiceService', 'foo' => 'getFooService', @@ -47,13 +52,15 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getBarService() { - $this->services['bar'] = $instance = new \FooClass('foo', $this->get('foo.baz'), $this->getParameter('foo_bar')); + $a = $this->get('foo.baz'); + + $this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar')); - $this->get('foo.baz')->configure($instance); + $a->configure($instance); return $instance; } @@ -64,7 +71,7 @@ protected function getBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Baz A Baz instance. + * @return \Baz A Baz instance. */ protected function getBazService() { @@ -75,13 +82,69 @@ protected function getBazService() return $instance; } + /** + * Gets the 'configured_service' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getConfiguredServiceService() + { + $this->services['configured_service'] = $instance = new \stdClass(); + + $this->get('configurator_service')->configureStdClass($instance); + + return $instance; + } + + /** + * Gets the 'decorated' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getDecoratedService() + { + return $this->services['decorated'] = new \stdClass(); + } + + /** + * Gets the 'decorator_service' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getDecoratorServiceService() + { + return $this->services['decorator_service'] = new \stdClass(); + } + + /** + * Gets the 'decorator_service_with_name' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getDecoratorServiceWithNameService() + { + return $this->services['decorator_service_with_name'] = new \stdClass(); + } + /** * Gets the 'depends_on_request' service. * * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getDependsOnRequestService() { @@ -98,7 +161,7 @@ protected function getDependsOnRequestService() * This service is shared. * This method always returns the same instance of the service. * - * @return Bar A Bar instance. + * @return \Bar A Bar instance. */ protected function getFactoryServiceService() { @@ -111,13 +174,13 @@ protected function getFactoryServiceService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getFooService() { $a = $this->get('foo.baz'); - $this->services['foo'] = $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')), true, $this); + $this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')), true, $this); $instance->setBar($this->get('bar')); $instance->initialize(); @@ -164,7 +227,7 @@ protected function getFooBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Foo A Foo instance. + * @return \Foo A Foo instance. */ protected function getFooWithInlineService() { @@ -181,13 +244,13 @@ protected function getFooWithInlineService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getMethodCall1Service() { require_once '%path%foo.php'; - $this->services['method_call1'] = $instance = new \FooClass(); + $this->services['method_call1'] = $instance = new \Bar\FooClass(); $instance->setBar($this->get('foo')); $instance->setBar($this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)); @@ -197,7 +260,7 @@ protected function getMethodCall1Service() if ($this->has('foobaz')) { $instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)); } - $instance->setBar(($this->get("foo")->foo() . $this->getParameter("foo"))); + $instance->setBar(($this->get("foo")->foo() . (($this->hasparameter("foo")) ? ($this->getParameter("foo")) : ("default")))); return $instance; } @@ -225,6 +288,27 @@ protected function synchronizeRequestService() } } + /** + * Gets the 'configurator_service' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * This service is private. + * If you want to be able to request this service from the container directly, + * make it public, otherwise you might end up with broken code. + * + * @return \ConfClass A ConfClass instance. + */ + protected function getConfiguratorServiceService() + { + $this->services['configurator_service'] = $instance = new \ConfClass(); + + $instance->setFoo($this->get('baz')); + + return $instance; + } + /** * Gets the 'inlined' service. * @@ -235,7 +319,7 @@ protected function synchronizeRequestService() * If you want to be able to request this service from the container directly, * make it public, otherwise you might end up with broken code. * - * @return Bar A Bar instance. + * @return \Bar A Bar instance. */ protected function getInlinedService() { @@ -256,7 +340,7 @@ protected function getDefaultParameters() { return array( 'baz_class' => 'BazClass', - 'foo_class' => 'FooClass', + 'foo_class' => 'Bar\\FooClass', 'foo' => 'bar', ); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index c4b8e47586f9218f6abd62873373e9a9ee7dc43a..8962b26398841f3ff2d04776facc1f134d2ab9f3 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -16,6 +16,8 @@ */ class ProjectServiceContainer extends Container { + private $parameters; + /** * Constructor. */ @@ -34,6 +36,9 @@ public function __construct() $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', + 'configured_service' => 'getConfiguredServiceService', + 'decorator_service' => 'getDecoratorServiceService', + 'decorator_service_with_name' => 'getDecoratorServiceWithNameService', 'depends_on_request' => 'getDependsOnRequestService', 'factory_service' => 'getFactoryServiceService', 'foo' => 'getFooService', @@ -46,6 +51,7 @@ public function __construct() $this->aliases = array( 'alias_for_alias' => 'foo', 'alias_for_foo' => 'foo', + 'decorated' => 'decorator_service_with_name', ); } @@ -55,13 +61,15 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getBarService() { - $this->services['bar'] = $instance = new \FooClass('foo', $this->get('foo.baz'), $this->getParameter('foo_bar')); + $a = $this->get('foo.baz'); + + $this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar')); - $this->get('foo.baz')->configure($instance); + $a->configure($instance); return $instance; } @@ -72,7 +80,7 @@ protected function getBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Baz A Baz instance. + * @return \Baz A Baz instance. */ protected function getBazService() { @@ -83,13 +91,59 @@ protected function getBazService() return $instance; } + /** + * Gets the 'configured_service' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getConfiguredServiceService() + { + $a = new \ConfClass(); + $a->setFoo($this->get('baz')); + + $this->services['configured_service'] = $instance = new \stdClass(); + + $a->configureStdClass($instance); + + return $instance; + } + + /** + * Gets the 'decorator_service' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getDecoratorServiceService() + { + return $this->services['decorator_service'] = new \stdClass(); + } + + /** + * Gets the 'decorator_service_with_name' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getDecoratorServiceWithNameService() + { + return $this->services['decorator_service_with_name'] = new \stdClass(); + } + /** * Gets the 'depends_on_request' service. * * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getDependsOnRequestService() { @@ -106,7 +160,7 @@ protected function getDependsOnRequestService() * This service is shared. * This method always returns the same instance of the service. * - * @return Bar A Bar instance. + * @return \Bar A Bar instance. */ protected function getFactoryServiceService() { @@ -119,13 +173,13 @@ protected function getFactoryServiceService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getFooService() { $a = $this->get('foo.baz'); - $this->services['foo'] = $instance = call_user_func(array('FooClass', 'getInstance'), 'foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this); + $this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this); $instance->setBar($this->get('bar')); $instance->initialize(); @@ -143,13 +197,13 @@ protected function getFooService() * This service is shared. * This method always returns the same instance of the service. * - * @return BazClass A BazClass instance. + * @return \BazClass A BazClass instance. */ protected function getFoo_BazService() { - $this->services['foo.baz'] = $instance = call_user_func(array('BazClass', 'getInstance')); + $this->services['foo.baz'] = $instance = \BazClass::getInstance(); - call_user_func(array('BazClass', 'configureStatic1'), $instance); + \BazClass::configureStatic1($instance); return $instance; } @@ -157,11 +211,11 @@ protected function getFoo_BazService() /** * Gets the 'foo_bar' service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getFooBarService() { - return new \FooClass(); + return new \Bar\FooClass(); } /** @@ -170,7 +224,7 @@ protected function getFooBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Foo A Foo instance. + * @return \Foo A Foo instance. */ protected function getFooWithInlineService() { @@ -192,17 +246,17 @@ protected function getFooWithInlineService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \Bar\FooClass A Bar\FooClass instance. */ protected function getMethodCall1Service() { require_once '%path%foo.php'; - $this->services['method_call1'] = $instance = new \FooClass(); + $this->services['method_call1'] = $instance = new \Bar\FooClass(); $instance->setBar($this->get('foo')); $instance->setBar(NULL); - $instance->setBar(($this->get("foo")->foo() . $this->getParameter("foo"))); + $instance->setBar(($this->get("foo")->foo() . (($this->hasparameter("foo")) ? ($this->getParameter("foo")) : ("default")))); return $instance; } @@ -263,7 +317,7 @@ public function setParameter($name, $value) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getParameterBag() { @@ -282,7 +336,7 @@ protected function getDefaultParameters() { return array( 'baz_class' => 'BazClass', - 'foo_class' => 'FooClass', + 'foo_class' => 'Bar\\FooClass', 'foo' => 'bar', ); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/namespaces.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/namespaces.xml new file mode 100644 index 0000000000000000000000000000000000000000..5a05cedd7e79e7e0f5b68e065286922cd5d6157a --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/namespaces.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" ?> + +<srv:container xmlns="http://symfony.com/schema/dic/doctrine" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:srv="http://symfony.com/schema/dic/services" + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd + http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> + + <srv:services> + <srv:service id="foo" class="FooClass"> + <srv:tag name="foo.tag" /> + <srv:call method="setBar"> + <srv:argument>foo</srv:argument> + </srv:call> + </srv:service> + </srv:services> +</srv:container> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services14.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services14.xml new file mode 100644 index 0000000000000000000000000000000000000000..73446214e4920487e1e19259dea4b1d3303ff904 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services14.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<container xmlns="http://symfony.com/schema/dic/services" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + <services> + <service id="monolog.logger" parent="monolog.logger_prototype" public="false"> + <argument index="0">app</argument> + </service> + + <service id="logger" alias="monolog.logger" /> + + <service id="monolog.logger" parent="monolog.logger_prototype" public="false"> + <argument index="0">app</argument> + </service> + <service id="monolog.logger_prototype" class="Symfony\Bridge\Monolog\Logger" abstract="true"> + <argument /><!-- Channel --> + </service> + </services> +</container> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml index 43cf86c54751a340a79d85c8c3278a23800c4a66..f1ac14dd5d343fa3bc0329dfd6352013dd9cb48a 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml @@ -23,7 +23,6 @@ <parameter>bar</parameter> </parameter> </parameter> - <parameter key="foo_bar" type="service" id="foo_bar" /> <parameter key="MixedCase" type="collection"> <!-- Should be lower cased --> <parameter key="MixedCaseKey">value</parameter> <!-- Should stay mixed case --> </parameter> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml index ffc038234fae3eb9af756f8b8279a062401f06e8..a6df4b1432e9996e1534e47a139d4bee21f86de0 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml @@ -33,7 +33,7 @@ <service id="method_call1" class="FooClass"> <call method="setBar" /> <call method="setBar"> - <argument type="expression">service("foo").foo() ~ parameter("foo")</argument> + <argument type="expression">service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")</argument> </call> </service> <service id="method_call2" class="FooClass"> @@ -50,5 +50,7 @@ <service id="another_alias_for_foo" alias="foo" public="false" /> <service id="factory_service" factory-method="getInstance" factory-service="baz_factory" /> <service id="request" class="Request" synthetic="true" synchronized="true" lazy="true"/> + <service id="decorator_service" decorates="decorated" /> + <service id="decorator_service_with_name" decorates="decorated" decoration-inner-name="decorated.pif-pouf"/> </services> </container> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml index c5fa5fb52d151db69bbf8d169206750f5bbfd7c2..b17e50043cd1bb1f9ea96025078ca3e72c648170 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" ?> +<?xml version="1.0" encoding="utf-8"?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml index e53b03ed70913f03d00da42c8cb585080bedb83b..50c48d663c101676289213f8660bd02e3280633e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml @@ -2,11 +2,11 @@ <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <parameters> <parameter key="baz_class">BazClass</parameter> - <parameter key="foo_class">FooClass</parameter> + <parameter key="foo_class">Bar\FooClass</parameter> <parameter key="foo">bar</parameter> </parameters> <services> - <service id="foo" class="FooClass" factory-method="getInstance"> + <service id="foo" class="Bar\FooClass" factory-method="getInstance" factory-class="Bar\FooClass"> <tag name="foo" foo="foo"/> <tag name="foo" bar="bar"/> <argument>foo</argument> @@ -29,17 +29,17 @@ <call method="initialize"/> <configurator function="sc_configure"/> </service> - <service id="bar" class="FooClass"> + <service id="bar" class="Bar\FooClass"> <argument>foo</argument> <argument type="service" id="foo.baz"/> <argument>%foo_bar%</argument> <configurator service="foo.baz" method="configure"/> </service> - <service id="foo.baz" class="%baz_class%" factory-method="getInstance"> + <service id="foo.baz" class="%baz_class%" factory-method="getInstance" factory-class="%baz_class%"> <configurator class="%baz_class%" method="configureStatic1"/> </service> <service id="foo_bar" class="%foo_class%" scope="prototype"/> - <service id="method_call1" class="FooClass"> + <service id="method_call1" class="Bar\FooClass"> <file>%path%foo.php</file> <call method="setBar"> <argument type="service" id="foo"/> @@ -54,7 +54,7 @@ <argument type="service" id="foobaz" on-invalid="ignore"/> </call> <call method="setBar"> - <argument type="expression">service("foo").foo() ~ parameter("foo")</argument> + <argument type="expression">service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")</argument> </call> </service> <service id="factory_service" class="Bar" factory-method="getInstance" factory-service="foo.baz"/> @@ -80,6 +80,17 @@ <argument type="service" id="request" on-invalid="null" strict="false"/> </call> </service> + <service id="configurator_service" class="ConfClass" public="false"> + <call method="setFoo"> + <argument type="service" id="baz"/> + </call> + </service> + <service id="configured_service" class="stdClass"> + <configurator service="configurator_service" method="configureStdClass"/> + </service> + <service id="decorated" class="stdClass"/> + <service id="decorator_service" class="stdClass" decorates="decorated"/> + <service id="decorator_service_with_name" class="stdClass" decorates="decorated" decoration-inner-name="decorated.pif-pouf"/> <service id="alias_for_foo" alias="foo"/> <service id="alias_for_alias" alias="foo"/> </services> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml new file mode 100644 index 0000000000000000000000000000000000000000..3f34b07eb0eaaab967b85b17680d67cddd36fe39 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml @@ -0,0 +1,4 @@ +services: + method_call1: + class: FooClass + calls: foo diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml new file mode 100644 index 0000000000000000000000000000000000000000..0765dc8dd0856794ea09a0daeb5838b8cae7f221 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml @@ -0,0 +1,2 @@ +imports: + - foo.yml diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml new file mode 100644 index 0000000000000000000000000000000000000000..1ce9d57c6c728db48bc3c4abaae55fb48909c215 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml @@ -0,0 +1,2 @@ +imports: + foo:bar diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml new file mode 100644 index 0000000000000000000000000000000000000000..bbd13ac0b349aa3a03274e3dd15adee58548d4a6 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml @@ -0,0 +1,2 @@ +parameters: + foo:bar diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml new file mode 100644 index 0000000000000000000000000000000000000000..811af3c0efd799c90b04c116275ea7d59b725503 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml @@ -0,0 +1,2 @@ +services: + foo: bar diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml new file mode 100644 index 0000000000000000000000000000000000000000..cfbf17ce5f8c6c9eb387baafcc657ee4180533cc --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml @@ -0,0 +1 @@ +services: foo diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml new file mode 100644 index 0000000000000000000000000000000000000000..e8e99395b1fdf11ceeb47b99598f2b78a9ea4507 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml @@ -0,0 +1,6 @@ +services: + foo_service: + class: FooClass + tags: + # tag is not an array + - foo diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml index 18f10658c437d16989b2ac913153b2fa23693b94..8e0987fd03a6c90baf7632e36ceeb0b9c4c449c4 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml @@ -1,6 +1,7 @@ imports: - { resource: services2.yml } - { resource: services3.yml } + - { resource: "../php/simple.php" } - { resource: "../ini/parameters.ini", class: Symfony\Component\DependencyInjection\Loader\IniFileLoader } - { resource: "../ini/parameters2.ini" } - { resource: "../xml/services13.xml" } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index d3c793f2e31c3e1c9ac9c0f60f1f0f1c941c9259..7c1a62c327847011e900347c893a51f922fd61ed 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -15,7 +15,7 @@ services: calls: - [ setBar, [] ] - [ setBar ] - - [ setBar, ['@=service("foo").foo() ~ parameter("foo")'] ] + - [ setBar, ['@=service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")'] ] method_call2: class: FooClass calls: @@ -30,3 +30,8 @@ services: synthetic: true synchronized: true lazy: true + decorator_service: + decorates: decorated + decorator_service_with_name: + decorates: decorated + decoration_inner_name: decorated.pif-pouf diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index 6de64ee4639667008b100b1236a3f23b8a0f39f0..52bfb0dc4c5e054ef057aeebc9eef1ee731e4a7e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -1,15 +1,15 @@ parameters: baz_class: BazClass - foo_class: FooClass + foo_class: Bar\FooClass foo: bar services: foo: - class: FooClass + class: Bar\FooClass tags: - { name: foo, foo: foo } - { name: foo, bar: bar } - factory_class: FooClass + factory_class: Bar\FooClass factory_method: getInstance arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', foobar: '%foo%' }, true, '@service_container'] properties: { foo: bar, moo: '@foo.baz', qux: { '%foo%': 'foo is %foo%', foobar: '%foo%' } } @@ -19,7 +19,7 @@ services: configurator: sc_configure bar: - class: FooClass + class: Bar\FooClass arguments: [foo, '@foo.baz', '%foo_bar%'] configurator: ['@foo.baz', configure] foo.baz: @@ -31,14 +31,14 @@ services: class: %foo_class% scope: prototype method_call1: - class: FooClass + class: Bar\FooClass file: %path%foo.php calls: - [setBar, ['@foo']] - [setBar, ['@?foo2']] - [setBar, ['@?foo3']] - [setBar, ['@?foobaz']] - - [setBar, ['@=service("foo").foo() ~ parameter("foo")']] + - [setBar, ['@=service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")']] factory_service: class: Bar @@ -70,5 +70,23 @@ services: calls: - [setRequest, ['@?request']] + configurator_service: + class: ConfClass + public: false + calls: + - [setFoo, ['@baz']] + + configured_service: + class: stdClass + configurator: ['@configurator_service', configureStdClass] + decorated: + class: stdClass + decorator_service: + class: stdClass + decorates: decorated + decorator_service_with_name: + class: stdClass + decorates: decorated + decoration_inner_name: decorated.pif-pouf alias_for_foo: @foo alias_for_alias: @foo diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 74db3c8eff5d45188a94e07aac8cc204b28136a7..db6598e671a80a33156e0e49d547712f4c0de1a7 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -53,37 +53,37 @@ public function testParseFile() { $loader = new XmlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini')); $r = new \ReflectionObject($loader); - $m = $r->getMethod('parseFile'); + $m = $r->getMethod('parseFileToDOM'); $m->setAccessible(true); try { $m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini'); - $this->fail('->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); - $this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'parameters.ini'), $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'parameters.ini'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); - $this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); } $loader = new XmlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/xml')); try { $m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml'); - $this->fail('->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + $this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); - $this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'nonvalid.xml'), $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + $this->assertRegExp(sprintf('#^Unable to parse file ".+%s".$#', 'nonvalid.xml'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); - $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + $this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); } $xml = $m->invoke($loader, self::$fixturesPath.'/xml/services1.xml'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', get_class($xml), '->parseFile() returns an SimpleXMLElement object'); + $this->assertInstanceOf('DOMDocument', $xml, '->parseFileToDOM() returns an SimpleXMLElement object'); } public function testLoadParameters() @@ -110,7 +110,6 @@ public function testLoadParameters() 'a string', array('foo', 'bar'), ), - 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'constant' => PHP_EOL, ); @@ -147,12 +146,11 @@ public function testLoadImports() 'a string', array('foo', 'bar'), ), - 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'constant' => PHP_EOL, 'bar' => '%foo%', 'imported_from_ini' => true, - 'imported_from_yaml' => true + 'imported_from_yaml' => true, ); $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); @@ -167,28 +165,29 @@ public function testLoadAnonymousServices() $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader->load('services5.xml'); $services = $container->getDefinitions(); - $this->assertEquals(4, count($services), '->load() attributes unique ids to anonymous services'); + $this->assertCount(4, $services, '->load() attributes unique ids to anonymous services'); // anonymous service as an argument $args = $services['foo']->getArguments(); - $this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services'); + $this->assertCount(1, $args, '->load() references anonymous services as "normal" ones'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services'); $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; $this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); // inner anonymous services $args = $inner->getArguments(); - $this->assertEquals(1, count($args), '->load() references anonymous services as "normal" ones'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($args[0]), '->load() converts anonymous services to references to "normal" services'); + $this->assertCount(1, $args, '->load() references anonymous services as "normal" ones'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services'); $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); + $this->assertFalse($inner->isPublic()); // anonymous service as a property $properties = $services['foo']->getProperties(); $property = $properties['p']; - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Reference', get_class($property), '->load() converts anonymous services to references to "normal" services'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services'); $this->assertTrue(isset($services[(string) $property]), '->load() makes a reference to the created ones'); $inner = $services[(string) $property]; $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); @@ -201,7 +200,7 @@ public function testLoadServices() $loader->load('services6.xml'); $services = $container->getDefinitions(); $this->assertTrue(isset($services['foo']), '->load() parses <service> elements'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts <service> element to Definition instances'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts <service> element to Definition instances'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('container', $services['scope.container']->getScope()); $this->assertEquals('custom', $services['scope.custom']->getScope()); @@ -212,7 +211,7 @@ public function testLoadServices() $this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag'); $this->assertEquals(array(new Reference('baz', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag'); $this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag'); - $this->assertEquals(array(array('setBar', array()), array('setBar', array(new Expression('service("foo").foo() ~ parameter("foo")')))), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); + $this->assertEquals(array(array('setBar', array()), array('setBar', array(new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")')))), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); $this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag'); $this->assertNull($services['factory_service']->getClass()); $this->assertEquals('getInstance', $services['factory_service']->getFactoryMethod()); @@ -229,6 +228,10 @@ public function testLoadServices() $this->assertTrue(isset($aliases['another_alias_for_foo'])); $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); + + $this->assertNull($services['request']->getDecoratedService()); + $this->assertEquals(array('decorated', null), $services['decorator_service']->getDecoratedService()); + $this->assertEquals(array('decorated', 'decorated.pif-pouf'), $services['decorator_service_with_name']->getDecoratedService()); } public function testParsesTags() @@ -394,11 +397,11 @@ public function testNoNamingConflictsForAnonymousServices() $loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension1')); $loader1->load('services.xml'); $services = $container->getDefinitions(); - $this->assertEquals(2, count($services), '->load() attributes unique ids to anonymous services'); + $this->assertCount(2, $services, '->load() attributes unique ids to anonymous services'); $loader2 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension2')); $loader2->load('services.xml'); $services = $container->getDefinitions(); - $this->assertEquals(4, count($services), '->load() attributes unique ids to anonymous services'); + $this->assertCount(4, $services, '->load() attributes unique ids to anonymous services'); $services = $container->getDefinitions(); $args1 = $services['extension1.foo']->getArguments(); @@ -428,4 +431,25 @@ public function testDocTypeIsNotAllowed() $this->assertSame('Document types are not allowed.', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type'); } } + + public function testXmlNamespaces() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('namespaces.xml'); + $services = $container->getDefinitions(); + + $this->assertTrue(isset($services['foo']), '->load() parses <srv:service> elements'); + $this->assertEquals(1, count($services['foo']->getTag('foo.tag')), '->load parses <srv:tag> elements'); + $this->assertEquals(array(array('setBar', array('foo'))), $services['foo']->getMethodCalls(), '->load() parses the <srv:call> tag'); + } + + public function testLoadIndexedArguments() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('services14.xml'); + + $this->assertEquals(array('index_0' => 'app'), $container->findDefinition('logger')->getArguments()); + } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index c7cb0cde5f01b048f081e503b2bed36248f3be42..57b308766610cfeb70dda1f612dd3838691abe66 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -13,11 +13,11 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\Config\Loader\Loader; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\IniFileLoader; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\FileLocator; use Symfony\Component\ExpressionLanguage\Expression; @@ -69,6 +69,29 @@ public function testLoadFile() } } + /** + * @dataProvider provideInvalidFiles + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + */ + public function testLoadInvalidFile($file) + { + $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); + + $loader->load($file.'.yml'); + } + + public function provideInvalidFiles() + { + return array( + array('bad_parameters'), + array('bad_imports'), + array('bad_import'), + array('bad_services'), + array('bad_service'), + array('bad_calls'), + ); + } + public function testLoadParameters() { $container = new ContainerBuilder(); @@ -83,6 +106,7 @@ public function testLoadImports() $resolver = new LoaderResolver(array( new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')), new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')), + new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')), $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')), )); $loader->setResolver($resolver); @@ -103,7 +127,7 @@ public function testLoadServices() $loader->load('services6.yml'); $services = $container->getDefinitions(); $this->assertTrue(isset($services['foo']), '->load() parses service elements'); - $this->assertEquals('Symfony\\Component\\DependencyInjection\\Definition', get_class($services['foo']), '->load() converts service element to Definition instances'); + $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts service element to Definition instances'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('container', $services['scope.container']->getScope()); $this->assertEquals('custom', $services['scope.custom']->getScope()); @@ -114,7 +138,7 @@ public function testLoadServices() $this->assertEquals('sc_configure', $services['configurator1']->getConfigurator(), '->load() parses the configurator tag'); $this->assertEquals(array(new Reference('baz'), 'configure'), $services['configurator2']->getConfigurator(), '->load() parses the configurator tag'); $this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag'); - $this->assertEquals(array(array('setBar', array()), array('setBar', array()), array('setBar', array(new Expression('service("foo").foo() ~ parameter("foo")')))), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); + $this->assertEquals(array(array('setBar', array()), array('setBar', array()), array('setBar', array(new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")')))), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag'); $this->assertEquals(array(array('setBar', array('foo', new Reference('foo'), array(true, false)))), $services['method_call2']->getMethodCalls(), '->load() parses the method_call tag'); $this->assertEquals('baz_factory', $services['factory_service']->getFactoryService()); @@ -129,6 +153,10 @@ public function testLoadServices() $this->assertTrue(isset($aliases['another_alias_for_foo'])); $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); + + $this->assertNull($services['request']->getDecoratedService()); + $this->assertEquals(array('decorated', null), $services['decorator_service']->getDecoratedService()); + $this->assertEquals(array('decorated', 'decorated.pif-pouf'), $services['decorator_service_with_name']->getDecoratedService()); } public function testExtensions() @@ -167,7 +195,7 @@ public function testSupports() $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); } - public function testNonArrayTagThrowsException() + public function testNonArrayTagsThrowsException() { $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); try { @@ -179,6 +207,16 @@ public function testNonArrayTagThrowsException() } } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + * @expectedExceptionMessage A "tags" entry must be an array for service + */ + public function testNonArrayTagThrowsException() + { + $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('badtag4.yml'); + } + public function testTagWithoutNameThrowsException() { $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json index 1a29489d2bafde3f36d3beba22331cf28460f8ed..2190101fa2c9f69a7246e28f62f412bffcd45000 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json @@ -35,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist index 53f5f99d6002fd20a2c6497a0fb18bb16d4a4ef5..d636cde6dc9f960ae97c4dfba1b270e5fe9cb541 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/services10.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/services10.xml deleted file mode 100644 index 824d8b5d753969de96af6c55f6d0a153b3fc2c5b..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/services10.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" ?> - -<container xmlns="http://symfony.com/schema/dic/services" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - <services> - <service id="foo" class="BarClass" /> - </services> -</container> diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md index 536c5ac729812f028180eaa50e9c7e8345049852..bb42ee19c04ca2961e01b8fb314d2e6e9dcb92a7 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +2.5.0 +----- + + * added Debug\TraceableEventDispatcher (originally in HttpKernel) + * changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface + * added RegisterListenersPass (originally in HttpKernel) + 2.1.0 ----- diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php index 9448ed43e932dbf9923e5311115f78e543a0ee4d..e97d427ea15ebd0ad478e49e4808665664de717c 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -57,7 +57,7 @@ public function __construct(ContainerInterface $container) * @param string $eventName Event for which the listener is added * @param array $callback The service ID of the listener service & the method * name that has to be called - * @param integer $priority The higher this value, the earlier an event listener + * @param int $priority The higher this value, the earlier an event listener * will be triggered in the chain. * Defaults to 0. * @@ -105,7 +105,7 @@ public function removeListener($eventName, $listener) public function hasListeners($eventName = null) { if (null === $eventName) { - return (Boolean) count($this->listenerIds) || (Boolean) count($this->listeners); + return (bool) count($this->listenerIds) || (bool) count($this->listeners); } if (isset($this->listenerIds[$eventName])) { @@ -153,7 +153,7 @@ public function addSubscriberService($serviceId, $class) } /** - * {@inheritDoc} + * {@inheritdoc} * * Lazily loads listeners for this event from the dependency injection * container. diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php new file mode 100644 index 0000000000000000000000000000000000000000..b797667208bb5967a8934732e15391484ce17a8e --- /dev/null +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -0,0 +1,317 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\EventDispatcher\Debug; + +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\Stopwatch\Stopwatch; +use Psr\Log\LoggerInterface; + +/** + * Collects some data about event listeners. + * + * This event dispatcher delegates the dispatching to another one. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class TraceableEventDispatcher implements TraceableEventDispatcherInterface +{ + protected $logger; + protected $stopwatch; + + private $called; + private $dispatcher; + + /** + * Constructor. + * + * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance + * @param Stopwatch $stopwatch A Stopwatch instance + * @param LoggerInterface $logger A LoggerInterface instance + */ + public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null) + { + $this->dispatcher = $dispatcher; + $this->stopwatch = $stopwatch; + $this->logger = $logger; + $this->called = array(); + } + + /** + * {@inheritdoc} + */ + public function addListener($eventName, $listener, $priority = 0) + { + $this->dispatcher->addListener($eventName, $listener, $priority); + } + + /** + * {@inheritdoc} + */ + public function addSubscriber(EventSubscriberInterface $subscriber) + { + $this->dispatcher->addSubscriber($subscriber); + } + + /** + * {@inheritdoc} + */ + public function removeListener($eventName, $listener) + { + return $this->dispatcher->removeListener($eventName, $listener); + } + + /** + * {@inheritdoc} + */ + public function removeSubscriber(EventSubscriberInterface $subscriber) + { + return $this->dispatcher->removeSubscriber($subscriber); + } + + /** + * {@inheritdoc} + */ + public function getListeners($eventName = null) + { + return $this->dispatcher->getListeners($eventName); + } + + /** + * {@inheritdoc} + */ + public function hasListeners($eventName = null) + { + return $this->dispatcher->hasListeners($eventName); + } + + /** + * {@inheritdoc} + */ + public function dispatch($eventName, Event $event = null) + { + if (null === $event) { + $event = new Event(); + } + + $this->preProcess($eventName); + $this->preDispatch($eventName, $event); + + $e = $this->stopwatch->start($eventName, 'section'); + + $this->dispatcher->dispatch($eventName, $event); + + if ($e->isStarted()) { + $e->stop(); + } + + $this->postDispatch($eventName, $event); + $this->postProcess($eventName); + + return $event; + } + + /** + * {@inheritdoc} + */ + public function getCalledListeners() + { + $called = array(); + foreach ($this->called as $eventName => $listeners) { + foreach ($listeners as $listener) { + $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); + $called[$eventName.'.'.$info['pretty']] = $info; + } + } + + return $called; + } + + /** + * {@inheritdoc} + */ + public function getNotCalledListeners() + { + try { + $allListeners = $this->getListeners(); + } catch (\Exception $e) { + if (null !== $this->logger) { + $this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e)); + } + + // unable to retrieve the uncalled listeners + return array(); + } + + $notCalled = array(); + foreach ($allListeners as $eventName => $listeners) { + foreach ($listeners as $listener) { + $called = false; + if (isset($this->called[$eventName])) { + foreach ($this->called[$eventName] as $l) { + if ($l->getWrappedListener() === $listener) { + $called = true; + + break; + } + } + } + + if (!$called) { + $info = $this->getListenerInfo($listener, $eventName); + $notCalled[$eventName.'.'.$info['pretty']] = $info; + } + } + } + + return $notCalled; + } + + /** + * Proxies all method calls to the original event dispatcher. + * + * @param string $method The method name + * @param array $arguments The method arguments + * + * @return mixed + */ + public function __call($method, $arguments) + { + return call_user_func_array(array($this->dispatcher, $method), $arguments); + } + + /** + * Called before dispatching the event. + * + * @param string $eventName The event name + * @param Event $event The event + */ + protected function preDispatch($eventName, Event $event) + { + } + + /** + * Called after dispatching the event. + * + * @param string $eventName The event name + * @param Event $event The event + */ + protected function postDispatch($eventName, Event $event) + { + } + + private function preProcess($eventName) + { + foreach ($this->dispatcher->getListeners($eventName) as $listener) { + $this->dispatcher->removeListener($eventName, $listener); + $info = $this->getListenerInfo($listener, $eventName); + $name = isset($info['class']) ? $info['class'] : $info['type']; + $this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch)); + } + } + + private function postProcess($eventName) + { + $skipped = false; + foreach ($this->dispatcher->getListeners($eventName) as $listener) { + // Unwrap listener + $this->dispatcher->removeListener($eventName, $listener); + $this->dispatcher->addListener($eventName, $listener->getWrappedListener()); + + $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); + if ($listener->wasCalled()) { + if (null !== $this->logger) { + $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty'])); + } + + if (!isset($this->called[$eventName])) { + $this->called[$eventName] = new \SplObjectStorage(); + } + + $this->called[$eventName]->attach($listener); + } + + if (null !== $this->logger && $skipped) { + $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName)); + } + + if ($listener->stoppedPropagation()) { + if (null !== $this->logger) { + $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName)); + } + + $skipped = true; + } + } + } + + /** + * Returns information about the listener + * + * @param object $listener The listener + * @param string $eventName The event name + * + * @return array Information about the listener + */ + private function getListenerInfo($listener, $eventName) + { + $info = array( + 'event' => $eventName, + ); + if ($listener instanceof \Closure) { + $info += array( + 'type' => 'Closure', + 'pretty' => 'closure', + ); + } elseif (is_string($listener)) { + try { + $r = new \ReflectionFunction($listener); + $file = $r->getFileName(); + $line = $r->getStartLine(); + } catch (\ReflectionException $e) { + $file = null; + $line = null; + } + $info += array( + 'type' => 'Function', + 'function' => $listener, + 'file' => $file, + 'line' => $line, + 'pretty' => $listener, + ); + } elseif (is_array($listener) || (is_object($listener) && is_callable($listener))) { + if (!is_array($listener)) { + $listener = array($listener, '__invoke'); + } + $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0]; + try { + $r = new \ReflectionMethod($class, $listener[1]); + $file = $r->getFileName(); + $line = $r->getStartLine(); + } catch (\ReflectionException $e) { + $file = null; + $line = null; + } + $info += array( + 'type' => 'Method', + 'class' => $class, + 'method' => $listener[1], + 'file' => $file, + 'line' => $line, + 'pretty' => $class.'::'.$listener[1], + ); + } + + return $info; + } +} diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php index a67a979014f9be5409e5c2cac86a3b0fac7b6242..5483e815068c4388fa90ce6b6dd14f547ca52d4c 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php @@ -11,10 +11,12 @@ namespace Symfony\Component\EventDispatcher\Debug; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + /** * @author Fabien Potencier <fabien@symfony.com> */ -interface TraceableEventDispatcherInterface +interface TraceableEventDispatcherInterface extends EventDispatcherInterface { /** * Gets the called listeners. diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php new file mode 100644 index 0000000000000000000000000000000000000000..c501662b07d1da049bed5a2ed0ffbeabf118f0df --- /dev/null +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php @@ -0,0 +1,69 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\EventDispatcher\Debug; + +use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + +/** + * @author Fabien Potencier <fabien@symfony.com> + */ +class WrappedListener +{ + private $listener; + private $name; + private $called; + private $stoppedPropagation; + private $stopwatch; + + public function __construct($listener, $name, Stopwatch $stopwatch) + { + $this->listener = $listener; + $this->name = $name; + $this->stopwatch = $stopwatch; + $this->called = false; + $this->stoppedPropagation = false; + } + + public function getWrappedListener() + { + return $this->listener; + } + + public function wasCalled() + { + return $this->called; + } + + public function stoppedPropagation() + { + return $this->stoppedPropagation; + } + + public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher) + { + $this->called = true; + + $e = $this->stopwatch->start($this->name, 'event_listener'); + + call_user_func($this->listener, $event, $eventName, $dispatcher); + + if ($e->isStarted()) { + $e->stop(); + } + + if ($event->isPropagationStopped()) { + $this->stoppedPropagation = true; + } + } +} diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php new file mode 100644 index 0000000000000000000000000000000000000000..afe3ecd18221246ae730e8a67d88346c6e374044 --- /dev/null +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -0,0 +1,106 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\EventDispatcher\DependencyInjection; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Compiler pass to register tagged services for an event dispatcher. + */ +class RegisterListenersPass implements CompilerPassInterface +{ + /** + * @var string + */ + protected $dispatcherService; + + /** + * @var string + */ + protected $listenerTag; + + /** + * @var string + */ + protected $subscriberTag; + + /** + * Constructor. + * + * @param string $dispatcherService Service name of the event dispatcher in processed container + * @param string $listenerTag Tag name used for listener + * @param string $subscriberTag Tag name used for subscribers + */ + public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber') + { + $this->dispatcherService = $dispatcherService; + $this->listenerTag = $listenerTag; + $this->subscriberTag = $subscriberTag; + } + + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { + return; + } + + $definition = $container->findDefinition($this->dispatcherService); + + foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) { + $def = $container->getDefinition($id); + if (!$def->isPublic()) { + throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id)); + } + + if ($def->isAbstract()) { + throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id)); + } + + foreach ($events as $event) { + $priority = isset($event['priority']) ? $event['priority'] : 0; + + if (!isset($event['event'])) { + throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag)); + } + + if (!isset($event['method'])) { + $event['method'] = 'on'.preg_replace_callback(array( + '/(?<=\b)[a-z]/i', + '/[^a-z0-9]/i', + ), function ($matches) { return strtoupper($matches[0]); }, $event['event']); + $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); + } + + $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); + } + } + + foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) { + $def = $container->getDefinition($id); + if (!$def->isPublic()) { + throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id)); + } + + // We must assume that the class value has been correctly filled, even if the service is created by a factory + $class = $def->getClass(); + + $refClass = new \ReflectionClass($class); + $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; + if (!$refClass->implementsInterface($interface)) { + throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); + } + + $definition->addMethodCall('addSubscriberService', array($id, $class)); + } + } +} diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php index e25e7f1ebae42902adc7e1fe6f11646be968c32c..bf792a2579927aa303602975804e7737480b4010 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php @@ -30,7 +30,7 @@ class Event { /** - * @var Boolean Whether no further event listeners should be triggered + * @var bool Whether no further event listeners should be triggered */ private $propagationStopped = false; @@ -48,7 +48,7 @@ class Event * Returns whether further event listeners should be triggered. * * @see Event::stopPropagation - * @return Boolean Whether propagation was already stopped for this event. + * @return bool Whether propagation was already stopped for this event. * * @api */ diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php index ad48d4311d8e6979d63617fbecd8871e42f71564..222a9371412542386b090d9dd434fb98823cf08b 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -74,7 +74,7 @@ public function getListeners($eventName = null) } } - return $this->sorted; + return array_filter($this->sorted); } /** @@ -82,7 +82,7 @@ public function getListeners($eventName = null) */ public function hasListeners($eventName = null) { - return (Boolean) count($this->getListeners($eventName)); + return (bool) count($this->getListeners($eventName)); } /** diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index 7aead23b0d9259f9fa8fbe9d211aff3d6d64bfec..3fdbfd8822e3d61ea69f1064fd3fb20e6ecb2ce8 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -42,7 +42,7 @@ public function dispatch($eventName, Event $event = null); * * @param string $eventName The event to listen on * @param callable $listener The listener - * @param integer $priority The higher this value, the earlier an event + * @param int $priority The higher this value, the earlier an event * listener will be triggered in the chain (defaults to 0) * * @api @@ -90,7 +90,7 @@ public function getListeners($eventName = null); * * @param string $eventName The name of the event * - * @return Boolean true if the specified event has any listeners, false otherwise + * @return bool true if the specified event has any listeners, false otherwise */ public function hasListeners($eventName = null); } diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php index c226fdf2e599b8d4a556bcf1c2d2819610579e16..1e8c44a678ff67f6f2b06630929c0dafd3ac1b8e 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php @@ -118,7 +118,7 @@ public function setArguments(array $args = array()) * * @param string $key Key of arguments array. * - * @return boolean + * @return bool */ public function hasArgument($key) { @@ -167,7 +167,7 @@ public function offsetUnset($key) * * @param string $key Array key. * - * @return boolean + * @return bool */ public function offsetExists($key) { diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php index 965a0c6bcfb5c0c4346afab39dcf7c0a4ff66d4a..fb3b4caa266240cd6c70129eb194829bde06832e 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -175,8 +175,6 @@ public function testHasListenersOnLazyLoad() public function testGetListenersOnLazyLoad() { - $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $container = new Container(); @@ -194,8 +192,6 @@ public function testGetListenersOnLazyLoad() public function testRemoveAfterDispatch() { - $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $container = new Container(); @@ -211,8 +207,6 @@ public function testRemoveAfterDispatch() public function testRemoveBeforeDispatch() { - $event = new Event(); - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); $container = new Container(); diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php new file mode 100644 index 0000000000000000000000000000000000000000..47dd5da168234a144eeb27834046243fb7f35f67 --- /dev/null +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -0,0 +1,171 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\EventDispatcher\Tests\Debug; + +use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\Stopwatch\Stopwatch; + +class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase +{ + public function testAddRemoveListener() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $tdispatcher->addListener('foo', $listener = function () {; }); + $listeners = $dispatcher->getListeners('foo'); + $this->assertCount(1, $listeners); + $this->assertSame($listener, $listeners[0]); + + $tdispatcher->removeListener('foo', $listener); + $this->assertCount(0, $dispatcher->getListeners('foo')); + } + + public function testGetListeners() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $tdispatcher->addListener('foo', $listener = function () {; }); + $this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo')); + } + + public function testHasListeners() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $this->assertFalse($dispatcher->hasListeners('foo')); + $this->assertFalse($tdispatcher->hasListeners('foo')); + + $tdispatcher->addListener('foo', $listener = function () {; }); + $this->assertTrue($dispatcher->hasListeners('foo')); + $this->assertTrue($tdispatcher->hasListeners('foo')); + } + + public function testAddRemoveSubscriber() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $subscriber = new EventSubscriber(); + + $tdispatcher->addSubscriber($subscriber); + $listeners = $dispatcher->getListeners('foo'); + $this->assertCount(1, $listeners); + $this->assertSame(array($subscriber, 'call'), $listeners[0]); + + $tdispatcher->removeSubscriber($subscriber); + $this->assertCount(0, $dispatcher->getListeners('foo')); + } + + public function testGetCalledListeners() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + $tdispatcher->addListener('foo', $listener = function () {; }); + + $this->assertEquals(array(), $tdispatcher->getCalledListeners()); + $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getNotCalledListeners()); + + $tdispatcher->dispatch('foo'); + + $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getCalledListeners()); + $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); + } + + public function testLogger() + { + $logger = $this->getMock('Psr\Log\LoggerInterface'); + + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); + $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\"."); + + $tdispatcher->dispatch('foo'); + } + + public function testLoggerWithStoppedEvent() + { + $logger = $this->getMock('Psr\Log\LoggerInterface'); + + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); + $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\"."); + + $tdispatcher->dispatch('foo'); + } + + public function testDispatchCallListeners() + { + $called = array(); + + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + $tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; }); + $tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; }); + + $tdispatcher->dispatch('foo'); + + $this->assertEquals(array('foo1', 'foo2'), $called); + } + + public function testDispatchNested() + { + $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $loop = 1; + $dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) { + ++$loop; + if (2 == $loop) { + $dispatcher->dispatch('foo'); + } + }); + + $dispatcher->dispatch('foo'); + } + + public function testDispatchReusedEventNested() + { + $nestedCall = false; + $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) { + $dispatcher->dispatch('bar', $e); + }); + $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) { + $nestedCall = true; + }); + + $this->assertFalse($nestedCall); + $dispatcher->dispatch('foo'); + $this->assertTrue($nestedCall); + } +} + +class EventSubscriber implements EventSubscriberInterface +{ + public static function getSubscribedEvents() + { + return array('foo' => 'call'); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php similarity index 93% rename from core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php rename to core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php index b82053ece6f092163487ec087ce3db41c863cd02..9c5ee5f7e9d8d0710f9d90a4e12e26b805a73d27 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; +namespace Symfony\Component\EventDispatcher\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; +use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase { @@ -67,7 +67,7 @@ public function testValidEventSubscriber() ->will($this->returnValue(true)); $definition->expects($this->atLeastOnce()) ->method('getClass') - ->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\SubscriberService')); + ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')); $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $builder->expects($this->any()) @@ -136,5 +136,7 @@ public function testAbstractEventListener() class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { - public static function getSubscribedEvents() {} + public static function getSubscribedEvents() + { + } } diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 50af44549b0c392cde33ecfdfaf2a011c217113e..2bd0750b141608a5f3ad29a6e378d2291e94d1a0 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -240,6 +240,7 @@ public function testRemoveSubscriberWithMultipleListeners() public function testEventReceivesTheDispatcherInstance() { + $dispatcher = null; $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) { $dispatcher = $event->getDispatcher(); }); @@ -273,6 +274,28 @@ public function testWorkaroundForPhpBug62976() $dispatcher->removeListener('bug.62976', function () {}); $this->assertTrue($dispatcher->hasListeners('bug.62976')); } + + public function testHasListenersWhenAddedCallbackListenerIsRemoved() + { + $listener = function () {}; + $this->dispatcher->addListener('foo', $listener); + $this->dispatcher->removeListener('foo', $listener); + $this->assertFalse($this->dispatcher->hasListeners()); + } + + public function testGetListenersWhenAddedCallbackListenerIsRemoved() + { + $listener = function () {}; + $this->dispatcher->addListener('foo', $listener); + $this->dispatcher->removeListener('foo', $listener); + $this->assertSame(array(), $this->dispatcher->getListeners()); + } + + public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled() + { + $this->assertFalse($this->dispatcher->hasListeners('foo')); + $this->assertFalse($this->dispatcher->hasListeners()); + } } class CallableClass @@ -339,7 +362,7 @@ public static function getSubscribedEvents() { return array('pre.foo' => array( array('preFoo1'), - array('preFoo2', 10) + array('preFoo2', 10), )); } } diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php index c1e22f4451365139d2f6d5be0a932478c4288b51..1090bcb29609ef5143bd08e8cf3dc5594d9b73cd 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php @@ -18,7 +18,6 @@ */ class GenericEventTest extends \PHPUnit_Framework_TestCase { - /** * @var GenericEvent */ @@ -34,7 +33,7 @@ protected function setUp() parent::setUp(); $this->subject = new \stdClass(); - $this->event = new GenericEvent($this->subject, array('name' => 'Event'), 'foo'); + $this->event = new GenericEvent($this->subject, array('name' => 'Event')); } /** diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index 6402f89fa5fd4bc8822b4e6d57025b4619e6c796..80a7e43be6205a4b9202befd5b12ca46510b43bb 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php @@ -13,7 +13,6 @@ use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * @author Bernhard Schussek <bschussek@gmail.com> diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json index e748c506c1883db2a0a39210e43dd68309ed6117..75fd243d529ea6e475fef02dfd4b563de1c9dd2d 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json @@ -19,7 +19,10 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "~2.0" + "symfony/dependency-injection": "~2.0,<2.6.0", + "symfony/config": "~2.0", + "symfony/stopwatch": "~2.2", + "psr/log": "~1.0" }, "suggest": { "symfony/dependency-injection": "", @@ -32,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist index 0c3de4f7b214ed4738dc7253c517552859ee75e4..cca1259b3793877290661cf43f5211edf26ddc42 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php index 48c10c153f560d819e0ac8b8d1721dfb26cca4b0..2a89a86f24998a6eea5e4573158009c406f69e24 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php @@ -77,7 +77,7 @@ public function __toString() * * @param string $value * - * @return Boolean + * @return bool */ public function has($value) { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php index 0cec4eda1317fcd79818bd3064983279bd7d662a..21a5d155f5ab836db7a9bfadedce2697a58e6433 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -175,7 +175,7 @@ public function getIndex() * * @param string $name * - * @return Boolean + * @return bool */ public function hasAttribute($name) { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 4d2743580727957c9486dd37a96776abe6073b57..bcd4c40f30b5eb5d0be2cad0cce3f8a1c6927c03 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -35,12 +35,12 @@ class BinaryFileResponse extends Response * Constructor. * * @param \SplFileInfo|string $file The file to stream - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers - * @param boolean $public Files are public by default + * @param bool $public Files are public by default * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * @param boolean $autoEtag Whether the ETag header should be automatically set - * @param boolean $autoLastModified Whether the Last-Modified header should be automatically set + * @param bool $autoEtag Whether the ETag header should be automatically set + * @param bool $autoLastModified Whether the Last-Modified header should be automatically set */ public function __construct($file, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { @@ -55,12 +55,14 @@ public function __construct($file, $status = 200, $headers = array(), $public = /** * @param \SplFileInfo|string $file The file to stream - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers - * @param boolean $public Files are public by default + * @param bool $public Files are public by default * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * @param boolean $autoEtag Whether the ETag header should be automatically set - * @param boolean $autoLastModified Whether the Last-Modified header should be automatically set + * @param bool $autoEtag Whether the ETag header should be automatically set + * @param bool $autoLastModified Whether the Last-Modified header should be automatically set + * + * @return BinaryResponse The created response */ public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { @@ -72,8 +74,8 @@ public static function create($file = null, $status = 200, $headers = array(), $ * * @param \SplFileInfo|string $file The file to stream * @param string $contentDisposition - * @param Boolean $autoEtag - * @param Boolean $autoLastModified + * @param bool $autoEtag + * @param bool $autoLastModified * * @return BinaryFileResponse * @@ -81,7 +83,13 @@ public static function create($file = null, $status = 200, $headers = array(), $ */ public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { - $file = new File((string) $file); + if (!$file instanceof File) { + if ($file instanceof \SplFileInfo) { + $file = new File($file->getPathname()); + } else { + $file = new File((string) $file); + } + } if (!$file->isReadable()) { throw new FileException('File must be readable.'); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md index 061d47e7eec94c3a0707abec26328239e0aa4778..0da734bce2f1ce1d919165404cd574a7909b8507 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +2.5.0 +----- + + * added `JsonResponse::setEncodingOptions()` & `JsonResponse::getEncodingOptions()` for easier manipulation + of the options used while encoding data to JSON format. + 2.4.0 ----- diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php index 68fe853b2f08564432728948714b4494fe07a81e..d112123bde462c7656f3b1e17c109ffe7e2a7363 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php @@ -33,11 +33,11 @@ class Cookie * * @param string $name The name of the cookie * @param string $value The value of the cookie - * @param integer|string|\DateTime $expire The time the cookie expires + * @param int|string|\DateTime $expire The time the cookie expires * @param string $path The path on the server in which the cookie will be available on * @param string $domain The domain that the cookie is available to - * @param Boolean $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client - * @param Boolean $httpOnly Whether the cookie will be made accessible only through the HTTP protocol + * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client + * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol * * @throws \InvalidArgumentException * @@ -70,8 +70,8 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom $this->domain = $domain; $this->expire = $expire; $this->path = empty($path) ? '/' : $path; - $this->secure = (Boolean) $secure; - $this->httpOnly = (Boolean) $httpOnly; + $this->secure = (bool) $secure; + $this->httpOnly = (bool) $httpOnly; } /** @@ -151,7 +151,7 @@ public function getDomain() /** * Gets the time the cookie expires. * - * @return integer + * @return int * * @api */ @@ -175,7 +175,7 @@ public function getPath() /** * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client. * - * @return Boolean + * @return bool * * @api */ @@ -187,7 +187,7 @@ public function isSecure() /** * Checks whether the cookie will be made accessible only through the HTTP protocol. * - * @return Boolean + * @return bool * * @api */ @@ -199,7 +199,7 @@ public function isHttpOnly() /** * Whether this cookie is about to be cleared * - * @return Boolean + * @return bool * * @api */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php index 4fabfb910692ea5d81c916b79cdbf6740042c3a1..0fdf7b04283593c90de4fc2f5ece17b14bc2e811 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php @@ -29,7 +29,7 @@ class File extends \SplFileInfo * Constructs a new file from the given path. * * @param string $path The path to the file - * @param Boolean $checkPath Whether to check the path or not + * @param bool $checkPath Whether to check the path or not * * @throws FileNotFoundException If the given path is not a file * diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php index cc646180c8888b95e04a50d094a25f1eded8252f..fe66543e18b98f7b7c7b0a01a0a3c1b56d74ad75 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php @@ -82,18 +82,15 @@ public function register(ExtensionGuesserInterface $guesser) * value. * * @param string $mimeType The mime type + * * @return string The guessed extension or NULL, if none could be guessed */ public function guess($mimeType) { foreach ($this->guessers as $guesser) { - $extension = $guesser->guess($mimeType); - - if (null !== $extension) { - break; + if (null !== $extension = $guesser->guess($mimeType)) { + return $extension; } } - - return $extension; } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php index f23ddd2f489eae475190c22ebdc03332ff136431..f3c208d04baceee84a77db755ff923b74722b7dc 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php @@ -41,7 +41,7 @@ public function __construct($cmd = 'file -b --mime %s 2>/dev/null') /** * Returns whether this guesser is supported on the current OS * - * @return Boolean + * @return bool */ public static function isSupported() { @@ -62,7 +62,7 @@ public function guess($path) } if (!self::isSupported()) { - return null; + return; } ob_start(); @@ -72,14 +72,14 @@ public function guess($path) if ($return > 0) { ob_end_clean(); - return null; + return; } $type = trim(ob_get_clean()); if (!preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match)) { // it's not a type, but an error message - return null; + return; } return $match[1]; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php index a6950df2cd6cac8437e189939a84ec907fcea84b..3b348bdd2db865eb4a1a45542f7e92b122061cad 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php @@ -38,7 +38,7 @@ public function __construct($magicFile = null) /** * Returns whether this guesser is supported on the current OS/PHP setup * - * @return Boolean + * @return bool */ public static function isSupported() { @@ -59,11 +59,11 @@ public function guess($path) } if (!self::isSupported()) { - return null; + return; } if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) { - return null; + return; } return $finfo->file($path); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php index 42e7b77af0a1521c2f0e94b4d6605d59c6124da8..75eeefbf5d780a5f498eed336bff995843784163 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php @@ -655,6 +655,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface 'chemical/x-csml' => 'csml', 'chemical/x-xyz' => 'xyz', 'image/bmp' => 'bmp', + 'image/x-ms-bmp' => 'bmp', 'image/cgm' => 'cgm', 'image/g3fax' => 'g3', 'image/gif' => 'gif', @@ -722,6 +723,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface 'text/plain' => 'txt', 'text/prs.lines.tag' => 'dsc', 'text/richtext' => 'rtx', + 'text/rtf' => 'rtf', 'text/sgml' => 'sgml', 'text/tab-separated-values' => 'tsv', 'text/troff' => 't', diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php index 16c4cdb65eda94e9bb2010a8138229b56e22a063..31f349c759a95bcaa0bccd150d15f6ebf763e180 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -31,7 +31,7 @@ class UploadedFile extends File * * Local files are used in test mode hence the code should not enforce HTTP uploads. * - * @var Boolean + * @var bool */ private $test = false; @@ -59,7 +59,7 @@ class UploadedFile extends File /** * The UPLOAD_ERR_XXX constant provided by the uploader. * - * @var integer + * @var int */ private $error; @@ -80,9 +80,9 @@ class UploadedFile extends File * @param string $path The full temporary path to the file * @param string $originalName The original file name * @param string $mimeType The type of the file as provided by PHP - * @param integer $size The file size - * @param integer $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants) - * @param Boolean $test Whether the test mode is active + * @param int $size The file size + * @param int $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants) + * @param bool $test Whether the test mode is active * * @throws FileException If file_uploads is disabled * @throws FileNotFoundException If the file does not exist @@ -91,15 +91,11 @@ class UploadedFile extends File */ public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) { - if (!ini_get('file_uploads')) { - throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path'))); - } - $this->originalName = $this->getName($originalName); $this->mimeType = $mimeType ?: 'application/octet-stream'; $this->size = $size; $this->error = $error ?: UPLOAD_ERR_OK; - $this->test = (Boolean) $test; + $this->test = (bool) $test; parent::__construct($path, UPLOAD_ERR_OK === $this->error); } @@ -108,7 +104,7 @@ public function __construct($path, $originalName, $mimeType = null, $size = null * Returns the original file name. * * It is extracted from the request from which the file has been uploaded. - * Then is should not be considered as a safe value. + * Then it should not be considered as a safe value. * * @return string|null The original name * @@ -123,7 +119,7 @@ public function getClientOriginalName() * Returns the original file extension * * It is extracted from the original file name that was uploaded. - * Then is should not be considered as a safe value. + * Then it should not be considered as a safe value. * * @return string The extension */ @@ -181,9 +177,9 @@ public function guessClientExtension() * Returns the file size. * * It is extracted from the request from which the file has been uploaded. - * Then is should not be considered as a safe value. + * Then it should not be considered as a safe value. * - * @return integer|null The file size + * @return int|null The file size * * @api */ @@ -198,7 +194,7 @@ public function getClientSize() * If the upload was successful, the constant UPLOAD_ERR_OK is returned. * Otherwise one of the other UPLOAD_ERR_XXX constants is returned. * - * @return integer The upload error + * @return int The upload error * * @api */ @@ -210,7 +206,7 @@ public function getError() /** * Returns whether the file was uploaded successfully. * - * @return Boolean True if the file has been uploaded with HTTP and no error occurred. + * @return bool True if the file has been uploaded with HTTP and no error occurred. * * @api */ @@ -295,7 +291,7 @@ public static function getMaxFilesize() public function getErrorMessage() { static $errors = array( - UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d kb).', + UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).', UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.', UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.', UPLOAD_ERR_NO_FILE => 'No file was uploaded.', diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php index b2775efb2fb0f6d5742bf6311be100dbb7900f80..699e408d02ab0514ebab15f83b78c8afb263a12c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php @@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; /** - * FileBag is a container for HTTP headers. + * FileBag is a container for uploaded files. * * @author Fabien Potencier <fabien@symfony.com> * @author Bulat Shakirzyanov <mallluhuct@gmail.com> @@ -146,7 +146,7 @@ protected function fixPhpFilesArray($data) 'name' => $data['name'][$key], 'type' => $data['type'][$key], 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key] + 'size' => $data['size'][$key], )); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php index 2b9ef0e443e151ac4db6930bd8887d9fa90b48a6..45849159c661ac55b07a6a53c8c5777bffc11f2f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php @@ -117,7 +117,7 @@ public function add(array $headers) * * @param string $key The header name * @param mixed $default The default value - * @param Boolean $first Whether to return the first value or all header values + * @param bool $first Whether to return the first value or all header values * * @return string|array The first header value if $first is true, an array of values otherwise * @@ -147,7 +147,7 @@ public function get($key, $default = null, $first = true) * * @param string $key The key * @param string|array $values The value or an array of values - * @param Boolean $replace Whether to replace the actual value or not (true by default) + * @param bool $replace Whether to replace the actual value or not (true by default) * * @api */ @@ -173,7 +173,7 @@ public function set($key, $values, $replace = true) * * @param string $key The HTTP header * - * @return Boolean true if the parameter exists, false otherwise + * @return bool true if the parameter exists, false otherwise * * @api */ @@ -188,7 +188,7 @@ public function has($key) * @param string $key The HTTP header name * @param string $value The HTTP value * - * @return Boolean true if the value is contained in the header, false otherwise + * @return bool true if the value is contained in the header, false otherwise * * @api */ @@ -240,6 +240,12 @@ public function getDate($key, \DateTime $default = null) return $date; } + /** + * Adds a custom Cache-Control directive. + * + * @param string $key The Cache-Control directive name + * @param mixed $value The Cache-Control directive value + */ public function addCacheControlDirective($key, $value = true) { $this->cacheControl[$key] = $value; @@ -247,16 +253,35 @@ public function addCacheControlDirective($key, $value = true) $this->set('Cache-Control', $this->getCacheControlHeader()); } + /** + * Returns true if the Cache-Control directive is defined. + * + * @param string $key The Cache-Control directive + * + * @return bool true if the directive exists, false otherwise + */ public function hasCacheControlDirective($key) { return array_key_exists($key, $this->cacheControl); } + /** + * Returns a Cache-Control directive value by name. + * + * @param string $key The directive name + * + * @return mixed|null The directive value if defined, null otherwise + */ public function getCacheControlDirective($key) { return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; } + /** + * Removes a Cache-Control directive. + * + * @param string $key The Cache-Control directive + */ public function removeCacheControlDirective($key) { unset($this->cacheControl[$key]); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php index 98b848108cb5d58b13520f53e61aa4234057fea3..892503e98fa089046d444a1d30d3e5de201973cd 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php @@ -21,7 +21,9 @@ class IpUtils /** * This class should not be instantiated */ - private function __construct() {} + private function __construct() + { + } /** * Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets @@ -29,7 +31,7 @@ private function __construct() {} * @param string $requestIp IP to check * @param string|array $ips List of IPs or subnets (can be a string if only a single one) * - * @return boolean Whether the IP is valid + * @return bool Whether the IP is valid */ public static function checkIp($requestIp, $ips) { @@ -37,7 +39,7 @@ public static function checkIp($requestIp, $ips) $ips = array($ips); } - $method = false !== strpos($requestIp, ':') ? 'checkIp6': 'checkIp4'; + $method = false !== strpos($requestIp, ':') ? 'checkIp6' : 'checkIp4'; foreach ($ips as $ip) { if (self::$method($requestIp, $ip)) { @@ -55,7 +57,7 @@ public static function checkIp($requestIp, $ips) * @param string $requestIp IPv4 address to check * @param string $ip IPv4 address or subnet in CIDR notation * - * @return boolean Whether the IP is valid + * @return bool Whether the IP is valid */ public static function checkIp4($requestIp, $ip) { @@ -83,7 +85,7 @@ public static function checkIp4($requestIp, $ip) * @param string $requestIp IPv6 address to check * @param string $ip IPv6 address or subnet in CIDR notation * - * @return boolean Whether the IP is valid + * @return bool Whether the IP is valid * * @throws \RuntimeException When IPV6 support is not enabled */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php index 6dfa75cd2ddc4a25431608810caeed58cd413918..accd57cf3adc8b7a3492ba0dbf11e1ae14cefea4 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php @@ -26,12 +26,13 @@ class JsonResponse extends Response { protected $data; protected $callback; + protected $encodingOptions; /** * Constructor. * * @param mixed $data The response data - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers */ public function __construct($data = null, $status = 200, $headers = array()) @@ -41,11 +42,15 @@ public function __construct($data = null, $status = 200, $headers = array()) if (null === $data) { $data = new \ArrayObject(); } + + // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML. + $this->encodingOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT; + $this->setData($data); } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function create($data = null, $status = 200, $headers = array()) { @@ -80,7 +85,7 @@ public function setCallback($callback = null) } /** - * Sets the data to be sent as json. + * Sets the data to be sent as JSON. * * @param mixed $data * @@ -90,8 +95,29 @@ public function setCallback($callback = null) */ public function setData($data = array()) { - // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML. - $this->data = json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); + $errorHandler = null; + $errorHandler = set_error_handler(function () use (&$errorHandler) { + if (JSON_ERROR_NONE !== json_last_error()) { + return; + } + + if ($errorHandler) { + call_user_func_array($errorHandler, func_get_args()); + } + }); + + try { + // Clear json_last_error() + json_encode(null); + + $this->data = json_encode($data, $this->encodingOptions); + + restore_error_handler(); + } catch (\Exception $exception) { + restore_error_handler(); + + throw $exception; + } if (JSON_ERROR_NONE !== json_last_error()) { throw new \InvalidArgumentException($this->transformJsonError()); @@ -101,7 +127,31 @@ public function setData($data = array()) } /** - * Updates the content and headers according to the json data and callback. + * Returns options used while encoding data to JSON. + * + * @return int + */ + public function getEncodingOptions() + { + return $this->encodingOptions; + } + + /** + * Sets options used while encoding data to JSON. + * + * @param int $encodingOptions + * + * @return JsonResponse + */ + public function setEncodingOptions($encodingOptions) + { + $this->encodingOptions = (int) $encodingOptions; + + return $this->setData(json_decode($this->data)); + } + + /** + * Updates the content and headers according to the JSON data and callback. * * @return JsonResponse */ @@ -111,7 +161,7 @@ protected function update() // Not using application/javascript for compatibility reasons with older browsers. $this->headers->set('Content-Type', 'text/javascript'); - return $this->setContent(sprintf('%s(%s);', $this->callback, $this->data)); + return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); } // Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback) diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php index a4ac98cffebf92d963596dbcc47d5fdc81b4f335..8791275bafdaa323e393e2c2691327564bf1428d 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php @@ -92,7 +92,7 @@ public function add(array $parameters = array()) * * @param string $path The key * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items + * @param bool $deep If true, a path like foo[bar] will find deeper items * * @return mixed * @@ -167,7 +167,7 @@ public function set($key, $value) * * @param string $key The key * - * @return Boolean true if the parameter exists, false otherwise + * @return bool true if the parameter exists, false otherwise * * @api */ @@ -193,7 +193,7 @@ public function remove($key) * * @param string $key The parameter key * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items + * @param bool $deep If true, a path like foo[bar] will find deeper items * * @return string The filtered value * @@ -209,7 +209,7 @@ public function getAlpha($key, $default = '', $deep = false) * * @param string $key The parameter key * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items + * @param bool $deep If true, a path like foo[bar] will find deeper items * * @return string The filtered value * @@ -225,7 +225,7 @@ public function getAlnum($key, $default = '', $deep = false) * * @param string $key The parameter key * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items + * @param bool $deep If true, a path like foo[bar] will find deeper items * * @return string The filtered value * @@ -242,9 +242,9 @@ public function getDigits($key, $default = '', $deep = false) * * @param string $key The parameter key * @param mixed $default The default value if the parameter key does not exist - * @param boolean $deep If true, a path like foo[bar] will find deeper items + * @param bool $deep If true, a path like foo[bar] will find deeper items * - * @return integer The filtered value + * @return int The filtered value * * @api */ @@ -258,8 +258,8 @@ public function getInt($key, $default = 0, $deep = false) * * @param string $key Key. * @param mixed $default Default = null. - * @param boolean $deep Default = false. - * @param integer $filter FILTER_* constant. + * @param bool $deep Default = false. + * @param int $filter FILTER_* constant. * @param mixed $options Filter options. * * @see http://php.net/manual/en/function.filter-var.php diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php index fbf377bae02b68009f0323e89f666f1eb8db5dfc..641bd93f630a7171f5488edcc0d5fbb38241bce0 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -26,7 +26,7 @@ class RedirectResponse extends Response * Creates a redirect response so that it conforms to the rules defined for a redirect status code. * * @param string $url The URL to redirect to - * @param integer $status The status code (302 by default) + * @param int $status The status code (302 by default) * @param array $headers The headers (Location is always set to the given URL) * * @throws \InvalidArgumentException @@ -51,7 +51,7 @@ public function __construct($url, $status = 302, $headers = array()) } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function create($url = '', $status = 302, $headers = array()) { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php index 88a61b642dd88fe038f312bf76e8af9fb7096c56..98c747306ca6ffcd9efd99804285d5fe25d4572e 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php @@ -358,6 +358,7 @@ public static function create($uri, $method = 'GET', $parameters = array(), $coo if (!isset($server['CONTENT_TYPE'])) { $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; } + // no break case 'PATCH': $request = $parameters; $query = array(); @@ -501,6 +502,8 @@ public function __toString() */ public function overrideGlobals() { + $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null, '&'))); + $_GET = $this->query->all(); $_POST = $this->request->all(); $_SERVER = $this->server->all(); @@ -679,7 +682,7 @@ public static function enableHttpMethodParameterOverride() /** * Checks whether support for the _method request parameter is enabled. * - * @return Boolean True when the _method request parameter is enabled, false otherwise + * @return bool True when the _method request parameter is enabled, false otherwise */ public static function getHttpMethodParameterOverride() { @@ -703,7 +706,7 @@ public static function getHttpMethodParameterOverride() * * @param string $key the key * @param mixed $default the default value - * @param Boolean $deep is parameter deep in multidimensional array + * @param bool $deep is parameter deep in multidimensional array * * @return mixed */ @@ -728,7 +731,7 @@ public function getSession() * Whether the request contains a Session which was started in one of the * previous requests. * - * @return Boolean + * @return bool * * @api */ @@ -745,7 +748,7 @@ public function hasPreviousSession() * like whether the session is started or not. It is just a way to check if this Request * is associated with a Session instance. * - * @return Boolean true when the Request contains a Session object, false otherwise + * @return bool true when the Request contains a Session object, false otherwise * * @api */ @@ -955,7 +958,13 @@ public function getPort() } if ($host = $this->headers->get('HOST')) { - if (false !== $pos = strrpos($host, ':')) { + if ($host[0] === '[') { + $pos = strpos($host, ':', strrpos($host, ']')); + } else { + $pos = strrpos($host, ':'); + } + + if (false !== $pos) { return intval(substr($host, $pos + 1)); } @@ -972,7 +981,7 @@ public function getPort() */ public function getUser() { - return $this->server->get('PHP_AUTH_USER'); + return $this->headers->get('PHP_AUTH_USER'); } /** @@ -982,7 +991,7 @@ public function getUser() */ public function getPassword() { - return $this->server->get('PHP_AUTH_PW'); + return $this->headers->get('PHP_AUTH_PW'); } /** @@ -1024,9 +1033,9 @@ public function getHttpHost() } /** - * Returns the requested URI. + * Returns the requested URI (path and query string). * - * @return string The raw URI (i.e. not urldecoded) + * @return string The raw URI (i.e. not URI decoded) * * @api */ @@ -1053,9 +1062,9 @@ public function getSchemeAndHttpHost() } /** - * Generates a normalized URI for the Request. + * Generates a normalized URI (URL) for the Request. * - * @return string A normalized URI for the Request + * @return string A normalized URI (URL) for the Request * * @see getQueryString() * @@ -1113,7 +1122,7 @@ public function getQueryString() * ("SSL_HTTPS" for instance), configure it via "setTrustedHeaderName()" with * the "client-proto" key. * - * @return Boolean + * @return bool * * @api */ @@ -1123,7 +1132,9 @@ public function isSecure() return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1')); } - return 'on' == strtolower($this->server->get('HTTPS')) || 1 == $this->server->get('HTTPS'); + $https = $this->server->get('HTTPS'); + + return !empty($https) && 'off' !== strtolower($https); } /** @@ -1161,7 +1172,8 @@ public function getHost() // as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user) // check that it does not contain forbidden characters (see RFC 952 and RFC 2181) - if ($host && !preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host)) { + // use preg_replace() instead of preg_match() to prevent DoS attacks with long host names + if ($host && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) { throw new \UnexpectedValueException(sprintf('Invalid Host "%s"', $host)); } @@ -1287,8 +1299,6 @@ public function getFormat($mimeType) return $format; } } - - return null; } /** @@ -1372,6 +1382,16 @@ public function setDefaultLocale($locale) } } + /** + * Get the default locale. + * + * @return string + */ + public function getDefaultLocale() + { + return $this->defaultLocale; + } + /** * Sets the locale. * @@ -1399,7 +1419,7 @@ public function getLocale() * * @param string $method Uppercase request method (GET, POST etc). * - * @return Boolean + * @return bool */ public function isMethod($method) { @@ -1409,7 +1429,7 @@ public function isMethod($method) /** * Checks whether the method is safe or not. * - * @return Boolean + * @return bool * * @api */ @@ -1421,7 +1441,7 @@ public function isMethodSafe() /** * Returns the request body content. * - * @param Boolean $asResource If true, a resource will be returned + * @param bool $asResource If true, a resource will be returned * * @return string|resource The request body content or a resource to read the body stream. * @@ -1457,7 +1477,7 @@ public function getETags() } /** - * @return Boolean + * @return bool */ public function isNoCache() { @@ -1596,7 +1616,7 @@ public function getAcceptableContentTypes() * It is known to work with common JavaScript frameworks: * @link http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript * - * @return Boolean true if the request is an XMLHttpRequest, false otherwise + * @return bool true if the request is an XMLHttpRequest, false otherwise * * @api */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php index 695fd21788d5205be25ac97100fe6d510ba674c4..20e14e3ab214c80dd9d3dc74ab727c0507c595f1 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php @@ -25,7 +25,7 @@ interface RequestMatcherInterface * * @param Request $request The request to check for a match * - * @return Boolean true if the request matches, false otherwise + * @return bool true if the request matches, false otherwise * * @api */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php index 4b0ef28deefd347644dd5e623ce85376b8f17eb9..3d9cfd0c641944728f0d21dcbbdbe89e5d0a3d85 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php @@ -47,7 +47,7 @@ public function push(Request $request) public function pop() { if (!$this->requests) { - return null; + return; } return array_pop($this->requests); @@ -73,7 +73,7 @@ public function getCurrentRequest() public function getMasterRequest() { if (!$this->requests) { - return null; + return; } return $this->requests[0]; @@ -95,7 +95,7 @@ public function getParentRequest() $pos = count($this->requests) - 2; if (!isset($this->requests[$pos])) { - return null; + return; } return $this->requests[$pos]; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php index b6bbfc2d937401bb5078e7034799797307f61e3f..24280e38fca4ad7607aecef7ea42d72a1e9a0408 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php @@ -10,9 +10,7 @@ */ /** - * SessionHandlerInterface - * - * Provides forward compatibility with PHP 5.4 + * SessionHandlerInterface for PHP < 5.4 * * Extensive documentation can be found at php.net, see links: * @@ -25,76 +23,68 @@ interface SessionHandlerInterface { /** - * Open session. + * Re-initializes existing session, or creates a new one. * * @see http://php.net/sessionhandlerinterface.open * - * @param string $savePath Save path. - * @param string $sessionName Session Name. - * - * @throws \RuntimeException If something goes wrong starting the session. + * @param string $savePath Save path + * @param string $sessionName Session name, see http://php.net/function.session-name.php * - * @return boolean + * @return bool true on success, false on failure */ public function open($savePath, $sessionName); /** - * Close session. + * Closes the current session. * * @see http://php.net/sessionhandlerinterface.close * - * @return boolean + * @return bool true on success, false on failure */ public function close(); /** - * Read session. - * - * @param string $sessionId + * Reads the session data. * * @see http://php.net/sessionhandlerinterface.read * - * @throws \RuntimeException On fatal error but not "record not found". + * @param string $sessionId Session ID, see http://php.net/function.session-id * - * @return string String as stored in persistent storage or empty string in all other cases. + * @return string Same session data as passed in write() or empty string when non-existent or on failure */ public function read($sessionId); /** - * Commit session to storage. + * Writes the session data to the storage. * * @see http://php.net/sessionhandlerinterface.write * - * @param string $sessionId Session ID. - * @param string $data Session serialized data to save. + * @param string $sessionId Session ID , see http://php.net/function.session-id + * @param string $data Serialized session data to save * - * @return boolean + * @return bool true on success, false on failure */ public function write($sessionId, $data); /** - * Destroys this session. + * Destroys a session. * * @see http://php.net/sessionhandlerinterface.destroy * - * @param string $sessionId Session ID. + * @param string $sessionId Session ID, see http://php.net/function.session-id * - * @throws \RuntimeException On fatal error. - * - * @return boolean + * @return bool true on success, false on failure */ public function destroy($sessionId); /** - * Garbage collection for storage. + * Cleans up expired sessions (garbage collection). * * @see http://php.net/sessionhandlerinterface.gc * - * @param integer $lifetime Max lifetime in seconds to keep sessions stored. - * - * @throws \RuntimeException On fatal error. + * @param string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed * - * @return boolean + * @return bool true on success, false on failure */ - public function gc($lifetime); + public function gc($maxlifetime); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php index bc9a193c7dc2c298501a8eac8b85a7a919e83ad2..fbb86f6edd86255496f0263affe812fca1c043f3 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php @@ -41,7 +41,7 @@ class Response const HTTP_USE_PROXY = 305; const HTTP_RESERVED = 306; const HTTP_TEMPORARY_REDIRECT = 307; - const HTTP_PERMANENTLY_REDIRECT = 308; // RFC-reschke-http-status-308-07 + const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238 const HTTP_BAD_REQUEST = 400; const HTTP_UNAUTHORIZED = 401; const HTTP_PAYMENT_REQUIRED = 402; @@ -97,7 +97,7 @@ class Response protected $version; /** - * @var integer + * @var int */ protected $statusCode; @@ -144,7 +144,7 @@ class Response 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', // RFC-reschke-http-status-308-07 + 308 => 'Permanent Redirect', // RFC7238 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', @@ -189,7 +189,7 @@ class Response * Constructor. * * @param mixed $content The response content, see setContent() - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers * * @throws \InvalidArgumentException When the HTTP status code is not valid @@ -216,7 +216,7 @@ public function __construct($content = '', $status = 200, $headers = array()) * ->setSharedMaxAge(300); * * @param mixed $content The response content, see setContent() - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers * * @return Response @@ -270,36 +270,38 @@ public function prepare(Request $request) if ($this->isInformational() || in_array($this->statusCode, array(204, 304))) { $this->setContent(null); - } - - // Content-type based on the Request - if (!$headers->has('Content-Type')) { - $format = $request->getRequestFormat(); - if (null !== $format && $mimeType = $request->getMimeType($format)) { - $headers->set('Content-Type', $mimeType); + $headers->remove('Content-Type'); + $headers->remove('Content-Length'); + } else { + // Content-type based on the Request + if (!$headers->has('Content-Type')) { + $format = $request->getRequestFormat(); + if (null !== $format && $mimeType = $request->getMimeType($format)) { + $headers->set('Content-Type', $mimeType); + } } - } - // Fix Content-Type - $charset = $this->charset ?: 'UTF-8'; - if (!$headers->has('Content-Type')) { - $headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { - // add the charset - $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); - } + // Fix Content-Type + $charset = $this->charset ?: 'UTF-8'; + if (!$headers->has('Content-Type')) { + $headers->set('Content-Type', 'text/html; charset='.$charset); + } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { + // add the charset + $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); + } - // Fix Content-Length - if ($headers->has('Transfer-Encoding')) { - $headers->remove('Content-Length'); - } + // Fix Content-Length + if ($headers->has('Transfer-Encoding')) { + $headers->remove('Content-Length'); + } - if ($request->isMethod('HEAD')) { - // cf. RFC2616 14.13 - $length = $headers->get('Content-Length'); - $this->setContent(null); - if ($length) { - $headers->set('Content-Length', $length); + if ($request->isMethod('HEAD')) { + // cf. RFC2616 14.13 + $length = $headers->get('Content-Length'); + $this->setContent(null); + if ($length) { + $headers->set('Content-Length', $length); + } } } @@ -376,24 +378,7 @@ public function send() if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif ('cli' !== PHP_SAPI) { - // ob_get_level() never returns 0 on some Windows configurations, so if - // the level is the same two times in a row, the loop should be stopped. - $previous = null; - $obStatus = ob_get_status(1); - while (($level = ob_get_level()) > 0 && $level !== $previous) { - $previous = $level; - if ($obStatus[$level - 1]) { - if (version_compare(PHP_VERSION, '5.4', '>=')) { - if (isset($obStatus[$level - 1]['flags']) && ($obStatus[$level - 1]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE)) { - ob_end_flush(); - } - } else { - if (isset($obStatus[$level - 1]['del']) && $obStatus[$level - 1]['del']) { - ob_end_flush(); - } - } - } - } + static::closeOutputBuffers(0, true); flush(); } @@ -467,7 +452,7 @@ public function getProtocolVersion() /** * Sets the response status code. * - * @param integer $code HTTP status code + * @param int $code HTTP status code * @param mixed $text HTTP status text * * If the status text is null it will be automatically populated for the known @@ -506,7 +491,7 @@ public function setStatusCode($code, $text = null) /** * Retrieves the status code for the current web response. * - * @return integer Status code + * @return int Status code * * @api */ @@ -552,7 +537,7 @@ public function getCharset() * Responses with neither a freshness lifetime (Expires, max-age) nor cache * validator (Last-Modified, ETag) are considered uncacheable. * - * @return Boolean true if the response is worth caching, false otherwise + * @return bool true if the response is worth caching, false otherwise * * @api */ @@ -576,7 +561,7 @@ public function isCacheable() * origin. A response is considered fresh when it includes a Cache-Control/max-age * indicator or Expires header and the calculated age is less than the freshness lifetime. * - * @return Boolean true if the response is fresh, false otherwise + * @return bool true if the response is fresh, false otherwise * * @api */ @@ -589,7 +574,7 @@ public function isFresh() * Returns true if the response includes headers that can be used to validate * the response with the origin server using a conditional GET request. * - * @return Boolean true if the response is validateable, false otherwise + * @return bool true if the response is validateable, false otherwise * * @api */ @@ -640,7 +625,7 @@ public function setPublic() * When present, the TTL of the response should not be overridden to be * greater than the value provided by the origin. * - * @return Boolean true if the response must be revalidated by a cache, false otherwise + * @return bool true if the response must be revalidated by a cache, false otherwise * * @api */ @@ -683,7 +668,7 @@ public function setDate(\DateTime $date) /** * Returns the age of the response. * - * @return integer The age of the response in seconds + * @return int The age of the response in seconds */ public function getAge() { @@ -758,7 +743,7 @@ public function setExpires(\DateTime $date = null) * First, it checks for a s-maxage directive, then a max-age directive, and then it falls * back on an expires header. It returns null when no maximum age can be established. * - * @return integer|null Number of seconds + * @return int|null Number of seconds * * @api */ @@ -775,8 +760,6 @@ public function getMaxAge() if (null !== $this->getExpires()) { return $this->getExpires()->format('U') - $this->getDate()->format('U'); } - - return null; } /** @@ -784,7 +767,7 @@ public function getMaxAge() * * This methods sets the Cache-Control max-age directive. * - * @param integer $value Number of seconds + * @param int $value Number of seconds * * @return Response * @@ -802,7 +785,7 @@ public function setMaxAge($value) * * This methods sets the Cache-Control s-maxage directive. * - * @param integer $value Number of seconds + * @param int $value Number of seconds * * @return Response * @@ -824,7 +807,7 @@ public function setSharedMaxAge($value) * When the responses TTL is <= 0, the response may not be served from cache without first * revalidating with the origin. * - * @return integer|null The TTL in seconds + * @return int|null The TTL in seconds * * @api */ @@ -833,8 +816,6 @@ public function getTtl() if (null !== $maxAge = $this->getMaxAge()) { return $maxAge - $this->getAge(); } - - return null; } /** @@ -842,7 +823,7 @@ public function getTtl() * * This method adjusts the Cache-Control/s-maxage directive. * - * @param integer $seconds Number of seconds + * @param int $seconds Number of seconds * * @return Response * @@ -860,7 +841,7 @@ public function setTtl($seconds) * * This method adjusts the Cache-Control/max-age directive. * - * @param integer $seconds Number of seconds + * @param int $seconds Number of seconds * * @return Response * @@ -927,7 +908,7 @@ public function getEtag() * Sets the ETag value. * * @param string|null $etag The ETag unique identifier or null to remove the header - * @param Boolean $weak Whether you want a weak ETag or not + * @param bool $weak Whether you want a weak ETag or not * * @return Response * @@ -1030,7 +1011,7 @@ public function setNotModified() /** * Returns true if the response includes a Vary header. * - * @return Boolean true if the response includes a Vary header, false otherwise + * @return bool true if the response includes a Vary header, false otherwise * * @api */ @@ -1048,18 +1029,23 @@ public function hasVary() */ public function getVary() { - if (!$vary = $this->headers->get('Vary')) { + if (!$vary = $this->headers->get('Vary', null, false)) { return array(); } - return is_array($vary) ? $vary : preg_split('/[\s,]+/', $vary); + $ret = array(); + foreach ($vary as $item) { + $ret = array_merge($ret, preg_split('/[\s,]+/', $item)); + } + + return $ret; } /** * Sets the Vary header. * * @param string|array $headers - * @param Boolean $replace Whether to replace the actual value of not (true by default) + * @param bool $replace Whether to replace the actual value of not (true by default) * * @return Response * @@ -1081,7 +1067,7 @@ public function setVary($headers, $replace = true) * * @param Request $request A Request instance * - * @return Boolean true if the Response validators match the Request, false otherwise + * @return bool true if the Response validators match the Request, false otherwise * * @api */ @@ -1091,12 +1077,16 @@ public function isNotModified(Request $request) return false; } - $lastModified = $request->headers->get('If-Modified-Since'); - $notModified = false; + $notModified = false; + $lastModified = $this->headers->get('Last-Modified'); + $modifiedSince = $request->headers->get('If-Modified-Since'); + if ($etags = $request->getEtags()) { - $notModified = (in_array($this->getEtag(), $etags) || in_array('*', $etags)) && (!$lastModified || $this->headers->get('Last-Modified') == $lastModified); - } elseif ($lastModified) { - $notModified = $lastModified == $this->headers->get('Last-Modified'); + $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags); + } + + if ($modifiedSince && $lastModified) { + $notModified = strtotime($modifiedSince) >= strtotime($lastModified) && (!$etags || $notModified); } if ($notModified) { @@ -1110,7 +1100,7 @@ public function isNotModified(Request $request) /** * Is response invalid? * - * @return Boolean + * @return bool * * @api */ @@ -1122,7 +1112,7 @@ public function isInvalid() /** * Is response informative? * - * @return Boolean + * @return bool * * @api */ @@ -1134,7 +1124,7 @@ public function isInformational() /** * Is response successful? * - * @return Boolean + * @return bool * * @api */ @@ -1146,7 +1136,7 @@ public function isSuccessful() /** * Is the response a redirect? * - * @return Boolean + * @return bool * * @api */ @@ -1158,7 +1148,7 @@ public function isRedirection() /** * Is there a client error? * - * @return Boolean + * @return bool * * @api */ @@ -1170,7 +1160,7 @@ public function isClientError() /** * Was there a server side error? * - * @return Boolean + * @return bool * * @api */ @@ -1182,7 +1172,7 @@ public function isServerError() /** * Is the response OK? * - * @return Boolean + * @return bool * * @api */ @@ -1194,7 +1184,7 @@ public function isOk() /** * Is the response forbidden? * - * @return Boolean + * @return bool * * @api */ @@ -1206,7 +1196,7 @@ public function isForbidden() /** * Is the response a not found error? * - * @return Boolean + * @return bool * * @api */ @@ -1220,7 +1210,7 @@ public function isNotFound() * * @param string $location * - * @return Boolean + * @return bool * * @api */ @@ -1232,17 +1222,46 @@ public function isRedirect($location = null) /** * Is the response empty? * - * @return Boolean + * @return bool * * @api */ public function isEmpty() { - return in_array($this->statusCode, array(201, 204, 304)); + return in_array($this->statusCode, array(204, 304)); + } + + /** + * Cleans or flushes output buffers up to target level. + * + * Resulting level can be greater than target level if a non-removable buffer has been encountered. + * + * @param int $targetLevel The target output buffering level + * @param bool $flush Whether to flush or clean the buffers + */ + public static function closeOutputBuffers($targetLevel, $flush) + { + $status = ob_get_status(true); + $level = count($status); + + while ($level-- > $targetLevel + && (!empty($status[$level]['del']) + || (isset($status[$level]['flags']) + && ($status[$level]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE) + && ($status[$level]['flags'] & ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE)) + ) + ) + ) { + if ($flush) { + ob_end_flush(); + } else { + ob_end_clean(); + } + } } /** - * Check if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9 + * Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9 * * @link http://support.microsoft.com/kb/323308 */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php index de6dbc9fb533bfd73e78ae15ce3b1399ac398653..6a4f2c2b167e0e608aec171b92ee821647d3c6f9 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php @@ -65,13 +65,13 @@ public function getHeaders() } if (null !== $authorizationHeader) { - if (0 === stripos($authorizationHeader, 'basic')) { + if (0 === stripos($authorizationHeader, 'basic ')) { // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic - $exploded = explode(':', base64_decode(substr($authorizationHeader, 6))); + $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); if (count($exploded) == 2) { list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; } - } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest'))) { + } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) { // In some circumstances PHP_AUTH_DIGEST needs to be set $headers['PHP_AUTH_DIGEST'] = $authorizationHeader; $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php index af416d6d3a4c444443cf3f44e7bd1a6f6d02329c..ffe1770da3559d2418c0b876bf64344306e28cf4 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php @@ -148,7 +148,7 @@ public function getIterator() /** * Returns the number of attributes. * - * @return integer The number of attributes + * @return int The number of attributes */ public function count() { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php index 6356056edddeea07349aa3f8069d5b1b54f0d42b..4bf3c656ca113fe36caf8bd1cd7d221d7ffb3b4f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php @@ -25,7 +25,7 @@ interface AttributeBagInterface extends SessionBagInterface * * @param string $name The attribute name * - * @return Boolean true if the attribute is defined, false otherwise + * @return bool true if the attribute is defined, false otherwise */ public function has($name); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php index 7cafb2241c838027147c90a9ca487c80c19651ff..10bceede43e248de19a7ac73e1c1ae515e20b09a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php @@ -100,7 +100,7 @@ public function remove($name) * This method allows structured namespacing of session attributes. * * @param string $name Key name - * @param boolean $writeContext Write context, default false + * @param bool $writeContext Write context, default false * * @return array */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php index a68dcfddda849f0b5f772d0416f442a929caa43a..be79d9d752a46674148e4ce7b3b99869e341918c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php @@ -80,7 +80,7 @@ public function setAll(array $messages); * * @param string $type * - * @return boolean + * @return bool */ public function has($type); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php index dc2f7bc4f339c4ce6d99489141d90d89c36f7a89..f98c0a4a1c3cae76eb3b5f8e30419a098444e272 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php @@ -23,7 +23,7 @@ interface SessionInterface /** * Starts the session storage. * - * @return Boolean True if session started. + * @return bool True if session started. * * @throws \RuntimeException If session fails to start. * @@ -73,12 +73,12 @@ public function setName($name); * Clears all session attributes and flashes and regenerates the * session and deletes the old session from persistence. * - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value + * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value * will leave the system settings unchanged, 0 sets the cookie * to expire with browser session. Time is in seconds, and is * not a Unix timestamp. * - * @return Boolean True if session invalidated, false if error. + * @return bool True if session invalidated, false if error. * * @api */ @@ -88,13 +88,13 @@ public function invalidate($lifetime = null); * Migrates the current session to a new session id while maintaining all * session attributes. * - * @param Boolean $destroy Whether to delete the old session or leave it to garbage collection. - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value + * @param bool $destroy Whether to delete the old session or leave it to garbage collection. + * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value * will leave the system settings unchanged, 0 sets the cookie * to expire with browser session. Time is in seconds, and is * not a Unix timestamp. * - * @return Boolean True if session migrated, false if error. + * @return bool True if session migrated, false if error. * * @api */ @@ -114,7 +114,7 @@ public function save(); * * @param string $name The attribute name * - * @return Boolean true if the attribute is defined, false otherwise + * @return bool true if the attribute is defined, false otherwise * * @api */ @@ -179,7 +179,7 @@ public function clear(); /** * Checks if the session was started. * - * @return Boolean + * @return bool */ public function isStarted(); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php index b2384505ae60db91f0c8f40cb13ac40d7f4bcf3f..caff49ac7bc15f29c19be8265a49e2061e418bea 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php @@ -24,7 +24,7 @@ class MemcacheSessionHandler implements \SessionHandlerInterface private $memcache; /** - * @var integer Time to live in seconds + * @var int Time to live in seconds */ private $ttl; @@ -59,7 +59,7 @@ public function __construct(\Memcache $memcache, array $options = array()) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function open($savePath, $sessionName) { @@ -67,7 +67,7 @@ public function open($savePath, $sessionName) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function close() { @@ -75,7 +75,7 @@ public function close() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function read($sessionId) { @@ -83,7 +83,7 @@ public function read($sessionId) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function write($sessionId, $data) { @@ -91,7 +91,7 @@ public function write($sessionId, $data) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function destroy($sessionId) { @@ -99,9 +99,9 @@ public function destroy($sessionId) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function gc($lifetime) + public function gc($maxlifetime) { // not required here because memcache will auto expire the records anyhow. return true; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index ed7d6edf4b824a1ddb287d4bf93efca14ee2758e..d623ba98b1e5e5ebbc107642a7a592613cd6e31a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -29,7 +29,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface private $memcached; /** - * @var integer Time to live in seconds + * @var int Time to live in seconds */ private $ttl; @@ -65,7 +65,7 @@ public function __construct(\Memcached $memcached, array $options = array()) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function open($savePath, $sessionName) { @@ -73,7 +73,7 @@ public function open($savePath, $sessionName) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function close() { @@ -81,7 +81,7 @@ public function close() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function read($sessionId) { @@ -89,7 +89,7 @@ public function read($sessionId) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function write($sessionId, $data) { @@ -97,7 +97,7 @@ public function write($sessionId, $data) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function destroy($sessionId) { @@ -105,9 +105,9 @@ public function destroy($sessionId) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function gc($lifetime) + public function gc($maxlifetime) { // not required here because memcached will auto expire the records anyhow. return true; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 4d819fe3f8cc962d23a8c7a87f2d6699d4cda990..9579a74c6ec7b8d1fe9eacc01226c930ae527115 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -69,7 +69,7 @@ public function __construct($mongo, array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function open($savePath, $sessionName) { @@ -77,7 +77,7 @@ public function open($savePath, $sessionName) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function close() { @@ -85,21 +85,21 @@ public function close() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function destroy($sessionId) { $this->getCollection()->remove(array( - $this->options['id_field'] => $sessionId + $this->options['id_field'] => $sessionId, )); return true; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function gc($lifetime) + public function gc($maxlifetime) { /* Note: MongoDB 2.2+ supports TTL collections, which may be used in * place of this method by indexing the "time_field" field with an @@ -109,7 +109,7 @@ public function gc($lifetime) * * See: http://docs.mongodb.org/manual/tutorial/expire-data/ */ - $time = new \MongoDate(time() - $lifetime); + $time = new \MongoDate(time() - $maxlifetime); $this->getCollection()->remove(array( $this->options['time_field'] => array('$lt' => $time), @@ -119,7 +119,7 @@ public function gc($lifetime) } /** - * {@inheritDoc] + * {@inheritdoc} */ public function write($sessionId, $data) { @@ -136,7 +136,7 @@ public function write($sessionId, $data) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function read($sessionId) { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 1260ad0d295a9f16bc4d201ee0a8bef265770df4..22acdecf610478bab0518dfb62dda769e5c6c256 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -18,7 +18,11 @@ */ if (version_compare(phpversion(), '5.4.0', '>=')) { - class NativeSessionHandler extends \SessionHandler {} + class NativeSessionHandler extends \SessionHandler + { + } } else { - class NativeSessionHandler {} + class NativeSessionHandler + { + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php index 62068aff1b7c7be47172745172b1730d1f3b1da7..d88ce895b7ddb4eb13aba3e3c2de329b92ad2cfa 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php @@ -65,7 +65,7 @@ public function destroy($sessionId) /** * {@inheritdoc} */ - public function gc($lifetime) + public function gc($maxlifetime) { return true; } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index baf8eea8f610edfac96affa016f34c1f47883aa3..c6e4eb3c0692818023c899a40b666b4730baa185 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -12,22 +12,44 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** - * PdoSessionHandler. + * 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 <fabien@symfony.com> * @author Michael Williams <michael.williams@funsational.com> + * @author Tobias Schultze <http://tobion.de> */ class PdoSessionHandler implements \SessionHandlerInterface { /** - * @var \PDO PDO instance. + * @var \PDO PDO instance */ private $pdo; /** - * @var array Database options. + * @var string Table name + */ + private $table; + + /** + * @var string Column for session id + */ + private $idCol; + + /** + * @var string Column for session data */ - private $dbOptions; + private $dataCol; + + /** + * @var string Column for timestamp + */ + private $timeCol; /** * Constructor. @@ -52,23 +74,28 @@ public function __construct(\PDO $pdo, array $dbOptions = array()) 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; - $this->dbOptions = array_merge(array( + $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} + * {@inheritdoc} */ - public function open($path, $name) + public function open($savePath, $sessionName) { return true; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function close() { @@ -76,79 +103,62 @@ public function close() } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function destroy($id) + public function destroy($sessionId) { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbIdCol = $this->dbOptions['db_id_col']; - // delete the record associated with this id - $sql = "DELETE FROM $dbTable WHERE $dbIdCol = :id"; + $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; try { $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); } return true; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function gc($lifetime) + public function gc($maxlifetime) { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbTimeCol = $this->dbOptions['db_time_col']; - // delete the session records that have expired - $sql = "DELETE FROM $dbTable WHERE $dbTimeCol < :time"; + $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; try { $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time() - $lifetime, \PDO::PARAM_INT); + $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); $stmt->execute(); } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); } return true; } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function read($id) + public function read($sessionId) { - // get table/columns - $dbTable = $this->dbOptions['db_table']; - $dbDataCol = $this->dbOptions['db_data_col']; - $dbIdCol = $this->dbOptions['db_id_col']; + $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; try { - $sql = "SELECT $dbDataCol FROM $dbTable WHERE $dbIdCol = :id"; - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); - // it is recommended to use fetchAll so that PDO can close the DB cursor - // we anyway expect either no rows, or one row with one column. fetchColumn, seems to be buggy #4777 + + // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); - if (count($sessionRows) == 1) { + if ($sessionRows) { return base64_decode($sessionRows[0][0]); } - // session does not exist, create it - $this->createNewSession($id); - return ''; } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); @@ -156,89 +166,91 @@ public function read($id) } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function write($id, $data) + public function write($sessionId, $data) { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbDataCol = $this->dbOptions['db_data_col']; - $dbIdCol = $this->dbOptions['db_id_col']; - $dbTimeCol = $this->dbOptions['db_time_col']; - - //session data can contain non binary safe characters so we need to encode it $encoded = base64_encode($data); try { - $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - - if ('mysql' === $driver) { - // MySQL would report $stmt->rowCount() = 0 on UPDATE when the data is left unchanged - // it could result in calling createNewSession() whereas the session already exists in - // the DB which would fail as the id is unique - $stmt = $this->pdo->prepare( - "INSERT INTO $dbTable ($dbIdCol, $dbDataCol, $dbTimeCol) VALUES (:id, :data, :time) " . - "ON DUPLICATE KEY UPDATE $dbDataCol = VALUES($dbDataCol), $dbTimeCol = VALUES($dbTimeCol)" - ); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - } elseif ('oci' === $driver) { - $stmt = $this->pdo->prepare("MERGE INTO $dbTable USING DUAL ON($dbIdCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($dbIdCol, $dbDataCol, $dbTimeCol) VALUES (:id, :data, sysdate) " . - "WHEN MATCHED THEN UPDATE SET $dbDataCol = :data WHERE $dbIdCol = :id"); - - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $stmt->execute(); - } else { - $stmt = $this->pdo->prepare("UPDATE $dbTable SET $dbDataCol = :data, $dbTimeCol = :time WHERE $dbIdCol = :id"); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - - if (!$stmt->rowCount()) { - // No session exists in the database to update. This happens when we have called - // session_regenerate_id() - $this->createNewSession($id, $data); + // 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); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); } return true; } /** - * Creates a new session with the given $id and $data + * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. * - * @param string $id - * @param string $data - * - * @return boolean True. + * @return string|null The SQL string or null when not supported */ - private function createNewSession($id, $data = '') + private function getMergeSql() { - // get table/column - $dbTable = $this->dbOptions['db_table']; - $dbDataCol = $this->dbOptions['db_data_col']; - $dbIdCol = $this->dbOptions['db_id_col']; - $dbTimeCol = $this->dbOptions['db_time_col']; - - $sql = "INSERT INTO $dbTable ($dbIdCol, $dbDataCol, $dbTimeCol) VALUES (:id, :data, :time)"; - - //session data can contain non binary safe characters so we need to encode it - $encoded = base64_encode($data); - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $id, \PDO::PARAM_STR); - $stmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - - return true; + $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)"; + } } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php index 44212979c307db1a97e45add7997a93bc10f4714..f996900d443096aa83fd41e5c72b23817a7b3ec8 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php @@ -44,12 +44,12 @@ class MetadataBag implements SessionBagInterface /** * Unix timestamp. * - * @var integer + * @var int */ private $lastUsed; /** - * @var integer + * @var int */ private $updateThreshold; @@ -57,7 +57,7 @@ class MetadataBag implements SessionBagInterface * Constructor. * * @param string $storageKey The key used to store bag in the session. - * @param integer $updateThreshold The time to wait between two UPDATED updates + * @param int $updateThreshold The time to wait between two UPDATED updates */ public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0) { @@ -87,7 +87,7 @@ public function initialize(array &$array) /** * Gets the lifetime that the session cookie was set with. * - * @return integer + * @return int */ public function getLifetime() { @@ -97,7 +97,7 @@ public function getLifetime() /** * Stamps a new session's metadata. * - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value + * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value * will leave the system settings unchanged, 0 sets the cookie * to expire with browser session. Time is in seconds, and is * not a Unix timestamp. @@ -118,7 +118,7 @@ public function getStorageKey() /** * Gets the created timestamp metadata. * - * @return integer Unix timestamp + * @return int Unix timestamp */ public function getCreated() { @@ -128,7 +128,7 @@ public function getCreated() /** * Gets the last used metadata. * - * @return integer Unix timestamp + * @return int Unix timestamp */ public function getLastUsed() { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php index 8b1c2137f6a8a2e0433de5a27781f307c95f3e0a..0b4ee3079ecb293bc9cddaab15ab772c704ced6c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php @@ -38,12 +38,12 @@ class MockArraySessionStorage implements SessionStorageInterface protected $name; /** - * @var boolean + * @var bool */ protected $started = false; /** - * @var boolean + * @var bool */ protected $closed = false; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 083df9de40f9d63a6cdceb934d50978bda2baa5c..31bf55c72dd993e829b8d1211a4693e9cc3dced8 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -32,12 +32,12 @@ class NativeSessionStorage implements SessionStorageInterface protected $bags; /** - * @var Boolean + * @var bool */ protected $started = false; /** - * @var Boolean + * @var bool */ protected $closed = false; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index ee6eb897287c946d7e590ffe4640fee7af814491..0b7e5648c0f1f3728a298540477f38972c8e28e4 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -21,12 +21,12 @@ abstract class AbstractProxy /** * Flag if handler wraps an internal PHP session handler (using \SessionHandler). * - * @var boolean + * @var bool */ protected $wrapper = false; /** - * @var boolean + * @var bool */ protected $active = false; @@ -48,7 +48,7 @@ public function getSaveHandlerName() /** * Is this proxy handler and instance of \SessionHandlerInterface. * - * @return boolean + * @return bool */ public function isSessionHandlerInterface() { @@ -58,7 +58,7 @@ public function isSessionHandlerInterface() /** * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. * - * @return Boolean + * @return bool */ public function isWrapper() { @@ -68,7 +68,7 @@ public function isWrapper() /** * Has a session started? * - * @return Boolean + * @return bool */ public function isActive() { @@ -87,7 +87,7 @@ public function isActive() * * @internal * - * @param Boolean $flag + * @param bool $flag * * @throws \LogicException */ diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php index 23eebb3281ae85955a72141e875fcf14f795d929..d2362b22a839147ca023a9d3f132cb476096ee27 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php @@ -32,7 +32,7 @@ public function __construct() /** * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. * - * @return Boolean False. + * @return bool False. */ public function isWrapper() { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php index e1f4fff1fa2aeb1f361afae57c7a274c17cbbe8c..81643c74b400105468522a4e4f6cb2eaefa924bd 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php @@ -64,25 +64,25 @@ public function close() /** * {@inheritdoc} */ - public function read($id) + public function read($sessionId) { - return (string) $this->handler->read($id); + return (string) $this->handler->read($sessionId); } /** * {@inheritdoc} */ - public function write($id, $data) + public function write($sessionId, $data) { - return (bool) $this->handler->write($id, $data); + return (bool) $this->handler->write($sessionId, $data); } /** * {@inheritdoc} */ - public function destroy($id) + public function destroy($sessionId) { - return (bool) $this->handler->destroy($id); + return (bool) $this->handler->destroy($sessionId); } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php index 74f19c5216dcb8fa706d9ffc770184dc99f2fd69..0fb2e2abc84649b942af9a5f7ab240cda3d7b223 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php @@ -28,7 +28,7 @@ interface SessionStorageInterface * * @throws \RuntimeException If something goes wrong starting the session. * - * @return boolean True if started. + * @return bool True if started. * * @api */ @@ -37,7 +37,7 @@ public function start(); /** * Checks if the session is started. * - * @return boolean True if started, false otherwise. + * @return bool True if started, false otherwise. */ public function isStarted(); @@ -88,13 +88,13 @@ public function setName($name); * Note regenerate+destroy should not clear the session data in memory * only delete the session data from persistent storage. * - * @param Boolean $destroy Destroy session when regenerating? - * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value + * @param bool $destroy Destroy session when regenerating? + * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value * will leave the system settings unchanged, 0 sets the cookie * to expire with browser session. Time is in seconds, and is * not a Unix timestamp. * - * @return Boolean True if session regenerated, false if error + * @return bool True if session regenerated, false if error * * @throws \RuntimeException If an error occurs while regenerating this storage * diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php index d9fece658f49a7c5d8e15750e4456c762449289d..4be9f48c9cf939d3840a2711b447c490a93447bc 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -35,7 +35,7 @@ class StreamedResponse extends Response * Constructor. * * @param callable|null $callback A valid PHP callback or null to set it later - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers * * @api @@ -54,7 +54,7 @@ public function __construct($callback = null, $status = 200, $headers = array()) * Factory method for chainability * * @param callable|null $callback A valid PHP callback or null to set it later - * @param integer $status The response status code + * @param int $status The response status code * @param array $headers An array of response headers * * @return StreamedResponse diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php index 582fbdefe1725d58dab06053a0472561c98c00d6..e4f354fc1f27d37e2ec57b27505be03df1728b81 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php @@ -30,19 +30,19 @@ public function provideFromStringData() return array( array( 'text/html', - 'text/html', array() + 'text/html', array(), ), array( '"this;should,not=matter"', - 'this;should,not=matter', array() + 'this;should,not=matter', array(), ), array( "text/plain; charset=utf-8;param=\"this;should,not=matter\";\tfootnotes=true", - 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true') + 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'), ), array( '"this;should,not=matter";charset=utf-8', - 'this;should,not=matter', array('charset' => 'utf-8') + 'this;should,not=matter', array('charset' => 'utf-8'), ), ); } @@ -61,11 +61,11 @@ public function provideToStringData() return array( array( 'text/html', array(), - 'text/html' + 'text/html', ), array( 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'), - 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true' + 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true', ), ); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php index 965a7d2bf0317572ded2069af71ff952f24f9778..d9f9a323302a0be67ebdfe8ef42b9bec494a3932 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php @@ -39,7 +39,7 @@ public function provideServerVars() ), '/foo/app_dev.php/bar', '/foo/app_dev.php', - '/bar' + '/bar', ), array( array( diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 75863168d1dbd8d9acefa49f4019799132d20937..cfb474dda1699ac5ae896b1dcb9158a25b97037a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -14,19 +14,21 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\ResponseHeaderBag; +use Symfony\Component\HttpFoundation\Tests\File\FakeFile; class BinaryFileResponseTest extends ResponseTestCase { public function testConstruction() { - $response = new BinaryFileResponse('README.md', 404, array('X-Header' => 'Foo'), true, null, true, true); + $file = __DIR__.'/../README.md'; + $response = new BinaryFileResponse($file, 404, array('X-Header' => 'Foo'), true, null, true, true); $this->assertEquals(404, $response->getStatusCode()); $this->assertEquals('Foo', $response->headers->get('X-Header')); $this->assertTrue($response->headers->has('ETag')); $this->assertTrue($response->headers->has('Last-Modified')); $this->assertFalse($response->headers->has('Content-Disposition')); - $response = BinaryFileResponse::create('README.md', 404, array(), true, ResponseHeaderBag::DISPOSITION_INLINE); + $response = BinaryFileResponse::create($file, 404, array(), true, ResponseHeaderBag::DISPOSITION_INLINE); $this->assertEquals(404, $response->getStatusCode()); $this->assertFalse($response->headers->has('ETag')); $this->assertEquals('inline; filename="README.md"', $response->headers->get('Content-Disposition')); @@ -37,13 +39,13 @@ public function testConstruction() */ public function testSetContent() { - $response = new BinaryFileResponse('README.md'); + $response = new BinaryFileResponse(__FILE__); $response->setContent('foo'); } public function testGetContent() { - $response = new BinaryFileResponse('README.md'); + $response = new BinaryFileResponse(__FILE__); $this->assertFalse($response->getContent()); } @@ -150,7 +152,7 @@ public function provideInvalidRanges() { return array( array('bytes=-40'), - array('bytes=30-40') + array('bytes=30-40'), ); } @@ -160,7 +162,7 @@ public function testXSendfile() $request->headers->set('X-Sendfile-Type', 'X-Sendfile'); BinaryFileResponse::trustXSendfileTypeHeader(); - $response = BinaryFileResponse::create('README.md'); + $response = BinaryFileResponse::create(__DIR__.'/../README.md'); $response->prepare($request); $this->expectOutputString(''); @@ -178,18 +180,10 @@ public function testXAccelMapping($realpath, $mapping, $virtual) $request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect'); $request->headers->set('X-Accel-Mapping', $mapping); - $file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() - ->getMock(); - $file->expects($this->any()) - ->method('getRealPath') - ->will($this->returnValue($realpath)); - $file->expects($this->any()) - ->method('isReadable') - ->will($this->returnValue(true)); + $file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test'); BinaryFileResponse::trustXSendFileTypeHeader(); - $response = new BinaryFileResponse('README.md'); + $response = new BinaryFileResponse($file); $reflection = new \ReflectionObject($response); $property = $reflection->getProperty('file'); $property->setAccessible(true); @@ -199,6 +193,16 @@ public function testXAccelMapping($realpath, $mapping, $virtual) $this->assertEquals($virtual, $response->headers->get('X-Accel-Redirect')); } + public function testSplFileObject() + { + $filePath = __DIR__.'/File/Fixtures/test'; + $file = new \SplFileObject($filePath); + + $response = new BinaryFileResponse($file); + + $this->assertEquals(realpath($response->getFile()->getPathname()), realpath($filePath)); + } + public function getSampleXAccelMappings() { return array( @@ -209,6 +213,6 @@ public function getSampleXAccelMappings() protected function provideResponse() { - return new BinaryFileResponse('README.md'); + return new BinaryFileResponse(__DIR__.'/../README.md'); } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fda372f3fb70805d8b4348997fc8f89c75ed84e0 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php @@ -0,0 +1,68 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests; + +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; +use Symfony\Component\HttpFoundation\ExpressionRequestMatcher; +use Symfony\Component\HttpFoundation\Request; + +class ExpressionRequestMatcherTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException \LogicException + */ + public function testWhenNoExpressionIsSet() + { + $expressionRequestMatcher = new ExpressionRequestMatcher(); + $expressionRequestMatcher->matches(new Request()); + } + + /** + * @dataProvider provideExpressions + */ + public function testMatchesWhenParentMatchesIsTrue($expression, $expected) + { + $request = Request::create('/foo'); + $expressionRequestMatcher = new ExpressionRequestMatcher(); + + $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); + $this->assertSame($expected, $expressionRequestMatcher->matches($request)); + } + + /** + * @dataProvider provideExpressions + */ + public function testMatchesWhenParentMatchesIsFalse($expression) + { + $request = Request::create('/foo'); + $request->attributes->set('foo', 'foo'); + $expressionRequestMatcher = new ExpressionRequestMatcher(); + $expressionRequestMatcher->matchAttribute('foo', 'bar'); + + $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); + $this->assertFalse($expressionRequestMatcher->matches($request)); + } + + public function provideExpressions() + { + return array( + array('request.getMethod() == method', true), + array('request.getPathInfo() == path', true), + array('request.getHost() == host', true), + array('request.getClientIp() == ip', true), + array('request.attributes.all() == attributes', true), + array('request.getMethod() == method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', true), + array('request.getMethod() != method', false), + array('request.getMethod() != method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', false), + ); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php new file mode 100644 index 0000000000000000000000000000000000000000..c415989f2f7f8320929c940fc69842dd530fb758 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php @@ -0,0 +1,45 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests\File; + +use Symfony\Component\HttpFoundation\File\File as OrigFile; + +class FakeFile extends OrigFile +{ + private $realpath; + + public function __construct($realpath, $path) + { + $this->realpath = $realpath; + parent::__construct($path, false); + } + + public function isReadable() + { + return true; + } + + public function getRealpath() + { + return $this->realpath; + } + + public function getSize() + { + return 42; + } + + public function getMTime() + { + return time(); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index 1f29d56bc0348a69e882f8ebe6f83ce68df7460b..738604bcc78927024143fb0883db518a07a85702 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -40,7 +40,7 @@ public function testShouldConvertsUploadedFiles() 'type' => 'text/plain', 'tmp_name' => $tmpFile, 'error' => 0, - 'size' => 100 + 'size' => 100, ))); $this->assertEquals($file, $bag->get('file')); @@ -53,7 +53,7 @@ public function testShouldSetEmptyUploadedFilesToNull() 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0 + 'size' => 0, ))); $this->assertNull($bag->get('file')); @@ -81,7 +81,7 @@ public function testShouldConvertUploadedFilesWithPhpBug() 'size' => array( 'file' => 100, ), - ) + ), )); $files = $bag->all(); @@ -96,21 +96,21 @@ public function testShouldConvertNestedUploadedFilesWithPhpBug() $bag = new FileBag(array( 'child' => array( 'name' => array( - 'sub' => array('file' => basename($tmpFile)) + 'sub' => array('file' => basename($tmpFile)), ), 'type' => array( - 'sub' => array('file' => 'text/plain') + 'sub' => array('file' => 'text/plain'), ), 'tmp_name' => array( - 'sub' => array('file' => $tmpFile) + 'sub' => array('file' => $tmpFile), ), 'error' => array( - 'sub' => array('file' => 0) + 'sub' => array('file' => 0), ), 'size' => array( - 'sub' => array('file' => 100) + 'sub' => array('file' => 100), ), - ) + ), )); $files = $bag->all(); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index ef392ca59dbe682e841ccef0ebf39b87bbb9d832..48b86038a7e15a59b30bd3785ae673015d88e48d 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -155,7 +155,7 @@ public function testSetCallback() { $response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback'); - $this->assertEquals('callback({"foo":"bar"});', $response->getContent()); + $this->assertEquals('/**/callback({"foo":"bar"});', $response->getContent()); $this->assertEquals('text/javascript', $response->headers->get('Content-Type')); } @@ -166,6 +166,25 @@ public function testJsonEncodeFlags() $this->assertEquals('"\u003C\u003E\u0027\u0026\u0022"', $response->getContent()); } + public function testGetEncodingOptions() + { + $response = new JsonResponse(); + + $this->assertEquals(JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT, $response->getEncodingOptions()); + } + + public function testSetEncodingOptions() + { + $response = new JsonResponse(); + $response->setData(array(array(1, 2, 3))); + + $this->assertEquals('[[1,2,3]]', $response->getContent()); + + $response->setEncodingOptions(JSON_FORCE_OBJECT); + + $this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent()); + } + /** * @expectedException \InvalidArgumentException */ @@ -182,4 +201,32 @@ public function testSetContent() { JsonResponse::create("\xB1\x31"); } + + /** + * @expectedException Exception + * @expectedExceptionMessage Failed calling Symfony\Component\HttpFoundation\Tests\JsonSerializableObject::jsonSerialize() + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php#114688 + */ + public function testSetContentJsonSerializeError() + { + if (!interface_exists('JsonSerializable')) { + $this->markTestSkipped('Interface JsonSerializable is available in PHP 5.4+'); + } + + $serializable = new JsonSerializableObject(); + + JsonResponse::create($serializable); + } +} + +if (interface_exists('JsonSerializable')) { + class JsonSerializableObject implements \JsonSerializable + { + public function jsonSerialize() + { + trigger_error('This error is expected', E_USER_WARNING); + + return array(); + } + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php index 7f4f243b481bb94f5a79d3be0bba710fc2d87a72..95af8a14d930ae714999d69bda26798d6cfce851 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php @@ -212,16 +212,15 @@ public function testFilter() $this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff)) + 'options' => array('min_range' => 1, 'max_range' => 0xff),) ), '->filter() gets a value of parameter as integer between boundaries'); $this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff)) + 'options' => array('min_range' => 1, 'max_range' => 0xff),) ), '->filter() gets a value of parameter as integer between boundaries'); $this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array'); - } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php index 0e1a0f5caf363016f578e38518997edbb96bd199..63d37492ec1264b94c7c405d2089a0c0b36fedfb 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php @@ -54,7 +54,7 @@ public function testHost($pattern, $isMatch) $matcher->matchHost($pattern); $this->assertSame($isMatch, $matcher->matches($request)); - $matcher= new RequestMatcher(null, $pattern); + $matcher = new RequestMatcher(null, $pattern); $this->assertSame($isMatch, $matcher->matches($request)); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e26b806fd2877fcfb1a41b8c98b0c3259397900f --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php @@ -0,0 +1,69 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; + +class RequestStackTest extends \PHPUnit_Framework_TestCase +{ + public function testGetCurrentRequest() + { + $requestStack = new RequestStack(); + $this->assertNull($requestStack->getCurrentRequest()); + + $request = Request::create('/foo'); + + $requestStack->push($request); + $this->assertSame($request, $requestStack->getCurrentRequest()); + + $this->assertSame($request, $requestStack->pop()); + $this->assertNull($requestStack->getCurrentRequest()); + + $this->assertNull($requestStack->pop()); + } + + public function testGetMasterRequest() + { + $requestStack = new RequestStack(); + $this->assertNull($requestStack->getMasterRequest()); + + $masterRequest = Request::create('/foo'); + $subRequest = Request::create('/bar'); + + $requestStack->push($masterRequest); + $requestStack->push($subRequest); + + $this->assertSame($masterRequest, $requestStack->getMasterRequest()); + } + + public function testGetParentRequest() + { + $requestStack = new RequestStack(); + $this->assertNull($requestStack->getParentRequest()); + + $masterRequest = Request::create('/foo'); + + $requestStack->push($masterRequest); + $this->assertNull($requestStack->getParentRequest()); + + $firstSubRequest = Request::create('/bar'); + + $requestStack->push($firstSubRequest); + $this->assertSame($masterRequest, $requestStack->getParentRequest()); + + $secondSubRequest = Request::create('/baz'); + + $requestStack->push($secondSubRequest); + $this->assertSame($firstSubRequest, $requestStack->getParentRequest()); + } +} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php index db331f283d05b6bfff8e48d72a2e14f953cdfdaa..c07557b85c743dcb18cfb5d823f8ccde0cd5d009 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -42,7 +42,7 @@ public function testInitialize() $this->assertEquals('bar', $request->attributes->get('foo'), '->initialize() takes an array of attributes as its third argument'); $request->initialize(array(), array(), array(), array(), array(), array('HTTP_FOO' => 'bar')); - $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its fourth argument'); + $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its sixth argument'); } public function testGetLocale() @@ -163,6 +163,14 @@ public function testCreate() $this->assertEquals(90, $request->getPort()); $this->assertTrue($request->isSecure()); + $request = Request::create('https://[::1]/foo'); + $this->assertEquals('https://[::1]/foo', $request->getUri()); + $this->assertEquals('/foo', $request->getPathInfo()); + $this->assertEquals('[::1]', $request->getHost()); + $this->assertEquals('[::1]', $request->getHttpHost()); + $this->assertEquals(443, $request->getPort()); + $this->assertTrue($request->isSecure()); + $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; $request = Request::create('http://example.com/jsonrpc', 'POST', array(), array(), array(), array(), $json); $this->assertEquals($json, $request->getContent()); @@ -192,24 +200,24 @@ public function testCreate() $this->assertEquals('test.com:90', $request->getHttpHost()); $this->assertFalse($request->isSecure()); - $request = Request::create('http://test:test@test.com'); + $request = Request::create('http://username:password@test.com'); $this->assertEquals('http://test.com/', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); $this->assertEquals('', $request->getQueryString()); $this->assertEquals(80, $request->getPort()); $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('test', $request->getUser()); - $this->assertEquals('test', $request->getPassword()); + $this->assertEquals('username', $request->getUser()); + $this->assertEquals('password', $request->getPassword()); $this->assertFalse($request->isSecure()); - $request = Request::create('http://testnopass@test.com'); + $request = Request::create('http://username@test.com'); $this->assertEquals('http://test.com/', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); $this->assertEquals('', $request->getQueryString()); $this->assertEquals(80, $request->getPort()); $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('testnopass', $request->getUser()); - $this->assertNull($request->getPassword()); + $this->assertEquals('username', $request->getUser()); + $this->assertSame('',$request->getPassword()); $this->assertFalse($request->isSecure()); $request = Request::create('http://test.com/?foo'); @@ -594,6 +602,7 @@ public function testGetSchemeAndHttpHost() { $request = new Request(); + $server = array(); $server['SERVER_NAME'] = 'servername'; $server['SERVER_PORT'] = '90'; $request->initialize(array(), array(), array(), array(), array(), $server); @@ -688,7 +697,7 @@ public function testGetPort() { $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '443' + 'HTTP_X_FORWARDED_PORT' => '443', )); $port = $request->getPort(); @@ -697,40 +706,40 @@ public function testGetPort() Request::setTrustedProxies(array('1.1.1.1')); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '8443' + 'HTTP_X_FORWARDED_PORT' => '8443', )); $port = $request->getPort(); $this->assertEquals(8443, $port, 'With PROTO and PORT set PORT takes precedence.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https' + 'HTTP_X_FORWARDED_PROTO' => 'https', )); $port = $request->getPort(); $this->assertEquals(443, $port, 'With only PROTO set getPort() defaults to 443.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'http' + 'HTTP_X_FORWARDED_PROTO' => 'http', )); $port = $request->getPort(); $this->assertEquals(80, $port, 'If X_FORWARDED_PROTO is set to HTTP return 80.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'On' + 'HTTP_X_FORWARDED_PROTO' => 'On', )); $port = $request->getPort(); $this->assertEquals(443, $port, 'With only PROTO set and value is On, getPort() defaults to 443.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => '1' + 'HTTP_X_FORWARDED_PROTO' => '1', )); $port = $request->getPort(); $this->assertEquals(443, $port, 'With only PROTO set and value is 1, getPort() defaults to 443.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'something-else' + 'HTTP_X_FORWARDED_PROTO' => 'something-else', )); $port = $request->getPort(); $this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.'); @@ -1003,10 +1012,21 @@ public function testOverrideGlobals() $request->headers->set('CONTENT_TYPE', 'multipart/form-data'); $request->headers->set('CONTENT_LENGTH', 12345); + $request->overrideGlobals(); + $this->assertArrayHasKey('CONTENT_TYPE', $_SERVER); $this->assertArrayHasKey('CONTENT_LENGTH', $_SERVER); + $request->initialize(array('foo' => 'bar', 'baz' => 'foo')); + $request->query->remove('baz'); + + $request->overrideGlobals(); + + $this->assertEquals(array('foo' => 'bar'), $_GET); + $this->assertEquals('foo=bar', $_SERVER['QUERY_STRING']); + $this->assertEquals('foo=bar', $request->server->get('QUERY_STRING')); + // restore initial $_SERVER array $_SERVER = $server; } @@ -1519,31 +1539,31 @@ public function iisRequestUriProvider() 'X_ORIGINAL_URL' => '/foo/bar', ), array(), - '/foo/bar' + '/foo/bar', ), array( array( 'X_REWRITE_URL' => '/foo/bar', ), array(), - '/foo/bar' + '/foo/bar', ), array( array(), array( 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar' + 'UNENCODED_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array( 'X_ORIGINAL_URL' => '/foo/bar', ), array( - 'HTTP_X_ORIGINAL_URL' => '/foo/bar' + 'HTTP_X_ORIGINAL_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array( @@ -1551,9 +1571,9 @@ public function iisRequestUriProvider() ), array( 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar' + 'UNENCODED_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array( @@ -1562,16 +1582,16 @@ public function iisRequestUriProvider() array( 'HTTP_X_ORIGINAL_URL' => '/foo/bar', 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar' + 'UNENCODED_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array(), array( 'ORIG_PATH_INFO' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array(), @@ -1579,8 +1599,8 @@ public function iisRequestUriProvider() 'ORIG_PATH_INFO' => '/foo/bar', 'QUERY_STRING' => 'foo=bar', ), - '/foo/bar?foo=bar' - ) + '/foo/bar?foo=bar', + ), ); } @@ -1637,6 +1657,59 @@ public function testFactory() Request::setFactory(null); } + + /** + * @dataProvider getLongHostNames + */ + public function testVeryLongHosts($host) + { + $start = microtime(true); + + $request = Request::create('/'); + $request->headers->set('host', $host); + $this->assertEquals($host, $request->getHost()); + $this->assertLessThan(1, microtime(true) - $start); + } + + /** + * @dataProvider getHostValidities + */ + public function testHostValidity($host, $isValid, $expectedHost = null, $expectedPort = null) + { + $request = Request::create('/'); + $request->headers->set('host', $host); + + if ($isValid) { + $this->assertSame($expectedHost ?: $host, $request->getHost()); + if ($expectedPort) { + $this->assertSame($expectedPort, $request->getPort()); + } + } else { + $this->setExpectedException('UnexpectedValueException', 'Invalid Host'); + $request->getHost(); + } + } + + public function getHostValidities() + { + return array( + array('.a', false), + array('a..', false), + array('a.', true), + array("\xE9", false), + array('[::1]', true), + array('[::1]:80', true, '[::1]', 80), + array(str_repeat('.', 101), false), + ); + } + + public function getLongHostNames() + { + return array( + array('a'.str_repeat('.a', 40000)), + array(str_repeat(':', 101)), + ); + } } class RequestContentProxy extends Request diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 1cb327860d22351056be7b15b9b9db0622653dfa..1201deb9030ab469b39c750a2e23f0d0660fe635 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -32,31 +32,31 @@ public function provideAllPreserveCase() return array( array( array('fOo' => 'BAR'), - array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')) + array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')), ), array( array('ETag' => 'xyzzy'), - array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')) + array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')), ), array( array('Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ=='), - array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache')) + array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache')), ), array( array('P3P' => 'CP="CAO PSA OUR"'), - array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache')) + array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache')), ), array( array('WWW-Authenticate' => 'Basic realm="WallyWorld"'), - array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache')) + array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache')), ), array( array('X-UA-Compatible' => 'IE=edge,chrome=1'), - array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache')) + array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache')), ), array( array('X-XSS-Protection' => '1; mode=block'), - array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache')) + array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache')), ), ); } @@ -82,7 +82,7 @@ public function testCacheControlHeader() $bag = new ResponseHeaderBag(array( 'Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT', - 'Cache-Control' => 'max-age=3600' + 'Cache-Control' => 'max-age=3600', )); $this->assertEquals('max-age=3600, private', $bag->get('Cache-Control')); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 11eb38c72372fa23feea71fcceb3dee626680360..5b7de70bd8346481464db84578fdc1a121cbdfdc 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -141,16 +141,24 @@ public function testIsNotModifiedNotSafe() public function testIsNotModifiedLastModified() { + $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; + $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; $request = new Request(); $request->headers->set('If-Modified-Since', $modified); $response = new Response(); + $response->headers->set('Last-Modified', $modified); + $this->assertTrue($response->isNotModified($request)); + $response->headers->set('Last-Modified', $before); $this->assertTrue($response->isNotModified($request)); + $response->headers->set('Last-Modified', $after); + $this->assertFalse($response->isNotModified($request)); + $response->headers->set('Last-Modified', ''); $this->assertFalse($response->isNotModified($request)); } @@ -175,6 +183,50 @@ public function testIsNotModifiedEtag() $this->assertFalse($response->isNotModified($request)); } + public function testIsNotModifiedLastModifiedAndEtag() + { + $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; + $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; + $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; + $etag = 'randomly_generated_etag'; + + $request = new Request(); + $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); + $request->headers->set('If-Modified-Since', $modified); + + $response = new Response(); + + $response->headers->set('ETag', $etag); + $response->headers->set('Last-Modified', $after); + $this->assertFalse($response->isNotModified($request)); + + $response->headers->set('ETag', 'non-existent-etag'); + $response->headers->set('Last-Modified', $before); + $this->assertFalse($response->isNotModified($request)); + + $response->headers->set('ETag', $etag); + $response->headers->set('Last-Modified', $modified); + $this->assertTrue($response->isNotModified($request)); + } + + public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified() + { + $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; + $etag = 'randomly_generated_etag'; + + $request = new Request(); + $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); + $request->headers->set('If-Modified-Since', $modified); + + $response = new Response(); + + $response->headers->set('ETag', $etag); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('ETag', 'non-existent-etag'); + $this->assertFalse($response->isNotModified($request)); + } + public function testIsValidateable() { $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); @@ -189,8 +241,9 @@ public function testIsValidateable() public function testGetDate() { - $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $this->assertEquals(0, $this->createDateTimeOneHourAgo()->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present'); + $oneHourAgo = $this->createDateTimeOneHourAgo(); + $response = new Response('', 200, array('Date' => $oneHourAgo->format(DATE_RFC2822))); + $this->assertEquals(0, $oneHourAgo->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present'); $response = new Response(); $date = $response->getDate(); @@ -199,7 +252,7 @@ public function testGetDate() $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); $now = $this->createDateTimeNow(); $response->headers->set('Date', $now->format(DATE_RFC2822)); - $this->assertEquals(0, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified'); + $this->assertLessThanOrEqual(1, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified'); $response = new Response('', 200); $response->headers->remove('Date'); @@ -219,7 +272,7 @@ public function testGetMaxAge() $response = new Response(); $response->headers->set('Cache-Control', 'must-revalidate'); $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); + $this->assertLessThanOrEqual(1, $response->getMaxAge() - 3600, '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); $response = new Response(); $response->headers->set('Cache-Control', 'must-revalidate'); @@ -290,7 +343,7 @@ public function testGetTtl() $response = new Response(); $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertLessThan(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); + $this->assertLessThanOrEqual(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); $response = new Response(); $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)); @@ -341,6 +394,16 @@ public function testGetVary() $response = new Response(); $response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo'); $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas'); + + $vary = array('Accept-Language', 'User-Agent', 'X-foo'); + + $response = new Response(); + $response->headers->set('Vary', $vary); + $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); + + $response = new Response(); + $response->headers->set('Vary', 'Accept-Language, User-Agent, X-foo'); + $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); } public function testSetVary() @@ -353,7 +416,7 @@ public function testSetVary() $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default'); $response->setVary('X-Foo', false); - $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() doesn\'t change the Vary header if replace is set to false'); + $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false'); } public function testDefaultContentType() @@ -435,11 +498,15 @@ public function testPrepareRemovesContentForInformationalResponse() $response->setStatusCode(101); $response->prepare($request); $this->assertEquals('', $response->getContent()); + $this->assertFalse($response->headers->has('Content-Type')); + $this->assertFalse($response->headers->has('Content-Type')); $response->setContent('content'); $response->setStatusCode(304); $response->prepare($request); $this->assertEquals('', $response->getContent()); + $this->assertFalse($response->headers->has('Content-Type')); + $this->assertFalse($response->headers->has('Content-Length')); } public function testPrepareRemovesContentLength() @@ -609,7 +676,7 @@ public function getStatusCodeFixtures() array('200', 'foo', 'foo'), array('199', null, ''), array('199', false, ''), - array('199', 'foo', 'foo') + array('199', 'foo', 'foo'), ); } @@ -658,7 +725,7 @@ public function testIsNotFound() public function testIsEmpty() { - foreach (array(201, 204, 304) as $code) { + foreach (array(204, 304) as $code) { $response = new Response('', $code); $this->assertTrue($response->isEmpty()); } @@ -742,7 +809,7 @@ public function testSettersAreChainable() 'setCharset' => 'UTF-8', 'setPublic' => null, 'setPrivate' => null, - 'setDate' => new \DateTime, + 'setDate' => new \DateTime(), 'expire' => null, 'setMaxAge' => 1, 'setSharedMaxAge' => 1, @@ -767,7 +834,7 @@ public function validContentProvider() public function invalidContentProvider() { return array( - 'obj' => array(new \stdClass), + 'obj' => array(new \stdClass()), 'array' => array(array()), 'bool' => array(true, '1'), ); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php index 89920f1fbc546b1103e6cc1fcebaf185e57c072d..4cded7fa033b5521c153144c853539cc8203de55 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php @@ -52,7 +52,7 @@ public function testHttpPasswordIsOptional() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '' + 'PHP_AUTH_PW' => '', ), $bag->getHeaders()); } @@ -63,18 +63,28 @@ public function testHttpBasicAuthWithPhpCgi() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar' + 'PHP_AUTH_PW' => 'bar', ), $bag->getHeaders()); } + public function testHttpBasicAuthWithPhpCgiBogus() + { + $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'))); + + // Username and passwords should not be set as the header is bogus + $headers = $bag->getHeaders(); + $this->assertFalse(isset($headers['PHP_AUTH_USER'])); + $this->assertFalse(isset($headers['PHP_AUTH_PW'])); + } + public function testHttpBasicAuthWithPhpCgiRedirect() { - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'))); + $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'))); $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar' + 'AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'), + 'PHP_AUTH_USER' => 'username', + 'PHP_AUTH_PW' => 'pass:word', ), $bag->getHeaders()); } @@ -85,7 +95,7 @@ public function testHttpBasicAuthWithPhpCgiEmptyPassword() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '' + 'PHP_AUTH_PW' => '', ), $bag->getHeaders()); } @@ -100,6 +110,17 @@ public function testHttpDigestAuthWithPhpCgi() ), $bag->getHeaders()); } + public function testHttpDigestAuthWithPhpCgiBogus() + { + $digest = 'Digest_username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; + $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); + + // Username and passwords should not be set as the header is bogus + $headers = $bag->getHeaders(); + $this->assertFalse(isset($headers['PHP_AUTH_USER'])); + $this->assertFalse(isset($headers['PHP_AUTH_PW'])); + } + public function testHttpDigestAuthWithPhpCgiRedirect() { $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php index 93c634cde065e282d0f54fe237c3171f084f5bbc..2d1d77c3303435b7f1391d3e60909c1eabf03f4c 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php @@ -43,7 +43,7 @@ protected function setUp() 'category' => array( 'fishing' => array( 'first' => 'cod', - 'second' => 'sole') + 'second' => 'sole',), ), ); $this->bag = new AttributeBag('_sf2'); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php index 0c46a515a0c2b06d76d563b5f21011158ec2bf31..70910680baf0408148b2c585d1af9cf465344ce4 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php @@ -43,7 +43,7 @@ protected function setUp() 'category' => array( 'fishing' => array( 'first' => 'cod', - 'second' => 'sole') + 'second' => 'sole',), ), ); $this->bag = new NamespacedAttributeBag('_sf2', '/'); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php index 1dbfd2f0e9a099b1352022558c55ddc78b7fccaf..d6e27bb30de533173553f13b4d7c51c8c08219b5 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php @@ -91,7 +91,7 @@ public function testAll() $this->bag->set('error', 'Bar'); $this->assertEquals(array( 'notice' => array('Foo'), - 'error' => array('Bar')), $this->bag->all() + 'error' => array('Bar'),), $this->bag->all() ); $this->assertEquals(array(), $this->bag->all()); @@ -150,6 +150,6 @@ public function testGetIterator() } $this->assertEquals(count($flashes), $i); - $this->assertEquals(0, count($this->bag->all())); + $this->assertCount(0, $this->bag->all()); } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 9d5ad352845bf32655cf8117ff2e126ba500db44..56015fdf5ab75511f15b83f04b1d995f3f627cc6 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -217,7 +217,7 @@ public function testGetCount() $this->session->set('hello', 'world'); $this->session->set('symfony2', 'rocks'); - $this->assertEquals(2, count($this->session)); + $this->assertCount(2, $this->session); } public function testGetMeta() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index d907ce4a9031d1f24c2ef3661dd8af3521fffdf1..9be6352b3100152589fd86f0bc49ee144edd5647 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -34,7 +34,6 @@ protected function setUp() $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; $this->mongo = $this->getMockBuilder($mongoClass) - ->disableOriginalConstructor() ->getMock(); $this->options = array( @@ -42,7 +41,7 @@ protected function setUp() 'data_field' => 'data', 'time_field' => 'time', 'database' => 'sf2-test', - 'collection' => 'session-test' + 'collection' => 'session-test', ); $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); @@ -76,9 +75,7 @@ public function testCloseMethodAlwaysReturnTrue() public function testWrite() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -105,9 +102,7 @@ public function testWrite() public function testReplaceSessionData() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -130,9 +125,7 @@ public function testReplaceSessionData() public function testDestroy() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -148,9 +141,7 @@ public function testDestroy() public function testGc() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -178,4 +169,18 @@ public function testGetConnection() $this->assertInstanceOf($mongoClass, $method->invoke($this->storage)); } + + private function createMongoCollectionMock() + { + $mongoClient = $this->getMockBuilder('MongoClient') + ->getMock(); + $mongoDb = $this->getMockBuilder('MongoDB') + ->setConstructorArgs(array($mongoClient, 'database-name')) + ->getMock(); + $collection = $this->getMockBuilder('MongoCollection') + ->setConstructorArgs(array($mongoDb, 'collection-name')) + ->getMock(); + + return $collection; + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 06da0096f3c476290be18ab1b6cb4fefbd3cd4ea..1438102f84c25a4b984e37acef6fcc8c49bffef1 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -23,80 +23,80 @@ protected function setUp() $this->markTestSkipped('This test requires SQLite support in your environment'); } - $this->pdo = new \PDO("sqlite::memory:"); + $this->pdo = new \PDO('sqlite::memory:'); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $sql = "CREATE TABLE sessions (sess_id VARCHAR(255) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)"; + $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 PdoSessionHandler($this->pdo, array(), array()); + $storage = new PdoSessionHandler($this->pdo, array()); } public function testWrongPdoErrMode() { - $pdo = new \PDO("sqlite::memory:"); + $pdo = new \PDO('sqlite::memory:'); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - $pdo->exec("CREATE TABLE sessions (sess_id VARCHAR(255) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)"); + $pdo->exec('CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'); $this->setExpectedException('InvalidArgumentException'); - $storage = new PdoSessionHandler($pdo, array('db_table' => 'sessions'), array()); + $storage = new PdoSessionHandler($pdo, array('db_table' => 'sessions')); } public function testWrongTableOptionsWrite() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'), array()); + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); $this->setExpectedException('RuntimeException'); $storage->write('foo', 'bar'); } public function testWrongTableOptionsRead() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'), array()); + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); $this->setExpectedException('RuntimeException'); $storage->read('foo', 'bar'); } public function testWriteRead() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + $storage = new PdoSessionHandler($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 PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + $storage1 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); $storage1->write('foo', 'bar'); - $storage2 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + $storage2 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); $this->assertEquals('bar', $storage2->read('foo'), 'values persist between instances'); } public function testSessionDestroy() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); $storage->write('foo', 'bar'); - $this->assertEquals(1, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); + $this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); $storage->destroy('foo'); - $this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); + $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); } public function testSessionGC() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); $storage->write('foo', 'bar'); $storage->write('baz', 'bar'); - $this->assertEquals(2, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); + $this->assertCount(2, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); $storage->gc(-1); - $this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); + $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); } public function testGetConnection() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php index dcfd94bd1ecfbe4b5886186e3f19a8f444dc25fd..069c8870395916b331486f3051c18ef73e5ccbf9 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php @@ -30,7 +30,7 @@ public function test() ->will($this->returnValue(true)) ; - $this->assertEquals(true, $writeCheckSessionHandler->close()); + $this->assertTrue($writeCheckSessionHandler->close()); } public function testWrite() @@ -45,7 +45,7 @@ public function testWrite() ->will($this->returnValue(true)) ; - $this->assertEquals(true, $writeCheckSessionHandler->write('foo', 'bar')); + $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); } public function testSkippedWrite() @@ -66,7 +66,7 @@ public function testSkippedWrite() ; $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); - $this->assertEquals(true, $writeCheckSessionHandler->write('foo', 'bar')); + $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); } public function testNonSkippedWrite() @@ -89,6 +89,6 @@ public function testNonSkippedWrite() ; $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); - $this->assertEquals(true, $writeCheckSessionHandler->write('foo', 'baZZZ')); + $this->assertTrue($writeCheckSessionHandler->write('foo', 'baZZZ')); } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php index c502c38ae613e23f6d15646848dbe1688d606692..fb632a84f5245e8ee3156f1acf40154487e891a1 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php @@ -70,7 +70,6 @@ public function testGetSetName() $this->assertEquals('__metadata', $this->bag->getName()); $this->bag->setName('foo'); $this->assertEquals('foo', $this->bag->getName()); - } public function testGetStorageKey() @@ -110,7 +109,7 @@ public function testSkipLastUsedUpdate() $sessionMetadata = array( MetadataBag::CREATED => $created, MetadataBag::UPDATED => $created, - MetadataBag::LIFETIME => 1000 + MetadataBag::LIFETIME => 1000, ); $bag->initialize($sessionMetadata); @@ -126,7 +125,7 @@ public function testDoesNotSkipLastUsedUpdate() $sessionMetadata = array( MetadataBag::CREATED => $created, MetadataBag::UPDATED => $created, - MetadataBag::LIFETIME => 1000 + MetadataBag::LIFETIME => 1000, ); $bag->initialize($sessionMetadata); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 691ee1459347a921910943fec55e5e79bda0c363..4870115caa64cfa16ecea59c990af3c6908d3332 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -11,10 +11,11 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; +use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; +use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; +use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; @@ -158,7 +159,7 @@ public function testCookieOptions() public function testSetSaveHandlerException() { $storage = $this->getStorage(); - $storage->setSaveHandler(new \stdClass); + $storage->setSaveHandler(new \stdClass()); } public function testSetSaveHandler53() @@ -175,9 +176,9 @@ public function testSetSaveHandler53() $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 SessionHandler())); + $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandler()); + $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()); @@ -199,9 +200,9 @@ public function testSetSaveHandler54() $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $storage->setSaveHandler(new NativeSessionHandler()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new SessionHandler())); + $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandler()); + $storage->setSaveHandler(new NullSessionHandler()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); } @@ -254,30 +255,3 @@ public function testCanStartOutside54() $storage->start(); } } - -class SessionHandler implements \SessionHandlerInterface -{ - public function open($savePath, $sessionName) - { - } - - public function close() - { - } - - public function read($id) - { - } - - public function write($id, $data) - { - } - - public function destroy($id) - { - } - - public function gc($maxlifetime) - { - } -} diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index 58b632aeb0e50831f9293df655e1b0374e7ee6de..f8ac39c94c1d37f96a5e497a05c0e3c887f63ebe 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -17,7 +17,6 @@ // https://github.com/sebastianbergmann/phpunit-mock-objects/issues/73 class ConcreteProxy extends AbstractProxy { - } class ConcreteSessionHandlerInterfaceProxy extends AbstractProxy implements \SessionHandlerInterface diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json index 09f5b24aa0aedae9ba67aa08fe27368dbfcb6f70..db57eb563ebfcecb18445cc1fe5023ab87db6089 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json @@ -18,6 +18,9 @@ "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/expression-language": "~2.4" + }, "autoload": { "psr-0": { "Symfony\\Component\\HttpFoundation\\": "" }, "classmap": [ "Symfony/Component/HttpFoundation/Resources/stubs" ] @@ -26,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist index df11f72c0ff3b8ea5d5ad449d4b0654ff532e474..bbc5dc6dc8d7e5acac4a40ad632478f7efaf7ca3 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore index 22450b759c2a324997440048ce46ffb2cc1685a5..94a6a2528878364d8732c83d2234d177e4cd1862 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore @@ -1,5 +1,5 @@ vendor/ composer.lock phpunit.xml -Tests/ProjectContainer.php -Tests/classes.map +Tests/Fixtures/cache/ +Tests/Fixtures/logs/ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php index 2fdbe1ccd0faa0593da28b19a95199b8c1208cde..f80fd4a91c3404b58c733fed48601ee82ecf7d4a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -140,7 +140,6 @@ public function getPath() */ public function getParent() { - return null; } /** diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md index 66219ae11637b5cf4d606707455601b0e97e8756..2b2e827d979ea50fd45e4c501d2a4ce9e0d57dee 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.5.0 +----- + + * deprecated `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass`, use `Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` instead + 2.4.0 ----- diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php index 7b492d0bbd87c8d1e7d597f785f2bc408cf7c5ec..199a4be97466ab6f03c7a45e2af466e53501c8ac 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php @@ -34,7 +34,7 @@ public function __construct(array $clearers = array()) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function clear($cacheDir) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php index bd96057ded64c8e6e576a2febd6a162311b28c9a..3cc0e4069685b6f656a81141471f1efca20859ef 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php @@ -52,7 +52,7 @@ public function warmUp($cacheDir) /** * Checks whether this warmer is optional or not. * - * @return Boolean always true + * @return bool always false */ public function isOptional() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php index ed76ce35863b86ad4b47709647622b2c0f54a737..902d8d651b5058cd08c490f486e22fe53bf1c419 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php @@ -26,7 +26,7 @@ interface CacheWarmerInterface extends WarmableInterface * A warmer should return true if the cache can be * generated incrementally and on-demand. * - * @return Boolean true if the warmer is optional, false otherwise + * @return bool true if the warmer is optional, false otherwise */ public function isOptional(); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php index b40d7006d696cde716ad206097a7d472b6cba397..dfa30b9ee158c1b4e188da758c6dc4177089d2e2 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php @@ -143,7 +143,9 @@ protected function filterRequest(DomRequest $request) { $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); - $httpRequest->files->replace($this->filterFiles($httpRequest->files->all())); + foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) { + $httpRequest->files->set($key, $value); + } return $httpRequest; } @@ -189,8 +191,6 @@ protected function filterFiles(array $files) true ); } - } else { - $filtered[$key] = $value; } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 46484498474c12005edb0168a2230d463075bf1e..563ee8ffd93ad89b94887132b2eb7a9de3040216 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -57,13 +57,21 @@ public function getController(Request $request) return false; } - if (is_array($controller) || (is_object($controller) && method_exists($controller, '__invoke'))) { + if (is_array($controller)) { return $controller; } + if (is_object($controller)) { + if (method_exists($controller, '__invoke')) { + return $controller; + } + + throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo())); + } + if (false === strpos($controller, ':')) { if (method_exists($controller, '__invoke')) { - return new $controller; + return new $controller(); } elseif (function_exists($controller)) { return $controller; } @@ -72,7 +80,7 @@ public function getController(Request $request) $callable = $this->createController($controller); if (!is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable.', $request->getPathInfo())); + throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo())); } return $callable; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 51b6d7ae01a44618f246a8a78af39396107ddfb6..8a35ebc70fc6914baf2ae174be18f4c32fdc01eb 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -70,7 +70,7 @@ public function collect(Request $request, Response $response, \Exception $except 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), - 'sapi_name' => php_sapi_name() + 'sapi_name' => php_sapi_name(), ); if (isset($this->kernel)) { @@ -143,7 +143,7 @@ public function getEnv() /** * Returns true if the debug is enabled. * - * @return Boolean true if debug is enabled, false otherwise + * @return bool true if debug is enabled, false otherwise */ public function isDebug() { @@ -153,7 +153,7 @@ public function isDebug() /** * Returns true if the XDebug is enabled. * - * @return Boolean true if XDebug is enabled, false otherwise + * @return bool true if XDebug is enabled, false otherwise */ public function hasXDebug() { @@ -163,7 +163,7 @@ public function hasXDebug() /** * Returns true if EAccelerator is enabled. * - * @return Boolean true if EAccelerator is enabled, false otherwise + * @return bool true if EAccelerator is enabled, false otherwise */ public function hasEAccelerator() { @@ -173,7 +173,7 @@ public function hasEAccelerator() /** * Returns true if APC is enabled. * - * @return Boolean true if APC is enabled, false otherwise + * @return bool true if APC is enabled, false otherwise */ public function hasApc() { @@ -183,7 +183,7 @@ public function hasApc() /** * Returns true if Zend OPcache is enabled * - * @return Boolean true if Zend OPcache is enabled, false otherwise + * @return bool true if Zend OPcache is enabled, false otherwise */ public function hasZendOpcache() { @@ -193,7 +193,7 @@ public function hasZendOpcache() /** * Returns true if XCache is enabled. * - * @return Boolean true if XCache is enabled, false otherwise + * @return bool true if XCache is enabled, false otherwise */ public function hasXCache() { @@ -203,7 +203,7 @@ public function hasXCache() /** * Returns true if WinCache is enabled. * - * @return Boolean true if WinCache is enabled, false otherwise + * @return bool true if WinCache is enabled, false otherwise */ public function hasWinCache() { @@ -213,7 +213,7 @@ public function hasWinCache() /** * Returns true if any accelerator is enabled. * - * @return Boolean true if any accelerator is enabled, false otherwise + * @return bool true if any accelerator is enabled, false otherwise */ public function hasAccelerator() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php index 10a010bc622e7b75ec4159426088471dacb44aa8..476bfff6fb1dff4cedd0fb3cc1dad1eedbf01cd5 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php @@ -37,7 +37,7 @@ public function collect(Request $request, Response $response, \Exception $except /** * Checks if the exception is not null. * - * @return Boolean true if the exception is not null, false otherwise + * @return bool true if the exception is not null, false otherwise */ public function hasException() { @@ -67,7 +67,7 @@ public function getMessage() /** * Gets the exception code. * - * @return integer The exception code + * @return int The exception code */ public function getCode() { @@ -77,7 +77,7 @@ public function getCode() /** * Gets the status code. * - * @return integer The status code + * @return int The status code */ public function getStatusCode() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index ba2ea44c5ed32f986d752f417b85e54421346910..48cde6695b2d609622b9fac1df480ba9994564e3 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\DataCollector; +use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Debug\ErrorHandler; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -46,11 +46,8 @@ public function collect(Request $request, Response $response, \Exception $except public function lateCollect() { if (null !== $this->logger) { - $this->data = array( - 'error_count' => $this->logger->countErrors(), - 'logs' => $this->sanitizeLogs($this->logger->getLogs()), - 'deprecation_count' => $this->computeDeprecationCount() - ); + $this->data = $this->computeErrorsCount(); + $this->data['logs'] = $this->sanitizeLogs($this->logger->getLogs()); } } @@ -76,11 +73,21 @@ public function getLogs() return isset($this->data['logs']) ? $this->data['logs'] : array(); } + public function getPriorities() + { + return isset($this->data['priorities']) ? $this->data['priorities'] : array(); + } + public function countDeprecations() { return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0; } + public function countScreams() + { + return isset($this->data['scream_count']) ? $this->data['scream_count'] : 0; + } + /** * {@inheritdoc} */ @@ -119,15 +126,36 @@ private function sanitizeContext($context) return $context; } - private function computeDeprecationCount() + private function computeErrorsCount() { - $count = 0; + $count = array( + 'error_count' => $this->logger->countErrors(), + 'deprecation_count' => 0, + 'scream_count' => 0, + 'priorities' => array(), + ); + foreach ($this->logger->getLogs() as $log) { - if (isset($log['context']['type']) && ErrorHandler::TYPE_DEPRECATION === $log['context']['type']) { - $count++; + if (isset($count['priorities'][$log['priority']])) { + ++$count['priorities'][$log['priority']]['count']; + } else { + $count['priorities'][$log['priority']] = array( + 'count' => 1, + 'name' => $log['priorityName'], + ); + } + + if (isset($log['context']['type'])) { + if (ErrorHandler::TYPE_DEPRECATION === $log['context']['type']) { + ++$count['deprecation_count']; + } elseif (isset($log['context']['scream'])) { + ++$count['scream_count']; + } } } + ksort($count['priorities']); + return $count; } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php index e36f1f457e7b139c1b384874853ee5ba90050ea7..70f0c24b2a8bf9d99c198db233f17ae7986b7985 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php @@ -48,7 +48,7 @@ public function lateCollect() /** * Gets the memory. * - * @return integer The memory + * @return int The memory */ public function getMemory() { @@ -58,7 +58,7 @@ public function getMemory() /** * Gets the PHP memory limit. * - * @return integer The memory limit + * @return int The memory limit */ public function getMemoryLimit() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 4473605e843fc6020bb243bd604ec858c490b852..9c19f06783de341fbda0a98875367ca82002b6b2 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -48,14 +48,17 @@ public function collect(Request $request, Response $response, \Exception $except $responseHeaders['Set-Cookie'] = $cookies; } + // attributes are serialized and as they can be anything, they need to be converted to strings. $attributes = array(); foreach ($request->attributes->all() as $key => $value) { if ('_route' === $key && is_object($value)) { - $attributes['_route'] = $this->varToString($value->getPath()); + $attributes[$key] = $this->varToString($value->getPath()); } elseif ('_route_params' === $key) { - foreach ($value as $key => $v) { - $attributes['_route_params'][$key] = $this->varToString($v); + // we need to keep route params as an array (see getRouteParams()) + foreach ($value as $k => $v) { + $value[$k] = $this->varToString($v); } + $attributes[$key] = $value; } else { $attributes[$key] = $this->varToString($value); } @@ -298,13 +301,14 @@ private function getCookieHeader($name, $value, $expires, $path, $domain, $secur } elseif ($expires instanceof \DateTime) { $expires = $expires->getTimestamp(); } else { - $expires = strtotime($expires); - if (false === $expires || -1 == $expires) { - throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires)); + $tmp = strtotime($expires); + if (false === $tmp || -1 == $tmp) { + throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires)); } + $expires = $tmp; } - $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5); + $cookie .= '; expires='.str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))->format('D, d-M-Y H:i:s T')); } if ($domain) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php index 8757412c63c5d7d8633d734ceb836c173f43397f..a0fbac9472a720bec768068d3648640a565b1e97 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php @@ -69,7 +69,7 @@ public function onKernelController(FilterControllerEvent $event) } /** - * @return Boolean Whether this request will result in a redirect + * @return bool Whether this request will result in a redirect */ public function getRedirect() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index 4b5b00f0bf369aa7026fc5915b6fdc9931b1cd7c..b076daf58146703f55ccde11df62645ca40bff10 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -119,7 +119,7 @@ public function getInitTime() /** * Gets the request time. * - * @return integer The time + * @return int The time */ public function getStartTime() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php index f3aeb80cb227c4e6e35b09e3c6fef8d14b4506ba..31b60e6e40c98f55c991135ad335ad84e9b1bcb9 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php @@ -19,27 +19,42 @@ class ValueExporter /** * Converts a PHP value to a string. * - * @param mixed $value The PHP value + * @param mixed $value The PHP value + * @param int $depth only for internal usage + * @param bool $deep only for internal usage * * @return string The string representation of the given value */ - public function exportValue($value) + public function exportValue($value, $depth = 1, $deep = false) { if (is_object($value)) { return sprintf('Object(%s)', get_class($value)); } if (is_array($value)) { + if (empty($value)) { + return '[]'; + } + + $indent = str_repeat(' ', $depth); + $a = array(); foreach ($value as $k => $v) { - $a[] = sprintf('%s => %s', $k, $this->exportValue($v)); + if (is_array($v)) { + $deep = true; + } + $a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep)); + } + + if ($deep) { + return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1)); } - return sprintf("Array(%s)", implode(', ', $a)); + return sprintf("[%s]", implode(', ', $a)); } if (is_resource($value)) { - return sprintf('Resource(%s)', get_resource_type($value)); + return sprintf('Resource(%s#%d)', get_resource_type($value), $value); } if (null === $value) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index c8905fe304a7f67c2b810a538dd979910ca26fbe..02df5242bfc4777332bdef67c349dabc4f31a7ae 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -11,14 +11,10 @@ namespace Symfony\Component\HttpKernel\Debug; -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher; use Symfony\Component\HttpKernel\Profiler\Profiler; -use Psr\Log\LoggerInterface; +use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; /** * Collects some data about event listeners. @@ -27,31 +23,8 @@ * * @author Fabien Potencier <fabien@symfony.com> */ -class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEventDispatcherInterface +class TraceableEventDispatcher extends BaseTraceableEventDispatcher { - private $logger; - private $called = array(); - private $stopwatch; - private $dispatcher; - private $wrappedListeners = array(); - private $firstCalledEvent = array(); - private $id; - private $lastEventId = 0; - - /** - * Constructor. - * - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param Stopwatch $stopwatch A Stopwatch instance - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null) - { - $this->dispatcher = $dispatcher; - $this->stopwatch = $stopwatch; - $this->logger = $logger; - } - /** * Sets the profiler. * @@ -67,268 +40,11 @@ public function setProfiler(Profiler $profiler = null) { } - /** - * {@inheritDoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->dispatcher->addListener($eventName, $listener, $priority); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - $this->dispatcher->addSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - return $this->dispatcher->removeListener($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - return $this->dispatcher->removeSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - /** * {@inheritdoc} */ - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - if (null === $event) { - $event = new Event(); - } - - $this->id = $eventId = ++$this->lastEventId; - - $this->preDispatch($eventName, $event); - - $e = $this->stopwatch->start($eventName, 'section'); - - $this->firstCalledEvent[$eventName] = $this->stopwatch->start($eventName.'.loading', 'event_listener_loading'); - - if (!$this->dispatcher->hasListeners($eventName)) { - $this->firstCalledEvent[$eventName]->stop(); - } - - $this->dispatcher->dispatch($eventName, $event); - - // reset the id as another event might have been dispatched during the dispatching of this event - $this->id = $eventId; - - unset($this->firstCalledEvent[$eventName]); - - if ($e->isStarted()) { - $e->stop(); - } - - $this->postDispatch($eventName, $event); - - return $event; - } - - /** - * {@inheritDoc} - */ - public function getCalledListeners() + protected function preDispatch($eventName, Event $event) { - return $this->called; - } - - /** - * {@inheritDoc} - */ - public function getNotCalledListeners() - { - $notCalled = array(); - - foreach ($this->getListeners() as $name => $listeners) { - foreach ($listeners as $listener) { - $info = $this->getListenerInfo($listener, $name); - if (!isset($this->called[$name.'.'.$info['pretty']])) { - $notCalled[$name.'.'.$info['pretty']] = $info; - } - } - } - - return $notCalled; - } - - /** - * Proxies all method calls to the original event dispatcher. - * - * @param string $method The method name - * @param array $arguments The method arguments - * - * @return mixed - */ - public function __call($method, $arguments) - { - return call_user_func_array(array($this->dispatcher, $method), $arguments); - } - - /** - * This is a private method and must not be used. - * - * This method is public because it is used in a closure. - * Whenever Symfony will require PHP 5.4, this could be changed - * to a proper private method. - */ - public function logSkippedListeners($eventName, Event $event, $listener) - { - if (null === $this->logger) { - return; - } - - $info = $this->getListenerInfo($listener, $eventName); - - $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName)); - - $skippedListeners = $this->getListeners($eventName); - $skipped = false; - - foreach ($skippedListeners as $skippedListener) { - $skippedListener = $this->unwrapListener($skippedListener); - - if ($skipped) { - $info = $this->getListenerInfo($skippedListener, $eventName); - $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName)); - } - - if ($skippedListener === $listener) { - $skipped = true; - } - } - } - - /** - * This is a private method. - * - * This method is public because it is used in a closure. - * Whenever Symfony will require PHP 5.4, this could be changed - * to a proper private method. - */ - public function preListenerCall($eventName, $listener) - { - // is it the first called listener? - if (isset($this->firstCalledEvent[$eventName])) { - $this->firstCalledEvent[$eventName]->stop(); - - unset($this->firstCalledEvent[$eventName]); - } - - $info = $this->getListenerInfo($listener, $eventName); - - if (null !== $this->logger) { - $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty'])); - } - - $this->called[$eventName.'.'.$info['pretty']] = $info; - - return $this->stopwatch->start(isset($info['class']) ? $info['class'] : $info['type'], 'event_listener'); - } - - /** - * Returns information about the listener - * - * @param object $listener The listener - * @param string $eventName The event name - * - * @return array Information about the listener - */ - private function getListenerInfo($listener, $eventName) - { - $listener = $this->unwrapListener($listener); - - $info = array( - 'event' => $eventName, - ); - if ($listener instanceof \Closure) { - $info += array( - 'type' => 'Closure', - 'pretty' => 'closure' - ); - } elseif (is_string($listener)) { - try { - $r = new \ReflectionFunction($listener); - $file = $r->getFileName(); - $line = $r->getStartLine(); - } catch (\ReflectionException $e) { - $file = null; - $line = null; - } - $info += array( - 'type' => 'Function', - 'function' => $listener, - 'file' => $file, - 'line' => $line, - 'pretty' => $listener, - ); - } elseif (is_array($listener) || (is_object($listener) && is_callable($listener))) { - if (!is_array($listener)) { - $listener = array($listener, '__invoke'); - } - $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0]; - try { - $r = new \ReflectionMethod($class, $listener[1]); - $file = $r->getFileName(); - $line = $r->getStartLine(); - } catch (\ReflectionException $e) { - $file = null; - $line = null; - } - $info += array( - 'type' => 'Method', - 'class' => $class, - 'method' => $listener[1], - 'file' => $file, - 'line' => $line, - 'pretty' => $class.'::'.$listener[1], - ); - } - - return $info; - } - - private function preDispatch($eventName, Event $event) - { - // wrap all listeners before they are called - $this->wrappedListeners[$this->id] = new \SplObjectStorage(); - - $listeners = $this->dispatcher->getListeners($eventName); - - foreach ($listeners as $listener) { - $this->dispatcher->removeListener($eventName, $listener); - $wrapped = $this->wrapListener($eventName, $listener); - $this->wrappedListeners[$this->id][$wrapped] = $listener; - $this->dispatcher->addListener($eventName, $wrapped); - } - switch ($eventName) { case KernelEvents::REQUEST: $this->stopwatch->openSection(); @@ -342,19 +58,23 @@ private function preDispatch($eventName, Event $event) break; case KernelEvents::TERMINATE: $token = $event->getResponse()->headers->get('X-Debug-Token'); - // There is a very special case when using builtin AppCache class as kernel wrapper, in the case + // There is a very special case when using built-in AppCache class as kernel wrapper, in the case // of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A]. // In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID // is equal to the [A] debug token. Trying to reopen section with the [B] token throws an exception // which must be caught. try { $this->stopwatch->openSection($token); - } catch (\LogicException $e) {} + } catch (\LogicException $e) { + } break; } } - private function postDispatch($eventName, Event $event) + /** + * {@inheritdoc} + */ + protected function postDispatch($eventName, Event $event) { switch ($eventName) { case KernelEvents::CONTROLLER: @@ -370,44 +90,9 @@ private function postDispatch($eventName, Event $event) $token = $event->getResponse()->headers->get('X-Debug-Token'); try { $this->stopwatch->stopSection($token); - } catch (\LogicException $e) {} + } catch (\LogicException $e) { + } break; } - - foreach ($this->wrappedListeners[$this->id] as $wrapped) { - $this->dispatcher->removeListener($eventName, $wrapped); - $this->dispatcher->addListener($eventName, $this->wrappedListeners[$this->id][$wrapped]); - } - - unset($this->wrappedListeners[$this->id]); - } - - private function wrapListener($eventName, $listener) - { - $self = $this; - - return function (Event $event) use ($self, $eventName, $listener) { - $e = $self->preListenerCall($eventName, $listener); - - call_user_func($listener, $event, $eventName, $self); - - if ($e->isStarted()) { - $e->stop(); - } - - if ($event->isPropagationStopped()) { - $self->logSkippedListeners($eventName, $event, $listener); - } - }; - } - - private function unwrapListener($listener) - { - // get the original listener - if (is_object($listener) && isset($this->wrappedListeners[$this->id][$listener])) { - return $this->wrappedListeners[$this->id][$listener]; - } - - return $listener; } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php index b1f34158109ea62f7b0f2d642ff426f1940d590c..09af6bd25d93810147b2fda8dc93b2cd741fd660 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php @@ -30,7 +30,7 @@ public function __construct(Kernel $kernel) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function process(ContainerBuilder $container) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php index 1a24da02706e4b4c20fbc085cb1364c4ad4bffaf..3ec454bbcde27e2b9b66dfcedcd473517202437a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php @@ -28,7 +28,7 @@ abstract class ConfigurableExtension extends Extension { /** - * {@inheritDoc} + * {@inheritdoc} */ final public function load(array $configs, ContainerBuilder $container) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php index e48c409d8d00da1852761daf36838185fc08c856..0e14e91652b9a444010b01c179b70501c4ec8e94 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php @@ -11,96 +11,13 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass as BaseRegisterListenersPass; /** * Compiler pass to register tagged services for an event dispatcher. + * + * @deprecated Deprecated in 2.5, to be removed in 3.0. Use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass instead. */ -class RegisterListenersPass implements CompilerPassInterface +class RegisterListenersPass extends BaseRegisterListenersPass { - /** - * @var string - */ - protected $dispatcherService; - - /** - * @var string - */ - protected $listenerTag; - - /** - * @var string - */ - protected $subscriberTag; - - /** - * Constructor. - * - * @param string $dispatcherService Service name of the event dispatcher in processed container - * @param string $listenerTag Tag name used for listener - * @param string $subscriberTag Tag name used for subscribers - */ - public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber') - { - $this->dispatcherService = $dispatcherService; - $this->listenerTag = $listenerTag; - $this->subscriberTag = $subscriberTag; - } - - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { - return; - } - - $definition = $container->findDefinition($this->dispatcherService); - - foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) { - $def = $container->getDefinition($id); - if (!$def->isPublic()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id)); - } - - if ($def->isAbstract()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id)); - } - - foreach ($events as $event) { - $priority = isset($event['priority']) ? $event['priority'] : 0; - - if (!isset($event['event'])) { - throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag)); - } - - if (!isset($event['method'])) { - $event['method'] = 'on'.preg_replace_callback(array( - '/(?<=\b)[a-z]/i', - '/[^a-z0-9]/i', - ), function ($matches) { return strtoupper($matches[0]); }, $event['event']); - $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); - } - - $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); - } - } - - foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) { - $def = $container->getDefinition($id); - if (!$def->isPublic()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id)); - } - - // We must assume that the class value has been correctly filled, even if the service is created by a factory - $class = $def->getClass(); - - $refClass = new \ReflectionClass($class); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - if (!$refClass->implementsInterface($interface)) { - throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); - } - - $definition->addMethodCall('addSubscriberService', array($id, $class)); - } - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php index f71ccae2325d0926c22d1211e5175cbc07566222..5565f828351e70c647023d5daa2b4f99f7f8aa35 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php @@ -61,7 +61,7 @@ public function setResponse(Response $response) /** * Returns whether a response was set * - * @return Boolean Whether a response was set + * @return bool Whether a response was set * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php index 98763253daddcebcf1c72cd002478fb9a8189a36..93e0237c8340dda00f3cb778907d4d0d25085059 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php @@ -39,7 +39,7 @@ class KernelEvent extends Event /** * The request type the kernel is currently processing. One of * HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST - * @var integer + * @var int */ private $requestType; @@ -77,7 +77,7 @@ public function getRequest() /** * Returns the request type the kernel is currently processing * - * @return integer One of HttpKernelInterface::MASTER_REQUEST and + * @return int One of HttpKernelInterface::MASTER_REQUEST and * HttpKernelInterface::SUB_REQUEST * * @api @@ -90,7 +90,7 @@ public function getRequestType() /** * Checks if this is a master request. * - * @return Boolean True if the request is a master request + * @return bool True if the request is a master request * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php new file mode 100644 index 0000000000000000000000000000000000000000..c37a537009e98802b4d7cabfac394527f63ebd3c --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php @@ -0,0 +1,57 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\EventListener; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; + +/** + * Adds configured formats to each request + * + * @author Gildas Quemener <gildas.quemener@gmail.com> + */ +class AddRequestFormatsListener implements EventSubscriberInterface +{ + /** + * @var array + */ + protected $formats; + + /** + * @param array $formats + */ + public function __construct(array $formats) + { + $this->formats = $formats; + } + + /** + * Adds request formats + * + * @param GetResponseEvent $event + */ + public function onKernelRequest(GetResponseEvent $event) + { + foreach ($this->formats as $format => $mimeTypes) { + $event->getRequest()->setFormat($format, $mimeTypes); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return array(KernelEvents::REQUEST => 'onKernelRequest'); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php new file mode 100644 index 0000000000000000000000000000000000000000..4b7baf4ee5fbbee93601b20bd4ca977fb1e2141c --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -0,0 +1,51 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\EventListener; + +use Symfony\Component\Debug\ExceptionHandler; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\KernelEvents; + +/** + * Configures the ExceptionHandler. + * + * @author Nicolas Grekas <p@tchwork.com> + */ +class DebugHandlersListener implements EventSubscriberInterface +{ + private $exceptionHandler; + + public function __construct($exceptionHandler) + { + if (is_callable($exceptionHandler)) { + $this->exceptionHandler = $exceptionHandler; + } + } + + public function configure() + { + if ($this->exceptionHandler) { + $handler = set_exception_handler('var_dump'); + $handler = is_array($handler) ? $handler[0] : null; + restore_exception_handler(); + if ($handler instanceof ExceptionHandler) { + $handler->setHandler($this->exceptionHandler); + } + $this->exceptionHandler = null; + } + } + + public static function getSubscribedEvents() + { + return array(KernelEvents::REQUEST => array('configure', 2048)); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php index 13940ab7ac7b6c944b585f57abb5fa572a5e158f..025b6475a4632320fc8ad31a223beb82950cf68f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php @@ -12,7 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Debug\ErrorHandler; +use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -38,11 +38,12 @@ public function injectLogger() { if (null !== $this->logger) { ErrorHandler::setLogger($this->logger, $this->channel); + $this->logger = null; } } public static function getSubscribedEvents() { - return array(KernelEvents::REQUEST => 'injectLogger'); + return array(KernelEvents::REQUEST => array('injectLogger', 2048)); } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 33ce993b079c454880af6004eb0a72c1d68d20f4..3450b6210ce0742b3115808bebd3215a8665ac64 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -83,7 +83,7 @@ public static function getSubscribedEvents() * * @param \Exception $exception The original \Exception instance * @param string $message The error message to log - * @param Boolean $original False when the handling of the exception thrown another exception + * @param bool $original False when the handling of the exception thrown another exception */ protected function logException(\Exception $exception, $message, $original = true) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index ef3fad3d4cfe48002720579d43202a28d27ee6b2..d0a2298d1f5edb93cd7e30a41759ae61ed1e9386 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -25,8 +24,8 @@ * All URL paths starting with /_fragment are handled as * content fragments by this listener. * - * If the request does not come from a trusted IP, it throws an - * AccessDeniedHttpException exception. + * If throws an AccessDeniedHttpException exception if the request + * is not signed or if it is not an internal sub-request. * * @author Fabien Potencier <fabien@symfony.com> */ @@ -62,7 +61,9 @@ public function onKernelRequest(GetResponseEvent $event) return; } - $this->validateRequest($request); + if ($event->isMasterRequest()) { + $this->validateRequest($request); + } parse_str($request->query->get('_path', ''), $attributes); $request->attributes->add($attributes); @@ -77,13 +78,6 @@ protected function validateRequest(Request $request) throw new AccessDeniedHttpException(); } - // does the Request come from a trusted IP? - $trustedIps = array_merge($this->getLocalIpAddresses(), $request->getTrustedProxies()); - $remoteAddress = $request->server->get('REMOTE_ADDR'); - if (IpUtils::checkIp($remoteAddress, $trustedIps)) { - return; - } - // is the Request signed? // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) { @@ -93,6 +87,11 @@ protected function validateRequest(Request $request) throw new AccessDeniedHttpException(); } + /** + * @deprecated Deprecated since 2.3.19, to be removed in 3.0. + * + * @return string[] + */ protected function getLocalIpAddresses() { return array('127.0.0.1', 'fe80::1', '::1'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index 995c998b6ff1361cfbd4de1449db4516a25fe29c..43d8d03a7f2181714fb86d0f964247d1255eab07 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -41,17 +41,18 @@ class ProfilerListener implements EventSubscriberInterface /** * Constructor. * - * @param Profiler $profiler A Profiler instance - * @param RequestMatcherInterface $matcher A RequestMatcher instance - * @param Boolean $onlyException true if the profiler only collects data when an exception occurs, false otherwise - * @param Boolean $onlyMasterRequests true if the profiler only collects data when the request is a master request, false otherwise + * @param Profiler $profiler A Profiler instance + * @param RequestMatcherInterface|null $matcher A RequestMatcher instance + * @param bool $onlyException true if the profiler only collects data when an exception occurs, false otherwise + * @param bool $onlyMasterRequests true if the profiler only collects data when the request is a master request, false otherwise + * @param RequestStack|null $requestStack A RequestStack instance */ public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false, RequestStack $requestStack = null) { $this->profiler = $profiler; $this->matcher = $matcher; - $this->onlyException = (Boolean) $onlyException; - $this->onlyMasterRequests = (Boolean) $onlyMasterRequests; + $this->onlyException = (bool) $onlyException; + $this->onlyMasterRequests = (bool) $onlyMasterRequests; $this->profiles = new \SplObjectStorage(); $this->parents = new \SplObjectStorage(); $this->requestStack = $requestStack; @@ -127,7 +128,9 @@ public function onKernelTerminate(PostResponseEvent $event) foreach ($this->profiles as $request) { // isset call should be removed when requestStack is required if (isset($this->parents[$request]) && null !== $parentRequest = $this->parents[$request]) { - $this->profiles[$parentRequest]->addChild($this->profiles[$request]); + if (isset($this->profiles[$parentRequest])) { + $this->profiles[$parentRequest]->addChild($this->profiles[$request]); + } } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php index 27ac632b6faeea575dcf03ea15c6950d7f1af689..06279c7a451440149a28601a55629371cdd4e407 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -50,9 +50,10 @@ class RouterListener implements EventSubscriberInterface * * RequestStack will become required in 3.0. * - * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher - * @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface) - * @param LoggerInterface|null $logger The logger + * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher + * @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface) + * @param LoggerInterface|null $logger The logger + * @param RequestStack|null $requestStack A RequestStack instance * * @throws \InvalidArgumentException */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php index d1023b297c0fa3790c84b5e00f977d2a7bd9c06a..ecf065f0e87520d0c52abb095d23e6fad2df66c8 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpKernel\EventListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -25,7 +24,7 @@ abstract class SessionListener implements EventSubscriberInterface { public function onKernelRequest(GetResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { return; } @@ -48,7 +47,7 @@ public static function getSubscribedEvents() /** * Gets the session object. * - * @return SessionInterface|null A SessionInterface instance of null if no session is available + * @return SessionInterface|null A SessionInterface instance or null if no session is available */ abstract protected function getSession(); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php index ee047a6accbdf475340ad4fd6d36f1992a081052..42a0f20bd491ac759df2a9889097b8c0c84e133e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -30,7 +29,7 @@ abstract class TestSessionListener implements EventSubscriberInterface { public function onKernelRequest(GetResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { return; } @@ -55,7 +54,7 @@ public function onKernelRequest(GetResponseEvent $event) */ public function onKernelResponse(FilterResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { return; } @@ -78,7 +77,7 @@ public static function getSubscribedEvents() /** * Gets the session object. * - * @return SessionInterface|null A SessionInterface instance of null if no session is available + * @return SessionInterface|null A SessionInterface instance or null if no session is available */ abstract protected function getSession(); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php index 714102bed8d56cb0a033022b7c020d0feacd354d..79d8639a5f7d303f8f8fad57f1721d8d5e33f3d2 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php @@ -24,7 +24,7 @@ class AccessDeniedHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php index 33463452b001f95270284b85c7b29d46be95476d..3f30a437b7e5dbfd44262f4a72b09c51958f57d6 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php @@ -23,7 +23,7 @@ class BadRequestHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php index e416b345a4cf38e64648e03d327af2b776a2bdb8..35f077670e44bbc2078b1ef33428b2494d426682 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php @@ -23,7 +23,7 @@ class ConflictHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php index 9fea1643bd09ae622492d83fc51925afa720b60d..219da326354418ce24bf0ca16f8cb8db1e109bf8 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php @@ -23,7 +23,7 @@ class GoneHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php index dd4a9dc5a3a3ea01581c44dca934937e677327e5..67f0baeab40e660f76adff9d6a37d760baa96e41 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php @@ -21,7 +21,7 @@ interface HttpExceptionInterface /** * Returns the status code. * - * @return integer An HTTP response status code + * @return int An HTTP response status code */ public function getStatusCode(); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php index 7aca014d71b0c9bce2c8bb9ebb2644abe62d0378..878388a9ccfe53a84fc10b043341972decad971d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php @@ -23,7 +23,7 @@ class LengthRequiredHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php index 3a81586a62b61e4df2b0a0b85314a7a5d2c2cc37..78dd26bf0fd8f0fd6c6922f9e62dc27b67a8b8a0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php @@ -24,7 +24,7 @@ class MethodNotAllowedHttpException extends HttpException * @param array $allow An array of allowed methods * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php index 6ac448aa73245d56bbcc7a821b012db4e7e2c561..0985d4ab6497dd65fe7b62ad3e446944c01195b0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php @@ -23,7 +23,7 @@ class NotAcceptableHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php index 547976c3f1b1e28f40f0d060e7bc2ebd96ac6b31..4639e379b90fc94d780f793fc493b5dd71a6d9a4 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php @@ -23,7 +23,7 @@ class NotFoundHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php index 4126c881a3a3102ff030a0afe6a68fd21e230b00..0dc2174bf40087600af38ca59d70b5068ce0a06f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php @@ -23,7 +23,7 @@ class PreconditionFailedHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php index 75ba17702aecd01bfba67ac4256772f852bc4729..fb1494dda73b44adbd6a55e0088ede1cb1581562 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php @@ -24,7 +24,7 @@ class PreconditionRequiredHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php index 09bbb6ed319db731d7c8cd1ae373be410c06db75..dcf4d745f87767127608aee6a28688bc2706d42b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php @@ -24,7 +24,7 @@ class ServiceUnavailableHttpException extends HttpException * @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php index b1232ef6cbb150d7675e5918279ee8cfbf42311d..22f6dd587a3169971527bf225ab18440f9e7ea3e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php @@ -22,10 +22,10 @@ class TooManyRequestsHttpException extends HttpException /** * Constructor. * - * @param integer|string $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php index 2527d62f89061e0d513de57b0ecb75c908e8f048..0dfe42db972809cf2582c8b646eecfa545a226de 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php @@ -24,7 +24,7 @@ class UnauthorizedHttpException extends HttpException * @param string $challenge WWW-Authenticate challenge string * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($challenge, $message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php new file mode 100644 index 0000000000000000000000000000000000000000..c51da532ed7827af10b58fcd67fa59f705ad78ce --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php @@ -0,0 +1,32 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Exception; + +/** + * UnprocessableEntityHttpException. + * + * @author Steve Hutchins <hutchinsteve@gmail.com> + */ +class UnprocessableEntityHttpException extends HttpException +{ + /** + * Constructor. + * + * @param string $message The internal exception message + * @param \Exception $previous The previous exception + * @param int $code The internal exception code + */ + public function __construct($message = null, \Exception $previous = null, $code = 0) + { + parent::__construct(422, $message, $previous, array(), $code); + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php index 88bceecfee65b078b917cd08c7ff368366cba72c..b2634702b970c4adf83a2593b67c80d3eb9a602a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php @@ -23,7 +23,7 @@ class UnsupportedMediaTypeHttpException extends HttpException * * @param string $message The internal exception message * @param \Exception $previous The previous exception - * @param integer $code The internal exception code + * @param int $code The internal exception code */ public function __construct($message = null, \Exception $previous = null, $code = 0) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php index a491a85ade22ada35edcf36d2c86efbc4b0cebe5..772884d6341bdfea2509cdfa849edb181c643d33 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\HttpCache\Esi; +use Symfony\Component\HttpKernel\UriSigner; /** * Implements the ESI rendering strategy. @@ -25,6 +26,7 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer { private $esi; private $inlineStrategy; + private $signer; /** * Constructor. @@ -32,13 +34,15 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer * The "fallback" strategy when ESI is not available should always be an * instance of InlineFragmentRenderer. * - * @param Esi $esi An Esi instance - * @param InlineFragmentRenderer $inlineStrategy The inline strategy to use when ESI is not supported + * @param Esi $esi An Esi instance + * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when ESI is not supported + * @param UriSigner $signer */ - public function __construct(Esi $esi = null, InlineFragmentRenderer $inlineStrategy) + public function __construct(Esi $esi = null, InlineFragmentRenderer $inlineStrategy, UriSigner $signer = null) { $this->esi = $esi; $this->inlineStrategy = $inlineStrategy; + $this->signer = $signer; } /** @@ -61,12 +65,12 @@ public function render($uri, Request $request, array $options = array()) } if ($uri instanceof ControllerReference) { - $uri = $this->generateFragmentUri($uri, $request); + $uri = $this->generateSignedFragmentUri($uri, $request); } $alt = isset($options['alt']) ? $options['alt'] : null; if ($alt instanceof ControllerReference) { - $alt = $this->generateFragmentUri($alt, $request); + $alt = $this->generateSignedFragmentUri($alt, $request); } $tag = $this->esi->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : ''); @@ -81,4 +85,16 @@ public function getName() { return 'esi'; } + + private function generateSignedFragmentUri($uri, Request $request) + { + if (null === $this->signer) { + throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.'); + } + + // we need to sign the absolute URI, but want to return the path only. + $fragmentUri = $this->signer->sign($this->generateFragmentUri($uri, $request, true)); + + return substr($fragmentUri, strlen($request->getSchemeAndHttpHost())); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php index 0297304844397ea3d44dce68d1dcfd0dace1dc02..27fa7eabec3cadd0a562bac8023bdc227afa9cdb 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php @@ -45,7 +45,7 @@ class FragmentHandler * RequestStack will become required in 3.0. * * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances - * @param Boolean $debug Whether the debug mode is enabled or not + * @param bool $debug Whether the debug mode is enabled or not * @param RequestStack|null $requestStack The Request stack that controls the lifecycle of requests */ public function __construct(array $renderers = array(), $debug = false, RequestStack $requestStack = null) @@ -97,7 +97,7 @@ public function setRequest(Request $request = null) * @return string|null The Response content or null when the Response is streamed * * @throws \InvalidArgumentException when the renderer does not exist - * @throws \LogicException when the Request is not successful + * @throws \LogicException when no master request is being handled */ public function render($uri, $renderer = 'inline', array $options = array()) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 8fc45724e76b3d780d8b9daf31c84c0ddefb6639..e9bece022532a85456f47f382032dd13b3ab2373 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -68,7 +68,7 @@ public function setTemplating($templating) /** * Checks if a templating engine has been set. * - * @return Boolean true if the templating engine has been set, false otherwise + * @return bool true if the templating engine has been set, false otherwise */ public function hasTemplating() { @@ -126,7 +126,7 @@ public function render($uri, Request $request, array $options = array()) /** * @param string $template * - * @return boolean + * @return bool */ private function templateExists($template) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php index c6ca3d475e8828ba92ab621c88223e8f73dbd6c1..a6ab82ea28efa07b5317a5e1aabbf1b880ba4a19 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php @@ -93,9 +93,7 @@ public function render($uri, Request $request, array $options = array()) } // let's clean up the output buffers that were created by the sub-request - while (ob_get_level() > $level) { - ob_get_clean(); - } + Response::closeOutputBuffers($level, false); if (isset($options['alt'])) { $alt = $options['alt']; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php index bdf710b27a567c705ae9decf8ab7e3243d91a0d4..cfbf5356973fcc2864da9e6d0edc8cfcbe07a877 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php @@ -41,8 +41,8 @@ public function setFragmentPath($path) * * @param ControllerReference $reference A ControllerReference instance * @param Request $request A Request instance - * @param Boolean $absolute Whether to generate an absolute URL or not - * @param Boolean $strict Whether to allow non-scalar attributes or not + * @param bool $absolute Whether to generate an absolute URL or not + * @param bool $strict Whether to allow non-scalar attributes or not * * @return string A fragment URI */ @@ -82,8 +82,8 @@ private function checkNonScalar($values) foreach ($values as $key => $value) { if (is_array($value)) { $this->checkNonScalar($value); - } elseif (!is_scalar($value)) { - throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar values (value for key "%s" is not a scalar).', $key)); + } elseif (!is_scalar($value) && null !== $value) { + throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); } } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php index 455b3dcce968b6b6c2a4b0acc2c1d314257eea74..9dd99d64cc49172f50c1198994e9dbf91639f643 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php @@ -56,7 +56,7 @@ public function createCacheStrategy() * * @param Request $request A Request instance * - * @return Boolean true if one surrogate has ESI/1.0 capability, false otherwise + * @return bool true if one surrogate has ESI/1.0 capability, false otherwise */ public function hasSurrogateEsiCapability(Request $request) { @@ -99,7 +99,7 @@ public function addSurrogateControl(Response $response) * * @param Response $response A Response instance * - * @return Boolean true if the Response needs to be parsed, false otherwise + * @return bool true if the Response needs to be parsed, false otherwise */ public function needsEsiParsing(Response $response) { @@ -107,7 +107,7 @@ public function needsEsiParsing(Response $response) return false; } - return (Boolean) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control); + return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control); } /** @@ -115,7 +115,7 @@ public function needsEsiParsing(Response $response) * * @param string $uri A URI * @param string $alt An alternate URI - * @param Boolean $ignoreErrors Whether to ignore errors or not + * @param bool $ignoreErrors Whether to ignore errors or not * @param string $comment A comment to add as an esi:include tag * * @return string @@ -185,7 +185,7 @@ public function process(Request $request, Response $response) * @param HttpCache $cache An HttpCache instance * @param string $uri The main URI * @param string $alt An alternative URI - * @param Boolean $ignoreErrors Whether to ignore errors or not + * @param bool $ignoreErrors Whether to ignore errors or not * * @return string * @@ -236,9 +236,9 @@ private function handleEsiIncludeTag($attributes) throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.'); } - return sprintf('<?php echo $this->esi->handle($this, \'%s\', \'%s\', %s) ?>'."\n", - $options['src'], - isset($options['alt']) ? $options['alt'] : null, + return sprintf('<?php echo $this->esi->handle($this, %s, %s, %s) ?>'."\n", + var_export($options['src'], true), + var_export(isset($options['alt']) ? $options['alt'] : '', true), isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false' ); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index f80d6f03e73cec733e03e6ab9a2da50d2cd15376..f65eb2371baa23bfdd3ceac2e86858a85b8ddd2b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -152,7 +152,6 @@ public function getKernel() return $this->kernel; } - /** * Gets the Esi instance * @@ -232,7 +231,7 @@ public function terminate(Request $request, Response $response) * Forwards the Request to the backend without storing the Response in the cache. * * @param Request $request A Request instance - * @param Boolean $catch Whether to process exceptions + * @param bool $catch Whether to process exceptions * * @return Response A Response instance */ @@ -247,7 +246,7 @@ protected function pass(Request $request, $catch = false) * Invalidates non-safe methods (like POST, PUT, and DELETE). * * @param Request $request A Request instance - * @param Boolean $catch Whether to process exceptions + * @param bool $catch Whether to process exceptions * * @return Response A Response instance * @@ -296,7 +295,7 @@ protected function invalidate(Request $request, $catch = false) * it triggers "miss" processing. * * @param Request $request A Request instance - * @param Boolean $catch whether to process exceptions + * @param bool $catch whether to process exceptions * * @return Response A Response instance * @@ -308,7 +307,7 @@ protected function lookup(Request $request, $catch = false) if ($this->options['allow_reload'] && $request->isNoCache()) { $this->record($request, 'reload'); - return $this->fetch($request); + return $this->fetch($request, $catch); } try { @@ -350,7 +349,7 @@ protected function lookup(Request $request, $catch = false) * * @param Request $request A Request instance * @param Response $entry A Response instance to validate - * @param Boolean $catch Whether to process exceptions + * @param bool $catch Whether to process exceptions * * @return Response A Response instance */ @@ -411,7 +410,7 @@ protected function validate(Request $request, Response $entry, $catch = false) * This methods is triggered when the cache missed or a reload is required. * * @param Request $request A Request instance - * @param Boolean $catch whether to process exceptions + * @param bool $catch whether to process exceptions * * @return Response A Response instance */ @@ -428,12 +427,6 @@ protected function fetch(Request $request, $catch = false) $response = $this->forward($subRequest, $catch); - if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { - $response->setPrivate(true); - } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { - $response->setTtl($this->options['default_ttl']); - } - if ($response->isCacheable()) { $this->store($request, $response); } @@ -445,7 +438,7 @@ protected function fetch(Request $request, $catch = false) * Forwards the Request to the backend and returns the Response. * * @param Request $request A Request instance - * @param Boolean $catch Whether to catch exceptions or not + * @param bool $catch Whether to catch exceptions or not * @param Response $entry A Response instance (the stale entry if present, null otherwise) * * @return Response A Response instance @@ -468,6 +461,12 @@ protected function forward(Request $request, $catch = false, Response $entry = n // is always called from the same process as the backend. $request->server->set('REMOTE_ADDR', '127.0.0.1'); + // make sure HttpCache is a trusted proxy + if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { + $trustedProxies[] = '127.0.0.1'; + Request::setTrustedProxies($trustedProxies); + } + // always a "master" request (as the real master request can be in cache) $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); // FIXME: we probably need to also catch exceptions if raw === true @@ -487,6 +486,12 @@ protected function forward(Request $request, $catch = false, Response $entry = n $this->processResponseBody($request, $response); + if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { + $response->setPrivate(true); + } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { + $response->setTtl($this->options['default_ttl']); + } + return $response; } @@ -496,7 +501,7 @@ protected function forward(Request $request, $catch = false, Response $entry = n * @param Request $request A Request instance * @param Response $entry A Response instance * - * @return Boolean true if the cache entry if fresh enough, false otherwise + * @return bool true if the cache entry if fresh enough, false otherwise */ protected function isFreshEnough(Request $request, Response $entry) { @@ -517,12 +522,12 @@ protected function isFreshEnough(Request $request, Response $entry) * @param Request $request A Request instance * @param Response $entry A Response instance * - * @return Boolean true if the cache entry can be returned even if it is staled, false otherwise + * @return bool true if the cache entry can be returned even if it is staled, false otherwise */ protected function lock(Request $request, Response $entry) { // try to acquire a lock to call the backend - $lock = $this->store->lock($request, $entry); + $lock = $this->store->lock($request); // there is already another process calling the backend if (true !== $lock) { @@ -602,8 +607,6 @@ protected function store(Request $request, Response $response) * * @param Request $request A Request instance * @param Response $response A Response instance - * - * @return Response A Response instance */ private function restoreResponseBody(Request $request, Response $response) { @@ -651,7 +654,7 @@ protected function processResponseBody(Request $request, Response $response) * * @param Request $request A Request instance * - * @return Boolean true if the Request is private, false otherwise + * @return bool true if the Request is private, false otherwise */ private function isPrivateRequest(Request $request) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php index 1d55ab4118f2aefab2eb6d44d14b643c6c60932b..8e86a86e2875c8d6ad22cbd894a7e6fddf3a6853 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -69,7 +69,7 @@ public function cleanup() * * @param Request $request A Request instance * - * @return Boolean|string true if the lock is acquired, the path to the current lock otherwise + * @return bool|string true if the lock is acquired, the path to the current lock otherwise */ public function lock(Request $request) { @@ -95,7 +95,7 @@ public function lock(Request $request) * * @param Request $request A Request instance * - * @return Boolean False if the lock file does not exist or cannot be unlocked, true otherwise + * @return bool False if the lock file does not exist or cannot be unlocked, true otherwise */ public function unlock(Request $request) { @@ -121,7 +121,7 @@ public function lookup(Request $request) $key = $this->getCacheKey($request); if (!$entries = $this->getMetadata($key)) { - return null; + return; } // find a cached entry that matches the request. @@ -135,7 +135,7 @@ public function lookup(Request $request) } if (null === $match) { - return null; + return; } list($req, $headers) = $match; @@ -146,7 +146,6 @@ public function lookup(Request $request) // TODO the metaStore referenced an entity that doesn't exist in // the entityStore. We definitely want to return nil but we should // also purge the entry from the meta-store when this is detected. - return null; } /** @@ -258,7 +257,7 @@ public function invalidate(Request $request) * @param array $env1 A Request HTTP header array * @param array $env2 A Request HTTP header array * - * @return Boolean true if the two environments match, false otherwise + * @return bool true if the two environments match, false otherwise */ private function requestsMatch($vary, $env1, $env2) { @@ -301,7 +300,7 @@ private function getMetadata($key) * * @param string $url A URL * - * @return Boolean true if the URL exists and has been purged, false otherwise + * @return bool true if the URL exists and has been purged, false otherwise */ public function purge($url) { @@ -334,7 +333,7 @@ private function load($key) * @param string $key The store key * @param string $data The data to store * - * @return Boolean + * @return bool */ private function save($key, $data) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php index 29a54d87254459f345e0d380dbe7bd68d1852018..2f1587791d162a572b181ba35540f1b527623bfe 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php @@ -58,7 +58,7 @@ public function invalidate(Request $request); * * @param Request $request A Request instance * - * @return Boolean|string true if the lock is acquired, the path to the current lock otherwise + * @return bool|string true if the lock is acquired, the path to the current lock otherwise */ public function lock(Request $request); @@ -67,7 +67,7 @@ public function lock(Request $request); * * @param Request $request A Request instance * - * @return Boolean False if the lock file does not exist or cannot be unlocked, true otherwise + * @return bool False if the lock file does not exist or cannot be unlocked, true otherwise */ public function unlock(Request $request); @@ -76,7 +76,7 @@ public function unlock(Request $request); * * @param Request $request A Request instance * - * @return Boolean true if lock exists, false otherwise + * @return bool true if lock exists, false otherwise */ public function isLocked(Request $request); @@ -85,7 +85,7 @@ public function isLocked(Request $request); * * @param string $url A URL * - * @return Boolean true if the URL exists and has been purged, false otherwise + * @return bool true if the URL exists and has been purged, false otherwise */ public function purge($url); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php index 0be8e1b4dbb7c11e8e1d72fcc94d5fc218519ffc..68d89c94e9be37e04387ce54fc3147ae5fd8f02c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php @@ -85,13 +85,32 @@ public function terminate(Request $request, Response $response) $this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response)); } + /** + * @throws \LogicException If the request stack is empty + * + * @internal + */ + public function terminateWithException(\Exception $exception) + { + if (!$request = $this->requestStack->getMasterRequest()) { + throw new \LogicException('Request stack is empty', 0, $exception); + } + + $response = $this->handleException($exception, $request, self::MASTER_REQUEST); + + $response->sendHeaders(); + $response->sendContent(); + + $this->terminate($request, $response); + } + /** * Handles a request to convert it to a response. * * Exceptions are not caught. * * @param Request $request A Request instance - * @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) + * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) * * @return Response A Response instance * @@ -153,7 +172,7 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST) * * @param Response $response A Response instance * @param Request $request An error message in case the response is not a Response object - * @param integer $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) + * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) * * @return Response The filtered Response instance * @@ -191,7 +210,7 @@ private function finishRequest(Request $request, $type) * * @param \Exception $e An \Exception instance * @param Request $request A Request instance - * @param integer $type The type of the request + * @param int $type The type of the request * * @return Response A Response instance * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php index f49d37ccb1f96247db825020688aa64c8336ea10..79d44f179e16cd44a96b0c89d321314d4325f4cc 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php @@ -33,9 +33,9 @@ interface HttpKernelInterface * and do its best to convert them to a Response instance. * * @param Request $request A Request instance - * @param integer $type The type of the request + * @param int $type The type of the request * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * @param Boolean $catch Whether to catch exceptions or not + * @param bool $catch Whether to catch exceptions or not * * @return Response A Response instance * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php index 94353c0422115f2b291fcfff4aeb0dd1ec8ad698..c64db087a0443287ebe61cc8c206f585063e9271 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php @@ -59,25 +59,25 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.4.1'; - const VERSION_ID = '20401'; + const VERSION = '2.5.5'; + const VERSION_ID = '20505'; const MAJOR_VERSION = '2'; - const MINOR_VERSION = '4'; - const RELEASE_VERSION = '1'; + const MINOR_VERSION = '5'; + const RELEASE_VERSION = '5'; const EXTRA_VERSION = ''; /** * Constructor. * * @param string $environment The environment - * @param Boolean $debug Whether to enable debugging or not + * @param bool $debug Whether to enable debugging or not * * @api */ public function __construct($environment, $debug) { $this->environment = $environment; - $this->debug = (Boolean) $debug; + $this->debug = (bool) $debug; $this->rootDir = $this->getRootDir(); $this->name = $this->getName(); @@ -260,7 +260,7 @@ public function getBundle($name, $first = true) * * @param string $name A resource name to locate * @param string $dir A directory where to look for the resource first - * @param Boolean $first Whether to return the first path or paths for all matching bundles + * @param bool $first Whether to return the first path or paths for all matching bundles * * @return string|array The absolute path of the resource or an array if $first is false * @@ -517,7 +517,6 @@ protected function initializeBundles() array_pop($bundleMap); } } - } /** @@ -757,23 +756,39 @@ public static function stripComments($source) $rawChunk = ''; $output = ''; $tokens = token_get_all($source); + $ignoreSpace = false; for (reset($tokens); false !== $token = current($tokens); next($tokens)) { if (is_string($token)) { $rawChunk .= $token; } elseif (T_START_HEREDOC === $token[0]) { - $output .= preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $rawChunk).$token[1]; + $output .= $rawChunk.$token[1]; do { $token = next($tokens); $output .= $token[1]; } while ($token[0] !== T_END_HEREDOC); $rawChunk = ''; - } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + } elseif (T_WHITESPACE === $token[0]) { + if ($ignoreSpace) { + $ignoreSpace = false; + + continue; + } + + // replace multiple new lines with a single newline + $rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]); + } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + $ignoreSpace = true; + } else { $rawChunk .= $token[1]; + + // The PHP-open tag already has a new-line + if (T_OPEN_TAG === $token[0]) { + $ignoreSpace = true; + } } } - // replace multiple new lines with a single newline - $output .= preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $rawChunk); + $output .= $rawChunk; return $output; } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php index 5e6ebcb8d9926b324f2ab7f38b18f752632d32c4..ebeca3bf835aa142e5eb709e892df4fd3efe4414 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php @@ -104,7 +104,7 @@ final class KernelEvents const TERMINATE = 'kernel.terminate'; /** - * The REQUEST_FINISHED event occurs when a response was generated for a request. + * The FINISH_REQUEST event occurs when a response was generated for a request. * * This event allows you to reset the global and environmental state of * the application, when it was changed during the request. diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php index 6905a1279c3cb43a7fbc32d679ed76877c59c556..922f63180ffabe8218dbb77ba4e61a6b573743bc 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php @@ -27,7 +27,7 @@ interface KernelInterface extends HttpKernelInterface, \Serializable { /** - * Returns an array of bundles to registers. + * Returns an array of bundles to register. * * @return BundleInterface[] An array of bundle instances. * @@ -36,7 +36,7 @@ interface KernelInterface extends HttpKernelInterface, \Serializable public function registerBundles(); /** - * Loads the container configuration + * Loads the container configuration. * * @param LoaderInterface $loader A LoaderInterface instance * @@ -74,7 +74,7 @@ public function getBundles(); * * @param string $class A class name * - * @return Boolean true if the class belongs to an active bundle, false otherwise + * @return bool true if the class belongs to an active bundle, false otherwise * * @api */ @@ -84,7 +84,7 @@ public function isClassInActiveBundle($class); * Returns a bundle and optionally its descendants by its name. * * @param string $name Bundle name - * @param Boolean $first Whether to return the first bundle only or together with its descendants + * @param bool $first Whether to return the first bundle only or together with its descendants * * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false * @@ -113,7 +113,7 @@ public function getBundle($name, $first = true); * * @param string $name A resource name to locate * @param string $dir A directory where to look for the resource first - * @param Boolean $first Whether to return the first path or paths for all matching bundles + * @param bool $first Whether to return the first path or paths for all matching bundles * * @return string|array The absolute path of the resource or an array if $first is false * @@ -125,7 +125,7 @@ public function getBundle($name, $first = true); public function locateResource($name, $dir = null, $first = true); /** - * Gets the name of the kernel + * Gets the name of the kernel. * * @return string The kernel name * @@ -145,7 +145,7 @@ public function getEnvironment(); /** * Checks if debug mode is enabled. * - * @return Boolean true if debug mode is enabled, false otherwise + * @return bool true if debug mode is enabled, false otherwise * * @api */ @@ -172,7 +172,7 @@ public function getContainer(); /** * Gets the request start time (not available if debug is disabled). * - * @return integer The request start timestamp + * @return int The request start timestamp * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php index 4442c6398efa4d9614bd1e628adbe1a240155ca0..c015b0d702fe33c9a4c4212245321334fec84e5b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php @@ -32,7 +32,7 @@ public function getLogs(); /** * Returns the number of errors. * - * @return integer The number of errors + * @return int The number of errors */ public function countErrors(); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php index fd6bd96e2d853f25bac8879fe33796fad2ce4fb9..ba6f1952e4df8c73d0b43d7716e07f2d51c792d0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php @@ -53,12 +53,11 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null) $result = array(); foreach ($profileList as $item) { - if ($limit === 0) { break; } - if ($item=='') { + if ($item == '') { continue; } @@ -166,7 +165,6 @@ public function write(Profile $profile) $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) { - if (!$profileIndexed) { // Add to index $indexName = $this->getIndexName(); @@ -205,7 +203,7 @@ abstract protected function getValue($key); * @param mixed $value * @param int $expiration * - * @return boolean + * @return bool */ abstract protected function setValue($key, $value, $expiration = 0); @@ -214,7 +212,7 @@ abstract protected function setValue($key, $value, $expiration = 0); * * @param string $key * - * @return boolean + * @return bool */ abstract protected function delete($key); @@ -224,7 +222,7 @@ abstract protected function delete($key); * @param string $value * @param int $expiration * - * @return boolean + * @return bool */ abstract protected function appendValue($key, $value, $expiration = 0); @@ -304,5 +302,4 @@ private function isItemNameValid($name) return true; } - } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index e225b0dd2eeb13eda8d684ac89932a1a3b8afd42..b7abad735c08fdc8f4acc8b24feb4123a5fe1ab5 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -116,7 +116,7 @@ public function purge() public function read($token) { if (!$token || !file_exists($file = $this->getFilename($token))) { - return null; + return; } return $this->createProfileFromData($token, unserialize(file_get_contents($file))); @@ -215,7 +215,7 @@ protected function readLineFromFile($file) $position = ftell($file); if (0 === $position) { - return null; + return; } while (true) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php index 2034a19db1e6b7157410e571d37d8c9b177a38e1..31f11ef08629055194bbcf6621c638f560822aad 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php @@ -11,8 +11,6 @@ namespace Symfony\Component\HttpKernel\Profiler; -use Memcache; - /** * Memcache Profiler Storage * @@ -21,14 +19,14 @@ class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage { /** - * @var Memcache + * @var \Memcache */ private $memcache; /** * Internal convenience method that returns the instance of the Memcache * - * @return Memcache + * @return \Memcache * * @throws \RuntimeException */ @@ -42,7 +40,7 @@ protected function getMemcache() $host = $matches[1] ?: $matches[2]; $port = $matches[3]; - $memcache = new Memcache(); + $memcache = new \Memcache(); $memcache->addServer($host, $port); $this->memcache = $memcache; @@ -54,7 +52,7 @@ protected function getMemcache() /** * Set instance of the Memcache * - * @param Memcache $memcache + * @param \Memcache $memcache */ public function setMemcache($memcache) { @@ -93,8 +91,7 @@ protected function appendValue($key, $value, $expiration = 0) $memcache = $this->getMemcache(); if (method_exists($memcache, 'append')) { - - //Memcache v3.0 + // Memcache v3.0 if (!$result = $memcache->append($key, $value, false, $expiration)) { return $memcache->set($key, $value, false, $expiration); } @@ -102,7 +99,7 @@ protected function appendValue($key, $value, $expiration = 0) return $result; } - //simulate append in Memcache <3.0 + // simulate append in Memcache <3.0 $content = $memcache->get($key); return $memcache->set($key, $content.$value, false, $expiration); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php index 31f313639085164a1cfd904e9db90cce137c3c7f..94a562694b72e5042b79da052c09d6c40ca7938b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php @@ -11,8 +11,6 @@ namespace Symfony\Component\HttpKernel\Profiler; -use Memcached; - /** * Memcached Profiler Storage * @@ -21,14 +19,14 @@ class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage { /** - * @var Memcached + * @var \Memcached */ private $memcached; /** * Internal convenience method that returns the instance of the Memcached * - * @return Memcached + * @return \Memcached * * @throws \RuntimeException */ @@ -42,10 +40,10 @@ protected function getMemcached() $host = $matches[1] ?: $matches[2]; $port = $matches[3]; - $memcached = new Memcached(); + $memcached = new \Memcached(); - //disable compression to allow appending - $memcached->setOption(Memcached::OPT_COMPRESSION, false); + // disable compression to allow appending + $memcached->setOption(\Memcached::OPT_COMPRESSION, false); $memcached->addServer($host, $port); @@ -58,7 +56,7 @@ protected function getMemcached() /** * Set instance of the Memcached * - * @param Memcached $memcached + * @param \Memcached $memcached */ public function setMemcached($memcached) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php index 38a522a3e91fc5ad0b40ace6683313a8fe21b318..c5242806ee904d49d2516ec78c24386b2cca180e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php @@ -23,7 +23,7 @@ class MongoDbProfilerStorage implements ProfilerStorageInterface * @param string $dsn A data source name * @param string $username Not used * @param string $password Not used - * @param integer $lifetime The lifetime to use for the purge + * @param int $lifetime The lifetime to use for the purge */ public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) { @@ -82,12 +82,12 @@ public function write(Profile $profile) 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), - 'time' => $profile->getTime() + 'time' => $profile->getTime(), ); $result = $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) { return !empty($v); }), array('upsert' => true)); - return (boolean) (isset($result['ok']) ? $result['ok'] : $result); + return (bool) (isset($result['ok']) ? $result['ok'] : $result); } /** @@ -99,21 +99,19 @@ public function write(Profile $profile) */ protected function getMongo() { - if ($this->mongo === null) { - if (preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $this->dsn, $matches)) { - $server = $matches[1].(!empty($matches[2]) ? '/'.$matches[2] : ''); - $database = $matches[2]; - $collection = $matches[3]; - - $mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? '\Mongo' : '\MongoClient'; - $mongo = new $mongoClass($server); - $this->mongo = $mongo->selectCollection($database, $collection); - } else { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn)); - } + if (null !== $this->mongo) { + return $this->mongo; + } + + if (!$parsedDsn = $this->parseDsn($this->dsn)) { + throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn)); } - return $this->mongo; + list($server, $database, $collection) = $parsedDsn; + $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\Mongo' : '\MongoClient'; + $mongo = new $mongoClass($server); + + return $this->mongo = $mongo->selectCollection($database, $collection); } /** @@ -233,4 +231,27 @@ private function getProfile(array $data) return $profile; } + + /** + * @param string $dsn + * + * @return null|array Array($server, $database, $collection) + */ + private function parseDsn($dsn) + { + if (!preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $dsn, $matches)) { + return; + } + + $server = $matches[1]; + $database = $matches[2]; + $collection = $matches[3]; + preg_match('#^mongodb://(([^:]+):?(.*)(?=@))?@?([^/]*)(.*)$#', $server, $matchesServer); + + if ('' == $matchesServer[5] && '' != $matches[2]) { + $server .= '/'.$matches[2]; + } + + return array($server, $database, $collection); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php index 3f9e03da8019917785b07ac8ed6b468d356af3da..453a9a80c384f2e3240fde264876abeb3b4fe908 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php @@ -31,7 +31,7 @@ abstract class PdoProfilerStorage implements ProfilerStorageInterface * @param string $dsn A data source name * @param string $username The username for the database * @param string $password The password for the database - * @param integer $lifetime The lifetime to use for the purge + * @param int $lifetime The lifetime to use for the purge */ public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) { @@ -59,7 +59,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null) $criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : ''; $db = $this->initDb(); - $tokens = $this->fetch($db, 'SELECT token, ip, method, url, time, parent FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((integer) $limit), $args); + $tokens = $this->fetch($db, 'SELECT token, ip, method, url, time, parent FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((int) $limit), $args); $this->close($db); return $tokens; @@ -77,8 +77,6 @@ public function read($token) if (isset($data[0]['data'])) { return $this->createProfileFromData($token, $data[0]); } - - return null; } /** diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php index b3fa5514d3874e49b4140d42444c78e3d1d5657f..a2c57f3b0e280b41167d30eaa27ce7c9f9e63487 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -261,7 +261,7 @@ public function addCollector(DataCollectorInterface $collector) * * @param string $name A collector name * - * @return Boolean + * @return bool */ public function hasCollector($name) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php index b545b4acd510f00ae1db5473b9abb562ab2a8c12..62f5cd78ba0f0b3677c333049d4bcecb73698131 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -40,7 +40,7 @@ class Profiler private $logger; /** - * @var Boolean + * @var bool */ private $enabled = true; @@ -105,7 +105,7 @@ public function loadProfile($token) * * @param Profile $profile A Profile instance * - * @return Boolean + * @return bool */ public function saveProfile(Profile $profile) { @@ -175,25 +175,11 @@ public function import($data) * * @return array An array of tokens * - * @see http://fr2.php.net/manual/en/datetime.formats.php for the supported date/time formats + * @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats */ public function find($ip, $url, $limit, $method, $start, $end) { - if ('' != $start && null !== $start) { - $start = new \DateTime($start); - $start = $start->getTimestamp(); - } else { - $start = null; - } - - if ('' != $end && null !== $end) { - $end = new \DateTime($end); - $end = $end->getTimestamp(); - } else { - $end = null; - } - - return $this->storage->find($ip, $url, $limit, $method, $start, $end); + return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end)); } /** @@ -267,7 +253,7 @@ public function add(DataCollectorInterface $collector) * * @param string $name A collector name * - * @return Boolean + * @return bool */ public function has($name) { @@ -291,4 +277,19 @@ public function get($name) return $this->collectors[$name]; } + + private function getTimestamp($value) + { + if (null === $value || '' == $value) { + return; + } + + try { + $value = new \DateTime(is_numeric($value) ? '@'.$value : $value); + } catch (\Exception $e) { + return; + } + + return $value->getTimestamp(); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php index f4b9e5e212c19134d5998bd81ac45ff1be59c773..2e169155b5b510a3ee16f2be22e69aa19cecb4bb 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php @@ -48,7 +48,7 @@ public function read($token); * * @param Profile $profile A Profile instance * - * @return Boolean Write operation successful + * @return bool Write operation successful */ public function write(Profile $profile); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php index de2decfbf59edde781f06f581a03469788a47b2a..d56e49dbae76c75f8f894680426ec079ef8afc3b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php @@ -171,7 +171,6 @@ public function write(Profile $profile) $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) { - if (!$profileIndexed) { // Add to index $indexName = $this->getIndexName(); @@ -214,7 +213,7 @@ protected function getRedis() throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.'); } - $redis = new \Redis; + $redis = new \Redis(); $redis->connect($data['host'], $data['port']); if (isset($data['path'])) { @@ -344,7 +343,7 @@ private function getValue($key, $serializer = self::REDIS_SERIALIZER_NONE) * @param int $expiration * @param int $serializer * - * @return Boolean + * @return bool */ private function setValue($key, $value, $expiration = 0, $serializer = self::REDIS_SERIALIZER_NONE) { @@ -361,7 +360,7 @@ private function setValue($key, $value, $expiration = 0, $serializer = self::RED * @param string $value * @param int $expiration * - * @return Boolean + * @return bool */ private function appendValue($key, $value, $expiration = 0) { @@ -382,7 +381,7 @@ private function appendValue($key, $value, $expiration = 0) * * @param array $keys * - * @return Boolean + * @return bool */ private function delete(array $keys) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index a451b7aba021205a2de7764e125015c1c1b1d91e..c26a4f03c59249b3822ca8b69d2a56426ffe1eaf 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -11,10 +11,8 @@ namespace Symfony\Component\HttpKernel\Tests\Bundle; -use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; @@ -34,24 +32,4 @@ public function testRegisterCommands() $this->assertNull($bundle2->registerCommands($app)); } - - public function testRegisterCommandsIngoreCommandAsAService() - { - $container = new ContainerBuilder(); - $container->addCompilerPass(new AddConsoleCommandPass()); - $definition = new Definition('Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); - $definition->addTag('console.command'); - $container->setDefinition('my-command', $definition); - $container->compile(); - - $application = $this->getMock('Symfony\Component\Console\Application'); - // Never called, because it's the - // Symfony\Bundle\FrameworkBundle\Console\Application that register - // commands as a service - $application->expects($this->never())->method('add'); - - $bundle = new ExtensionPresentBundle(); - $bundle->setContainer($container); - $bundle->registerCommands($application); - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php index c58c9588d5d491c646ccec7847aec6fff5504c86..d24942a11f0923d947cee3fdca39c675ea99a3da 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -60,7 +60,7 @@ public function testFilterResponseConvertsCookies() $expected = array( 'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', - 'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly' + 'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', ); $response = new Response(); @@ -106,6 +106,7 @@ public function testUploadedFile() new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true), ); + $file = null; foreach ($files as $file) { $client->request('POST', '/', array(), array('foo' => $file)); @@ -127,6 +128,21 @@ public function testUploadedFile() unlink($target); } + public function testUploadedFileWhenNoFileSelected() + { + $kernel = new TestHttpKernel(); + $client = new Client($kernel); + + $file = array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE); + + $client->request('POST', '/', array(), array('foo' => $file)); + + $files = $client->getRequest()->files->all(); + + $this->assertCount(1, $files); + $this->assertNull($files['foo']); + } + public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() { $source = tempnam(sys_get_temp_dir(), 'source'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index dd14186dd2676f095c098f83587dd50fa31892af..0631ab660eb59ae05fca1c48ab541e1fa50bf867 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -17,66 +17,119 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase { - public function testGetController() + public function testGetControllerWithoutControllerParameter() { - $logger = new Logger(); + $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing'); $resolver = new ControllerResolver($logger); $request = Request::create('/'); $this->assertFalse($resolver->getController($request), '->getController() returns false when the request has no _controller attribute'); - $this->assertEquals(array('Unable to look for the controller as the "_controller" parameter is missing'), $logger->getLogs('warning')); + } - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::testGetController'); - $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable'); + public function testGetControllerWithLambda() + { + $resolver = new ControllerResolver(); + $request = Request::create('/'); $request->attributes->set('_controller', $lambda = function () {}); $controller = $resolver->getController($request); $this->assertSame($lambda, $controller); + } + public function testGetControllerWithObjectAndInvokeMethod() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); $request->attributes->set('_controller', $this); $controller = $resolver->getController($request); $this->assertSame($this, $controller); + } - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest'); - $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller); + public function testGetControllerWithObjectAndMethod() + { + $resolver = new ControllerResolver(); + $request = Request::create('/'); $request->attributes->set('_controller', array($this, 'controllerMethod1')); $controller = $resolver->getController($request); $this->assertSame(array($this, 'controllerMethod1'), $controller); + } + public function testGetControllerWithClassAndMethod() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); $request->attributes->set('_controller', array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4')); $controller = $resolver->getController($request); $this->assertSame(array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4'), $controller); + } + + public function testGetControllerWithObjectAndMethodAsString() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); + $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::controllerMethod1'); + $controller = $resolver->getController($request); + $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable'); + } + + public function testGetControllerWithClassAndInvokeMethod() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); + $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest'); + $controller = $resolver->getController($request); + $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testGetControllerOnObjectWithoutInvokeMethod() + { + $resolver = new ControllerResolver(); + + $request = Request::create('/'); + $request->attributes->set('_controller', new \stdClass()); + $resolver->getController($request); + } + + public function testGetControllerWithFunction() + { + $resolver = new ControllerResolver(); + $request = Request::create('/'); $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'); $controller = $resolver->getController($request); $this->assertSame('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function', $controller); + } - $request->attributes->set('_controller', 'foo'); - try { - $resolver->getController($request); - $this->fail('->getController() throws an \InvalidArgumentException if the _controller attribute is not well-formatted'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getController() throws an \InvalidArgumentException if the _controller attribute is not well-formatted'); - } + /** + * @dataProvider getUndefinedControllers + * @expectedException \InvalidArgumentException + */ + public function testGetControllerOnNonUndefinedFunction($controller) + { + $resolver = new ControllerResolver(); - $request->attributes->set('_controller', 'foo::bar'); - try { - $resolver->getController($request); - $this->fail('->getController() throws an \InvalidArgumentException if the _controller attribute contains a non-existent class'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getController() throws an \InvalidArgumentException if the _controller attribute contains a non-existent class'); - } + $request = Request::create('/'); + $request->attributes->set('_controller', $controller); + $resolver->getController($request); + } - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar'); - try { - $resolver->getController($request); - $this->fail('->getController() throws an \InvalidArgumentException if the _controller attribute contains a non-existent method'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getController() throws an \InvalidArgumentException if the _controller attribute contains a non-existent method'); - } + public function getUndefinedControllers() + { + return array( + array('foo'), + array('foo::bar'), + array('stdClass'), + array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar'), + ); } public function testGetArguments() @@ -158,7 +211,7 @@ public function __invoke($foo, $bar = null) { } - protected function controllerMethod1($foo) + public function controllerMethod1($foo) { } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php index ebea3ea6e1fc6fcaa503b247643d12a1e3b8b5b7..4cc64057ef4905ff29f7c24ee1924e692f57b8c4 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php @@ -36,5 +36,4 @@ public function testCollect() $this->assertSame('exception',$c->getName()); $this->assertSame($trace,$c->getTrace()); } - } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 7cd4d06c7ad6016218098edb0249cb79dac9d344..cdb06af9ffbbb024d5fb7c330a4926a0e8a6e4d3 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -19,7 +19,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getCollectTestData */ - public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount) + public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null) { $logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface'); $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); @@ -32,6 +32,11 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount $this->assertSame($nb, $c->countErrors()); $this->assertSame($expectedLogs ? $expectedLogs : $logs, $c->getLogs()); $this->assertSame($expectedDeprecationCount, $c->countDeprecations()); + $this->assertSame($expectedScreamCount, $c->countScreams()); + + if (isset($expectedPriorities)) { + $this->assertSame($expectedPriorities, $c->getPriorities()); + } } public function getCollectTestData() @@ -39,30 +44,36 @@ public function getCollectTestData() return array( array( 1, - array(array('message' => 'foo', 'context' => array())), + array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')), null, - 0 + 0, + 0, ), array( 1, - array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')))), - array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'))), - 0 + array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')), 'priority' => 100, 'priorityName' => 'DEBUG')), + array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'), 'priority' => 100, 'priorityName' => 'DEBUG')), + 0, + 0, ), array( 1, - array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()))), - array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'))), - 0 + array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()), 'priority' => 100, 'priorityName' => 'DEBUG')), + array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'), 'priority' => 100, 'priorityName' => 'DEBUG')), + 0, + 0, ), array( 1, array( - array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)), - array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)) + array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION), 'priority' => 100, 'priorityName' => 'DEBUG'), + array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION), 'priority' => 100, 'priorityName' => 'DEBUG'), + array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'scream' => 0), 'priority' => 100, 'priorityName' => 'DEBUG'), ), null, - 2 + 2, + 1, + array(100 => array('count' => 3, 'name' => 'DEBUG')), ), ); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index bb80781ebeb56a1f0325c22f547f8094976f5bfa..e10d96c127335d2b02193b778f7b24710922e4b1 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -22,20 +22,19 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase { - /** - * @dataProvider provider - */ - public function testCollect(Request $request, Response $response) + public function testCollect() { $c = new RequestDataCollector(); - $c->collect($request, $response); + $c->collect($this->createRequest(), $this->createResponse()); + + $attributes = $c->getRequestAttributes(); $this->assertSame('request', $c->getName()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getRequestHeaders()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestAttributes()); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); $this->assertSame('html', $c->getFormat()); @@ -43,6 +42,8 @@ public function testCollect(Request $request, Response $response) $this->assertSame(array('name' => 'foo'), $c->getRouteParams()); $this->assertSame(array(), $c->getSessionAttributes()); $this->assertSame('en', $c->getLocale()); + $this->assertRegExp('/Resource\(stream#\d+\)/', $attributes->get('resource')); + $this->assertSame('Object(stdClass)', $attributes->get('object')); $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getResponseHeaders()); $this->assertSame('OK', $c->getStatusText()); @@ -52,10 +53,8 @@ public function testCollect(Request $request, Response $response) /** * Test various types of controller callables. - * - * @dataProvider provider */ - public function testControllerInspection(Request $request, Response $response) + public function testControllerInspection() { // make sure we always match the line number $r1 = new \ReflectionMethod($this, 'testControllerInspection'); @@ -69,7 +68,7 @@ public function testControllerInspection(Request $request, Response $response) 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'testControllerInspection', 'file' => __FILE__, - 'line' => $r1->getStartLine() + 'line' => $r1->getStartLine(), ), ), @@ -97,7 +96,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, - 'line' => $r2->getStartLine() + 'line' => $r2->getStartLine(), ), ), @@ -108,7 +107,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, - 'line' => $r2->getStartLine() + 'line' => $r2->getStartLine(), ), ), @@ -119,7 +118,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'magicMethod', 'file' => 'n/a', - 'line' => 'n/a' + 'line' => 'n/a', ), ), @@ -130,13 +129,14 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'magicMethod', 'file' => 'n/a', - 'line' => 'n/a' + 'line' => 'n/a', ), ), ); $c = new RequestDataCollector(); - + $request = $this->createRequest(); + $response = $this->createResponse(); foreach ($controllerTests as $controllerTest) { $this->injectController($c, $controllerTest[1], $request); $c->collect($request, $response); @@ -144,17 +144,20 @@ function () { return 'foo'; }, } } - public function provider() + protected function createRequest() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - return array(array(null, null)); - } - $request = Request::create('http://test.com/foo?bar=baz'); $request->attributes->set('foo', 'bar'); $request->attributes->set('_route', 'foobar'); $request->attributes->set('_route_params', array('name' => 'foo')); + $request->attributes->set('resource', fopen(__FILE__, 'r')); + $request->attributes->set('object', new \stdClass()); + return $request; + } + + protected function createResponse() + { $response = new Response(); $response->setStatusCode(200); $response->headers->set('Content-Type', 'application/json'); @@ -162,9 +165,7 @@ public function provider() $response->headers->setCookie(new Cookie('bar','foo',new \DateTime('@946684800'))); $response->headers->setCookie(new Cookie('bazz','foo','2000-12-12')); - return array( - array($request, $response) - ); + return $response; } /** @@ -201,5 +202,4 @@ public static function __callStatic($method, $args) { throw new \LogicException('Unexpected method call'); } - } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index d30837d2c68555c83adb90d6bda9d8c79f37a9cb..399f1a788980bfaa2b6ceac36b3cd1058b57fc83 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -12,8 +12,6 @@ namespace Symfony\Component\HttpKernel\Tests\Debug; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpFoundation\Request; @@ -22,148 +20,6 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase { - public function testAddRemoveListener() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $tdispatcher->addListener('foo', $listener = function () { ; }); - $listeners = $dispatcher->getListeners('foo'); - $this->assertCount(1, $listeners); - $this->assertSame($listener, $listeners[0]); - - $tdispatcher->removeListener('foo', $listener); - $this->assertCount(0, $dispatcher->getListeners('foo')); - } - - public function testGetListeners() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $tdispatcher->addListener('foo', $listener = function () { ; }); - $this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo')); - } - - public function testHasListeners() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $this->assertFalse($dispatcher->hasListeners('foo')); - $this->assertFalse($tdispatcher->hasListeners('foo')); - - $tdispatcher->addListener('foo', $listener = function () { ; }); - $this->assertTrue($dispatcher->hasListeners('foo')); - $this->assertTrue($tdispatcher->hasListeners('foo')); - } - - public function testAddRemoveSubscriber() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $subscriber = new EventSubscriber(); - - $tdispatcher->addSubscriber($subscriber); - $listeners = $dispatcher->getListeners('foo'); - $this->assertCount(1, $listeners); - $this->assertSame(array($subscriber, 'call'), $listeners[0]); - - $tdispatcher->removeSubscriber($subscriber); - $this->assertCount(0, $dispatcher->getListeners('foo')); - } - - public function testGetCalledListeners() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener = function () { ; }); - - $this->assertEquals(array(), $tdispatcher->getCalledListeners()); - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getNotCalledListeners()); - - $tdispatcher->dispatch('foo'); - - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getCalledListeners()); - $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); - } - - public function testLogger() - { - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); - $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\"."); - - $tdispatcher->dispatch('foo'); - } - - public function testLoggerWithStoppedEvent() - { - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); - $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\"."); - - $tdispatcher->dispatch('foo'); - } - - public function testDispatchCallListeners() - { - $called = array(); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; }); - $tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; }); - - $tdispatcher->dispatch('foo'); - - $this->assertEquals(array('foo1', 'foo2'), $called); - } - - public function testDispatchNested() - { - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $loop = 1; - $dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) { - ++$loop; - if (2 == $loop) { - $dispatcher->dispatch('foo'); - } - }); - - $dispatcher->dispatch('foo'); - } - - public function testDispatchReusedEventNested() - { - $nestedCall = false; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) { - $dispatcher->dispatch('bar', $e); - }); - $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) { - $nestedCall = true; - }); - - $this->assertFalse($nestedCall); - $dispatcher->dispatch('foo'); - $this->assertTrue($nestedCall); - } - public function testStopwatchSections() { $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch = new Stopwatch()); @@ -176,14 +32,10 @@ public function testStopwatchSections() $this->assertEquals(array( '__section__', 'kernel.request', - 'kernel.request.loading', 'kernel.controller', - 'kernel.controller.loading', 'controller', 'kernel.response', - 'kernel.response.loading', 'kernel.terminate', - 'kernel.terminate.loading', ), array_keys($events)); } @@ -232,11 +84,3 @@ protected function getHttpKernel($dispatcher, $controller) return new HttpKernel($dispatcher, $resolver); } } - -class EventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('foo' => 'call'); - } -} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..26bdf70673743721b954c67458df650c0a15d7da --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -0,0 +1,83 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\EventListener; + +use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\KernelEvents; + +/** + * Test AddRequestFormatsListener class + * + * @author Gildas Quemener <gildas.quemener@gmail.com> + */ +class AddRequestFormatsListenerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AddRequestFormatsListener + */ + private $listener; + + protected function setUp() + { + $this->listener = new AddRequestFormatsListener(array('csv' => array('text/csv', 'text/plain'))); + } + + protected function tearDown() + { + $this->listener = null; + } + + public function testIsAnEventSubscriber() + { + $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); + } + + public function testRegisteredEvent() + { + $this->assertEquals( + array(KernelEvents::REQUEST => 'onKernelRequest'), + AddRequestFormatsListener::getSubscribedEvents() + ); + } + + public function testSetAdditionalFormats() + { + $request = $this->getRequestMock(); + $event = $this->getGetResponseEventMock($request); + + $request->expects($this->once()) + ->method('setFormat') + ->with('csv', array('text/csv', 'text/plain')); + + $this->listener->onKernelRequest($event); + } + + protected function getRequestMock() + { + return $this->getMock('Symfony\Component\HttpFoundation\Request'); + } + + protected function getGetResponseEventMock(Request $request) + { + $event = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + + $event->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + + return $event; + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index 30e8c74ecd294c96fc2bc982d9952448ba9a53d5..b4e88191613484f08905a31fc508dbb326ca4d9b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -97,7 +97,7 @@ public function provider() $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, 'foo', $exception); return array( - array($event, $event2) + array($event, $event2), ); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index ec9360a431eb6b343add7258bb8646f90b2de0f7..7ddb2fbbf2d6a35bf336a78276346e0d14b22b41 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -47,19 +47,6 @@ public function testAccessDeniedWithNonSafeMethods() $listener->onKernelRequest($event); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function testAccessDeniedWithNonLocalIps() - { - $request = Request::create('http://example.com/_fragment', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - } - /** * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 772dfd0a4c11694ee482312d9d23f6fe88411e3d..d43bbfefd19f490a7e1317e1fd5069ca2862511b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -11,10 +11,12 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\EventListener\ProfilerListener; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpKernel\Event\PostResponseEvent; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Kernel; class ProfilerListenerTest extends \PHPUnit_Framework_TestCase @@ -52,4 +54,50 @@ public function testEventsWithoutRequestStack() $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, Kernel::MASTER_REQUEST, $response)); $listener->onKernelTerminate(new PostResponseEvent($kernel, $request, $response)); } + + /** + * Test a master and sub request with an exception and `onlyException` profiler option enabled. + */ + public function testKernelTerminate() + { + $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') + ->disableOriginalConstructor() + ->getMock(); + + $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->disableOriginalConstructor() + ->getMock(); + + $profiler->expects($this->once()) + ->method('collect') + ->will($this->returnValue($profile)); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + + $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + ->disableOriginalConstructor() + ->getMock(); + + $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + ->disableOriginalConstructor() + ->getMock(); + + $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') + ->disableOriginalConstructor() + ->getMock(); + + $onlyException = true; + $listener = new ProfilerListener($profiler, null, $onlyException); + + // master request + $listener->onKernelRequest(new GetResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST)); + $listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response)); + + // sub request + $listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST)); + $listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404))); + $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response)); + + $listener->onKernelTerminate(new PostResponseEvent($kernel, $masterRequest, $response)); + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php index 2698f8e7625ff06ec555406f007ea666ac2572bf..821688eff4017ea11e030c05f2520d894a55a874 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php @@ -32,7 +32,6 @@ protected function setUp() $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - } protected function tearDown() diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php index b9a5417d945a67364535ac2231ce7945ee9da6ae..0eb420f78936f82bba4decd2b4510bbc80aad1aa 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php @@ -13,6 +13,5 @@ class BarCommand extends Command { public function __construct($example, $name = 'bar') { - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php index bfe189bea35e6618e6910ca623f366e489ffb0b3..c6570aa046c55a10afda8cde771c3868f78205b1 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php @@ -19,5 +19,4 @@ protected function configure() { $this->setName('foo'); } - } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php index 32c05f4ba6a829f83755fae8eab52e5fe9d4659a..a1102ab7843c3f3ba86a89f986e2ca7c4e0fe775 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php @@ -20,11 +20,9 @@ class KernelForOverrideName extends Kernel public function registerBundles() { - } public function registerContainerConfiguration(LoaderInterface $loader) { - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php index 8acf45d96f6d715d4bc4cd0c5426b355daeb2d4f..90768f9dac58a237f96743a426e225a56156db5c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\UriSigner; class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase { @@ -41,7 +42,52 @@ public function testRender() $this->assertEquals('<esi:include src="/" />', $strategy->render('/', $request)->getContent()); $this->assertEquals("<esi:comment text=\"This is a comment\" />\n<esi:include src=\"/\" />", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); $this->assertEquals('<esi:include src="/" alt="foo" />', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); - $this->assertEquals('<esi:include src="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller" alt="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dalt_controller" />', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent()); + } + + public function testRenderControllerReference() + { + $signer = new UriSigner('foo'); + $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(), $signer); + + $request = Request::create('/'); + $request->setLocale('fr'); + $request->headers->set('Surrogate-Capability', 'ESI/1.0'); + + $reference = new ControllerReference('main_controller', array(), array()); + $altReference = new ControllerReference('alt_controller', array(), array()); + + $this->assertEquals( + '<esi:include src="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dmain_controller&_hash=Jz1P8NErmhKTeI6onI1EdAXTB85359MY3RIk5mSJ60w%3D" alt="/_fragment?_path=_format%3Dhtml%26_locale%3Dfr%26_controller%3Dalt_controller&_hash=iPJEdRoUpGrM1ztqByiorpfMPtiW%2FOWwdH1DBUXHhEc%3D" />', + $strategy->render($reference, $request, array('alt' => $altReference))->getContent() + ); + } + + /** + * @expectedException \LogicException + */ + public function testRenderControllerReferenceWithoutSignerThrowsException() + { + $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); + + $request = Request::create('/'); + $request->setLocale('fr'); + $request->headers->set('Surrogate-Capability', 'ESI/1.0'); + + $strategy->render(new ControllerReference('main_controller'), $request); + } + + /** + * @expectedException \LogicException + */ + public function testRenderAltControllerReferenceWithoutSignerThrowsException() + { + $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); + + $request = Request::create('/'); + $request->setLocale('fr'); + $request->headers->set('Surrogate-Capability', 'ESI/1.0'); + + $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); } private function getInlineStrategy($called = false) diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index c7252c9cba558980f505f68f2efaad8b3b2dcb25..8a194f1cba9659505c4d5e6bd8af771cf9cd69c5 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -44,14 +44,7 @@ public function testRenderWithObjectsAsAttributes() $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $kernel - ->expects($this->any()) - ->method('handle') - ->with($subRequest) - ; - - $strategy = new InlineFragmentRenderer($kernel); + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/')); } @@ -80,15 +73,7 @@ public function testRenderWithTrustedHeaderDisabled() Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $kernel - ->expects($this->any()) - ->method('handle') - ->with(Request::create('/')) - ; - - $strategy = new InlineFragmentRenderer($kernel); - + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); $strategy->render('/', Request::create('/')); Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName); @@ -139,6 +124,22 @@ private function getKernel($returnValue) return $kernel; } + /** + * Creates a Kernel expecting a request equals to $request + * Allows delta in comparison in case REQUEST_TIME changed by 1 second + */ + private function getKernelExpectingRequest(Request $request) + { + $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel + ->expects($this->any()) + ->method('handle') + ->with($this->equalTo($request, 1)) + ; + + return $kernel; + } + public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); @@ -180,14 +181,7 @@ public function testESIHeaderIsKeptInSubrequest() $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $kernel - ->expects($this->any()) - ->method('handle') - ->with($expectedSubRequest) - ; - - $strategy = new InlineFragmentRenderer($kernel); + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $request = Request::create('/'); $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php index 4af3601b410960acde262db60cef42744286770c..184175cc81aa7ee869984c45ebbf379b1d626891 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php @@ -90,9 +90,4 @@ public function getFoo() { return $this->foo; } - - public function doGenerateFragmentUri(ControllerReference $reference, Request $request, $absolute = false, $strict = true) - { - return parent::generateFragmentUri($reference, $request, $absolute, $strict); - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index c50970638901ed2c20c8241504477faffb027b23..ad400c69ae3e3f5e958955853958f654bab3fcde 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -103,6 +103,11 @@ public function testProcess() $this->assertEquals('foo <?php echo $this->esi->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent()); $this->assertEquals('ESI', $response->headers->get('x-body-eval')); + $response = new Response('foo <esi:comment text="some comment" /><esi:include src="foo\'" alt="bar\'" onerror="continue" />'); + $esi->process($request, $response); + + $this->assertEquals("foo <?php echo \$this->esi->handle(\$this, 'foo\\'', 'bar\\'', true) ?>"."\n", $response->getContent()); + $response = new Response('foo <esi:include src="..." />'); $esi->process($request, $response); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index a2b38bd807c02bc58cbae21143dfc77a22ef4b79..974dc9ba2c3406c31668f3df1a97abbfe11eb493 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -582,6 +582,105 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); + } + + public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() + { + $this->setNextResponse(); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertTraceContains('miss'); + $this->assertTraceContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=(?:2|3)/', $this->response->headers->get('Cache-Control')); + + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + // expires the cache + $values = $this->getMetaStorageValues(); + $this->assertCount(1, $values); + $tmp = unserialize($values[0]); + $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); + $r = new \ReflectionObject($this->store); + $m = $r->getMethod('save'); + $m->setAccessible(true); + $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); + + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('stale'); + $this->assertTraceContains('invalid'); + $this->assertTraceContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + $this->setNextResponse(); + + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + } + + public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() + { + $this->setNextResponse(); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertTraceContains('miss'); + $this->assertTraceContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + + // expires the cache + $values = $this->getMetaStorageValues(); + $this->assertCount(1, $values); + $tmp = unserialize($values[0]); + $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); + $r = new \ReflectionObject($this->store); + $m = $r->getMethod('save'); + $m->setAccessible(true); + $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); + + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('stale'); + $this->assertTraceContains('valid'); + $this->assertTraceContains('store'); + $this->assertTraceNotContains('miss'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); } public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() @@ -923,6 +1022,17 @@ public function testShouldCatchExceptions() $this->assertExceptionsAreCaught(); } + public function testShouldCatchExceptionsWhenReloadingAndNoCacheRequest() + { + $this->catchExceptions(); + + $this->setNextResponse(); + $this->cacheConfig['allow_reload'] = true; + $this->request('GET', '/', array(), array(), false, array('Pragma' => 'no-cache')); + + $this->assertExceptionsAreCaught(); + } + public function testShouldNotCatchExceptions() { $this->catchExceptions(false); @@ -1032,6 +1142,28 @@ public function testClientIpIsAlwaysLocalhostForForwardedRequests() $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); } + /** + * @dataProvider getTrustedProxyData + */ + public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected) + { + Request::setTrustedProxies($existing); + + $this->setNextResponse(); + $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); + + $this->assertEquals($expected, Request::getTrustedProxies()); + } + + public function getTrustedProxyData() + { + return array( + array(array(), array('127.0.0.1')), + array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')), + array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')), + ); + } + /** * @dataProvider getXForwardedForData */ @@ -1067,7 +1199,7 @@ public function testXForwarderForHeaderForPassRequests() public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses() { - $time = new \DateTime; + $time = new \DateTime(); $responses = array( array( diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php index 9a1c7d767fdaa2dbe25e94678023afb47a33a73c..766e2b1d499a516dcbb2a70b7be3ac11a53d2719 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php @@ -103,7 +103,7 @@ public function assertExceptionsAreNotCaught() $this->assertFalse($this->kernel->isCatchingExceptions()); } - public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false) + public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false, $headers = array()) { if (null === $this->kernel) { throw new \LogicException('You must call setNextResponse() before calling request().'); @@ -118,6 +118,7 @@ public function request($method, $uri = '/', $server = array(), $cookies = array $this->esi = $esi ? new Esi() : null; $this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig); $this->request = Request::create($uri, $method, array(), $cookies, array(), $server); + $this->request->headers->add($headers); $this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php index f4aba74c721d567894130316767960c369452b11..03af905b20714b71f90c8b568fe5d2fe18c9be8b 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -77,11 +77,7 @@ public function testBootSetsTheContainerToTheBundles() public function testBootSetsTheBootedFlagToTrue() { // use test kernel to access isBooted() - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setConstructorArgs(array('test', false)) - ->setMethods(array('initializeBundles', 'initializeContainer')) - ->getMock(); - + $kernel = $this->getKernelForTest(array('initializeBundles', 'initializeContainer')); $kernel->boot(); $this->assertTrue($kernel->isBooted()); @@ -208,6 +204,10 @@ public function testStripComments() $string = 'string should not be modified'; +$string = 'string should not be + +modified'; + $heredoc = <<<HD @@ -242,16 +242,17 @@ public function doStuff() $expected = <<<'EOF' <?php $string = 'string should not be modified'; -$heredoc = -<<<HD +$string = 'string should not be + +modified'; +$heredoc = <<<HD Heredoc should not be modified HD; -$nowdoc = -<<<'ND' +$nowdoc = <<<'ND' Nowdoc should not be modified @@ -262,7 +263,7 @@ class TestClass { public function doStuff() { - } + } } EOF; @@ -423,7 +424,7 @@ public function testLocateResourceReturnsAllMatches() $this->assertEquals(array( __DIR__.'/Fixtures/Bundle2Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), + __DIR__.'/Fixtures/Bundle1Bundle/foo.txt',), $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)); } @@ -435,7 +436,7 @@ public function testLocateResourceReturnsAllMatchesBis() ->method('getBundle') ->will($this->returnValue(array( $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), - $this->getBundle(__DIR__.'/Foobar') + $this->getBundle(__DIR__.'/Foobar'), ))) ; @@ -486,7 +487,7 @@ public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() $this->assertEquals(array( __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt'), + __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt',), $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) ); } @@ -570,12 +571,7 @@ public function testInitializeBundles() $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); // use test kernel so we can access getBundleMap() - $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setMethods(array('registerBundles')) - ->setConstructorArgs(array('test', false)) - ->getMock() - ; + $kernel = $this->getKernelForTest(array('registerBundles')); $kernel ->expects($this->once()) ->method('registerBundles') @@ -594,18 +590,12 @@ public function testInitializeBundlesSupportInheritanceCascade() $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); // use test kernel so we can access getBundleMap() - $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setMethods(array('registerBundles')) - ->setConstructorArgs(array('test', false)) - ->getMock() - ; + $kernel = $this->getKernelForTest(array('registerBundles')); $kernel ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($grandparent, $parent, $child))) ; - $kernel->boot(); $map = $kernel->getBundleMap(); @@ -632,18 +622,12 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle'); // use test kernel so we can access getBundleMap() - $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setMethods(array('registerBundles')) - ->setConstructorArgs(array('test', false)) - ->getMock() - ; + $kernel = $this->getKernelForTest(array('registerBundles')); $kernel ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($parent, $grandparent, $child))) ; - $kernel->boot(); $map = $kernel->getBundleMap(); @@ -788,17 +772,34 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu */ protected function getKernel(array $methods = array(), array $bundles = array()) { + $methods[] = 'registerBundles'; + $kernel = $this ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') ->setMethods($methods) ->setConstructorArgs(array('test', false)) ->getMockForAbstractClass() ; - $kernel->expects($this->any()) ->method('registerBundles') ->will($this->returnValue($bundles)) ; + $p = new \ReflectionProperty($kernel, 'rootDir'); + $p->setAccessible(true); + $p->setValue($kernel, __DIR__.'/Fixtures'); + + return $kernel; + } + + protected function getKernelForTest(array $methods = array()) + { + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->setConstructorArgs(array('test', false)) + ->setMethods($methods) + ->getMock(); + $p = new \ReflectionProperty($kernel, 'rootDir'); + $p->setAccessible(true); + $p->setValue($kernel, __DIR__.'/Fixtures'); return $kernel; } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php index 1be77f26ab995926ebe2129c5dca6bab06fdae54..017518a3059dd3bac87262816be7c71b8ddecea4 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php @@ -101,7 +101,7 @@ public function emerg($message, array $context = array()) */ public function crit($message, array $context = array()) { - trigger_error('Use crit() which is PSR-3 compatible', E_USER_DEPRECATED); + trigger_error('Use critical() which is PSR-3 compatible', E_USER_DEPRECATED); $this->log('critical', $message, $context); } @@ -111,7 +111,7 @@ public function crit($message, array $context = array()) */ public function err($message, array $context = array()) { - trigger_error('Use err() which is PSR-3 compatible', E_USER_DEPRECATED); + trigger_error('Use error() which is PSR-3 compatible', E_USER_DEPRECATED); $this->log('error', $message, $context); } @@ -121,7 +121,7 @@ public function err($message, array $context = array()) */ public function warn($message, array $context = array()) { - trigger_error('Use warn() which is PSR-3 compatible', E_USER_DEPRECATED); + trigger_error('Use warning() which is PSR-3 compatible', E_USER_DEPRECATED); $this->log('warning', $message, $context); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php index 9ff962c5b75e73dd4caeab4bd83e4d90b0e66468..71f74b9c65c7b25cf7ab049f1119309532801b4d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php @@ -25,10 +25,10 @@ class MemcacheMock * Open memcached server connection * * @param string $host - * @param integer $port - * @param integer $timeout + * @param int $port + * @param int $timeout * - * @return boolean + * @return bool */ public function connect($host, $port = null, $timeout = null) { @@ -45,10 +45,10 @@ public function connect($host, $port = null, $timeout = null) * Open memcached server persistent connection * * @param string $host - * @param integer $port - * @param integer $timeout + * @param int $port + * @param int $timeout * - * @return boolean + * @return bool */ public function pconnect($host, $port = null, $timeout = null) { @@ -65,16 +65,16 @@ public function pconnect($host, $port = null, $timeout = null) * Add a memcached server to connection pool * * @param string $host - * @param integer $port - * @param boolean $persistent - * @param integer $weight - * @param integer $timeout - * @param integer $retry_interval - * @param boolean $status + * @param int $port + * @param bool $persistent + * @param int $weight + * @param int $timeout + * @param int $retry_interval + * @param bool $status * @param callable $failure_callback - * @param integer $timeoutms + * @param int $timeoutms * - * @return boolean + * @return bool */ public function addServer($host, $port = 11211, $persistent = null, $weight = null, $timeout = null, $retry_interval = null, $status = null, $failure_callback = null, $timeoutms = null) { @@ -92,10 +92,10 @@ public function addServer($host, $port = 11211, $persistent = null, $weight = nu * * @param string $key * @param mixed $var - * @param integer $flag - * @param integer $expire + * @param int $flag + * @param int $expire * - * @return boolean + * @return bool */ public function add($key, $var, $flag = null, $expire = null) { @@ -117,10 +117,10 @@ public function add($key, $var, $flag = null, $expire = null) * * @param string $key * @param string $var - * @param integer $flag - * @param integer $expire + * @param int $flag + * @param int $expire * - * @return boolean + * @return bool */ public function set($key, $var, $flag = null, $expire = null) { @@ -138,10 +138,10 @@ public function set($key, $var, $flag = null, $expire = null) * * @param string $key * @param mixed $var - * @param integer $flag - * @param integer $expire + * @param int $flag + * @param int $expire * - * @return boolean + * @return bool */ public function replace($key, $var, $flag = null, $expire = null) { @@ -162,7 +162,7 @@ public function replace($key, $var, $flag = null, $expire = null) * Retrieve item from the server. * * @param string|array $key - * @param integer|array $flags + * @param int|array $flags * * @return mixed */ @@ -191,7 +191,7 @@ public function get($key, &$flags = null) * * @param string $key * - * @return boolean + * @return bool */ public function delete($key) { @@ -211,7 +211,7 @@ public function delete($key) /** * Flush all existing items at the server * - * @return boolean + * @return bool */ public function flush() { @@ -227,7 +227,7 @@ public function flush() /** * Close memcached server connection * - * @return boolean + * @return bool */ public function close() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php index d28d54211d1116658c07f0db0a3a5d949968f3d0..09f52dd116d008162589aec54d0b4ca2a7be2273 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php @@ -24,10 +24,10 @@ class MemcachedMock /** * Set a Memcached option * - * @param integer $option + * @param int $option * @param mixed $value * - * @return boolean + * @return bool */ public function setOption($option, $value) { @@ -38,10 +38,10 @@ public function setOption($option, $value) * Add a memcached server to connection pool * * @param string $host - * @param integer $port - * @param integer $weight + * @param int $port + * @param int $weight * - * @return boolean + * @return bool */ public function addServer($host, $port = 11211, $weight = 0) { @@ -59,9 +59,9 @@ public function addServer($host, $port = 11211, $weight = 0) * * @param string $key * @param mixed $value - * @param integer $expiration + * @param int $expiration * - * @return boolean + * @return bool */ public function add($key, $value, $expiration = 0) { @@ -83,9 +83,9 @@ public function add($key, $value, $expiration = 0) * * @param string $key * @param mixed $value - * @param integer $expiration + * @param int $expiration * - * @return boolean + * @return bool */ public function set($key, $value, $expiration = null) { @@ -103,9 +103,9 @@ public function set($key, $value, $expiration = null) * * @param string $key * @param mixed $value - * @param integer $expiration + * @param int $expiration * - * @return boolean + * @return bool */ public function replace($key, $value, $expiration = null) { @@ -129,7 +129,7 @@ public function replace($key, $value, $expiration = null) * @param callable $cache_cb * @param float $cas_token * - * @return boolean + * @return bool */ public function get($key, $cache_cb = null, &$cas_token = null) { @@ -146,7 +146,7 @@ public function get($key, $cache_cb = null, &$cas_token = null) * @param string $key * @param string $value * - * @return boolean + * @return bool */ public function append($key, $value) { @@ -168,7 +168,7 @@ public function append($key, $value) * * @param string $key * - * @return boolean + * @return bool */ public function delete($key) { @@ -188,7 +188,7 @@ public function delete($key) /** * Flush all existing items at the server * - * @return boolean + * @return bool */ public function flush() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php index 4a89e2db8872844487413d126f0e815d58af6b76..5fd3a576e30ab066c85c4e15aae461ea7ad2ba0a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php @@ -25,10 +25,10 @@ class RedisMock * Add a server to connection pool * * @param string $host - * @param integer $port + * @param int $port * @param float $timeout * - * @return boolean + * @return bool */ public function connect($host, $port = 6379, $timeout = 0) { @@ -44,10 +44,10 @@ public function connect($host, $port = 6379, $timeout = 0) /** * Set client option. * - * @param integer $name - * @param integer $value + * @param int $name + * @param int $value * - * @return boolean + * @return bool */ public function setOption($name, $value) { @@ -63,7 +63,7 @@ public function setOption($name, $value) * * @param string $key * - * @return boolean + * @return bool */ public function exists($key) { @@ -78,10 +78,10 @@ public function exists($key) * Store data at the server with expiration time. * * @param string $key - * @param integer $ttl + * @param int $ttl * @param mixed $value * - * @return boolean + * @return bool */ public function setex($key, $ttl, $value) { @@ -98,9 +98,9 @@ public function setex($key, $ttl, $value) * Sets an expiration time on an item. * * @param string $key - * @param integer $ttl + * @param int $ttl * - * @return boolean + * @return bool */ public function setTimeout($key, $ttl) { @@ -120,7 +120,7 @@ public function setTimeout($key, $ttl) * * @param string $key * - * @return boolean + * @return bool */ public function get($key) { @@ -137,7 +137,7 @@ public function get($key) * @param string $key * @param string $value * - * @return integer Size of the value after the append. + * @return int Size of the value after the append. */ public function append($key, $value) { @@ -159,7 +159,7 @@ public function append($key, $value) * * @param string|array $key * - * @return integer + * @return int */ public function delete($key) { @@ -191,7 +191,7 @@ public function delete($key) /** * Flush all existing items from all databases at the server. * - * @return boolean + * @return bool */ public function flushAll() { @@ -207,7 +207,7 @@ public function flushAll() /** * Close Redis server connection * - * @return boolean + * @return bool */ public function close() { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php index b63b84c0fbc29159523b8f3c4ac08c0d72cbc137..c72732563c6727fa4e783b5173e5b012d4b28746 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -71,6 +71,32 @@ public static function tearDownAfterClass() } } + public function getDsns() + { + return array( + array('mongodb://localhost/symfony_tests/profiler_data', array( + 'mongodb://localhost/symfony_tests', + 'symfony_tests', + 'profiler_data', + )), + array('mongodb://user:password@localhost/symfony_tests/profiler_data', array( + 'mongodb://user:password@localhost/symfony_tests', + 'symfony_tests', + 'profiler_data', + )), + array('mongodb://user:password@localhost/admin/symfony_tests/profiler_data', array( + 'mongodb://user:password@localhost/admin', + 'symfony_tests', + 'profiler_data', + )), + array('mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin/symfony_tests/profiler_data', array( + 'mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin', + 'symfony_tests', + 'profiler_data', + )), + ); + } + public function testCleanup() { $dt = new \DateTime('-2 day'); @@ -87,6 +113,17 @@ public function testCleanup() self::$storage->purge(); } + /** + * @dataProvider getDsns + */ + public function testDsnParser($dsn, $expected) + { + $m = new \ReflectionMethod(self::$storage, 'parseDsn'); + $m->setAccessible(true); + + $this->assertEquals($expected, $m->invoke(self::$storage, $dsn)); + } + public function testUtf8() { $profile = new Profile('utf8_test_profile'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php index ede7c3f14b0d7d4bd2f696d029a0e5b649811d7d..eee1a366587ca259932a170fb817b2405acf446f 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php @@ -19,31 +19,71 @@ class ProfilerTest extends \PHPUnit_Framework_TestCase { + private $tmp; + private $storage; + public function testCollect() { - if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } - $request = new Request(); $request->query->set('foo', 'bar'); $response = new Response(); $collector = new RequestDataCollector(); - $tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler'); - if (file_exists($tmp)) { - @unlink($tmp); - } - $storage = new SqliteProfilerStorage('sqlite:'.$tmp); - $storage->purge(); - - $profiler = new Profiler($storage); + $profiler = new Profiler($this->storage); $profiler->add($collector); $profile = $profiler->collect($request, $response); $profile = $profiler->loadProfile($profile->getToken()); $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all()); + } + + public function testFindWorksWithDates() + { + $profiler = new Profiler($this->storage); + + $this->assertCount(0, $profiler->find(null, null, null, null, '7th April 2014', '9th April 2014')); + } + + public function testFindWorksWithTimestamps() + { + $profiler = new Profiler($this->storage); + + $this->assertCount(0, $profiler->find(null, null, null, null, '1396828800', '1397001600')); + } + + public function testFindWorksWithInvalidDates() + { + $profiler = new Profiler($this->storage); + + $this->assertCount(0, $profiler->find(null, null, null, null, 'some string', '')); + } - @unlink($tmp); + protected function setUp() + { + if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + $this->markTestSkipped('The "HttpFoundation" component is not available'); + } + + if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { + $this->markTestSkipped('This test requires SQLite support in your environment'); + } + + $this->tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler'); + if (file_exists($this->tmp)) { + @unlink($this->tmp); + } + + $this->storage = new SqliteProfilerStorage('sqlite:'.$this->tmp); + $this->storage->purge(); + } + + protected function tearDown() + { + if (null !== $this->storage) { + $this->storage->purge(); + $this->storage = null; + + @unlink($this->tmp); + } } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php index 7ede0c32f76e5a60737ac4abe4435f943c06b85a..c3c3555df95a6044b481ead10744d59c9eb03744 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php @@ -54,7 +54,7 @@ public function sign($uri) * * @param string $uri A signed URI * - * @return Boolean True if the URI is signed correctly, false otherwise + * @return bool True if the URI is signed correctly, false otherwise */ public function check($uri) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json index a09b0013271c71eaff15efaeb940ef7fff767126..43e863bd92b41a1b5c2979202d05ba508c3b0b0d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json @@ -17,9 +17,9 @@ ], "require": { "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": "~2.4", - "symfony/debug": "~2.3", + "symfony/event-dispatcher": "~2.5", + "symfony/http-foundation": "~2.5", + "symfony/debug": "~2.5", "psr/log": "~1.0" }, "require-dev": { @@ -28,6 +28,7 @@ "symfony/config": "~2.0", "symfony/console": "~2.2", "symfony/dependency-injection": "~2.0", + "symfony/expression-language": "~2.4", "symfony/finder": "~2.0", "symfony/process": "~2.0", "symfony/routing": "~2.2", @@ -49,7 +50,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist index f8490c3f9e663dc1fbfd8f3d690b3a2c937817ac..f572ab27d37989b3388bcbbe8254303f3de8ba2c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md b/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md index 3bad982fcb124dc648d825aba00b03a0938befac..2f3c1beb74b7e819608c4f34c36b8122c329eb1f 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md +++ b/core/vendor/symfony/process/Symfony/Component/Process/CHANGELOG.md @@ -1,6 +1,20 @@ CHANGELOG ========= +2.5.0 +----- + + * added support for PTY mode + * added the convenience method "mustRun" + * deprecation: Process::setStdin() is deprecated in favor of Process::setInput() + * deprecation: Process::getStdin() is deprecated in favor of Process::getInput() + * deprecation: Process::setInput() and ProcessBuilder::setInput() do not accept non-scalar types + +2.4.0 +----- + + * added the ability to define an idle timeout + 2.3.0 ----- diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php b/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php index 890935933b641e8c740fd15d91c4d6996ae47897..7523a5e9cd4ea2c16390e0904968777941f3df02 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php @@ -28,16 +28,20 @@ public function __construct(Process $process) throw new InvalidArgumentException('Expected a failed process, but the given process was successful.'); } - parent::__construct( - sprintf( - 'The command "%s" failed.'."\nExit Code: %s(%s)\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", - $process->getCommandLine(), - $process->getExitCode(), - $process->getExitCodeText(), + $error = sprintf('The command "%s" failed.'."\nExit Code: %s(%s)", + $process->getCommandLine(), + $process->getExitCode(), + $process->getExitCodeText() + ); + + if (!$process->isOutputDisabled()) { + $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput() - ) - ); + ); + } + + parent::__construct($error); $this->process = $process; } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessTimedOutException.php b/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessTimedOutException.php new file mode 100644 index 0000000000000000000000000000000000000000..d45114696f640d9a05a4eea92ce1fa1b203d2a4a --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/Exception/ProcessTimedOutException.php @@ -0,0 +1,69 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Exception; + +use Symfony\Component\Process\Process; + +/** + * Exception that is thrown when a process times out. + * + * @author Johannes M. Schmitt <schmittjoh@gmail.com> + */ +class ProcessTimedOutException extends RuntimeException +{ + const TYPE_GENERAL = 1; + const TYPE_IDLE = 2; + + private $process; + private $timeoutType; + + public function __construct(Process $process, $timeoutType) + { + $this->process = $process; + $this->timeoutType = $timeoutType; + + parent::__construct(sprintf( + 'The process "%s" exceeded the timeout of %s seconds.', + $process->getCommandLine(), + $this->getExceededTimeout() + )); + } + + public function getProcess() + { + return $this->process; + } + + public function isGeneralTimeout() + { + return $this->timeoutType === self::TYPE_GENERAL; + } + + public function isIdleTimeout() + { + return $this->timeoutType === self::TYPE_IDLE; + } + + public function getExceededTimeout() + { + switch ($this->timeoutType) { + case self::TYPE_GENERAL: + return $this->process->getTimeout(); + + case self::TYPE_IDLE: + return $this->process->getIdleTimeout(); + + default: + throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)); + } + } +} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/ExecutableFinder.php b/core/vendor/symfony/process/Symfony/Component/Process/ExecutableFinder.php index 5cc99c7692051433cfe451e102661d1290c0680b..6ae74dca174b9bdb75c7edb54c69d8644f6c32a5 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/ExecutableFinder.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/ExecutableFinder.php @@ -53,14 +53,13 @@ public function addSuffix($suffix) public function find($name, $default = null, array $extraDirs = array()) { if (ini_get('open_basedir')) { - $searchPath = explode(PATH_SEPARATOR, getenv('open_basedir')); + $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir')); $dirs = array(); foreach ($searchPath as $path) { if (is_dir($path)) { $dirs[] = $path; } else { - $file = str_replace(dirname($path), '', $path); - if ($file == $name && is_executable($path)) { + if (basename($path) == $name && is_executable($path)) { return $path; } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/LICENSE b/core/vendor/symfony/process/Symfony/Component/Process/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/LICENSE +++ b/core/vendor/symfony/process/Symfony/Component/Process/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php b/core/vendor/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php index 6c9b8a1149a19728751f07e8072e6b71f8cb4b6f..7854487a26b23ebaa1baf96e6660a4f7c4136d33 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php @@ -29,12 +29,19 @@ public function __construct() /** * Finds The PHP executable. * + * @param bool $includeArgs Whether or not include command arguments + * * @return string|false The PHP executable path or false if it cannot be found */ - public function find() + public function find($includeArgs = true) { + // HHVM support + if (defined('HHVM_VERSION')) { + return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : ''); + } + // PHP_BINARY return the current sapi executable - if (defined('PHP_BINARY') && PHP_BINARY && ('cli' === PHP_SAPI) && is_file(PHP_BINARY)) { + if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) { return PHP_BINARY; } @@ -59,4 +66,21 @@ public function find() return $this->executableFinder->find('php', false, $dirs); } + + /** + * Finds the PHP executable arguments. + * + * @return array The PHP executable arguments + */ + public function findArguments() + { + $arguments = array(); + + // HHVM support + if (defined('HHVM_VERSION')) { + $arguments[] = '--php'; + } + + return $arguments; + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php b/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php index d146057e088135af86cdcdf19a7b8c71d0031149..93948e1db01b1ab7d602ddc6a9f58c9c28992413 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php @@ -34,7 +34,7 @@ class PhpProcess extends Process * @param string $script The PHP script to run (as a string) * @param string $cwd The working directory * @param array $env The environment variables - * @param integer $timeout The timeout in seconds + * @param int $timeout The timeout in seconds * @param array $options An array of options for proc_open * * @api diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Process.php b/core/vendor/symfony/process/Symfony/Component/Process/Process.php index 6d0b3c537b4e67440386b6b19cbc49babf17c03b..7503dadefc2cdf8f4ec770303345f90768780cca 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Process.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Process.php @@ -13,10 +13,12 @@ use Symfony\Component\Process\Exception\InvalidArgumentException; use Symfony\Component\Process\Exception\LogicException; +use Symfony\Component\Process\Exception\ProcessFailedException; +use Symfony\Component\Process\Exception\ProcessTimedOutException; use Symfony\Component\Process\Exception\RuntimeException; /** - * Process is a thin wrapper around proc_* functions to ease + * Process is a thin wrapper around proc_* functions to easily * start independent PHP processes. * * @author Fabien Potencier <fabien@symfony.com> @@ -43,26 +45,32 @@ class Process private $commandline; private $cwd; private $env; - private $stdin; + private $input; private $starttime; + private $lastOutputTime; private $timeout; + private $idleTimeout; private $options; private $exitcode; private $fallbackExitcode; private $processInformation; + private $outputDisabled = false; private $stdout; private $stderr; - private $enhanceWindowsCompatibility; + private $enhanceWindowsCompatibility = true; private $enhanceSigchildCompatibility; - private $pipes; private $process; private $status = self::STATUS_READY; - private $incrementalOutputOffset; - private $incrementalErrorOutputOffset; + private $incrementalOutputOffset = 0; + private $incrementalErrorOutputOffset = 0; private $tty; + private $pty; - private $fileHandles; - private $readBytes; + private $useFileHandles = false; + /** @var ProcessPipes */ + private $processPipes; + + private $latestSignal; private static $sigchild; @@ -119,18 +127,18 @@ class Process /** * Constructor. * - * @param string $commandline The command line to run - * @param string $cwd The working directory - * @param array $env The environment variables or null to inherit - * @param string $stdin The STDIN content - * @param integer $timeout The timeout in seconds - * @param array $options An array of options for proc_open + * @param string $commandline The command line to run + * @param string|null $cwd The working directory or null to use the working dir of the current PHP process + * @param array|null $env The environment variables or null to inherit + * @param string|null $input The input + * @param int|float|null $timeout The timeout in seconds or null to disable + * @param array $options An array of options for proc_open * * @throws RuntimeException When proc_open is not installed * * @api */ - public function __construct($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()) { if (!function_exists('proc_open')) { throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.'); @@ -139,21 +147,21 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin $this->commandline = $commandline; $this->cwd = $cwd; - // on windows, if the cwd changed via chdir(), proc_open defaults to the dir where php was started - // on gnu/linux, PHP builds with --enable-maintainer-zts are also affected + // on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started + // on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected // @see : https://bugs.php.net/bug.php?id=51800 // @see : https://bugs.php.net/bug.php?id=50524 - if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) { $this->cwd = getcwd(); } if (null !== $env) { $this->setEnv($env); - } else { - $this->env = null; } - $this->stdin = $stdin; + + $this->input = $input; $this->setTimeout($timeout); + $this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD'); + $this->pty = false; $this->enhanceWindowsCompatibility = true; $this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled(); $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options); @@ -180,12 +188,14 @@ public function __clone() * The STDOUT and STDERR are also available after the process is finished * via the getOutput() and getErrorOutput() methods. * - * @param callback|null $callback A PHP callback to run whenever there is some + * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @return integer The exit status code + * @return int The exit status code * - * @throws RuntimeException When process can't be launch or is stopped + * @throws RuntimeException When process can't be launched + * @throws RuntimeException When process stopped after receiving signal + * @throws LogicException In case a callback is provided and output has been disabled * * @api */ @@ -197,7 +207,33 @@ public function run($callback = null) } /** - * Starts the process and returns after sending the STDIN. + * Runs the process. + * + * This is identical to run() except that an exception is thrown if the process + * exits with a non-zero exit code. + * + * @param callable|null $callback + * + * @return self + * + * @throws RuntimeException if PHP was compiled with --enable-sigchild and the enhanced sigchild compatibility mode is not enabled + * @throws ProcessFailedException if the process didn't terminate successfully + */ + public function mustRun($callback = null) + { + if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.'); + } + + if (0 !== $this->run($callback)) { + throw new ProcessFailedException($this); + } + + return $this; + } + + /** + * Starts the process and returns after writing the input to STDIN. * * This method blocks until all STDIN data is sent to the process then it * returns while the process runs in the background. @@ -211,44 +247,57 @@ public function run($callback = null) * with true as a second parameter then the callback will get all data occurred * in (and since) the start call. * - * @param callback|null $callback A PHP callback to run whenever there is some + * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @throws RuntimeException When process can't be launch or is stopped + * @return Process The process itself + * + * @throws RuntimeException When process can't be launched * @throws RuntimeException When process is already running + * @throws LogicException In case a callback is provided and output has been disabled */ public function start($callback = null) { if ($this->isRunning()) { throw new RuntimeException('Process is already running'); } + if ($this->outputDisabled && null !== $callback) { + throw new LogicException('Output has been disabled, enable it to allow the use of a callback.'); + } $this->resetProcessData(); - $this->starttime = microtime(true); + $this->starttime = $this->lastOutputTime = microtime(true); $this->callback = $this->buildCallback($callback); $descriptors = $this->getDescriptors(); $commandline = $this->commandline; if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->enhanceWindowsCompatibility) { - $commandline = 'cmd /V:ON /E:ON /C "'.$commandline.'"'; + $commandline = 'cmd /V:ON /E:ON /C "('.$commandline.')'; + foreach ($this->processPipes->getFiles() as $offset => $filename) { + $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename); + } + $commandline .= '"'; + if (!isset($this->options['bypass_shell'])) { $this->options['bypass_shell'] = true; } } - $this->process = proc_open($commandline, $descriptors, $this->pipes, $this->cwd, $this->env, $this->options); + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options); if (!is_resource($this->process)) { throw new RuntimeException('Unable to launch a new process.'); } $this->status = self::STATUS_STARTED; - foreach ($this->pipes as $pipe) { - stream_set_blocking($pipe, false); + $this->processPipes->unblock(); + + if ($this->tty) { + return; } - $this->writePipes(); + $this->processPipes->write(false, $this->input); $this->updateStatus(false); $this->checkTimeout(); } @@ -258,13 +307,13 @@ public function start($callback = null) * * Be warned that the process is cloned before being started. * - * @param callable $callback A PHP callback to run whenever there is some - * output available on STDOUT or STDERR + * @param callable|null $callback A PHP callback to run whenever there is some + * output available on STDOUT or STDERR * * @return Process The new process * - * @throws \RuntimeException When process can't be launch or is stopped - * @throws \RuntimeException When process is already running + * @throws RuntimeException When process can't be launched + * @throws RuntimeException When process is already running * * @see start() */ @@ -287,43 +336,35 @@ public function restart($callback = null) * from the output in real-time while writing the standard input to the process. * It allows to have feedback from the independent process during execution. * - * @param callback|null $callback A valid PHP callback + * @param callable|null $callback A valid PHP callback * - * @return integer The exitcode of the process + * @return int The exitcode of the process * - * @throws \RuntimeException When process timed out - * @throws \RuntimeException When process stopped after receiving signal + * @throws RuntimeException When process timed out + * @throws RuntimeException When process stopped after receiving signal + * @throws LogicException When process is not yet started */ public function wait($callback = null) { + $this->requireProcessIsStarted(__FUNCTION__); + $this->updateStatus(false); if (null !== $callback) { $this->callback = $this->buildCallback($callback); } - while ($this->pipes || (defined('PHP_WINDOWS_VERSION_BUILD') && $this->fileHandles)) { - $this->checkTimeout(); - $this->readPipes(true); - } - $this->updateStatus(false); - if ($this->processInformation['signaled']) { - if ($this->isSigchildEnabled()) { - throw new RuntimeException('The process has been signaled.'); - } - throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig'])); - } + do { + $this->checkTimeout(); + $running = defined('PHP_WINDOWS_VERSION_BUILD') ? $this->isRunning() : $this->processPipes->hasOpenHandles(); + $close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running; + $this->readPipes(true, $close); + } while ($running); - $time = 0; - while ($this->isRunning() && $time < 1000000) { - $time += 1000; + while ($this->isRunning()) { usleep(1000); } - if ($this->processInformation['signaled']) { - if ($this->isSigchildEnabled()) { - throw new RuntimeException('The process has been signaled.'); - } - + if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) { throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig'])); } @@ -333,7 +374,7 @@ public function wait($callback = null) /** * Returns the Pid (process identifier), if applicable. * - * @return integer|null The process id if running, null otherwise + * @return int|null The process id if running, null otherwise * * @throws RuntimeException In case --enable-sigchild is activated */ @@ -349,9 +390,10 @@ public function getPid() } /** - * Sends a posix signal to the process. + * Sends a POSIX signal to the process. + * + * @param int $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php) * - * @param integer $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php) * @return Process * * @throws LogicException In case the process is not running @@ -360,31 +402,80 @@ public function getPid() */ public function signal($signal) { - if (!$this->isRunning()) { - throw new LogicException('Can not send signal on a non running process.'); - } + $this->doSignal($signal, true); - if ($this->isSigchildEnabled()) { - throw new RuntimeException('This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + return $this; + } + + /** + * Disables fetching output and error output from the underlying process. + * + * @return Process + * + * @throws RuntimeException In case the process is already running + * @throws LogicException if an idle timeout is set + */ + public function disableOutput() + { + if ($this->isRunning()) { + throw new RuntimeException('Disabling output while the process is running is not possible.'); + } + if (null !== $this->idleTimeout) { + throw new LogicException('Output can not be disabled while an idle timeout is set.'); } - if (true !== @proc_terminate($this->process, $signal)) { - throw new RuntimeException(sprintf('Error while sending signal `%d`.', $signal)); + $this->outputDisabled = true; + + return $this; + } + + /** + * Enables fetching output and error output from the underlying process. + * + * @return Process + * + * @throws RuntimeException In case the process is already running + */ + public function enableOutput() + { + if ($this->isRunning()) { + throw new RuntimeException('Enabling output while the process is running is not possible.'); } + $this->outputDisabled = false; + return $this; } + /** + * Returns true in case the output is disabled, false otherwise. + * + * @return bool + */ + public function isOutputDisabled() + { + return $this->outputDisabled; + } + /** * Returns the current output of the process (STDOUT). * * @return string The process output * + * @throws LogicException in case the output has been disabled + * @throws LogicException In case the process is not started + * * @api */ public function getOutput() { - $this->readPipes(false); + if ($this->outputDisabled) { + throw new LogicException('Output has been disabled.'); + } + + $this->requireProcessIsStarted(__FUNCTION__); + + $this->readPipes(false, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true); return $this->stdout; } @@ -395,10 +486,15 @@ public function getOutput() * In comparison with the getOutput method which always return the whole * output, this one returns the new output since the last call. * + * @throws LogicException in case the output has been disabled + * @throws LogicException In case the process is not started + * * @return string The process output since the last call */ public function getIncrementalOutput() { + $this->requireProcessIsStarted(__FUNCTION__); + $data = $this->getOutput(); $latest = substr($data, $this->incrementalOutputOffset); @@ -407,16 +503,38 @@ public function getIncrementalOutput() return $latest; } + /** + * Clears the process output. + * + * @return Process + */ + public function clearOutput() + { + $this->stdout = ''; + $this->incrementalOutputOffset = 0; + + return $this; + } + /** * Returns the current error output of the process (STDERR). * * @return string The process error output * + * @throws LogicException in case the output has been disabled + * @throws LogicException In case the process is not started + * * @api */ public function getErrorOutput() { - $this->readPipes(false); + if ($this->outputDisabled) { + throw new LogicException('Output has been disabled.'); + } + + $this->requireProcessIsStarted(__FUNCTION__); + + $this->readPipes(false, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true); return $this->stderr; } @@ -428,10 +546,15 @@ public function getErrorOutput() * whole error output, this one returns the new error output since the last * call. * + * @throws LogicException in case the output has been disabled + * @throws LogicException In case the process is not started + * * @return string The process error output since the last call */ public function getIncrementalErrorOutput() { + $this->requireProcessIsStarted(__FUNCTION__); + $data = $this->getErrorOutput(); $latest = substr($data, $this->incrementalErrorOutputOffset); @@ -440,10 +563,23 @@ public function getIncrementalErrorOutput() return $latest; } + /** + * Clears the process output. + * + * @return Process + */ + public function clearErrorOutput() + { + $this->stderr = ''; + $this->incrementalErrorOutputOffset = 0; + + return $this; + } + /** * Returns the exit code returned by the process. * - * @return integer The exit status code + * @return null|int The exit status code, null if the Process is not terminated * * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled * @@ -452,7 +588,7 @@ public function getIncrementalErrorOutput() public function getExitCode() { if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) { - throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method'); + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.'); } $this->updateStatus(false); @@ -466,14 +602,18 @@ public function getExitCode() * This method relies on the Unix exit code status standardization * and might not be relevant for other operating systems. * - * @return string A string representation for the exit status code + * @return null|string A string representation for the exit status code, null if the Process is not terminated. + * + * @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled * * @see http://tldp.org/LDP/abs/html/exitcodes.html * @see http://en.wikipedia.org/wiki/Unix_signal */ public function getExitCodeText() { - $exitcode = $this->getExitCode(); + if (null === $exitcode = $this->getExitCode()) { + return; + } return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error'; } @@ -481,7 +621,7 @@ public function getExitCodeText() /** * Checks if the process ended successfully. * - * @return Boolean true if the process ended successfully, false otherwise + * @return bool true if the process ended successfully, false otherwise * * @api */ @@ -495,16 +635,19 @@ public function isSuccessful() * * It always returns false on Windows. * - * @return Boolean + * @return bool * * @throws RuntimeException In case --enable-sigchild is activated + * @throws LogicException In case the process is not terminated * * @api */ public function hasBeenSignaled() { + $this->requireProcessIsTerminated(__FUNCTION__); + if ($this->isSigchildEnabled()) { - throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.'); } $this->updateStatus(false); @@ -517,16 +660,19 @@ public function hasBeenSignaled() * * It is only meaningful if hasBeenSignaled() returns true. * - * @return integer + * @return int * * @throws RuntimeException In case --enable-sigchild is activated + * @throws LogicException In case the process is not terminated * * @api */ public function getTermSignal() { + $this->requireProcessIsTerminated(__FUNCTION__); + if ($this->isSigchildEnabled()) { - throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.'); } $this->updateStatus(false); @@ -539,12 +685,16 @@ public function getTermSignal() * * It always returns false on Windows. * - * @return Boolean + * @return bool + * + * @throws LogicException In case the process is not terminated * * @api */ public function hasBeenStopped() { + $this->requireProcessIsTerminated(__FUNCTION__); + $this->updateStatus(false); return $this->processInformation['stopped']; @@ -555,12 +705,16 @@ public function hasBeenStopped() * * It is only meaningful if hasBeenStopped() returns true. * - * @return integer + * @return int + * + * @throws LogicException In case the process is not terminated * * @api */ public function getStopSignal() { + $this->requireProcessIsTerminated(__FUNCTION__); + $this->updateStatus(false); return $this->processInformation['stopsig']; @@ -569,7 +723,7 @@ public function getStopSignal() /** * Checks if the process is currently running. * - * @return Boolean true if the process is currently running, false otherwise + * @return bool true if the process is currently running, false otherwise */ public function isRunning() { @@ -585,7 +739,7 @@ public function isRunning() /** * Checks if the process has been started with no regard to the current state. * - * @return Boolean true if status is ready, false otherwise + * @return bool true if status is ready, false otherwise */ public function isStarted() { @@ -595,7 +749,7 @@ public function isStarted() /** * Checks if the process is terminated. * - * @return Boolean true if process is terminated, false otherwise + * @return bool true if process is terminated, false otherwise */ public function isTerminated() { @@ -621,10 +775,10 @@ public function getStatus() /** * Stops the process. * - * @param integer|float $timeout The timeout in seconds - * @param integer $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL + * @param int|float $timeout The timeout in seconds + * @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL * - * @return integer The exit-code of the process + * @return int The exit-code of the process * * @throws RuntimeException if the process got signaled */ @@ -632,20 +786,33 @@ public function stop($timeout = 10, $signal = null) { $timeoutMicro = microtime(true) + $timeout; if ($this->isRunning()) { - proc_terminate($this->process); + if (defined('PHP_WINDOWS_VERSION_BUILD') && !$this->isSigchildEnabled()) { + exec(sprintf("taskkill /F /T /PID %d 2>&1", $this->getPid()), $output, $exitCode); + if ($exitCode > 0) { + throw new RuntimeException('Unable to kill the process'); + } + } + // given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here + $this->doSignal(15, false); do { usleep(1000); } while ($this->isRunning() && microtime(true) < $timeoutMicro); if ($this->isRunning() && !$this->isSigchildEnabled()) { if (null !== $signal || defined('SIGKILL')) { - $this->signal($signal ?: SIGKILL); + // avoid exception here : + // process is supposed to be running, but it might have stop + // just after this line. + // in any case, let's silently discard the error, we can not do anything + $this->doSignal($signal ?: SIGKILL, false); } } + } - $this->updateStatus(false); + $this->updateStatus(false); + if ($this->processInformation['running']) { + $this->close(); } - $this->status = self::STATUS_TERMINATED; return $this->exitcode; } @@ -657,6 +824,7 @@ public function stop($timeout = 10, $signal = null) */ public function addOutput($line) { + $this->lastOutputTime = microtime(true); $this->stdout .= $line; } @@ -667,6 +835,7 @@ public function addOutput($line) */ public function addErrorOutput($line) { + $this->lastOutputTime = microtime(true); $this->stderr .= $line; } @@ -695,9 +864,9 @@ public function setCommandLine($commandline) } /** - * Gets the process timeout. + * Gets the process timeout (max. runtime). * - * @return integer|null The timeout in seconds or null if it's disabled + * @return float|null The timeout in seconds or null if it's disabled */ public function getTimeout() { @@ -705,11 +874,21 @@ public function getTimeout() } /** - * Sets the process timeout. + * Gets the process idle timeout (max. time since last output). + * + * @return float|null The timeout in seconds or null if it's disabled + */ + public function getIdleTimeout() + { + return $this->idleTimeout; + } + + /** + * Sets the process timeout (max. runtime). * * To disable the timeout, set this value to null. * - * @param float|null $timeout The timeout in seconds + * @param int|float|null $timeout The timeout in seconds * * @return self The current Process instance * @@ -717,19 +896,30 @@ public function getTimeout() */ public function setTimeout($timeout) { - if (null === $timeout) { - $this->timeout = null; + $this->timeout = $this->validateTimeout($timeout); - return $this; - } - - $timeout = (float) $timeout; + return $this; + } - if ($timeout < 0) { - throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); + /** + * Sets the process idle timeout (max. time since last output). + * + * To disable the timeout, set this value to null. + * + * @param int|float|null $timeout The timeout in seconds + * + * @return self The current Process instance. + * + * @throws LogicException if the output is disabled + * @throws InvalidArgumentException if the timeout is negative + */ + public function setIdleTimeout($timeout) + { + if (null !== $timeout && $this->outputDisabled) { + throw new LogicException('Idle timeout can not be set while the output is disabled.'); } - $this->timeout = $timeout; + $this->idleTimeout = $this->validateTimeout($timeout); return $this; } @@ -737,35 +927,64 @@ public function setTimeout($timeout) /** * Enables or disables the TTY mode. * - * @param boolean $tty True to enabled and false to disable + * @param bool $tty True to enabled and false to disable * * @return self The current Process instance + * + * @throws RuntimeException In case the TTY mode is not supported */ public function setTty($tty) { - $this->tty = (Boolean) $tty; + if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) { + throw new RuntimeException('TTY mode is not supported on Windows platform.'); + } + + $this->tty = (bool) $tty; return $this; } /** - * Checks if the TTY mode is enabled. + * Checks if the TTY mode is enabled. * - * @return Boolean true if the TTY mode is enabled, false otherwise + * @return bool true if the TTY mode is enabled, false otherwise */ public function isTty() { return $this->tty; } + /** + * Sets PTY mode. + * + * @param bool $bool + * + * @return self + */ + public function setPty($bool) + { + $this->pty = (bool) $bool; + + return $this; + } + + /** + * Returns PTY state. + * + * @return bool + */ + public function isPty() + { + return $this->pty; + } + /** * Gets the working directory. * - * @return string The current working directory + * @return string|null The current working directory or null on failure */ public function getWorkingDirectory() { - // This is for BC only if (null === $this->cwd) { // getcwd() will return false if any one of the parent directories does not have // the readable or search mode set, even if the current directory does @@ -815,7 +1034,9 @@ public function getEnv() public function setEnv(array $env) { // Process can not handle env values that are arrays - $env = array_filter($env, function ($value) { if (!is_array($value)) { return true; } }); + $env = array_filter($env, function ($value) { + return !is_array($value); + }); $this->env = array(); foreach ($env as $key => $value) { @@ -828,23 +1049,64 @@ public function setEnv(array $env) /** * Gets the contents of STDIN. * - * @return string The current contents + * @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->stdin; + return $this->getInput(); + } + + /** + * Gets the Process input. + * + * @return null|string The Process input + */ + public function getInput() + { + return $this->input; } /** * Sets the contents of STDIN. * - * @param string $stdin The new contents + * Deprecation: As of Symfony 2.5, this method only accepts scalar values. + * + * @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) { - $this->stdin = $stdin; + return $this->setInput($stdin); + } + + /** + * Sets the input. + * + * This content will be passed to the underlying process standard input. + * + * @param string|null $input The content + * + * @return self The current Process instance + * + * @throws LogicException In case the process is running + */ + public function setInput($input) + { + if ($this->isRunning()) { + throw new LogicException('Input can not be set while the process is running.'); + } + + $this->input = ProcessUtils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input); return $this; } @@ -878,7 +1140,7 @@ public function setOptions(array $options) * * This is true by default. * - * @return Boolean + * @return bool */ public function getEnhanceWindowsCompatibility() { @@ -888,13 +1150,13 @@ public function getEnhanceWindowsCompatibility() /** * Sets whether or not Windows compatibility is enabled. * - * @param Boolean $enhance + * @param bool $enhance * * @return self The current Process instance */ public function setEnhanceWindowsCompatibility($enhance) { - $this->enhanceWindowsCompatibility = (Boolean) $enhance; + $this->enhanceWindowsCompatibility = (bool) $enhance; return $this; } @@ -902,7 +1164,7 @@ public function setEnhanceWindowsCompatibility($enhance) /** * Returns whether sigchild compatibility mode is activated or not. * - * @return Boolean + * @return bool */ public function getEnhanceSigchildCompatibility() { @@ -916,13 +1178,13 @@ public function getEnhanceSigchildCompatibility() * determine the success of a process when PHP has been compiled with * the --enable-sigchild option * - * @param Boolean $enhance + * @param bool $enhance * * @return self The current Process instance */ public function setEnhanceSigchildCompatibility($enhance) { - $this->enhanceSigchildCompatibility = (Boolean) $enhance; + $this->enhanceSigchildCompatibility = (bool) $enhance; return $this; } @@ -933,56 +1195,65 @@ public function setEnhanceSigchildCompatibility($enhance) * In case you run a background process (with the start method), you should * trigger this method regularly to ensure the process timeout * - * @throws RuntimeException In case the timeout was reached + * @throws ProcessTimedOutException In case the timeout was reached */ public function checkTimeout() { - if (0 < $this->timeout && $this->timeout < microtime(true) - $this->starttime) { + if ($this->status !== self::STATUS_STARTED) { + return; + } + + if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) { $this->stop(0); - throw new RuntimeException('The process timed-out.'); + throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL); + } + + if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) { + $this->stop(0); + + throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE); } } /** - * Creates the descriptors needed by the proc_open. + * Returns whether PTY is supported on the current operating system. * - * @return array + * @return bool */ - private function getDescriptors() + public static function isPtySupported() { - //Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big. - //Workaround for this problem is to use temporary files instead of pipes on Windows platform. - //@see https://bugs.php.net/bug.php?id=51800 - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->fileHandles = array( - self::STDOUT => tmpfile(), - ); - if (false === $this->fileHandles[self::STDOUT]) { - throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable'); - } - $this->readBytes = array( - self::STDOUT => 0, - ); + static $result; - return array(array('pipe', 'r'), $this->fileHandles[self::STDOUT], array('pipe', 'w')); + if (null !== $result) { + return $result; } - if ($this->tty) { - $descriptors = array( - array('file', '/dev/tty', 'r'), - array('file', '/dev/tty', 'w'), - array('file', '/dev/tty', 'w'), - ); - } else { - $descriptors = array( - array('pipe', 'r'), // stdin - array('pipe', 'w'), // stdout - array('pipe', 'w'), // stderr - ); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + return $result = false; } - if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { + $proc = @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes); + if (is_resource($proc)) { + proc_close($proc); + + return $result = true; + } + + return $result = false; + } + + /** + * Creates the descriptors needed by the proc_open. + * + * @return array + */ + private function getDescriptors() + { + $this->processPipes = new ProcessPipes($this->useFileHandles, $this->tty, $this->pty, $this->outputDisabled); + $descriptors = $this->processPipes->getDescriptors(); + + if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) { // last exit code is output on the fourth pipe and caught to work around --enable-sigchild $descriptors = array_merge($descriptors, array(array('pipe', 'w'))); @@ -998,9 +1269,9 @@ private function getDescriptors() * The callbacks adds all occurred output to the specific buffer and calls * the user callback (if present) with the received output. * - * @param callback|null $callback The user defined PHP callback + * @param callable|null $callback The user defined PHP callback * - * @return callback A PHP callable + * @return callable A PHP callable */ protected function buildCallback($callback) { @@ -1025,7 +1296,7 @@ protected function buildCallback($callback) /** * Updates the status of the process, reads pipes. * - * @param Boolean $blocking Whether to use a clocking read call. + * @param bool $blocking Whether to use a blocking read call. */ protected function updateStatus($blocking) { @@ -1033,20 +1304,20 @@ protected function updateStatus($blocking) return; } - $this->readPipes($blocking); - $this->processInformation = proc_get_status($this->process); $this->captureExitCode(); + + $this->readPipes($blocking, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true); + if (!$this->processInformation['running']) { $this->close(); - $this->status = self::STATUS_TERMINATED; } } /** * Returns whether PHP has been compiled with the '--enable-sigchild' option or not. * - * @return Boolean + * @return bool */ protected function isSigchildEnabled() { @@ -1054,6 +1325,10 @@ protected function isSigchildEnabled() return self::$sigchild; } + if (!function_exists('phpinfo')) { + return self::$sigchild = false; + } + ob_start(); phpinfo(INFO_GENERAL); @@ -1061,166 +1336,52 @@ protected function isSigchildEnabled() } /** - * Handles the windows file handles fallbacks. + * Validates and returns the filtered timeout. * - * @param Boolean $closeEmptyHandles if true, handles that are empty will be assumed closed - */ - private function processFileHandles($closeEmptyHandles = false) - { - $fh = $this->fileHandles; - foreach ($fh as $type => $fileHandle) { - fseek($fileHandle, $this->readBytes[$type]); - $data = fread($fileHandle, 8192); - if (strlen($data) > 0) { - $this->readBytes[$type] += strlen($data); - call_user_func($this->callback, $type == 1 ? self::OUT : self::ERR, $data); - } - if (false === $data || ($closeEmptyHandles && '' === $data && feof($fileHandle))) { - fclose($fileHandle); - unset($this->fileHandles[$type]); - } - } - } - - /** - * Returns true if a system call has been interrupted. + * @param int|float|null $timeout * - * @return Boolean - */ - private function hasSystemCallBeenInterrupted() - { - $lastError = error_get_last(); - - // stream_select returns false when the `select` system call is interrupted by an incoming signal - return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call'); - } - - /** - * Reads pipes, executes callback. - * - * @param Boolean $blocking Whether to use blocking calls or not. - */ - private function readPipes($blocking) - { - if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->fileHandles) { - $this->processFileHandles(!$this->pipes); - } - - if ($this->pipes) { - $r = $this->pipes; - $w = null; - $e = null; - - // let's have a look if something changed in streams - if (false === $n = @stream_select($r, $w, $e, 0, $blocking ? ceil(self::TIMEOUT_PRECISION * 1E6) : 0)) { - // if a system call has been interrupted, forget about it, let's try again - // otherwise, an error occured, let's reset pipes - if (!$this->hasSystemCallBeenInterrupted()) { - $this->pipes = array(); - } - - return; - } - - // nothing has changed - if (0 === $n) { - return; - } - - $this->processReadPipes($r); - } - } - - /** - * Writes data to pipes. + * @return float|null * - * @param Boolean $blocking Whether to use blocking calls or not. + * @throws InvalidArgumentException if the given timeout is a negative number */ - private function writePipes() + private function validateTimeout($timeout) { - if ($this->tty) { - $this->status = self::STATUS_TERMINATED; - - return; - } - - if (null === $this->stdin) { - fclose($this->pipes[0]); - unset($this->pipes[0]); + $timeout = (float) $timeout; - return; + if (0.0 === $timeout) { + $timeout = null; + } elseif ($timeout < 0) { + throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); } - $writePipes = array($this->pipes[0]); - unset($this->pipes[0]); - $stdinLen = strlen($this->stdin); - $stdinOffset = 0; - - while ($writePipes) { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->processFileHandles(); - } - - $r = $this->pipes; - $w = $writePipes; - $e = null; - - if (false === $n = @stream_select($r, $w, $e, 0, $blocking ? ceil(static::TIMEOUT_PRECISION * 1E6) : 0)) { - // if a system call has been interrupted, forget about it, let's try again - if ($this->hasSystemCallBeenInterrupted()) { - continue; - } - break; - } - - // nothing has changed, let's wait until the process is ready - if (0 === $n) { - continue; - } - - if ($w) { - $written = fwrite($writePipes[0], (binary) substr($this->stdin, $stdinOffset), 8192); - if (false !== $written) { - $stdinOffset += $written; - } - if ($stdinOffset >= $stdinLen) { - fclose($writePipes[0]); - $writePipes = null; - } - } - - $this->processReadPipes($r); - } + return $timeout; } /** - * Processes read pipes, executes callback on it. + * Reads pipes, executes callback. * - * @param array $pipes + * @param bool $blocking Whether to use blocking calls or not. + * @param bool $close Whether to close file handles or not. */ - private function processReadPipes(array $pipes) + private function readPipes($blocking, $close) { - foreach ($pipes as $pipe) { - $type = array_search($pipe, $this->pipes); - $data = fread($pipe, 8192); + if ($close) { + $result = $this->processPipes->readAndCloseHandles($blocking); + } else { + $result = $this->processPipes->read($blocking); + } - if (strlen($data) > 0) { - // last exit code is output and caught to work around --enable-sigchild - if (3 == $type) { - $this->fallbackExitcode = (int) $data; - } else { - call_user_func($this->callback, $type == 1 ? self::OUT : self::ERR, $data); - } - } - if (false === $data || feof($pipe)) { - fclose($pipe); - unset($this->pipes[$type]); + foreach ($result as $type => $data) { + if (3 == $type) { + $this->fallbackExitcode = (int) $data; + } else { + call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data); } } } /** - * Captures the exitcode if mentioned in the process informations. + * Captures the exitcode if mentioned in the process information. */ private function captureExitCode() { @@ -1229,42 +1390,30 @@ private function captureExitCode() } } - /** * Closes process resource, closes file handles, sets the exitcode. * - * @return Integer The exitcode + * @return int The exitcode */ private function close() { - foreach ($this->pipes as $pipe) { - fclose($pipe); - } - - $this->pipes = null; - $exitcode = -1; - + $this->processPipes->close(); if (is_resource($this->process)) { $exitcode = proc_close($this->process); + } else { + $exitcode = -1; } - $this->exitcode = $this->exitcode !== null ? $this->exitcode : -1; - $this->exitcode = -1 != $exitcode ? $exitcode : $this->exitcode; + $this->exitcode = -1 !== $exitcode ? $exitcode : (null !== $this->exitcode ? $this->exitcode : -1); + $this->status = self::STATUS_TERMINATED; - if (-1 == $this->exitcode && null !== $this->fallbackExitcode) { + if (-1 === $this->exitcode && null !== $this->fallbackExitcode) { $this->exitcode = $this->fallbackExitcode; } elseif (-1 === $this->exitcode && $this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) { - // if process has been signaled, no exitcode but a valid termsig, apply unix convention + // if process has been signaled, no exitcode but a valid termsig, apply Unix convention $this->exitcode = 128 + $this->processInformation['termsig']; } - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - foreach ($this->fileHandles as $fileHandle) { - fclose($fileHandle); - } - $this->fileHandles = array(); - } - return $this->exitcode; } @@ -1280,12 +1429,81 @@ private function resetProcessData() $this->processInformation = null; $this->stdout = null; $this->stderr = null; - $this->pipes = null; $this->process = null; + $this->latestSignal = null; $this->status = self::STATUS_READY; - $this->fileHandles = null; - $this->readBytes = null; $this->incrementalOutputOffset = 0; $this->incrementalErrorOutputOffset = 0; } + + /** + * Sends a POSIX signal to the process. + * + * @param int $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php) + * @param bool $throwException Whether to throw exception in case signal failed + * + * @return bool True if the signal was sent successfully, false otherwise + * + * @throws LogicException In case the process is not running + * @throws RuntimeException In case --enable-sigchild is activated + * @throws RuntimeException In case of failure + */ + private function doSignal($signal, $throwException) + { + if (!$this->isRunning()) { + if ($throwException) { + throw new LogicException('Can not send signal on a non running process.'); + } + + return false; + } + + if ($this->isSigchildEnabled()) { + if ($throwException) { + throw new RuntimeException('This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + } + + return false; + } + + if (true !== @proc_terminate($this->process, $signal)) { + if ($throwException) { + throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal)); + } + + return false; + } + + $this->latestSignal = $signal; + + return true; + } + + /** + * Ensures the process is running or terminated, throws a LogicException if the process has a not started. + * + * @param string $functionName The function name that was called. + * + * @throws LogicException If the process has not run. + */ + private function requireProcessIsStarted($functionName) + { + if (!$this->isStarted()) { + throw new LogicException(sprintf('Process must be started before calling %s.', $functionName)); + } + } + + /** + * Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`. + * + * @param string $functionName The function name that was called. + * + * @throws LogicException If the process is not yet terminated. + */ + private function requireProcessIsTerminated($functionName) + { + if (!$this->isTerminated()) { + throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName)); + } + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php b/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php index ddd064a2b877e28beeab0f7e10723eabf82f5038..71633cd7fac3c5acf0d3d08a575a6456e33c2cf7 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/ProcessBuilder.php @@ -23,23 +23,31 @@ class ProcessBuilder { private $arguments; private $cwd; - private $env; - private $stdin; - private $timeout; - private $options; - private $inheritEnv; - private $prefix; + private $env = array(); + private $input; + private $timeout = 60; + private $options = array(); + private $inheritEnv = true; + private $prefix = array(); + private $outputDisabled = false; + /** + * Constructor + * + * @param string[] $arguments An array of arguments + */ public function __construct(array $arguments = array()) { $this->arguments = $arguments; - - $this->timeout = 60; - $this->options = array(); - $this->env = array(); - $this->inheritEnv = true; } + /** + * Creates a process builder instance. + * + * @param string[] $arguments An array of arguments + * + * @return ProcessBuilder + */ public static function create(array $arguments = array()) { return new static($arguments); @@ -62,21 +70,26 @@ public function add($argument) /** * Adds an unescaped prefix to the command string. * - * The prefix is preserved when reseting arguments. + * The prefix is preserved when resetting arguments. * - * @param string $prefix A command prefix + * @param string|array $prefix A command prefix or an array of command prefixes * * @return ProcessBuilder */ public function setPrefix($prefix) { - $this->prefix = $prefix; + $this->prefix = is_array($prefix) ? $prefix : array($prefix); return $this; } /** - * @param array $arguments + * Sets the arguments of the process. + * + * Arguments must not be escaped. + * Previous arguments are removed. + * + * @param string[] $arguments * * @return ProcessBuilder */ @@ -87,6 +100,13 @@ public function setArguments(array $arguments) return $this; } + /** + * Sets the working directory. + * + * @param null|string $cwd The working directory + * + * @return ProcessBuilder + */ public function setWorkingDirectory($cwd) { $this->cwd = $cwd; @@ -94,6 +114,13 @@ public function setWorkingDirectory($cwd) return $this; } + /** + * Sets whether environment variables will be inherited or not. + * + * @param bool $inheritEnv + * + * @return ProcessBuilder + */ public function inheritEnvironmentVariables($inheritEnv = true) { $this->inheritEnv = $inheritEnv; @@ -101,6 +128,17 @@ public function inheritEnvironmentVariables($inheritEnv = true) return $this; } + /** + * Sets an environment variable + * + * Setting a variable overrides its previous value. Use `null` to unset a + * defined environment variable. + * + * @param string $name The variable name + * @param null|string $value The variable value + * + * @return ProcessBuilder + */ public function setEnv($name, $value) { $this->env[$name] = $value; @@ -108,9 +146,38 @@ public function setEnv($name, $value) return $this; } - public function setInput($stdin) + /** + * Adds a set of environment variables. + * + * Already existing environment variables with the same name will be + * overridden by the new values passed to this method. Pass `null` to unset + * a variable. + * + * @param array $variables The variables + * + * @return ProcessBuilder + */ + public function addEnvironmentVariables(array $variables) { - $this->stdin = $stdin; + $this->env = array_replace($this->env, $variables); + + return $this; + } + + /** + * Sets the input of the process. + * + * Deprecation: As of Symfony 2.5, this method only accepts string values. + * + * @param string|null $input The input as a string + * + * @return ProcessBuilder + * + * @throws InvalidArgumentException In case the argument is invalid + */ + public function setInput($input) + { + $this->input = ProcessUtils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input); return $this; } @@ -145,6 +212,14 @@ public function setTimeout($timeout) return $this; } + /** + * Adds a proc_open option. + * + * @param string $name The option name + * @param string $value The option value + * + * @return ProcessBuilder + */ public function setOption($name, $value) { $this->options[$name] = $value; @@ -152,23 +227,61 @@ public function setOption($name, $value) return $this; } + /** + * Disables fetching output and error output from the underlying process. + * + * @return ProcessBuilder + */ + public function disableOutput() + { + $this->outputDisabled = true; + + return $this; + } + + /** + * Enables fetching output and error output from the underlying process. + * + * @return ProcessBuilder + */ + public function enableOutput() + { + $this->outputDisabled = false; + + return $this; + } + + /** + * Creates a Process instance and returns it. + * + * @return Process + * + * @throws LogicException In case no arguments have been provided + */ public function getProcess() { - if (!$this->prefix && !count($this->arguments)) { + if (0 === count($this->prefix) && 0 === count($this->arguments)) { throw new LogicException('You must add() command arguments before calling getProcess().'); } $options = $this->options; - $arguments = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments; + $arguments = array_merge($this->prefix, $this->arguments); $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments)); if ($this->inheritEnv) { - $env = $this->env ? $this->env + $_ENV : null; + // include $_ENV for BC purposes + $env = array_replace($_ENV, $_SERVER, $this->env); } else { $env = $this->env; } - return new Process($script, $this->cwd, $env, $this->stdin, $this->timeout, $options); + $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options); + + if ($this->outputDisabled) { + $process->disableOutput(); + } + + return $process; } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/ProcessPipes.php b/core/vendor/symfony/process/Symfony/Component/Process/ProcessPipes.php new file mode 100644 index 0000000000000000000000000000000000000000..9ed1def9f29e34c2bb7dcaa39db59651b0163a33 --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/ProcessPipes.php @@ -0,0 +1,382 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process; + +use Symfony\Component\Process\Exception\RuntimeException; + +/** + * ProcessPipes manages descriptors and pipes for the use of proc_open. + */ +class ProcessPipes +{ + /** @var array */ + public $pipes = array(); + /** @var array */ + private $files = array(); + /** @var array */ + private $fileHandles = array(); + /** @var array */ + private $readBytes = array(); + /** @var bool */ + private $useFiles; + /** @var bool */ + private $ttyMode; + /** @var bool */ + private $ptyMode; + /** @var bool */ + private $disableOutput; + + const CHUNK_SIZE = 16384; + + public function __construct($useFiles, $ttyMode, $ptyMode = false, $disableOutput = false) + { + $this->useFiles = (bool) $useFiles; + $this->ttyMode = (bool) $ttyMode; + $this->ptyMode = (bool) $ptyMode; + $this->disableOutput = (bool) $disableOutput; + + // Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big. + // Workaround for this problem is to use temporary files instead of pipes on Windows platform. + // + // @see https://bugs.php.net/bug.php?id=51800 + if ($this->useFiles && !$this->disableOutput) { + $this->files = array( + Process::STDOUT => tempnam(sys_get_temp_dir(), 'sf_proc_stdout'), + Process::STDERR => tempnam(sys_get_temp_dir(), 'sf_proc_stderr'), + ); + foreach ($this->files as $offset => $file) { + $this->fileHandles[$offset] = fopen($this->files[$offset], 'rb'); + if (false === $this->fileHandles[$offset]) { + throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable'); + } + } + $this->readBytes = array( + Process::STDOUT => 0, + Process::STDERR => 0, + ); + } + } + + public function __destruct() + { + $this->close(); + $this->removeFiles(); + } + + /** + * Sets non-blocking mode on pipes. + */ + public function unblock() + { + foreach ($this->pipes as $pipe) { + stream_set_blocking($pipe, 0); + } + } + + /** + * Closes file handles and pipes. + */ + public function close() + { + $this->closeUnixPipes(); + foreach ($this->fileHandles as $handle) { + fclose($handle); + } + $this->fileHandles = array(); + } + + /** + * Closes Unix pipes. + * + * Nothing happens in case file handles are used. + */ + public function closeUnixPipes() + { + foreach ($this->pipes as $pipe) { + fclose($pipe); + } + $this->pipes = array(); + } + + /** + * Returns an array of descriptors for the use of proc_open. + * + * @return array + */ + public function getDescriptors() + { + if ($this->disableOutput) { + $nullstream = fopen(defined('PHP_WINDOWS_VERSION_BUILD') ? 'NUL' : '/dev/null', 'c'); + + return array( + array('pipe', 'r'), + $nullstream, + $nullstream, + ); + } + + if ($this->useFiles) { + // We're not using pipe on Windows platform as it hangs (https://bugs.php.net/bug.php?id=51800) + // We're not using file handles as it can produce corrupted output https://bugs.php.net/bug.php?id=65650 + // So we redirect output within the commandline and pass the nul device to the process + return array( + array('pipe', 'r'), + array('file', 'NUL', 'w'), + array('file', 'NUL', 'w'), + ); + } + + if ($this->ttyMode) { + return array( + array('file', '/dev/tty', 'r'), + array('file', '/dev/tty', 'w'), + array('file', '/dev/tty', 'w'), + ); + } elseif ($this->ptyMode && Process::isPtySupported()) { + return array( + array('pty'), + array('pty'), + array('pty'), + ); + } + + return array( + array('pipe', 'r'), // stdin + array('pipe', 'w'), // stdout + array('pipe', 'w'), // stderr + ); + } + + /** + * Returns an array of filenames indexed by their related stream in case these pipes use temporary files. + * + * @return array + */ + public function getFiles() + { + if ($this->useFiles) { + return $this->files; + } + + return array(); + } + + /** + * Reads data in file handles and pipes. + * + * @param bool $blocking Whether to use blocking calls or not. + * + * @return array An array of read data indexed by their fd. + */ + public function read($blocking) + { + return array_replace($this->readStreams($blocking), $this->readFileHandles()); + } + + /** + * Reads data in file handles and pipes, closes them if EOF is reached. + * + * @param bool $blocking Whether to use blocking calls or not. + * + * @return array An array of read data indexed by their fd. + */ + public function readAndCloseHandles($blocking) + { + return array_replace($this->readStreams($blocking, true), $this->readFileHandles(true)); + } + + /** + * Returns if the current state has open file handles or pipes. + * + * @return bool + */ + public function hasOpenHandles() + { + if (!$this->useFiles) { + return (bool) $this->pipes; + } + + return (bool) $this->pipes && (bool) $this->fileHandles; + } + + /** + * Writes stdin data. + * + * @param bool $blocking Whether to use blocking calls or not. + * @param string|null $stdin The data to write. + */ + public function write($blocking, $stdin) + { + if (null === $stdin) { + fclose($this->pipes[0]); + unset($this->pipes[0]); + + return; + } + + $writePipes = array($this->pipes[0]); + unset($this->pipes[0]); + $stdinLen = strlen($stdin); + $stdinOffset = 0; + + while ($writePipes) { + $r = null; + $w = $writePipes; + $e = null; + + if (false === $n = @stream_select($r, $w, $e, 0, $blocking ? ceil(Process::TIMEOUT_PRECISION * 1E6) : 0)) { + // if a system call has been interrupted, forget about it, let's try again + if ($this->hasSystemCallBeenInterrupted()) { + continue; + } + break; + } + + // nothing has changed, let's wait until the process is ready + if (0 === $n) { + continue; + } + + if ($w) { + $written = fwrite($writePipes[0], (binary) substr($stdin, $stdinOffset), 8192); + if (false !== $written) { + $stdinOffset += $written; + } + if ($stdinOffset >= $stdinLen) { + fclose($writePipes[0]); + $writePipes = null; + } + } + } + } + + /** + * Reads data in file handles. + * + * @param bool $close Whether to close file handles or not. + * + * @return array An array of read data indexed by their fd. + */ + private function readFileHandles($close = false) + { + $read = array(); + $fh = $this->fileHandles; + foreach ($fh as $type => $fileHandle) { + if (0 !== fseek($fileHandle, $this->readBytes[$type])) { + continue; + } + $data = ''; + $dataread = null; + while (!feof($fileHandle)) { + if (false !== $dataread = fread($fileHandle, self::CHUNK_SIZE)) { + $data .= $dataread; + } + } + if (0 < $length = strlen($data)) { + $this->readBytes[$type] += $length; + $read[$type] = $data; + } + + if (false === $dataread || (true === $close && feof($fileHandle) && '' === $data)) { + fclose($this->fileHandles[$type]); + unset($this->fileHandles[$type]); + } + } + + return $read; + } + + /** + * Reads data in file pipes streams. + * + * @param bool $blocking Whether to use blocking calls or not. + * @param bool $close Whether to close file handles or not. + * + * @return array An array of read data indexed by their fd. + */ + private function readStreams($blocking, $close = false) + { + if (empty($this->pipes)) { + usleep(Process::TIMEOUT_PRECISION * 1E4); + + return array(); + } + + $read = array(); + + $r = $this->pipes; + $w = null; + $e = null; + + // let's have a look if something changed in streams + if (false === $n = @stream_select($r, $w, $e, 0, $blocking ? ceil(Process::TIMEOUT_PRECISION * 1E6) : 0)) { + // if a system call has been interrupted, forget about it, let's try again + // otherwise, an error occurred, let's reset pipes + if (!$this->hasSystemCallBeenInterrupted()) { + $this->pipes = array(); + } + + return $read; + } + + // nothing has changed + if (0 === $n) { + return $read; + } + + foreach ($r as $pipe) { + $type = array_search($pipe, $this->pipes); + + $data = ''; + while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) { + $data .= $dataread; + } + + if ('' !== $data) { + $read[$type] = $data; + } + + if (false === $data || (true === $close && feof($pipe) && '' === $data)) { + fclose($this->pipes[$type]); + unset($this->pipes[$type]); + } + } + + return $read; + } + + /** + * Returns true if a system call has been interrupted. + * + * @return bool + */ + private function hasSystemCallBeenInterrupted() + { + $lastError = error_get_last(); + + // stream_select returns false when the `select` system call is interrupted by an incoming signal + return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call'); + } + + /** + * Removes temporary files + */ + private function removeFiles() + { + foreach ($this->files as $filename) { + if (file_exists($filename)) { + @unlink($filename); + } + } + $this->files = array(); + } +} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php b/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php index 4a5b7d60731a7102f3f59cd044cfdc1cc90ef2d9..35ae17c5088220b08ddef9e8d45b91ef77cc06e2 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Process; +use Symfony\Component\Process\Exception\InvalidArgumentException; + /** * ProcessUtils is a bunch of utility methods. * @@ -37,7 +39,7 @@ private function __construct() public static function escapeArgument($argument) { //Fix for PHP bug #43784 escapeshellarg removes % from given string - //Fix for PHP bug #49446 escapeshellarg dosn`t work on windows + //Fix for PHP bug #49446 escapeshellarg doesn't work on Windows //@see https://bugs.php.net/bug.php?id=43784 //@see https://bugs.php.net/bug.php?id=49446 if (defined('PHP_WINDOWS_VERSION_BUILD')) { @@ -46,19 +48,61 @@ public static function escapeArgument($argument) } $escapedArgument = ''; - foreach (preg_split('/([%"])/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + $quote = false; + foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { if ('"' === $part) { $escapedArgument .= '\\"'; - } elseif ('%' === $part) { - $escapedArgument .= '^%'; + } elseif (self::isSurroundedBy($part, '%')) { + // Avoid environment variable expansion + $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%'; } else { - $escapedArgument .= escapeshellarg($part); + // escape trailing backslash + if ('\\' === substr($part, -1)) { + $part .= '\\'; + } + $quote = true; + $escapedArgument .= $part; } } + if ($quote) { + $escapedArgument = '"'.$escapedArgument.'"'; + } return $escapedArgument; } return escapeshellarg($argument); } + + /** + * Validates and normalizes a Process input + * + * @param string $caller The name of method call that validates the input + * @param mixed $input The input to validate + * + * @return string The validated input + * + * @throws InvalidArgumentException In case the input is not valid + */ + public static function validateInput($caller, $input) + { + if (null !== $input) { + if (is_scalar($input)) { + return (string) $input; + } + // deprecated as of Symfony 2.5, to be removed in 3.0 + if (is_object($input) && method_exists($input, '__toString')) { + return (string) $input; + } + + throw new InvalidArgumentException(sprintf('%s only accepts strings.', $caller)); + } + + return $input; + } + + private static function isSurroundedBy($arg, $char) + { + return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/README.md b/core/vendor/symfony/process/Symfony/Component/Process/README.md index 7b9f30757beaa0029e9a2a10b0955049b6e34d75..c7e21386dac845bbd611d8ddd7433c03ece5d3a4 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/README.md +++ b/core/vendor/symfony/process/Symfony/Component/Process/README.md @@ -27,7 +27,7 @@ as it becomes available: $process = new Process('ls -lsa'); $process->run(function ($type, $buffer) { - if ('err' === $type) { + if (Process::ERR === $type) { echo 'ERR > '.$buffer; } else { echo 'OUT > '.$buffer; @@ -42,6 +42,6 @@ Resources You can run the unit tests with the following command: - $ cd path/to/Symfony/Component/XXX/ - $ composer.phar install --dev + $ cd path/to/Symfony/Component/Process/ + $ composer.phar install $ phpunit diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php index d0228f0e5517fa52b0c8e11b8a265f6f93ce17af..c5737e1a9e38c49dfed32d8145663a50d40c36cc 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -11,14 +11,27 @@ namespace Symfony\Component\Process\Tests; +use Symfony\Component\Process\Exception\ProcessTimedOutException; +use Symfony\Component\Process\Exception\LogicException; use Symfony\Component\Process\Process; use Symfony\Component\Process\Exception\RuntimeException; +use Symfony\Component\Process\ProcessPipes; /** * @author Robert Schönthal <seroscho@googlemail.com> */ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { + public function testThatProcessDoesNotThrowWarningDuringRun() + { + @trigger_error('Test Error', E_USER_NOTICE); + $process = $this->getProcess("php -r 'sleep(3)'"); + $process->run(); + $actualError = error_get_last(); + $this->assertEquals('Test Error', $actualError['message']); + $this->assertEquals(E_USER_NOTICE, $actualError['type']); + } + /** * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException */ @@ -36,12 +49,17 @@ public function testNegativeTimeoutFromSetter() $p->setTimeout(-1); } - public function testNullTimeout() + public function testFloatAndNullTimeout() { $p = $this->getProcess(''); + $p->setTimeout(10); + $this->assertSame(10.0, $p->getTimeout()); + $p->setTimeout(null); + $this->assertNull($p->getTimeout()); + $p->setTimeout(0.0); $this->assertNull($p->getTimeout()); } @@ -65,21 +83,48 @@ public function testStopWithTimeoutIsActuallyWorking() $this->assertLessThan(1.8, $duration); } + public function testAllOutputIsActuallyReadOnTermination() + { + // this code will result in a maximum of 2 reads of 8192 bytes by calling + // start() and isRunning(). by the time getOutput() is called the process + // has terminated so the internal pipes array is already empty. normally + // the call to start() will not read any data as the process will not have + // generated output, but this is non-deterministic so we must count it as + // a possibility. therefore we need 2 * ProcessPipes::CHUNK_SIZE plus + // another byte which will never be read. + $expectedOutputSize = ProcessPipes::CHUNK_SIZE * 2 + 2; + + $code = sprintf('echo str_repeat(\'*\', %d);', $expectedOutputSize); + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code))); + + $p->start(); + // Let's wait enough time for process to finish... + // Here we don't call Process::run or Process::wait to avoid any read of pipes + usleep(500000); + + if ($p->isRunning()) { + $this->markTestSkipped('Process execution did not complete in the required time frame'); + } + + $o = $p->getOutput(); + + $this->assertEquals($expectedOutputSize, strlen($o)); + } + public function testCallbacksAreExecutedWithStart() { $data = ''; - $process = $this->getProcess('echo "foo";sleep 1;echo "foo"'); + $process = $this->getProcess('echo foo && php -r "sleep(1);" && echo foo'); $process->start(function ($type, $buffer) use (&$data) { $data .= $buffer; }); - $start = microtime(true); while ($process->isRunning()) { usleep(10000); } - $this->assertEquals("foo\nfoo\n", $data); + $this->assertEquals(2, preg_match_all('/foo/', $data, $matches)); } /** @@ -102,23 +147,80 @@ public function testProcessResponses($expected, $getter, $code) */ public function testProcessPipes($code, $size) { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800'); - } - - $expected = str_repeat(str_repeat('*', 1024), $size) . '!'; + $expected = str_repeat(str_repeat('*', 1024), $size).'!'; $expectedLength = (1024 * $size) + 1; $p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code))); - $p->setStdin($expected); + $p->setInput($expected); $p->run(); $this->assertEquals($expectedLength, strlen($p->getOutput())); $this->assertEquals($expectedLength, strlen($p->getErrorOutput())); } + public function testSetInputWhileRunningThrowsAnException() + { + $process = $this->getProcess('php -r "usleep(500000);"'); + $process->start(); + try { + $process->setInput('foobar'); + $process->stop(); + $this->fail('A LogicException should have been raised.'); + } catch (LogicException $e) { + $this->assertEquals('Input can not be set while the process is running.', $e->getMessage()); + } + $process->stop(); + } + + /** + * @dataProvider provideInvalidInputValues + * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException + * @expectedExceptionMessage Symfony\Component\Process\Process::setInput only accepts strings. + */ + public function testInvalidInput($value) + { + $process = $this->getProcess('php -v'); + $process->setInput($value); + } + + public function provideInvalidInputValues() + { + return array( + array(array()), + array(new NonStringifiable()), + array(fopen('php://temporary', 'w')), + ); + } + + /** + * @dataProvider provideInputValues + */ + public function testValidInput($expected, $value) + { + $process = $this->getProcess('php -v'); + $process->setInput($value); + $this->assertSame($expected, $process->getInput()); + } + + public function provideInputValues() + { + return array( + array(null, null), + array('24.5', 24.5), + array('input data', 'input data'), + // to maintain BC, supposed to be removed in 3.0 + array('stringifiable', new Stringifiable()), + ); + } + public function chainedCommandsOutputProvider() { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + return array( + array("2 \r\n2\r\n", '&&', '2'), + ); + } + return array( array("1\n1\n", ';', '1'), array("2\n2\n", '&&', '2'), @@ -131,10 +233,6 @@ public function chainedCommandsOutputProvider() */ public function testChainedCommandsOutput($expected, $operator, $input) { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Does it work on windows ?'); - } - $process = $this->getProcess(sprintf('echo %s %s echo %s', $input, $operator, $input)); $process->run(); $this->assertEquals($expected, $process->getOutput()); @@ -154,7 +252,7 @@ public function testCallbackIsExecutedForOutput() public function testGetErrorOutput() { - $p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); $p->run(); $this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches)); @@ -162,18 +260,37 @@ public function testGetErrorOutput() public function testGetIncrementalErrorOutput() { - $p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); + // use a lock file to toggle between writing ("W") and reading ("R") the + // error stream + $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); + file_put_contents($lock, 'W'); + + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); $p->start(); while ($p->isRunning()) { - $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches)); - usleep(20000); + if ('R' === file_get_contents($lock)) { + $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches)); + file_put_contents($lock, 'W'); + } + usleep(100); } + + unlink($lock); + } + + public function testFlushErrorOutput() + { + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); + + $p->run(); + $p->clearErrorOutput(); + $this->assertEmpty($p->getErrorOutput()); } public function testGetOutput() { - $p = new Process(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++;}'))); + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { echo \' foo \'; $n++; }'))); $p->run(); $this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches)); @@ -181,13 +298,45 @@ public function testGetOutput() public function testGetIncrementalOutput() { - $p = new Process(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) { echo \' foo \'; usleep(50000); $n++; }'))); + // use a lock file to toggle between writing ("W") and reading ("R") the + // output stream + $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); + file_put_contents($lock, 'W'); + + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); $p->start(); while ($p->isRunning()) { - $this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches)); - usleep(20000); + if ('R' === file_get_contents($lock)) { + $this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches)); + file_put_contents($lock, 'W'); + } + usleep(100); } + + unlink($lock); + } + + public function testFlushOutput() + { + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++;}'))); + + $p->run(); + $p->clearOutput(); + $this->assertEmpty($p->getOutput()); + } + + public function testZeroAsOutput() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + // see http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line + $p = $this->getProcess('echo | set /p dummyName=0'); + } else { + $p = $this->getProcess('printf 0'); + } + + $p->run(); + $this->assertSame('0', $p->getOutput()); } public function testExitCodeCommandFailed() @@ -209,11 +358,81 @@ public function testTTYCommand() $this->markTestSkipped('Windows does have /dev/tty support'); } + $process = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"'); + $process->setTty(true); + $process->start(); + $this->assertTrue($process->isRunning()); + $process->wait(); + + $this->assertSame(Process::STATUS_TERMINATED, $process->getStatus()); + } + + public function testTTYCommandExitCode() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Windows does have /dev/tty support'); + } + + $process = $this->getProcess('echo "foo" >> /dev/null'); + $process->setTty(true); + $process->run(); + + $this->assertTrue($process->isSuccessful()); + } + + public function testTTYInWindowsEnvironment() + { + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('This test is for Windows platform only'); + } + $process = $this->getProcess('echo "foo" >> /dev/null'); - $process->setTTY(true); + $process->setTty(false); + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'TTY mode is not supported on Windows platform.'); + $process->setTty(true); + } + + public function testExitCodeTextIsNullWhenExitCodeIsNull() + { + $process = $this->getProcess(''); + $this->assertNull($process->getExitCodeText()); + } + + public function testPTYCommand() + { + if (!Process::isPtySupported()) { + $this->markTestSkipped('PTY is not supported on this operating system.'); + } + + $process = $this->getProcess('echo "foo"'); + $process->setPty(true); $process->run(); $this->assertSame(Process::STATUS_TERMINATED, $process->getStatus()); + $this->assertEquals("foo\r\n", $process->getOutput()); + } + + public function testMustRun() + { + $process = $this->getProcess('echo foo'); + + $this->assertSame($process, $process->mustRun()); + $this->assertEquals("foo".PHP_EOL, $process->getOutput()); + } + + public function testSuccessfulMustRunHasCorrectExitCode() + { + $process = $this->getProcess('echo foo')->mustRun(); + $this->assertEquals(0, $process->getExitCode()); + } + + /** + * @expectedException \Symfony\Component\Process\Exception\ProcessFailedException + */ + public function testMustRunThrowsException() + { + $process = $this->getProcess('exit 1'); + $process->mustRun(); } public function testExitCodeText() @@ -229,11 +448,12 @@ public function testExitCodeText() public function testStartIsNonBlocking() { - $process = $this->getProcess('php -r "sleep(4);"'); + $process = $this->getProcess('php -r "usleep(500000);"'); $start = microtime(true); $process->start(); $end = microtime(true); - $this->assertLessThan(1 , $end-$start); + $this->assertLessThan(0.2, $end-$start); + $process->wait(); } public function testUpdateStatus() @@ -268,7 +488,7 @@ public function testGetExitCode() { $process = $this->getProcess('php -m'); $process->run(); - $this->assertEquals(0, $process->getExitCode()); + $this->assertSame(0, $process->getExitCode()); } public function testStatus() @@ -308,7 +528,7 @@ public function testIsSuccessful() public function testIsSuccessfulOnlyAfterTerminated() { - $process = $this->getProcess('sleep 1'); + $process = $this->getProcess('php -r "sleep(1);"'); $process->start(); while ($process->isRunning()) { $this->assertFalse($process->isSuccessful()); @@ -320,10 +540,10 @@ public function testIsSuccessfulOnlyAfterTerminated() public function testIsNotSuccessful() { - $process = $this->getProcess('php -r "sleep(4);"'); + $process = $this->getProcess('php -r "usleep(500000);throw new \Exception(\'BOUM\');"'); $process->start(); $this->assertTrue($process->isRunning()); - $process->stop(); + $process->wait(); $this->assertFalse($process->isSuccessful()); } @@ -414,7 +634,7 @@ public function testRestart() $process1->run(); $process2 = $process1->restart(); - usleep(300000); // wait for output + $process2->wait(); // wait for output // Ensure that both processed finished and the output is numeric $this->assertFalse($process1->isRunning()); @@ -428,7 +648,7 @@ public function testRestart() public function testPhpDeadlock() { - $this->markTestSkipped('Can course php to hang'); + $this->markTestSkipped('Can cause PHP to hang'); // Sleep doesn't work as it will allow the process to handle signals and close // file handles from the other end. @@ -441,25 +661,44 @@ public function testPhpDeadlock() public function testRunProcessWithTimeout() { $timeout = 0.5; - $process = $this->getProcess('sleep 3'); + $process = $this->getProcess('php -r "usleep(600000);"'); $process->setTimeout($timeout); $start = microtime(true); try { $process->run(); $this->fail('A RuntimeException should have been raised'); } catch (RuntimeException $e) { - } $duration = microtime(true) - $start; - $this->assertLessThan($timeout + Process::TIMEOUT_PRECISION, $duration); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + // Windows is a bit slower as it read file handles, then allow twice the precision + $maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION; + } else { + $maxDuration = $timeout + Process::TIMEOUT_PRECISION; + } + + $this->assertLessThan($maxDuration, $duration); + } + + public function testCheckTimeoutOnNonStartedProcess() + { + $process = $this->getProcess('php -r "sleep(3);"'); + $process->checkTimeout(); + } + + public function testCheckTimeoutOnTerminatedProcess() + { + $process = $this->getProcess('php -v'); + $process->run(); + $process->checkTimeout(); } public function testCheckTimeoutOnStartedProcess() { $timeout = 0.5; $precision = 100000; - $process = $this->getProcess('sleep 3'); + $process = $this->getProcess('php -r "sleep(3);"'); $process->setTimeout($timeout); $start = microtime(true); @@ -472,7 +711,6 @@ public function testCheckTimeoutOnStartedProcess() } $this->fail('A RuntimeException should have been raised'); } catch (RuntimeException $e) { - } $duration = microtime(true) - $start; @@ -480,12 +718,66 @@ public function testCheckTimeoutOnStartedProcess() $this->assertFalse($process->isSuccessful()); } + /** + * @group idle-timeout + */ + public function testIdleTimeout() + { + $process = $this->getProcess('php -r "sleep(3);"'); + $process->setTimeout(10); + $process->setIdleTimeout(0.5); + + try { + $process->run(); + + $this->fail('A timeout exception was expected.'); + } catch (ProcessTimedOutException $ex) { + $this->assertTrue($ex->isIdleTimeout()); + $this->assertFalse($ex->isGeneralTimeout()); + $this->assertEquals(0.5, $ex->getExceededTimeout()); + } + } + + /** + * @group idle-timeout + */ + public function testIdleTimeoutNotExceededWhenOutputIsSent() + { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'foo\'; sleep(1); echo \'foo\'; sleep(1); "'); + $process->setTimeout(2); + $process->setIdleTimeout(1.5); + + try { + $process->run(); + $this->fail('A timeout exception was expected.'); + } catch (ProcessTimedOutException $ex) { + $this->assertTrue($ex->isGeneralTimeout()); + $this->assertFalse($ex->isIdleTimeout()); + $this->assertEquals(2, $ex->getExceededTimeout()); + } + } + + public function testStartAfterATimeout() + { + $process = $this->getProcess('php -r "$n = 1000; while ($n--) {echo \'\'; usleep(1000); }"'); + $process->setTimeout(0.1); + + try { + $process->run(); + $this->fail('An exception should have been raised.'); + } catch (\Exception $e) { + } + $process->start(); + usleep(1000); + $process->stop(); + } + public function testGetPid() { - $process = $this->getProcess('php -r "sleep(1);"'); + $process = $this->getProcess('php -r "usleep(500000);"'); $process->start(); $this->assertGreaterThan(0, $process->getPid()); - $process->stop(); + $process->wait(); } public function testGetPidIsNullBeforeStart() @@ -505,12 +797,12 @@ public function testSignal() { $this->verifyPosixIsEnabled(); - $process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php'); + $process = $this->getProcess('exec php -f '.__DIR__.'/SignalListener.php'); $process->start(); usleep(500000); $process->signal(SIGUSR1); - while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) { + while ($process->isRunning() && false === strpos($process->getOutput(), 'Caught SIGUSR1')) { usleep(10000); } @@ -536,7 +828,7 @@ public function testExitCodeIsAvailableAfterSignal() } /** - * @expectedException Symfony\Component\Process\Exception\LogicException + * @expectedException \Symfony\Component\Process\Exception\LogicException */ public function testSignalProcessNotRunning() { @@ -545,10 +837,59 @@ public function testSignalProcessNotRunning() $process->signal(SIGHUP); } + /** + * @dataProvider provideMethodsThatNeedARunningProcess + */ + public function testMethodsThatNeedARunningProcess($method) + { + $process = $this->getProcess('php -m'); + $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method)); + call_user_func(array($process, $method)); + } + + public function provideMethodsThatNeedARunningProcess() + { + return array( + array('getOutput'), + array('getIncrementalOutput'), + array('getErrorOutput'), + array('getIncrementalErrorOutput'), + array('wait'), + ); + } + + /** + * @dataProvider provideMethodsThatNeedATerminatedProcess + */ + public function testMethodsThatNeedATerminatedProcess($method) + { + $process = $this->getProcess('php -r "sleep(1);"'); + $process->start(); + try { + call_user_func(array($process, $method)); + $process->stop(0); + $this->fail('A LogicException must have been thrown'); + } catch (\Exception $e) { + $this->assertInstanceOf('Symfony\Component\Process\Exception\LogicException', $e); + $this->assertEquals(sprintf('Process must be terminated before calling %s.', $method), $e->getMessage()); + } + $process->stop(0); + } + + public function provideMethodsThatNeedATerminatedProcess() + { + return array( + array('hasBeenSignaled'), + array('getTermSignal'), + array('hasBeenStopped'), + array('getStopSignal'), + ); + } + private function verifyPosixIsEnabled() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('POSIX signals do not work on windows'); + $this->markTestSkipped('POSIX signals do not work on Windows'); } if (!defined('SIGUSR1')) { $this->markTestSkipped('The pcntl extension is not enabled'); @@ -556,12 +897,12 @@ private function verifyPosixIsEnabled() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException */ public function testSignalWithWrongIntSignal() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('POSIX signals do not work on windows'); + $this->markTestSkipped('POSIX signals do not work on Windows'); } $process = $this->getProcess('php -r "sleep(3);"'); @@ -570,12 +911,12 @@ public function testSignalWithWrongIntSignal() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException */ public function testSignalWithWrongNonIntSignal() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('POSIX signals do not work on windows'); + $this->markTestSkipped('POSIX signals do not work on Windows'); } $process = $this->getProcess('php -r "sleep(3);"'); @@ -583,6 +924,108 @@ public function testSignalWithWrongNonIntSignal() $process->signal('Céphalopodes'); } + public function testDisableOutputDisablesTheOutput() + { + $p = $this->getProcess('php -r "usleep(500000);"'); + $this->assertFalse($p->isOutputDisabled()); + $p->disableOutput(); + $this->assertTrue($p->isOutputDisabled()); + $p->enableOutput(); + $this->assertFalse($p->isOutputDisabled()); + } + + public function testDisableOutputWhileRunningThrowsException() + { + $p = $this->getProcess('php -r "usleep(500000);"'); + $p->start(); + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Disabling output while the process is running is not possible.'); + $p->disableOutput(); + } + + public function testEnableOutputWhileRunningThrowsException() + { + $p = $this->getProcess('php -r "usleep(500000);"'); + $p->disableOutput(); + $p->start(); + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Enabling output while the process is running is not possible.'); + $p->enableOutput(); + } + + public function testEnableOrDisableOutputAfterRunDoesNotThrowException() + { + $p = $this->getProcess('php -r "usleep(500000);"'); + $p->disableOutput(); + $p->start(); + $p->wait(); + $p->enableOutput(); + $p->disableOutput(); + } + + public function testDisableOutputWhileIdleTimeoutIsSet() + { + $process = $this->getProcess('sleep 3'); + $process->setIdleTimeout(1); + $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Output can not be disabled while an idle timeout is set.'); + $process->disableOutput(); + } + + public function testSetIdleTimeoutWhileOutputIsDisabled() + { + $process = $this->getProcess('sleep 3'); + $process->disableOutput(); + $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Idle timeout can not be set while the output is disabled.'); + $process->setIdleTimeout(1); + } + + public function testSetNullIdleTimeoutWhileOutputIsDisabled() + { + $process = $this->getProcess('sleep 3'); + $process->disableOutput(); + $process->setIdleTimeout(null); + } + + /** + * @dataProvider provideStartMethods + */ + public function testStartWithACallbackAndDisabledOutput($startMethod, $exception, $exceptionMessage) + { + $p = $this->getProcess('php -r "usleep(500000);"'); + $p->disableOutput(); + $this->setExpectedException($exception, $exceptionMessage); + call_user_func(array($p, $startMethod), function () {}); + } + + public function provideStartMethods() + { + return array( + array('start', 'Symfony\Component\Process\Exception\LogicException', 'Output has been disabled, enable it to allow the use of a callback.'), + array('run', 'Symfony\Component\Process\Exception\LogicException', 'Output has been disabled, enable it to allow the use of a callback.'), + array('mustRun', 'Symfony\Component\Process\Exception\LogicException', 'Output has been disabled, enable it to allow the use of a callback.'), + ); + } + + /** + * @dataProvider provideOutputFetchingMethods + */ + public function testGetOutputWhileDisabled($fetchMethod) + { + $p = $this->getProcess('php -r "usleep(500000);"'); + $p->disableOutput(); + $p->start(); + $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Output has been disabled.'); + call_user_func(array($p, $fetchMethod)); + } + + public function provideOutputFetchingMethods() + { + return array( + array('getOutput'), + array('getIncrementalOutput'), + array('getErrorOutput'), + array('getIncrementalErrorOutput'), + ); + } + public function responsesCodeProvider() { return array( @@ -597,11 +1040,18 @@ public function pipesCodeProvider() { $variations = array( 'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);', - 'include \''.__DIR__.'/ProcessTestHelper.php\';', + 'include \''.__DIR__.'/PipeStdinInStdoutStdErrStreamSelect.php\';', ); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + // Avoid XL buffers on Windows because of https://bugs.php.net/bug.php?id=65650 + $sizes = array(1, 2, 4, 8); + } else { + $sizes = array(1, 16, 64, 1024, 4096); + } + $codes = array(); - foreach (array(1, 16, 64, 1024, 4096) as $size) { + foreach ($sizes as $size) { foreach ($variations as $code) { $codes[] = array($code, $size); } @@ -621,21 +1071,34 @@ public function methodProvider() array('WorkingDirectory'), array('Env'), array('Stdin'), - array('Options') + array('Input'), + array('Options'), ); return $defaults; } /** - * @param string $commandline - * @param null $cwd - * @param array $env - * @param null $stdin - * @param integer $timeout - * @param array $options + * @param string $commandline + * @param null|string $cwd + * @param null|array $env + * @param null|string $input + * @param int $timeout + * @param array $options * * @return Process */ - abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); + abstract protected function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()); +} + +class Stringifiable +{ + public function __toString() + { + return 'stringifiable'; + } +} + +class NonStringifiable +{ } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ExecutableFinderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5fbe1e0aa70fe1c4cc6366550146d8f2a96df625 --- /dev/null +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -0,0 +1,147 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Tests; + +use Symfony\Component\Process\ExecutableFinder; + +/** + * @author Chris Smith <chris@cs278.org> + */ +class ExecutableFinderTest extends \PHPUnit_Framework_TestCase +{ + private $path; + + public function tearDown() + { + if ($this->path) { + // Restore path if it was changed. + putenv('PATH='.$this->path); + } + } + + private function setPath($path) + { + $this->path = getenv('PATH'); + putenv('PATH='.$path); + } + + public function testFind() + { + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + $this->setPath(dirname(PHP_BINARY)); + + $finder = new ExecutableFinder(); + $result = $finder->find($this->getPhpBinaryName()); + + $this->assertSamePath(PHP_BINARY, $result); + } + + public function testFindWithDefault() + { + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + $expected = 'defaultValue'; + + $this->setPath(''); + + $finder = new ExecutableFinder(); + $result = $finder->find('foo', $expected); + + $this->assertEquals($expected, $result); + } + + public function testFindWithExtraDirs() + { + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + $this->setPath(''); + + $extraDirs = array(dirname(PHP_BINARY)); + + $finder = new ExecutableFinder(); + $result = $finder->find($this->getPhpBinaryName(), null, $extraDirs); + + $this->assertSamePath(PHP_BINARY, $result); + } + + public function testFindWithOpenBaseDir() + { + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Cannot run test on windows'); + } + + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + ini_set('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/'); + + $finder = new ExecutableFinder(); + $result = $finder->find($this->getPhpBinaryName()); + + $this->assertSamePath(PHP_BINARY, $result); + } + + public function testFindProcessInOpenBasedir() + { + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + $execPath = __DIR__.'/SignalListener.php'; + + $this->setPath(''); + ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); + + $finder = new ExecutableFinder(); + $result = $finder->find($this->getPhpBinaryName(), false); + + $this->assertSamePath(PHP_BINARY, $result); + } + + private function assertSamePath($expected, $tested) + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals(strtolower($expected), strtolower($tested)); + } else { + $this->assertEquals($expected, $tested); + } + } + + private function getPhpBinaryName() + { + return basename(PHP_BINARY, defined('PHP_WINDOWS_VERSION_BUILD') ? '.exe' : ''); + } +} diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php index a4db838256afca490a3848033f17a831633c5b1b..2183e48c6436d1a770c2497dadb3c9a9a30958bd 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php @@ -18,14 +18,14 @@ function handleSignal($signal) $name = 'SIGINT'; break; default: - $name = $signal . ' (unknown)'; + $name = $signal.' (unknown)'; break; } echo "received signal $name\n"; } -declare(ticks=1); +declare (ticks = 1); pcntl_signal(SIGTERM, 'handleSignal'); pcntl_signal(SIGINT, 'handleSignal'); diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index 99c4a1e7c96144843f6836f10f7c913e123adaf2..e16f3f8bed14361076c23b39bb99e5504409af78 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -33,11 +33,44 @@ public function testFindWithPhpPath() //not executable PHP_PATH putenv('PHP_PATH=/not/executable/php'); - $this->assertFalse($f->find(), '::find() returns false for not executable php'); + $this->assertFalse($f->find(), '::find() returns false for not executable PHP'); + $this->assertFalse($f->find(false), '::find() returns false for not executable PHP'); //executable PHP_PATH putenv('PHP_PATH='.$current); - $this->assertEquals($f->find(), $current, '::find() returns the executable php'); + $this->assertEquals($f->find(), $current, '::find() returns the executable PHP'); + $this->assertEquals($f->find(false), $current, '::find() returns the executable PHP'); + } + + /** + * tests find() with the env var PHP_PATH + */ + public function testFindWithHHVM() + { + if (!defined('HHVM_VERSION')) { + $this->markTestSkipped('Should be executed in HHVM context.'); + } + + $f = new PhpExecutableFinder(); + + $current = $f->find(); + + $this->assertEquals($f->find(), $current.' --php', '::find() returns the executable PHP'); + $this->assertEquals($f->find(false), $current, '::find() returns the executable PHP'); + } + + /** + * tests find() with the env var PHP_PATH + */ + public function testFindArguments() + { + $f = new PhpExecutableFinder(); + + if (defined('HHVM_VERSION')) { + $this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments'); + } else { + $this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments'); + } } /** @@ -55,10 +88,10 @@ public function testFindWithSuffix() $current = $f->find(); - //TODO maybe php executable is custom or even windows + //TODO maybe php executable is custom or even Windows if (defined('PHP_WINDOWS_VERSION_BUILD')) { $this->assertTrue(is_executable($current)); - $this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable php with suffixes'); + $this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes'); } } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php similarity index 66% rename from core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php rename to core/vendor/symfony/process/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php index 25cfb41f9335700e06cf406bdcd9c4f5624fa9eb..89d1f6a1acafb28a42cdf137580d4a4b8347c8ed 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessTestHelper.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php @@ -8,9 +8,9 @@ $read = array(STDIN); $write = array(STDOUT, STDERR); -stream_set_blocking(STDIN, false); -stream_set_blocking(STDOUT, false); -stream_set_blocking(STDERR, false); +stream_set_blocking(STDIN, 0); +stream_set_blocking(STDOUT, 0); +stream_set_blocking(STDERR, 0); $out = $err = ''; while ($read || $write) { @@ -26,29 +26,29 @@ } if (in_array(STDOUT, $w) && strlen($out) > 0) { - $written = fwrite(STDOUT, (binary) $out, 1024); - if (false === $written) { - die(ERR_WRITE_FAILED); - } - $out = (binary) substr($out, $written); + $written = fwrite(STDOUT, (binary) $out, 32768); + if (false === $written) { + die(ERR_WRITE_FAILED); + } + $out = (binary) substr($out, $written); } if (null === $read && strlen($out) < 1) { $write = array_diff($write, array(STDOUT)); } if (in_array(STDERR, $w) && strlen($err) > 0) { - $written = fwrite(STDERR, (binary) $err, 1024); - if (false === $written) { - die(ERR_WRITE_FAILED); - } - $err = (binary) substr($err, $written); + $written = fwrite(STDERR, (binary) $err, 32768); + if (false === $written) { + die(ERR_WRITE_FAILED); + } + $err = (binary) substr($err, $written); } if (null === $read && strlen($err) < 1) { $write = array_diff($write, array(STDERR)); } if ($r) { - $str = fread(STDIN, 1024); + $str = fread(STDIN, 32768); if (false !== $str) { $out .= $str; $err .= $str; diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php index 4c88b55ce110a21a103f5b061013322b92aea8bc..56e40520754bc83dd043928ff77fbcac2ed9265a 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -17,75 +17,51 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase { public function testInheritEnvironmentVars() { - $snapshot = $_ENV; - $_ENV = $expected = array('foo' => 'bar'); + $_ENV['MY_VAR_1'] = 'foo'; - $pb = new ProcessBuilder(); - $pb->add('foo')->inheritEnvironmentVariables(); - $proc = $pb->getProcess(); - - $this->assertNull($proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); - - $_ENV = $snapshot; - } - - public function testProcessShouldInheritAndOverrideEnvironmentVars() - { - $snapshot = $_ENV; - $_ENV = array('foo' => 'bar', 'bar' => 'baz'); - $expected = array('foo' => 'foo', 'bar' => 'baz'); - - $pb = new ProcessBuilder(); - $pb->add('foo')->inheritEnvironmentVariables() - ->setEnv('foo', 'foo'); - $proc = $pb->getProcess(); - - $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); - - $_ENV = $snapshot; - } - - public function testProcessBuilderShouldNotPassEnvArrays() - { - $snapshot = $_ENV; - $_ENV = array('a' => array('b', 'c'), 'd' => 'e', 'f' => 'g'); - $expected = array('d' => 'e', 'f' => 'g'); - - $pb = new ProcessBuilder(); - $pb->add('a')->inheritEnvironmentVariables() - ->setEnv('d', 'e'); - $proc = $pb->getProcess(); + $proc = ProcessBuilder::create() + ->add('foo') + ->getProcess(); - $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() removes array values from $_ENV'); + unset($_ENV['MY_VAR_1']); - $_ENV = $snapshot; + $env = $proc->getEnv(); + $this->assertArrayHasKey('MY_VAR_1', $env); + $this->assertEquals('foo', $env['MY_VAR_1']); } - public function testInheritEnvironmentVarsByDefault() + public function testAddEnvironmentVariables() { $pb = new ProcessBuilder(); - $proc = $pb->add('foo')->getProcess(); + $env = array( + 'foo' => 'bar', + 'foo2' => 'bar2', + ); + $proc = $pb + ->add('command') + ->setEnv('foo', 'bar2') + ->addEnvironmentVariables($env) + ->inheritEnvironmentVariables(false) + ->getProcess() + ; - $this->assertNull($proc->getEnv()); + $this->assertSame($env, $proc->getEnv()); } - public function testNotReplaceExplicitlySetVars() + public function testProcessShouldInheritAndOverrideEnvironmentVars() { - $snapshot = $_ENV; - $_ENV = array('foo' => 'bar'); - $expected = array('foo' => 'baz'); + $_ENV['MY_VAR_1'] = 'foo'; - $pb = new ProcessBuilder(); - $pb - ->setEnv('foo', 'baz') - ->inheritEnvironmentVariables() + $proc = ProcessBuilder::create() + ->setEnv('MY_VAR_1', 'bar') ->add('foo') - ; - $proc = $pb->getProcess(); + ->getProcess(); - $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); + unset($_ENV['MY_VAR_1']); - $_ENV = $snapshot; + $env = $proc->getEnv(); + $this->assertArrayHasKey('MY_VAR_1', $env); + $this->assertEquals('bar', $env['MY_VAR_1']); } /** @@ -140,15 +116,35 @@ public function testPrefixIsPrependedToAllGeneratedProcess() } } + public function testArrayPrefixesArePrependedToAllGeneratedProcess() + { + $pb = new ProcessBuilder(); + $pb->setPrefix(array('/usr/bin/php', 'composer.phar')); + + $proc = $pb->setArguments(array('-v'))->getProcess(); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals('"/usr/bin/php" "composer.phar" "-v"', $proc->getCommandLine()); + } else { + $this->assertEquals("'/usr/bin/php' 'composer.phar' '-v'", $proc->getCommandLine()); + } + + $proc = $pb->setArguments(array('-i'))->getProcess(); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals('"/usr/bin/php" "composer.phar" "-i"', $proc->getCommandLine()); + } else { + $this->assertEquals("'/usr/bin/php' 'composer.phar' '-i'", $proc->getCommandLine()); + } + } + public function testShouldEscapeArguments() { - $pb = new ProcessBuilder(array('%path%', 'foo " bar')); + $pb = new ProcessBuilder(array('%path%', 'foo " bar', '%baz%baz')); $proc = $pb->getProcess(); if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->assertSame('^%"path"^% "foo "\\"" bar"', $proc->getCommandLine()); + $this->assertSame('^%"path"^% "foo \\" bar" "%baz%baz"', $proc->getCommandLine()); } else { - $this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine()); + $this->assertSame("'%path%' 'foo \" bar' '%baz%baz'", $proc->getCommandLine()); } } @@ -197,4 +193,33 @@ public function testShouldNotThrowALogicExceptionIfNoPrefix() $this->assertEquals("'/usr/bin/php'", $process->getCommandLine()); } } + + public function testShouldReturnProcessWithDisabledOutput() + { + $process = ProcessBuilder::create(array('/usr/bin/php')) + ->disableOutput() + ->getProcess(); + + $this->assertTrue($process->isOutputDisabled()); + } + + public function testShouldReturnProcessWithEnabledOutput() + { + $process = ProcessBuilder::create(array('/usr/bin/php')) + ->disableOutput() + ->enableOutput() + ->getProcess(); + + $this->assertFalse($process->isOutputDisabled()); + } + + /** + * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException + * @expectedExceptionMessage Symfony\Component\Process\ProcessBuilder::setInput only accepts strings. + */ + public function testInvalidInput() + { + $builder = ProcessBuilder::create(); + $builder->setInput(array()); + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 5da55e75ecfd0cfdb202bb6abc1274564beb5fcc..c48648f51735f8b0221d3b707180dda6a3c5b198 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -54,25 +54,33 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $process = $this->getMock( 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText'), + array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled'), array($cmd) ); $process->expects($this->once()) ->method('isSuccessful') ->will($this->returnValue(false)); + $process->expects($this->once()) ->method('getOutput') ->will($this->returnValue($output)); + $process->expects($this->once()) ->method('getErrorOutput') ->will($this->returnValue($errorOutput)); + $process->expects($this->once()) ->method('getExitCode') ->will($this->returnValue($exitCode)); + $process->expects($this->once()) ->method('getExitCodeText') ->will($this->returnValue($exitText)); + $process->expects($this->once()) + ->method('isOutputDisabled') + ->will($this->returnValue(false)); + $exception = new ProcessFailedException($process); $this->assertEquals( @@ -80,4 +88,49 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $exception->getMessage() ); } + + /** + * Tests that ProcessFailedException does not extract information from + * process output if it was previously disabled + */ + public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() + { + $cmd = 'php'; + $exitCode = 1; + $exitText = 'General error'; + + $process = $this->getMock( + 'Symfony\Component\Process\Process', + array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput'), + array($cmd) + ); + $process->expects($this->once()) + ->method('isSuccessful') + ->will($this->returnValue(false)); + + $process->expects($this->never()) + ->method('getOutput'); + + $process->expects($this->never()) + ->method('getErrorOutput'); + + $process->expects($this->once()) + ->method('getExitCode') + ->will($this->returnValue($exitCode)); + + $process->expects($this->once()) + ->method('getExitCodeText') + ->will($this->returnValue($exitText)); + + $process->expects($this->once()) + ->method('isOutputDisabled') + ->will($this->returnValue(true)); + + $exception = new ProcessFailedException($process); + + $this->assertEquals( + "The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)", + $exception->getMessage() + ); + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php index 603fac53e7877d03ccf95a59264282e608dd3e96..8ba94c114d266ee43c054384f30c7a38196cc6e7 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/ProcessUtilsTest.php @@ -27,18 +27,22 @@ public function dataArguments() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { return array( + array('"\"php\" \"-v\""', '"php" "-v"'), array('"foo bar"', 'foo bar'), array('^%"path"^%', '%path%'), - array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'), + array('"<|>\\" \\"\'f"', '<|>" "\'f'), array('""', ''), + array('"with\trailingbs\\\\"', 'with\trailingbs\\'), ); } return array( + array("'\"php\" \"-v\"'", '"php" "-v"'), array("'foo bar'", 'foo bar'), array("'%path%'", '%path%'), array("'<|>\" \"'\\''f'", '<|>" "\'f'), array("''", ''), + array("'with\\trailingbs\\'", 'with\trailingbs\\'), ); } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 29f3cd9a04da9a974fde732963854e59d53f4229..fdae5ec25e41dbb2315c5f6e94a8bb46df502bc5 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -15,6 +15,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest { /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testGetExitCode() { @@ -23,6 +24,7 @@ public function testGetExitCode() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testGetExitCodeIsNullOnStart() { @@ -31,6 +33,7 @@ public function testGetExitCodeIsNullOnStart() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testGetExitCodeIsNullOnWhenStartingAgain() { @@ -39,12 +42,39 @@ public function testGetExitCodeIsNullOnWhenStartingAgain() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testExitCodeCommandFailed() { parent::testExitCodeCommandFailed(); } + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. + */ + public function testMustRun() + { + parent::testMustRun(); + } + + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. + */ + public function testSuccessfulMustRunHasCorrectExitCode() + { + parent::testSuccessfulMustRunHasCorrectExitCode(); + } + + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + */ + public function testMustRunThrowsException() + { + parent::testMustRunThrowsException(); + } + /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException */ @@ -55,6 +85,7 @@ public function testProcessIsSignaledIfStopped() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithTermSignal() { @@ -63,6 +94,7 @@ public function testProcessWithTermSignal() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessIsNotSignaled() { @@ -71,6 +103,7 @@ public function testProcessIsNotSignaled() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithoutTermSignal() { @@ -79,6 +112,7 @@ public function testProcessWithoutTermSignal() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testCheckTimeoutOnStartedProcess() { @@ -87,6 +121,7 @@ public function testCheckTimeoutOnStartedProcess() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved. */ public function testGetPid() { @@ -94,7 +129,8 @@ public function testGetPid() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved. */ public function testGetPidIsNullBeforeStart() { @@ -102,7 +138,8 @@ public function testGetPidIsNullBeforeStart() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved. */ public function testGetPidIsNullAfterRun() { @@ -110,7 +147,8 @@ public function testGetPidIsNullAfterRun() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testExitCodeText() { @@ -122,6 +160,16 @@ public function testExitCodeText() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. + */ + public function testExitCodeTextIsNullWhenExitCodeIsNull() + { + parent::testExitCodeTextIsNullWhenExitCodeIsNull(); + } + + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testIsSuccessful() { @@ -130,6 +178,7 @@ public function testIsSuccessful() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testIsSuccessfulOnlyAfterTerminated() { @@ -138,6 +187,7 @@ public function testIsSuccessfulOnlyAfterTerminated() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. */ public function testIsNotSuccessful() { @@ -145,7 +195,17 @@ public function testIsNotSuccessful() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method. + */ + public function testTTYCommandExitCode() + { + parent::testTTYCommandExitCode(); + } + + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process can not be signaled. */ public function testSignal() { @@ -153,7 +213,8 @@ public function testSignal() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithoutTermSignalIsNotSignaled() { @@ -175,12 +236,26 @@ public function testExitCodeIsAvailableAfterSignal() $this->markTestSkipped('Signal is not supported in sigchild environment'); } + public function testRunProcessWithTimeout() + { + $this->markTestSkipped('Signal (required for timeout) is not supported in sigchild environment'); + } + + public function provideStartMethods() + { + return array( + array('start', 'Symfony\Component\Process\Exception\LogicException', 'Output has been disabled, enable it to allow the use of a callback.'), + array('run', 'Symfony\Component\Process\Exception\LogicException', 'Output has been disabled, enable it to allow the use of a callback.'), + array('mustRun', 'Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.'), + ); + } + /** * {@inheritdoc} */ - protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + protected function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()) { - $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options); + $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $input, $timeout, $options); $process->setEnhanceSigchildCompatibility(false); return $process; diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php index 296b00dfcbe0d6938f91cbed9bc82dd223c00214..3fea3ba1cd337d91409b1932277510dc11b1b0a4 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php @@ -15,6 +15,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest { /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessIsSignaledIfStopped() { @@ -23,6 +24,7 @@ public function testProcessIsSignaledIfStopped() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithTermSignal() { @@ -31,6 +33,7 @@ public function testProcessWithTermSignal() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessIsNotSignaled() { @@ -39,6 +42,7 @@ public function testProcessIsNotSignaled() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithoutTermSignal() { @@ -46,7 +50,8 @@ public function testProcessWithoutTermSignal() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved. */ public function testGetPid() { @@ -54,7 +59,8 @@ public function testGetPid() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved. */ public function testGetPidIsNullBeforeStart() { @@ -62,7 +68,8 @@ public function testGetPidIsNullBeforeStart() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process identifier can not be retrieved. */ public function testGetPidIsNullAfterRun() { @@ -78,7 +85,8 @@ public function testExitCodeText() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. The process can not be signaled. */ public function testSignal() { @@ -86,7 +94,8 @@ public function testSignal() } /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithoutTermSignalIsNotSignaled() { @@ -103,12 +112,35 @@ public function testExitCodeIsAvailableAfterSignal() $this->markTestSkipped('Signal is not supported in sigchild environment'); } + public function testStartAfterATimeout() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Restarting a timed-out process on Windows is not supported in sigchild environment'); + } + parent::testStartAfterATimeout(); + } + + public function testStopWithTimeoutIsActuallyWorking() + { + $this->markTestSkipped('Stopping with signal is not supported in sigchild environment'); + } + + public function testRunProcessWithTimeout() + { + $this->markTestSkipped('Signal (required for timeout) is not supported in sigchild environment'); + } + + public function testCheckTimeoutOnStartedProcess() + { + $this->markTestSkipped('Signal (required for timeout) is not supported in sigchild environment'); + } + /** * {@inheritdoc} */ - protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + protected function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()) { - $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $stdin, $timeout, $options); + $process = new ProcessInSigchildEnvironment($commandline, $cwd, $env, $input, $timeout, $options); $process->setEnhanceSigchildCompatibility(true); return $process; diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php index 0bf191e37170e260633dbdd451d7492b2c994593..32910e17068746718773733b8f6df9a2ab177736 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SignalListener.php @@ -1,11 +1,11 @@ <?php // required for signal handling -declare(ticks = 1); +declare (ticks = 1); -pcntl_signal(SIGUSR1, function(){echo "Caught SIGUSR1"; exit;}); +pcntl_signal(SIGUSR1, function () {echo "Caught SIGUSR1"; exit;}); -$n=0; +$n = 0; // ticks require activity to work - sleep(4); does not work while ($n < 400) { diff --git a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php index c5a571888d1e96277212f7a3a07ee04edbbbafc7..cd206ea4c390c75d88f224c33d9cf3c97dc43162 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/core/vendor/symfony/process/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -27,115 +27,183 @@ public function setUp() public function testGetExitCode() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case parent::testGetExitCode(); } public function testExitCodeCommandFailed() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case parent::testExitCodeCommandFailed(); } public function testProcessIsSignaledIfStopped() { - $this->skipIfPHPSigchild(); + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); parent::testProcessIsSignaledIfStopped(); } public function testProcessWithTermSignal() { - $this->skipIfPHPSigchild(); + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); parent::testProcessWithTermSignal(); } public function testProcessIsNotSignaled() { - $this->skipIfPHPSigchild(); + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); parent::testProcessIsNotSignaled(); } public function testProcessWithoutTermSignal() { - $this->skipIfPHPSigchild(); + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); parent::testProcessWithoutTermSignal(); } public function testExitCodeText() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case parent::testExitCodeText(); } public function testIsSuccessful() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use PID that is not available in this case parent::testIsSuccessful(); } public function testIsNotSuccessful() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use PID that is not available in this case parent::testIsNotSuccessful(); } public function testGetPid() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use PID that is not available in this case parent::testGetPid(); } public function testGetPidIsNullBeforeStart() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use PID that is not available in this case parent::testGetPidIsNullBeforeStart(); } public function testGetPidIsNullAfterRun() { - $this->skipIfPHPSigchild(); + $this->skipIfPHPSigchild(); // This test use PID that is not available in this case parent::testGetPidIsNullAfterRun(); } public function testSignal() { - $this->skipIfPHPSigchild(); + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); parent::testSignal(); } - /** - * @expectedException Symfony\Component\Process\Exception\LogicException - */ + public function testProcessWithoutTermSignalIsNotSignaled() + { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved'); + parent::testProcessWithoutTermSignalIsNotSignaled(); + } + + public function testProcessThrowsExceptionWhenExternallySignaled() + { + $this->skipIfPHPSigchild(); // This test use PID that is not available in this case + parent::testProcessThrowsExceptionWhenExternallySignaled(); + } + + public function testExitCodeIsAvailableAfterSignal() + { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + parent::testExitCodeIsAvailableAfterSignal(); + } + public function testSignalProcessNotRunning() { - $this->skipIfPHPSigchild(); + $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Can not send signal on a non running process.'); parent::testSignalProcessNotRunning(); } - /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException - */ public function testSignalWithWrongIntSignal() { - $this->skipIfPHPSigchild(); + if ($this->enabledSigchild) { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + } else { + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `-4`.'); + } parent::testSignalWithWrongIntSignal(); } - /** - * @expectedException Symfony\Component\Process\Exception\RuntimeException - */ public function testSignalWithWrongNonIntSignal() { - $this->skipIfPHPSigchild(); + if ($this->enabledSigchild) { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + } else { + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `Céphalopodes`.'); + } parent::testSignalWithWrongNonIntSignal(); } + public function testStopTerminatesProcessCleanly() + { + try { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process->run(function () use ($process) { + $process->stop(); + }); + } catch (RuntimeException $e) { + $this->fail('A call to stop() is not expected to cause wait() to throw a RuntimeException'); + } + } + + public function testKillSignalTerminatesProcessCleanly() + { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + + try { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process->run(function () use ($process) { + if ($process->isRunning()) { + $process->signal(defined('SIGKILL') ? SIGKILL : 9); + } + }); + } catch (RuntimeException $e) { + $this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException'); + } + } + + public function testTermSignalTerminatesProcessCleanly() + { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + + try { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process->run(function () use ($process) { + if ($process->isRunning()) { + $process->signal(defined('SIGTERM') ? SIGTERM : 15); + } + }); + } catch (RuntimeException $e) { + $this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException'); + } + } + + public function testStopWithTimeoutIsActuallyWorking() + { + $this->skipIfPHPSigchild(); + + parent::testStopWithTimeoutIsActuallyWorking(); + } + /** * {@inheritdoc} */ - protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) + protected function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()) { - return new Process($commandline, $cwd, $env, $stdin, $timeout, $options); + return new Process($commandline, $cwd, $env, $input, $timeout, $options); } private function skipIfPHPSigchild() @@ -144,4 +212,11 @@ private function skipIfPHPSigchild() $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed'); } } + + private function expectExceptionIfPHPSigchild($classname, $message) + { + if ($this->enabledSigchild) { + $this->setExpectedException($classname, $message); + } + } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/composer.json b/core/vendor/symfony/process/Symfony/Component/Process/composer.json index 427e63b87fce40370571256ce011963c69f12f82..b5dbfe1390a2bf674a3aba8ed2898e3241e2def1 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/composer.json +++ b/core/vendor/symfony/process/Symfony/Component/Process/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist b/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist index 9d5830f9e24e9e8ac53c3d31fcea355864c0ea85..fcb230a06259fb48e93898f972d1a52722d61dd3 100644 --- a/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist +++ b/core/vendor/symfony/process/Symfony/Component/Process/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitattributes b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitattributes deleted file mode 100644 index 80481513cff2c5c6cde0c1bff5655bcde5f34976..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/Tests export-ignore -phpunit.xml.dist export-ignore diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/CHANGELOG.md b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/CHANGELOG.md deleted file mode 100644 index 071ef3b5201b09b7b4e01e065935d3cea2bbdf9c..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/CHANGELOG.md +++ /dev/null @@ -1,14 +0,0 @@ -CHANGELOG -========= - -2.3.0 ------- - - * added PropertyAccessorBuilder, to enable or disable the support of "__call" - * added support for "__call" in the PropertyAccessor (disabled by default) - * [BC BREAK] changed PropertyAccessor to continue its search for a property or - method even if a non-public match was found. Before, a PropertyAccessDeniedException - was thrown in this case. Class PropertyAccessDeniedException was removed - now. - * deprecated PropertyAccess::getPropertyAccessor - * added PropertyAccess::createPropertyAccessor and PropertyAccess::createPropertyAccessorBuilder diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php deleted file mode 100644 index 029d48c22a9eb364a2b9f2c7a5e04c4abdfff0ac..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess\Exception; - -/** - * Thrown when a value does not match an expected type. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class UnexpectedTypeException extends RuntimeException -{ - public function __construct($value, $expectedType) - { - parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/LICENSE b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/LICENSE deleted file mode 100644 index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2013 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/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccess.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccess.php deleted file mode 100644 index 3b234df9d27536a6926b759b8d884ff775d41494..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccess.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * Entry point of the PropertyAccess component. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -final class PropertyAccess -{ - /** - * Creates a property accessor with the default configuration. - * - * @return PropertyAccessor The new property accessor - */ - public static function createPropertyAccessor() - { - return self::createPropertyAccessorBuilder()->getPropertyAccessor(); - } - - /** - * Creates a property accessor builder. - * - * @return PropertyAccessorBuilder The new property accessor builder - */ - public static function createPropertyAccessorBuilder() - { - return new PropertyAccessorBuilder(); - } - - /** - * Alias of {@link getPropertyAccessor}. - * - * @return PropertyAccessor The new property accessor - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link createPropertyAccessor()} instead. - */ - public static function getPropertyAccessor() - { - return self::createPropertyAccessor(); - } - - /** - * This class cannot be instantiated. - */ - private function __construct() - { - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessor.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessor.php deleted file mode 100644 index d48891ef275d8e573e5f5b0ca7e117238abd71e7..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ /dev/null @@ -1,457 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; -use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException; -use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; - -/** - * Default implementation of {@link PropertyAccessorInterface}. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class PropertyAccessor implements PropertyAccessorInterface -{ - const VALUE = 0; - const IS_REF = 1; - - /** - * @var Boolean - */ - private $magicCall; - - /** - * @var Boolean - */ - private $throwExceptionOnInvalidIndex; - - /** - * Should not be used by application code. Use - * {@link PropertyAccess::createPropertyAccessor()} instead. - */ - public function __construct($magicCall = false, $throwExceptionOnInvalidIndex = false) - { - $this->magicCall = $magicCall; - $this->throwExceptionOnInvalidIndex = $throwExceptionOnInvalidIndex; - } - - /** - * {@inheritdoc} - */ - public function getValue($objectOrArray, $propertyPath) - { - if (is_string($propertyPath)) { - $propertyPath = new PropertyPath($propertyPath); - } elseif (!$propertyPath instanceof PropertyPathInterface) { - throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface'); - } - - $propertyValues =& $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength(), $this->throwExceptionOnInvalidIndex); - - return $propertyValues[count($propertyValues) - 1][self::VALUE]; - } - - /** - * {@inheritdoc} - */ - public function setValue(&$objectOrArray, $propertyPath, $value) - { - if (is_string($propertyPath)) { - $propertyPath = new PropertyPath($propertyPath); - } elseif (!$propertyPath instanceof PropertyPathInterface) { - throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface'); - } - - $propertyValues =& $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1); - $overwrite = true; - - // Add the root object to the list - array_unshift($propertyValues, array( - self::VALUE => &$objectOrArray, - self::IS_REF => true, - )); - - for ($i = count($propertyValues) - 1; $i >= 0; --$i) { - $objectOrArray =& $propertyValues[$i][self::VALUE]; - - if ($overwrite) { - if (!is_object($objectOrArray) && !is_array($objectOrArray)) { - throw new UnexpectedTypeException($objectOrArray, 'object or array'); - } - - $property = $propertyPath->getElement($i); - //$singular = $propertyPath->singulars[$i]; - $singular = null; - - if ($propertyPath->isIndex($i)) { - $this->writeIndex($objectOrArray, $property, $value); - } else { - $this->writeProperty($objectOrArray, $property, $singular, $value); - } - } - - $value =& $objectOrArray; - $overwrite = !$propertyValues[$i][self::IS_REF]; - } - } - - /** - * Reads the path from an object up to a given path index. - * - * @param object|array $objectOrArray The object or array to read from - * @param PropertyPathInterface $propertyPath The property path to read - * @param integer $lastIndex The index up to which should be read - * - * @return array The values read in the path. - * - * @throws UnexpectedTypeException If a value within the path is neither object nor array. - */ - private function &readPropertiesUntil(&$objectOrArray, PropertyPathInterface $propertyPath, $lastIndex, $throwExceptionOnNonexistantIndex = false) - { - $propertyValues = array(); - - for ($i = 0; $i < $lastIndex; ++$i) { - if (!is_object($objectOrArray) && !is_array($objectOrArray)) { - throw new UnexpectedTypeException($objectOrArray, 'object or array'); - } - - $property = $propertyPath->getElement($i); - $isIndex = $propertyPath->isIndex($i); - $isArrayAccess = is_array($objectOrArray) || $objectOrArray instanceof \ArrayAccess; - - // Create missing nested arrays on demand - if ($isIndex && $isArrayAccess && !isset($objectOrArray[$property])) { - if ($throwExceptionOnNonexistantIndex) { - throw new NoSuchIndexException(sprintf('Cannot read property "%s". Available properties are "%s"', $property, print_r(array_keys($objectOrArray), true))); - } - $objectOrArray[$property] = $i + 1 < $propertyPath->getLength() ? array() : null; - } - - if ($isIndex) { - $propertyValue =& $this->readIndex($objectOrArray, $property); - } else { - $propertyValue =& $this->readProperty($objectOrArray, $property); - } - - $objectOrArray =& $propertyValue[self::VALUE]; - - $propertyValues[] =& $propertyValue; - } - - return $propertyValues; - } - - /** - * Reads a key from an array-like structure. - * - * @param \ArrayAccess|array $array The array or \ArrayAccess object to read from - * @param string|integer $index The key to read - * - * @return mixed The value of the key - * - * @throws NoSuchPropertyException If the array does not implement \ArrayAccess or it is not an array - */ - private function &readIndex(&$array, $index) - { - if (!$array instanceof \ArrayAccess && !is_array($array)) { - throw new NoSuchPropertyException(sprintf('Index "%s" cannot be read from object of type "%s" because it doesn\'t implement \ArrayAccess', $index, get_class($array))); - } - - // Use an array instead of an object since performance is very crucial here - $result = array( - self::VALUE => null, - self::IS_REF => false - ); - - if (isset($array[$index])) { - if (is_array($array)) { - $result[self::VALUE] =& $array[$index]; - $result[self::IS_REF] = true; - } else { - $result[self::VALUE] = $array[$index]; - // Objects are always passed around by reference - $result[self::IS_REF] = is_object($array[$index]) ? true : false; - } - } - - return $result; - } - - /** - * Reads the a property from an object or array. - * - * @param object $object The object to read from. - * @param string $property The property to read. - * - * @return mixed The value of the read property - * - * @throws NoSuchPropertyException If the property does not exist or is not - * public. - */ - private function &readProperty(&$object, $property) - { - // Use an array instead of an object since performance is - // very crucial here - $result = array( - self::VALUE => null, - self::IS_REF => false - ); - - if (!is_object($object)) { - throw new NoSuchPropertyException(sprintf('Cannot read property "%s" from an array. Maybe you should write the property path as "[%s]" instead?', $property, $property)); - } - - $camelProp = $this->camelize($property); - $reflClass = new \ReflectionClass($object); - $getter = 'get'.$camelProp; - $isser = 'is'.$camelProp; - $hasser = 'has'.$camelProp; - $classHasProperty = $reflClass->hasProperty($property); - - if ($reflClass->hasMethod($getter) && $reflClass->getMethod($getter)->isPublic()) { - $result[self::VALUE] = $object->$getter(); - } elseif ($reflClass->hasMethod($isser) && $reflClass->getMethod($isser)->isPublic()) { - $result[self::VALUE] = $object->$isser(); - } elseif ($reflClass->hasMethod($hasser) && $reflClass->getMethod($hasser)->isPublic()) { - $result[self::VALUE] = $object->$hasser(); - } elseif ($reflClass->hasMethod('__get') && $reflClass->getMethod('__get')->isPublic()) { - $result[self::VALUE] = $object->$property; - } elseif ($classHasProperty && $reflClass->getProperty($property)->isPublic()) { - $result[self::VALUE] =& $object->$property; - $result[self::IS_REF] = true; - } elseif (!$classHasProperty && property_exists($object, $property)) { - // Needed to support \stdClass instances. We need to explicitly - // exclude $classHasProperty, otherwise if in the previous clause - // a *protected* property was found on the class, property_exists() - // returns true, consequently the following line will result in a - // fatal error. - $result[self::VALUE] =& $object->$property; - $result[self::IS_REF] = true; - } elseif ($this->magicCall && $reflClass->hasMethod('__call') && $reflClass->getMethod('__call')->isPublic()) { - // we call the getter and hope the __call do the job - $result[self::VALUE] = $object->$getter(); - } else { - $methods = array($getter, $isser, $hasser, '__get'); - if ($this->magicCall) { - $methods[] = '__call'; - } - - throw new NoSuchPropertyException(sprintf( - 'Neither the property "%s" nor one of the methods "%s()" '. - 'exist and have public access in class "%s".', - $property, - implode('()", "', $methods), - $reflClass->name - )); - } - - // Objects are always passed around by reference - if (is_object($result[self::VALUE])) { - $result[self::IS_REF] = true; - } - - return $result; - } - - /** - * Sets the value of the property at the given index in the path - * - * @param \ArrayAccess|array $array An array or \ArrayAccess object to write to - * @param string|integer $index The index to write at - * @param mixed $value The value to write - * - * @throws NoSuchPropertyException If the array does not implement \ArrayAccess or it is not an array - */ - private function writeIndex(&$array, $index, $value) - { - if (!$array instanceof \ArrayAccess && !is_array($array)) { - throw new NoSuchPropertyException(sprintf('Index "%s" cannot be modified in object of type "%s" because it doesn\'t implement \ArrayAccess', $index, get_class($array))); - } - - $array[$index] = $value; - } - - /** - * Sets the value of the property at the given index in the path - * - * @param object|array $object The object or array to write to - * @param string $property The property to write - * @param string|null $singular The singular form of the property name or null - * @param mixed $value The value to write - * - * @throws NoSuchPropertyException If the property does not exist or is not - * public. - */ - private function writeProperty(&$object, $property, $singular, $value) - { - $guessedAdders = ''; - - if (!is_object($object)) { - throw new NoSuchPropertyException(sprintf('Cannot write property "%s" to an array. Maybe you should write the property path as "[%s]" instead?', $property, $property)); - } - - $reflClass = new \ReflectionClass($object); - $plural = $this->camelize($property); - - // Any of the two methods is required, but not yet known - $singulars = null !== $singular ? array($singular) : (array) StringUtil::singularify($plural); - - if (is_array($value) || $value instanceof \Traversable) { - $methods = $this->findAdderAndRemover($reflClass, $singulars); - - if (null !== $methods) { - // At this point the add and remove methods have been found - // Use iterator_to_array() instead of clone in order to prevent side effects - // see https://github.com/symfony/symfony/issues/4670 - $itemsToAdd = is_object($value) ? iterator_to_array($value) : $value; - $itemToRemove = array(); - $propertyValue = $this->readProperty($object, $property); - $previousValue = $propertyValue[self::VALUE]; - - if (is_array($previousValue) || $previousValue instanceof \Traversable) { - foreach ($previousValue as $previousItem) { - foreach ($value as $key => $item) { - if ($item === $previousItem) { - // Item found, don't add - unset($itemsToAdd[$key]); - - // Next $previousItem - continue 2; - } - } - - // Item not found, add to remove list - $itemToRemove[] = $previousItem; - } - } - - foreach ($itemToRemove as $item) { - call_user_func(array($object, $methods[1]), $item); - } - - foreach ($itemsToAdd as $item) { - call_user_func(array($object, $methods[0]), $item); - } - - return; - } else { - // It is sufficient to include only the adders in the error - // message. If the user implements the adder but not the remover, - // an exception will be thrown in findAdderAndRemover() that - // the remover has to be implemented as well. - $guessedAdders = '"add'.implode('()", "add', $singulars).'()", '; - } - } - - $setter = 'set'.$this->camelize($property); - $classHasProperty = $reflClass->hasProperty($property); - - if ($reflClass->hasMethod($setter) && $reflClass->getMethod($setter)->isPublic()) { - $object->$setter($value); - } elseif ($reflClass->hasMethod('__set') && $reflClass->getMethod('__set')->isPublic()) { - $object->$property = $value; - } elseif ($classHasProperty && $reflClass->getProperty($property)->isPublic()) { - $object->$property = $value; - } elseif (!$classHasProperty && property_exists($object, $property)) { - // Needed to support \stdClass instances. We need to explicitly - // exclude $classHasProperty, otherwise if in the previous clause - // a *protected* property was found on the class, property_exists() - // returns true, consequently the following line will result in a - // fatal error. - $object->$property = $value; - } elseif ($this->magicCall && $reflClass->hasMethod('__call') && $reflClass->getMethod('__call')->isPublic()) { - // we call the getter and hope the __call do the job - $object->$setter($value); - } else { - throw new NoSuchPropertyException(sprintf( - 'Neither the property "%s" nor one of the methods %s"%s()", '. - '"__set()" or "__call()" exist and have public access in class "%s".', - $property, - $guessedAdders, - $setter, - $reflClass->name - )); - } - } - - /** - * Camelizes a given string. - * - * @param string $string Some string - * - * @return string The camelized version of the string - */ - private function camelize($string) - { - return preg_replace_callback('/(^|_|\.)+(.)/', function ($match) { return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); }, $string); - } - - /** - * Searches for add and remove methods. - * - * @param \ReflectionClass $reflClass The reflection class for the given object - * @param array $singulars The singular form of the property name or null - * - * @return array|null An array containing the adder and remover when found, null otherwise - * - * @throws NoSuchPropertyException If the property does not exist - */ - private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars) - { - foreach ($singulars as $singular) { - $addMethod = 'add'.$singular; - $removeMethod = 'remove'.$singular; - - $addMethodFound = $this->isAccessible($reflClass, $addMethod, 1); - $removeMethodFound = $this->isAccessible($reflClass, $removeMethod, 1); - - if ($addMethodFound && $removeMethodFound) { - return array($addMethod, $removeMethod); - } - - if ($addMethodFound xor $removeMethodFound) { - throw new NoSuchPropertyException(sprintf( - 'Found the public method "%s()", but did not find a public "%s()" on class %s', - $addMethodFound ? $addMethod : $removeMethod, - $addMethodFound ? $removeMethod : $addMethod, - $reflClass->name - )); - } - } - - return null; - } - - /** - * Returns whether a method is public and has a specific number of required parameters. - * - * @param \ReflectionClass $class The class of the method - * @param string $methodName The method name - * @param integer $parameters The number of parameters - * - * @return Boolean Whether the method is public and has $parameters - * required parameters - */ - private function isAccessible(\ReflectionClass $class, $methodName, $parameters) - { - if ($class->hasMethod($methodName)) { - $method = $class->getMethod($methodName); - - if ($method->isPublic() && $method->getNumberOfRequiredParameters() === $parameters) { - return true; - } - } - - return false; - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php deleted file mode 100644 index 50b872f3a35c73fda36afe3b8a3e0cf8acf6cdfc..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * A configurable builder for PropertyAccessorInterface objects. - * - * @author Jérémie Augustin <jeremie.augustin@pixel-cookers.com> - */ -class PropertyAccessorBuilder -{ - /** - * @var Boolean - */ - private $magicCall = false; - - /** - * @var Boolean - */ - private $throwExceptionOnInvalidIndex = false; - - /** - * Enables the use of "__call" by the PropertyAccessor. - * - * @return PropertyAccessorBuilder The builder object - */ - public function enableMagicCall() - { - $this->magicCall = true; - - return $this; - } - - /** - * Disables the use of "__call" by the PropertyAccessor. - * - * @return PropertyAccessorBuilder The builder object - */ - public function disableMagicCall() - { - $this->magicCall = false; - - return $this; - } - - /** - * @return Boolean true if the use of "__call" by the PropertyAccessor is enabled - */ - public function isMagicCallEnabled() - { - return $this->magicCall; - } - - /** - * Enables exceptions in read context for array by PropertyAccessor - * - * @return PropertyAccessorBuilder The builder object - */ - public function enableExceptionOnInvalidIndex() - { - $this->throwExceptionOnInvalidIndex = true; - - return $this; - } - - /** - * Disables exceptions in read context for array by PropertyAccessor - * - * @return PropertyAccessorBuilder The builder object - */ - public function disableExceptionOnInvalidIndex() - { - $this->throwExceptionOnInvalidIndex = false; - - return $this; - } - - /** - * @return Boolean true is exceptions in read context for array is enabled - */ - public function isExceptionOnInvalidIndexEnabled() - { - return $this->throwExceptionOnInvalidIndex; - } - - /** - * Builds and returns a new propertyAccessor object. - * - * @return PropertyAccessorInterface The built propertyAccessor - */ - public function getPropertyAccessor() - { - return new PropertyAccessor($this->magicCall, $this->throwExceptionOnInvalidIndex); - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php deleted file mode 100644 index 1eed7c7b074cf4f91e23d8980349128ff68b8d09..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * Writes and reads values to/from an object/array graph. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -interface PropertyAccessorInterface -{ - /** - * Sets the value at the end of the property path of the object - * - * Example: - * - * use Symfony\Component\PropertyAccess\PropertyAccess; - * - * $propertyAccessor = PropertyAccess::getPropertyAccessor(); - * - * echo $propertyAccessor->setValue($object, 'child.name', 'Fabien'); - * // equals echo $object->getChild()->setName('Fabien'); - * - * This method first tries to find a public setter for each property in the - * path. The name of the setter must be the camel-cased property name - * prefixed with "set". - * - * If the setter does not exist, this method tries to find a public - * property. The value of the property is then changed. - * - * If neither is found, an exception is thrown. - * - * @param object|array $objectOrArray The object or array to modify - * @param string|PropertyPathInterface $propertyPath The property path to modify - * @param mixed $value The value to set at the end of the property path - * - * @throws Exception\NoSuchPropertyException If a property does not exist or is not public. - * @throws Exception\UnexpectedTypeException If a value within the path is neither object - * nor array - */ - public function setValue(&$objectOrArray, $propertyPath, $value); - - /** - * Returns the value at the end of the property path of the object - * - * Example: - * - * use Symfony\Component\PropertyAccess\PropertyAccess; - * - * $propertyAccessor = PropertyAccess::getPropertyAccessor(); - * - * echo $propertyAccessor->getValue($object, 'child.name); - * // equals echo $object->getChild()->getName(); - * - * This method first tries to find a public getter for each property in the - * path. The name of the getter must be the camel-cased property name - * prefixed with "get", "is", or "has". - * - * If the getter does not exist, this method tries to find a public - * property. The value of the property is then returned. - * - * If none of them are found, an exception is thrown. - * - * @param object|array $objectOrArray The object or array to traverse - * @param string|PropertyPathInterface $propertyPath The property path to read - * - * @return mixed The value at the end of the property path - * - * @throws Exception\NoSuchPropertyException If a property does not exist or is not public. - */ - public function getValue($objectOrArray, $propertyPath); -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPath.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPath.php deleted file mode 100644 index 840fc71572339fed682f1ed4f807572745e7244d..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPath.php +++ /dev/null @@ -1,225 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException; -use Symfony\Component\PropertyAccess\Exception\OutOfBoundsException; -use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; - -/** - * Default implementation of {@link PropertyPathInterface}. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class PropertyPath implements \IteratorAggregate, PropertyPathInterface -{ - /** - * Character used for separating between plural and singular of an element. - * @var string - */ - const SINGULAR_SEPARATOR = '|'; - - /** - * The elements of the property path - * @var array - */ - private $elements = array(); - - /** - * The singular forms of the elements in the property path. - * @var array - */ - private $singulars = array(); - - /** - * The number of elements in the property path - * @var integer - */ - private $length; - - /** - * Contains a Boolean for each property in $elements denoting whether this - * element is an index. It is a property otherwise. - * @var array - */ - private $isIndex = array(); - - /** - * String representation of the path - * @var string - */ - private $pathAsString; - - /** - * Constructs a property path from a string. - * - * @param PropertyPath|string $propertyPath The property path as string or instance - * - * @throws UnexpectedTypeException If the given path is not a string - * @throws InvalidPropertyPathException If the syntax of the property path is not valid - */ - public function __construct($propertyPath) - { - // Can be used as copy constructor - if ($propertyPath instanceof PropertyPath) { - /* @var PropertyPath $propertyPath */ - $this->elements = $propertyPath->elements; - $this->singulars = $propertyPath->singulars; - $this->length = $propertyPath->length; - $this->isIndex = $propertyPath->isIndex; - $this->pathAsString = $propertyPath->pathAsString; - - return; - } - if (!is_string($propertyPath)) { - throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPath'); - } - - if ('' === $propertyPath) { - throw new InvalidPropertyPathException('The property path should not be empty.'); - } - - $this->pathAsString = $propertyPath; - $position = 0; - $remaining = $propertyPath; - - // first element is evaluated differently - no leading dot for properties - $pattern = '/^(([^\.\[]+)|\[([^\]]+)\])(.*)/'; - - while (preg_match($pattern, $remaining, $matches)) { - if ('' !== $matches[2]) { - $element = $matches[2]; - $this->isIndex[] = false; - } else { - $element = $matches[3]; - $this->isIndex[] = true; - } - // Disabled this behaviour as the syntax is not yet final - //$pos = strpos($element, self::SINGULAR_SEPARATOR); - $pos = false; - $singular = null; - - if (false !== $pos) { - $singular = substr($element, $pos + 1); - $element = substr($element, 0, $pos); - } - - $this->elements[] = $element; - $this->singulars[] = $singular; - - $position += strlen($matches[1]); - $remaining = $matches[4]; - $pattern = '/^(\.(\w+)|\[([^\]]+)\])(.*)/'; - } - - if ('' !== $remaining) { - throw new InvalidPropertyPathException(sprintf( - 'Could not parse property path "%s". Unexpected token "%s" at position %d', - $propertyPath, - $remaining{0}, - $position - )); - } - - $this->length = count($this->elements); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->pathAsString; - } - - /** - * {@inheritdoc} - */ - public function getLength() - { - return $this->length; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - if ($this->length <= 1) { - return null; - } - - $parent = clone $this; - - --$parent->length; - $parent->pathAsString = substr($parent->pathAsString, 0, max(strrpos($parent->pathAsString, '.'), strrpos($parent->pathAsString, '['))); - array_pop($parent->elements); - array_pop($parent->singulars); - array_pop($parent->isIndex); - - return $parent; - } - - /** - * Returns a new iterator for this path - * - * @return PropertyPathIteratorInterface - */ - public function getIterator() - { - return new PropertyPathIterator($this); - } - - /** - * {@inheritdoc} - */ - public function getElements() - { - return $this->elements; - } - - /** - * {@inheritdoc} - */ - public function getElement($index) - { - if (!isset($this->elements[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index)); - } - - return $this->elements[$index]; - } - - /** - * {@inheritdoc} - */ - public function isProperty($index) - { - if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index)); - } - - return !$this->isIndex[$index]; - } - - /** - * {@inheritdoc} - */ - public function isIndex($index) - { - if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index)); - } - - return $this->isIndex[$index]; - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathBuilder.php deleted file mode 100644 index f4eb0fb93ff508c64aef2868ba161ef0e8e30f01..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ /dev/null @@ -1,306 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -use Symfony\Component\PropertyAccess\Exception\OutOfBoundsException; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class PropertyPathBuilder -{ - /** - * @var array - */ - private $elements = array(); - - /** - * @var array - */ - private $isIndex = array(); - - /** - * Creates a new property path builder. - * - * @param null|PropertyPathInterface|string $path The path to initially store - * in the builder. Optional. - */ - public function __construct($path = null) - { - if (null !== $path) { - $this->append($path); - } - } - - /** - * Appends a (sub-) path to the current path. - * - * @param PropertyPathInterface|string $path The path to append. - * @param integer $offset The offset where the appended - * piece starts in $path. - * @param integer $length The length of the appended piece. - * If 0, the full path is appended. - */ - public function append($path, $offset = 0, $length = 0) - { - if (is_string($path)) { - $path = new PropertyPath($path); - } - - if (0 === $length) { - $end = $path->getLength(); - } else { - $end = $offset + $length; - } - - for (; $offset < $end; ++$offset) { - $this->elements[] = $path->getElement($offset); - $this->isIndex[] = $path->isIndex($offset); - } - } - - /** - * Appends an index element to the current path. - * - * @param string $name The name of the appended index - */ - public function appendIndex($name) - { - $this->elements[] = $name; - $this->isIndex[] = true; - } - - /** - * Appends a property element to the current path. - * - * @param string $name The name of the appended property - */ - public function appendProperty($name) - { - $this->elements[] = $name; - $this->isIndex[] = false; - } - - /** - * Removes elements from the current path. - * - * @param integer $offset The offset at which to remove - * @param integer $length The length of the removed piece - * - * @throws OutOfBoundsException if offset is invalid - */ - public function remove($offset, $length = 1) - { - if (!isset($this->elements[$offset])) { - throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset)); - } - - $this->resize($offset, $length, 0); - } - - /** - * Replaces a sub-path by a different (sub-) path. - * - * @param integer $offset The offset at which to replace. - * @param integer $length The length of the piece to replace. - * @param PropertyPathInterface|string $path The path to insert. - * @param integer $pathOffset The offset where the inserted piece - * starts in $path. - * @param integer $pathLength The length of the inserted piece. - * If 0, the full path is inserted. - * - * @throws OutOfBoundsException If the offset is invalid - */ - public function replace($offset, $length, $path, $pathOffset = 0, $pathLength = 0) - { - if (is_string($path)) { - $path = new PropertyPath($path); - } - - if ($offset < 0 && abs($offset) <= $this->getLength()) { - $offset = $this->getLength() + $offset; - } elseif (!isset($this->elements[$offset])) { - throw new OutOfBoundsException('The offset ' . $offset . ' is not within the property path'); - } - - if (0 === $pathLength) { - $pathLength = $path->getLength() - $pathOffset; - } - - $this->resize($offset, $length, $pathLength); - - for ($i = 0; $i < $pathLength; ++$i) { - $this->elements[$offset + $i] = $path->getElement($pathOffset + $i); - $this->isIndex[$offset + $i] = $path->isIndex($pathOffset + $i); - } - } - - /** - * Replaces a property element by an index element. - * - * @param integer $offset The offset at which to replace - * @param string $name The new name of the element. Optional. - * - * @throws OutOfBoundsException If the offset is invalid - */ - public function replaceByIndex($offset, $name = null) - { - if (!isset($this->elements[$offset])) { - throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset)); - } - - if (null !== $name) { - $this->elements[$offset] = $name; - } - - $this->isIndex[$offset] = true; - } - - /** - * Replaces an index element by a property element. - * - * @param integer $offset The offset at which to replace - * @param string $name The new name of the element. Optional. - * - * @throws OutOfBoundsException If the offset is invalid - */ - public function replaceByProperty($offset, $name = null) - { - if (!isset($this->elements[$offset])) { - throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset)); - } - - if (null !== $name) { - $this->elements[$offset] = $name; - } - - $this->isIndex[$offset] = false; - } - - /** - * Returns the length of the current path. - * - * @return integer The path length - */ - public function getLength() - { - return count($this->elements); - } - - /** - * Returns the current property path. - * - * @return PropertyPathInterface The constructed property path - */ - public function getPropertyPath() - { - $pathAsString = $this->__toString(); - - return '' !== $pathAsString ? new PropertyPath($pathAsString) : null; - } - - /** - * Returns the current property path as string. - * - * @return string The property path as string - */ - public function __toString() - { - $string = ''; - - foreach ($this->elements as $offset => $element) { - if ($this->isIndex[$offset]) { - $element = '['.$element.']'; - } elseif ('' !== $string) { - $string .= '.'; - } - - $string .= $element; - } - - return $string; - } - - /** - * Resizes the path so that a chunk of length $cutLength is - * removed at $offset and another chunk of length $insertionLength - * can be inserted. - * - * @param integer $offset The offset where the removed chunk starts - * @param integer $cutLength The length of the removed chunk - * @param integer $insertionLength The length of the inserted chunk - */ - private function resize($offset, $cutLength, $insertionLength) - { - // Nothing else to do in this case - if ($insertionLength === $cutLength) { - return; - } - - $length = count($this->elements); - - if ($cutLength > $insertionLength) { - // More elements should be removed than inserted - $diff = $cutLength - $insertionLength; - $newLength = $length - $diff; - - // Shift elements to the left (left-to-right until the new end) - // Max allowed offset to be shifted is such that - // $offset + $diff < $length (otherwise invalid index access) - // i.e. $offset < $length - $diff = $newLength - for ($i = $offset; $i < $newLength; ++$i) { - $this->elements[$i] = $this->elements[$i + $diff]; - $this->isIndex[$i] = $this->isIndex[$i + $diff]; - } - - // All remaining elements should be removed - for (; $i < $length; ++$i) { - unset($this->elements[$i]); - unset($this->isIndex[$i]); - } - } else { - $diff = $insertionLength - $cutLength; - - $newLength = $length + $diff; - $indexAfterInsertion = $offset + $insertionLength; - - // $diff <= $insertionLength - // $indexAfterInsertion >= $insertionLength - // => $diff <= $indexAfterInsertion - - // In each of the following loops, $i >= $diff must hold, - // otherwise ($i - $diff) becomes negative. - - // Shift old elements to the right to make up space for the - // inserted elements. This needs to be done left-to-right in - // order to preserve an ascending array index order - // Since $i = max($length, $indexAfterInsertion) and $indexAfterInsertion >= $diff, - // $i >= $diff is guaranteed. - for ($i = max($length, $indexAfterInsertion); $i < $newLength; ++$i) { - $this->elements[$i] = $this->elements[$i - $diff]; - $this->isIndex[$i] = $this->isIndex[$i - $diff]; - } - - // Shift remaining elements to the right. Do this right-to-left - // so we don't overwrite elements before copying them - // The last written index is the immediate index after the inserted - // string, because the indices before that will be overwritten - // anyway. - // Since $i >= $indexAfterInsertion and $indexAfterInsertion >= $diff, - // $i >= $diff is guaranteed. - for ($i = $length - 1; $i >= $indexAfterInsertion; --$i) { - $this->elements[$i] = $this->elements[$i - $diff]; - $this->isIndex[$i] = $this->isIndex[$i - $diff]; - } - } - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathInterface.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathInterface.php deleted file mode 100644 index 95f34ffae6daf224ce9a800a051886c84c5e2fe1..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathInterface.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * A sequence of property names or array indices. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -interface PropertyPathInterface extends \Traversable -{ - /** - * Returns the string representation of the property path - * - * @return string The path as string - */ - public function __toString(); - - /** - * Returns the length of the property path, i.e. the number of elements. - * - * @return integer The path length - */ - public function getLength(); - - /** - * Returns the parent property path. - * - * The parent property path is the one that contains the same items as - * this one except for the last one. - * - * If this property path only contains one item, null is returned. - * - * @return PropertyPath The parent path or null - */ - public function getParent(); - - /** - * Returns the elements of the property path as array - * - * @return array An array of property/index names - */ - public function getElements(); - - /** - * Returns the element at the given index in the property path - * - * @param integer $index The index key - * - * @return string A property or index name - * - * @throws Exception\OutOfBoundsException If the offset is invalid - */ - public function getElement($index); - - /** - * Returns whether the element at the given index is a property - * - * @param integer $index The index in the property path - * - * @return Boolean Whether the element at this index is a property - * - * @throws Exception\OutOfBoundsException If the offset is invalid - */ - public function isProperty($index); - - /** - * Returns whether the element at the given index is an array index - * - * @param integer $index The index in the property path - * - * @return Boolean Whether the element at this index is an array index - * - * @throws Exception\OutOfBoundsException If the offset is invalid - */ - public function isIndex($index); -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIterator.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIterator.php deleted file mode 100644 index d6cd49caa077a90561ca7cddf6da54e063eff378..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIterator.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * Traverses a property path and provides additional methods to find out - * information about the current element - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class PropertyPathIterator extends \ArrayIterator implements PropertyPathIteratorInterface -{ - /** - * The traversed property path - * @var PropertyPathInterface - */ - protected $path; - - /** - * Constructor. - * - * @param PropertyPathInterface $path The property path to traverse - */ - public function __construct(PropertyPathInterface $path) - { - parent::__construct($path->getElements()); - - $this->path = $path; - } - - /** - * {@inheritdoc} - */ - public function isIndex() - { - return $this->path->isIndex($this->key()); - } - - /** - * {@inheritdoc} - */ - public function isProperty() - { - return $this->path->isProperty($this->key()); - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php deleted file mode 100644 index cb43f8d7ea5907f76ff7f90c5d18f219b88cb05b..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - */ -interface PropertyPathIteratorInterface extends \Iterator, \SeekableIterator -{ - /** - * Returns whether the current element in the property path is an array - * index. - * - * @return Boolean - */ - public function isIndex(); - - /** - * Returns whether the current element in the property path is a property - * name. - * - * @return Boolean - */ - public function isProperty(); -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/README.md b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/README.md deleted file mode 100644 index 79b6ebca5aa70f4aca7e5218d2ab693f638be1e5..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/README.md +++ /dev/null @@ -1,14 +0,0 @@ -PropertyAccess Component -======================== - -PropertyAccess reads/writes values from/to object/array graphs using a simple -string notation. - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/PropertyAccess/ - $ composer.phar install - $ phpunit diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/StringUtil.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/StringUtil.php deleted file mode 100644 index 509bce4b92d8c46a3e1f2e77a084518b8a25b3a9..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/StringUtil.php +++ /dev/null @@ -1,201 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\PropertyAccess; - -/** - * Creates singulars from plurals. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class StringUtil -{ - /** - * Map english plural to singular suffixes - * - * @var array - * - * @see http://english-zone.com/spelling/plurals.html - * @see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English - */ - private static $pluralMap = array( - // First entry: plural suffix, reversed - // Second entry: length of plural suffix - // Third entry: Whether the suffix may succeed a vocal - // Fourth entry: Whether the suffix may succeed a consonant - // Fifth entry: singular suffix, normal - - // bacteria (bacterium), criteria (criterion), phenomena (phenomenon) - array('a', 1, true, true, array('on', 'um')), - - // nebulae (nebula) - array('ea', 2, true, true, 'a'), - - // mice (mouse), lice (louse) - array('eci', 3, false, true, 'ouse'), - - // geese (goose) - array('esee', 4, false, true, 'oose'), - - // fungi (fungus), alumni (alumnus), syllabi (syllabus), radii (radius) - array('i', 1, true, true, 'us'), - - // men (man), women (woman) - array('nem', 3, true, true, 'man'), - - // children (child) - array('nerdlihc', 8, true, true, 'child'), - - // oxen (ox) - array('nexo', 4, false, false, 'ox'), - - // indices (index), appendices (appendix), prices (price) - array('seci', 4, false, true, array('ex', 'ix', 'ice')), - - // babies (baby) - array('sei', 3, false, true, 'y'), - - // accesses (access), addresses (address), kisses (kiss) - array('sess', 4, true, false, 'ss'), - - // analyses (analysis), ellipses (ellipsis), funguses (fungus), - // neuroses (neurosis), theses (thesis), emphases (emphasis), - // oases (oasis), crises (crisis), houses (house), bases (base), - // atlases (atlas) - array('ses', 3, true, true, array('s', 'se', 'sis')), - - // objectives (objective), alternative (alternatives) - array('sevit', 5, true, true, 'tive'), - - // lives (life), wives (wife) - array('sevi', 4, false, true, 'ife'), - - // moves (move) - array('sevom', 5, true, true, 'move'), - - // hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf) - array('sev', 3, true, true, 'f'), - - // axes (axis), axes (ax), axes (axe) - array('sexa', 4, false, false, array('ax', 'axe', 'axis')), - - // indexes (index), matrixes (matrix) - array('sex', 3, true, false, 'x'), - - // quizzes (quiz) - array('sezz', 4, true, false, 'z'), - - // bureaus (bureau) - array('suae', 4, false, true, 'eau'), - - // roses (rose), garages (garage), cassettes (cassette), - // waltzes (waltz), heroes (hero), bushes (bush), arches (arch), - // shoes (shoe) - array('se', 2, true, true, array('', 'e')), - - // tags (tag) - array('s', 1, true, true, ''), - - // chateaux (chateau) - array('xuae', 4, false, true, 'eau'), - ); - - /** - * This class should not be instantiated - */ - private function __construct() {} - - /** - * Returns the singular form of a word - * - * If the method can't determine the form with certainty, an array of the - * possible singulars is returned. - * - * @param string $plural A word in plural form - * @return string|array The singular form or an array of possible singular - * forms - */ - public static function singularify($plural) - { - $pluralRev = strrev($plural); - $lowerPluralRev = strtolower($pluralRev); - $pluralLength = strlen($lowerPluralRev); - - // The outer loop iterates over the entries of the plural table - // The inner loop $j iterates over the characters of the plural suffix - // in the plural table to compare them with the characters of the actual - // given plural suffix - foreach (self::$pluralMap as $map) { - $suffix = $map[0]; - $suffixLength = $map[1]; - $j = 0; - - // Compare characters in the plural table and of the suffix of the - // given plural one by one - while ($suffix[$j] === $lowerPluralRev[$j]) { - // Let $j point to the next character - ++$j; - - // Successfully compared the last character - // Add an entry with the singular suffix to the singular array - if ($j === $suffixLength) { - // Is there any character preceding the suffix in the plural string? - if ($j < $pluralLength) { - $nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]); - - if (!$map[2] && $nextIsVocal) { - // suffix may not succeed a vocal but next char is one - break; - } - - if (!$map[3] && !$nextIsVocal) { - // suffix may not succeed a consonant but next char is one - break; - } - } - - $newBase = substr($plural, 0, $pluralLength - $suffixLength); - $newSuffix = $map[4]; - - // Check whether the first character in the plural suffix - // is uppercased. If yes, uppercase the first character in - // the singular suffix too - $firstUpper = ctype_upper($pluralRev[$j - 1]); - - if (is_array($newSuffix)) { - $singulars = array(); - - foreach ($newSuffix as $newSuffixEntry) { - $singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry); - } - - return $singulars; - } - - return $newBase.($firstUpper ? ucFirst($newSuffix) : $newSuffix); - } - - // Suffix is longer than word - if ($j === $pluralLength) { - break; - } - } - } - - // Convert teeth to tooth, feet to foot - if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3) { - return substr_replace($plural, 'oo', $pos, 2); - } - - // Assume that plural and singular is identical - return $plural; - } -} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/composer.json b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/composer.json deleted file mode 100644 index d79eba11fdcabc452deb9a2c5d12b10871125722..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/composer.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "symfony/property-access", - "type": "library", - "description": "Symfony PropertyAccess Component", - "keywords": ["property", "index", "access", "object", "array", "extraction", "injection", "reflection", "property path"], - "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" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\PropertyAccess\\": "" } - }, - "target-dir": "Symfony/Component/PropertyAccess", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - } -} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php index ebda0971c5fda315b10a58c72f1aa9f9b85680e9..90521c0be8e0d4968ec815dcdd67591c539601a9 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php @@ -15,6 +15,7 @@ * Annotation class for @Route(). * * @Annotation + * @Target({"CLASS", "METHOD"}) * * @author Fabien Potencier <fabien@symfony.com> */ diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md index f0c616d080b5ea7aa706875882f5bacf6be92e5b..8b604ead11510b154d206778433b62c7d692b55b 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +2.5.0 +----- + + * [DEPRECATION] The `ApacheMatcherDumper` and `ApacheUrlMatcher` were deprecated and + will be removed in Symfony 3.0, since the performance gains were minimal and + it's hard to replicate the behaviour of PHP implementation. + 2.3.0 ----- diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php b/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php index 7878455427d41307113bee7ca1710cc5225c9e84..5e4c96073e718d3837b21e82c72894783bb22655 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php @@ -130,5 +130,4 @@ public function getHostVariables() { return $this->hostVariables; } - } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php index 8c25f34b120abb01748b68927bc5ed193ac45053..3cf7edfa7b1f3af0dcca5a3add34cefa93e08fa0 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php @@ -41,7 +41,7 @@ interface ConfigurableRequirementsInterface * Enables or disables the exception on incorrect parameters. * Passing null will deactivate the requirements check completely. * - * @param Boolean|null $enabled + * @param bool|null $enabled */ public function setStrictRequirements($enabled); @@ -49,7 +49,7 @@ public function setStrictRequirements($enabled); * Returns whether to throw an exception on incorrect parameters. * Null means the requirements check is deactivated completely. * - * @return Boolean|null + * @return bool|null */ public function isStrictRequirements(); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php index 4d19d2a2ec8db81da3061c579029906b29ea6b5d..8d4203019c4f1b227d7a78d16bab12066e45a80f 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php @@ -57,7 +57,7 @@ public function dump(array $options = array()) */ class {$options['class']} extends {$options['base_class']} { - static private \$declaredRoutes = {$this->generateDeclaredRoutes()}; + private static \$declaredRoutes = {$this->generateDeclaredRoutes()}; /** * Constructor. diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php index 468708479bbe9c1ad8bafabb3c5a79fdabf23b00..ccb9d968c8b9e2d34509371af74c2c42c2b03698 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -40,7 +40,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt protected $context; /** - * @var Boolean|null + * @var bool|null */ protected $strictRequirements = true; @@ -114,7 +114,7 @@ public function getContext() */ public function setStrictRequirements($enabled) { - $this->strictRequirements = null === $enabled ? null : (Boolean) $enabled; + $this->strictRequirements = null === $enabled ? null : (bool) $enabled; } /** @@ -126,7 +126,7 @@ public function isStrictRequirements() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { @@ -171,7 +171,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $this->logger->error($message); } - return null; + return; } $url = $token[1].$mergedParams[$token[3]].$url; @@ -219,7 +219,6 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $referenceType = self::ABSOLUTE_URL; $scheme = current($requiredSchemes); } - } elseif (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) { // We do this for BC; to be removed if _scheme is not supported anymore $referenceType = self::ABSOLUTE_URL; @@ -241,7 +240,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $this->logger->error($message); } - return null; + return; } $routeHost = $token[1].$mergedParams[$token[3]].$routeHost; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index 8e3b2778b977e4e3343e8d37ff9422b0ba7e29d9..b89966d08c0b24ac3c632f4c9cf974e16f38fcd0 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -72,7 +72,7 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * * @param string $name The name of the route * @param mixed $parameters An array of parameters - * @param Boolean|string $referenceType The type of reference to be generated (one of the constants) + * @param bool|string $referenceType The type of reference to be generated (one of the constants) * * @return string The generated URL * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE b/core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index af70a888b8673a5cf6d4cfa84327493275150da6..f6d44252157a14d0d56706b1a04f01d4717b7654 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -68,7 +68,7 @@ abstract class AnnotationClassLoader implements LoaderInterface protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route'; /** - * @var integer + * @var int */ protected $defaultRouteIndex = 0; @@ -108,58 +108,12 @@ public function load($class, $type = null) throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } - $globals = array( - 'path' => '', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), - 'schemes' => array(), - 'methods' => array(), - 'host' => '', - 'condition' => '', - ); - $class = new \ReflectionClass($class); if ($class->isAbstract()) { throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class)); } - if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { - // for BC reasons - if (null !== $annot->getPath()) { - $globals['path'] = $annot->getPath(); - } elseif (null !== $annot->getPattern()) { - $globals['path'] = $annot->getPattern(); - } - - if (null !== $annot->getRequirements()) { - $globals['requirements'] = $annot->getRequirements(); - } - - if (null !== $annot->getOptions()) { - $globals['options'] = $annot->getOptions(); - } - - if (null !== $annot->getDefaults()) { - $globals['defaults'] = $annot->getDefaults(); - } - - if (null !== $annot->getSchemes()) { - $globals['schemes'] = $annot->getSchemes(); - } - - if (null !== $annot->getMethods()) { - $globals['methods'] = $annot->getMethods(); - } - - if (null !== $annot->getHost()) { - $globals['host'] = $annot->getHost(); - } - - if (null !== $annot->getCondition()) { - $globals['condition'] = $annot->getCondition(); - } - } + $globals = $this->getGlobals($class); $collection = new RouteCollection(); $collection->addResource(new FileResource($class->getFileName())); @@ -204,7 +158,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl $condition = $globals['condition']; } - $route = new Route($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods, $condition); + $route = $this->createRoute($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods, $condition); $this->configureRoute($route, $class, $method, $annot); @@ -252,5 +206,63 @@ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMetho return $name; } + protected function getGlobals(\ReflectionClass $class) + { + $globals = array( + 'path' => '', + 'requirements' => array(), + 'options' => array(), + 'defaults' => array(), + 'schemes' => array(), + 'methods' => array(), + 'host' => '', + 'condition' => '', + ); + + if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { + // for BC reasons + if (null !== $annot->getPath()) { + $globals['path'] = $annot->getPath(); + } elseif (null !== $annot->getPattern()) { + $globals['path'] = $annot->getPattern(); + } + + if (null !== $annot->getRequirements()) { + $globals['requirements'] = $annot->getRequirements(); + } + + if (null !== $annot->getOptions()) { + $globals['options'] = $annot->getOptions(); + } + + if (null !== $annot->getDefaults()) { + $globals['defaults'] = $annot->getDefaults(); + } + + if (null !== $annot->getSchemes()) { + $globals['schemes'] = $annot->getSchemes(); + } + + if (null !== $annot->getMethods()) { + $globals['methods'] = $annot->getMethods(); + } + + if (null !== $annot->getHost()) { + $globals['host'] = $annot->getHost(); + } + + if (null !== $annot->getCondition()) { + $globals['condition'] = $annot->getCondition(); + } + } + + return $globals; + } + + protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition) + { + return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition); + } + abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index 33776fdc8648d92a6f9fe9b18ce6a576b83bd0ba..e54a0181c7861ff09d1f3d29e72392c643fcbdab 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -31,17 +31,16 @@ class AnnotationFileLoader extends FileLoader * * @param FileLocatorInterface $locator A FileLocator instance * @param AnnotationClassLoader $loader An AnnotationClassLoader instance - * @param string|array $paths A path or an array of paths where to look for resources * * @throws \RuntimeException */ - public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader, $paths = array()) + public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader) { if (!function_exists('token_get_all')) { throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.'); } - parent::__construct($locator, $paths); + parent::__construct($locator); $this->loader = $loader; } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php index e854202f7092cbc9215755df85a4125ae9d24699..8a95f512861d21a75efefc04a29afa9fbde741e2 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -167,6 +167,9 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $ if (null !== $host) { $subCollection->setHost($host); } + if (null !== $condition) { + $subCollection->setCondition($condition); + } if (null !== $schemes) { $subCollection->setSchemes($schemes); } @@ -216,7 +219,7 @@ private function parseConfigs(\DOMElement $node, $path) foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { switch ($n->localName) { case 'default': - if ($n->hasAttribute('xsi:nil') && 'true' == $n->getAttribute('xsi:nil')) { + if ($this->isElementValueNull($n)) { $defaults[$n->getAttribute('key')] = null; } else { $defaults[$n->getAttribute('key')] = trim($n->textContent); @@ -239,4 +242,15 @@ private function parseConfigs(\DOMElement $node, $path) return array($defaults, $requirements, $options, $condition); } + + private function isElementValueNull(\DOMElement $element) + { + $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance'; + + if (!$element->hasAttributeNS($namespaceUri, 'nil')) { + return false; + } + + return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil'); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php index d3eaea42e60415441f0a45545a6c80a73ef5cb70..8de520cd224eb0334dfa971fc277116ab3948c1b 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -28,7 +28,7 @@ class YamlFileLoader extends FileLoader { private static $availableKeys = array( - 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition' + 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', ); private $yamlParser; @@ -146,6 +146,7 @@ protected function parseImport(RouteCollection $collection, array $config, $path $requirements = isset($config['requirements']) ? $config['requirements'] : array(); $options = isset($config['options']) ? $config['options'] : array(); $host = isset($config['host']) ? $config['host'] : null; + $condition = isset($config['condition']) ? $config['condition'] : null; $schemes = isset($config['schemes']) ? $config['schemes'] : null; $methods = isset($config['methods']) ? $config['methods'] : null; @@ -157,6 +158,9 @@ protected function parseImport(RouteCollection $collection, array $config, $path if (null !== $host) { $subCollection->setHost($host); } + if (null !== $condition) { + $subCollection->setCondition($condition); + } if (null !== $schemes) { $subCollection->setSchemes($schemes); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index 9ab969a41d8a2e79c7a8159ee229d75e8df8e09f..d40aa422122a22656585e88d773f621842854fe0 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -29,7 +29,7 @@ <xsd:element name="default" nillable="true" type="element" /> <xsd:element name="requirement" type="element" /> <xsd:element name="option" type="element" /> - <xsd:element name="condition" type="condition" /> + <xsd:element name="condition" type="xsd:string" /> </xsd:choice> </xsd:group> @@ -62,9 +62,4 @@ </xsd:extension> </xsd:simpleContent> </xsd:complexType> - - <xsd:simpleType name="condition"> - <xsd:restriction base="xsd:string"> - </xsd:restriction> - </xsd:simpleType> </xsd:schema> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php index 55aac6b7079dccc1c357d1e685a273ce55ea4361..35b1dc50ed2d7a82f8906d54a890f6593bbbcda5 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php @@ -16,6 +16,10 @@ /** * 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 <fabien@symfony.com> * @author Arnaud Le Blanc <arnaud.lb@gmail.com> */ diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php index 5b32684876b96ea58ab00d85af5246f60acd2cfd..fc76c192778c546a38b1083344e0eafb4b736252 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php @@ -16,6 +16,10 @@ /** * 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 <fabien@symfony.com> * @author Kris Wallsmith <kris@symfony.com> */ diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php index 612ac0d25a147fdff374e6101031c79762c0447c..25e8e2453426f22a1f71ad3845279d3cb187ebf7 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php @@ -116,7 +116,7 @@ protected function setParent(DumperCollection $parent) * * @param string $name The attribute name * - * @return Boolean true if the attribute is defined, false otherwise + * @return bool true if the attribute is defined, false otherwise */ public function hasAttribute($name) { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php index 26382b0b4fd2ece311f3b2d7112d72e07ffe5f2e..3563d5149f1587c24d0e7f130a633c017d8f1e49 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php @@ -56,29 +56,26 @@ public function addPrefixRoute(DumperRoute $route) { $prefix = $route->getRoute()->compile()->getStaticPrefix(); - // Same prefix, add to current leave - if ($this->prefix === $prefix) { - $this->add($route); + for ($collection = $this; null !== $collection; $collection = $collection->getParent()) { + // Same prefix, add to current leave + if ($collection->prefix === $prefix) { + $collection->add($route); - return $this; - } - - // Prefix starts with route's prefix - if ('' === $this->prefix || 0 === strpos($prefix, $this->prefix)) { - $collection = new DumperPrefixCollection(); - $collection->setPrefix(substr($prefix, 0, strlen($this->prefix)+1)); - $this->add($collection); - - return $collection->addPrefixRoute($route); - } + return $collection; + } - // No match, fallback to parent (recursively) + // Prefix starts with route's prefix + if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) { + $child = new DumperPrefixCollection(); + $child->setPrefix(substr($prefix, 0, strlen($collection->prefix)+1)); + $collection->add($child); - if (null === $parent = $this->getParent()) { - throw new \LogicException("The collection root must not have a prefix"); + return $child->addPrefixRoute($route); + } } - return $parent->addPrefixRoute($route); + // Reached only if the root has a non empty prefix + throw new \LogicException("The collection root must not have a prefix"); } /** diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 784f3099daf59e5e9efe5d74074d788946ff150d..859ffcb8374644c4933174cfc4f31a967b1b6149 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -81,7 +81,7 @@ public function __construct(RequestContext \$context) /** * Generates the code for the match method implementing UrlMatcherInterface. * - * @param Boolean $supportsRedirections Whether redirections are supported by the base class + * @param bool $supportsRedirections Whether redirections are supported by the base class * * @return string Match method as PHP code */ @@ -108,7 +108,7 @@ public function match(\$pathinfo) * Generates PHP code to match a RouteCollection with all its routes. * * @param RouteCollection $routes A RouteCollection instance - * @param Boolean $supportsRedirections Whether redirections are supported by the base class + * @param bool $supportsRedirections Whether redirections are supported by the base class * * @return string PHP code */ @@ -149,7 +149,7 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections) * Generates PHP code recursively to match a tree of routes * * @param DumperPrefixCollection $collection A DumperPrefixCollection instance - * @param Boolean $supportsRedirections Whether redirections are supported by the base class + * @param bool $supportsRedirections Whether redirections are supported by the base class * @param string $parentPrefix Prefix of the parent collection * * @return string PHP code @@ -189,7 +189,7 @@ private function compilePrefixRoutes(DumperPrefixCollection $collection, $suppor * * @param Route $route A Route instance * @param string $name The name of the Route - * @param Boolean $supportsRedirections Whether redirections are supported by the base class + * @param bool $supportsRedirections Whether redirections are supported by the base class * @param string|null $parentPrefix The prefix of the parent collection used to optimize the code * * @return string PHP code @@ -319,7 +319,6 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren implode(', ', $vars), str_replace("\n", '', var_export($route->getDefaults(), true)) ); - } elseif ($route->getDefaults()) { $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); } else { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php index 3d13181f467dde73b9cbf01b9f006aeb00516a9b..236f55a5abf0ecf710ed61502bb0726f10a939d8 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -46,7 +46,7 @@ public function match($pathinfo) } /** - * {@inheritDoc} + * {@inheritdoc} */ protected function handleRouteRequirements($pathinfo, $name, Route $route) { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php index cb536968964998113527adf6d1a5b7ca0d49a59e..93fd09ad5b1e11349d0c71f7ae33f15a22ccfb21 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php @@ -43,8 +43,8 @@ class RequestContext * @param string $method The HTTP method * @param string $host The HTTP host name * @param string $scheme The HTTP scheme - * @param integer $httpPort The HTTP port - * @param integer $httpsPort The HTTPS port + * @param int $httpPort The HTTP port + * @param int $httpsPort The HTTPS port * @param string $path The path * @param string $queryString The query string * @@ -293,7 +293,7 @@ public function getParameter($name) * * @param string $name A parameter name * - * @return Boolean true if the parameter value is set, false otherwise + * @return bool true if the parameter value is set, false otherwise */ public function hasParameter($name) { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php index 08005541461ef1ad96234e722700a26304c7379f..ad8ec49b206cc093dd9eb93bea0f7a7b6c887db2 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php @@ -252,7 +252,7 @@ public function setSchemes($schemes) * * @param string $scheme * - * @return Boolean true if the scheme requirement exists, otherwise false + * @return bool true if the scheme requirement exists, otherwise false */ public function hasScheme($scheme) { @@ -387,7 +387,7 @@ public function getOption($name) * * @param string $name An option name * - * @return Boolean true if the option is set, false otherwise + * @return bool true if the option is set, false otherwise */ public function hasOption($name) { @@ -456,7 +456,7 @@ public function getDefault($name) * * @param string $name A variable name * - * @return Boolean true if the default value is set, false otherwise + * @return bool true if the default value is set, false otherwise */ public function hasDefault($name) { @@ -543,7 +543,7 @@ public function getRequirement($key) * * @param string $key A variable name * - * @return Boolean true if a requirement is specified, false otherwise + * @return bool true if a requirement is specified, false otherwise */ public function hasRequirement($key) { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php index 7ced4b3af8442c9433dac22a267beee8d1666771..9234b42b345b0e5a8b4ce52cb8db9e5197cef3a5 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php @@ -29,7 +29,7 @@ class RouteCompiler implements RouteCompilerInterface const SEPARATORS = '/,;.:-_~+*=@|'; /** - * {@inheritDoc} + * {@inheritdoc} * * @throws \LogicException If a variable is referenced more than once * @throws \DomainException If a variable name is numeric because PHP raises an error for such @@ -196,8 +196,8 @@ private static function findNextSeparator($pattern) * Computes the regexp used to match a specific token. It can be static text or a subpattern. * * @param array $tokens The route tokens - * @param integer $index The index of the current token - * @param integer $firstOptional The index of the first optional token + * @param int $index The index of the current token + * @param int $firstOptional The index of the first optional token * * @return string The regexp pattern for a single token */ diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml new file mode 100644 index 0000000000000000000000000000000000000000..f9e2aa24df804f6ab8c09b20f54fc05c813b6903 --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<routes xmlns="http://symfony.com/schema/routing" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> + + <route id="blog_show" path="/blog/{slug}"> + <default key="foo" xsi:nil="true" /> + <default key="bar" xsi:nil="1" /> + <default key="foobar" xsi:nil="false">foo</default> + <default key="baz" xsi:nil="0">bar</default> + </route> +</routes> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php index b652d946565991219eb8ec643af4e42fcc6001d9..9c6b55671c996c484bb3a9b8f011058d46763f54 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php @@ -16,7 +16,7 @@ $collection->add('blog_show_legacy', new Route( '/blog/{slug}', array('_controller' => 'MyBlogBundle:Blog:show'), - array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+',), + array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+'), array('compiler_class' => 'RouteCompiler'), '{locale}.example.com', array(), diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml index cfee9d6882839e5c160fa376654b95ce50bc41ec..a8221314cb5593fe7003a63a7bf3083a439c4884 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml @@ -20,4 +20,6 @@ <option key="compiler_class">RouteCompiler</option> <condition>context.getMethod() == "GET"</condition> </route> + + <route id="blog_show_inherited" path="/blog/{slug}" /> </routes> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml index 48cf7f8817cc26b9d4fd6496588a0bcd6aa8c16d..26136c3969d9cad483cd791cdb4ee849160822f5 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml @@ -17,3 +17,6 @@ blog_show_legacy: condition: 'context.getMethod() == "GET"' options: compiler_class: RouteCompiler + +blog_show_inherited: + path: /blog/{slug} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml index 295c3cc428a6edb1b3a4d7e629cf5b34880ec8b9..b7a15ddc7ee1fc008d3f80ee566b5359a83eb6ca 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml @@ -8,5 +8,6 @@ <default key="foo">123</default> <requirement key="foo">\d+</requirement> <option key="foo">bar</option> + <condition>context.getMethod() == "POST"</condition> </import> </routes> diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml index 495ed854d1dd1a4ddb2b3273b2b1e866d89f04cb..faf2263ae52f4f56aacfc3765081e763d60ebbfc 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml @@ -5,3 +5,4 @@ _blog: requirements: { 'foo': '\d+' } options: { 'foo': 'bar' } host: "" + condition: 'context.getMethod() == "POST"' diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php index 78e3907fd56bfcc8508035e529dc6b8c3f609884..4165741b06b0f60b95c0d2e1bcf0821e1feeca2d 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php @@ -60,7 +60,7 @@ public function testDumpWithRoutes() $this->routeCollection->add('Test2', new Route('/testing2')); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php')); @@ -81,7 +81,7 @@ public function testDumpWithRoutes() public function testDumpWithoutRoutes() { file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'WithoutRoutesUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \WithoutRoutesUrlGenerator(new RequestContext('/app.php')); @@ -96,7 +96,7 @@ public function testGenerateNonExistingRoute() $this->routeCollection->add('Test', new Route('/test')); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'NonExistingRoutesUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext()); $url = $projectUrlGenerator->generate('NonExisting', array()); @@ -107,7 +107,7 @@ public function testDumpForRouteWithDefaults() $this->routeCollection->add('Test', new Route('/testing/{foo}', array('foo' => 'bar'))); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'DefaultRoutesUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext()); $url = $projectUrlGenerator->generate('Test', array()); @@ -121,7 +121,7 @@ public function testDumpWithSchemeRequirement() $this->routeCollection->add('Test2', new Route('/testing_bc', array(), array('_scheme' => 'https'))); // BC file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator'))); - include ($this->testTmpFilepath); + include $this->testTmpFilepath; $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php')); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 143e3448a29c1e7eb544b10ee3cbf39c34e2eb4d..52b61d7d7e277d6b9088803741d47a1e877f4ee1 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -334,7 +334,7 @@ public function testUrlEncoding() .'?query=%40%3A%5B%5D%2F%28%29%2A%27%22+%2B%2C%3B-._%7E%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%23id', $this->getGenerator($routes)->generate('test', array( 'varpath' => $chars, - 'query' => $chars + 'query' => $chars, )) ); } @@ -409,21 +409,21 @@ public function testWithHostDifferentFromContext() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' =>'Fabien', 'locale' => 'fr'))); + $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' => 'Fabien', 'locale' => 'fr'))); } public function testWithHostSameAsContext() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - $this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr'))); + $this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr'))); } public function testWithHostSameAsContextAndAbsolute() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr'), true)); + $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr'), true)); } /** @@ -466,16 +466,16 @@ public function testGenerateNetworkPathBC() $routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com')); $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' ); $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', - array('name' =>'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' + array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' ); $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' ); $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' ); } @@ -484,16 +484,16 @@ public function testGenerateNetworkPath() $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array('http'))); $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' ); $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', - array('name' =>'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' + array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' ); $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' ); $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' ); } @@ -510,25 +510,25 @@ public function testGenerateRelativePath() $generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/')); $this->assertSame('comments', $generator->generate('comments', - array('author' =>'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('comments?page=2', $generator->generate('comments', - array('author' =>'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../twig-is-great/', $generator->generate('article', - array('author' =>'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article', - array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host', - array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('schemeBC', - array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme', - array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../../about', $generator->generate('unrelated', array(), UrlGeneratorInterface::RELATIVE_PATH) @@ -549,102 +549,102 @@ public function provideRelativePaths() array( '/same/dir/', '/same/dir/', - '' + '', ), array( '/same/file', '/same/file', - '' + '', ), array( '/', '/file', - 'file' + 'file', ), array( '/', '/dir/file', - 'dir/file' + 'dir/file', ), array( '/dir/file.html', '/dir/different-file.html', - 'different-file.html' + 'different-file.html', ), array( '/same/dir/extra-file', '/same/dir/', - './' + './', ), array( '/parent/dir/', '/parent/', - '../' + '../', ), array( '/parent/dir/extra-file', '/parent/', - '../' + '../', ), array( '/a/b/', '/x/y/z/', - '../../x/y/z/' + '../../x/y/z/', ), array( '/a/b/c/d/e', '/a/c/d', - '../../../c/d' + '../../../c/d', ), array( '/a/b/c//', '/a/b/c/', - '../' + '../', ), array( '/a/b/c/', '/a/b/c//', - './/' + './/', ), array( '/root/a/b/c/', '/root/x/b/c/', - '../../../x/b/c/' + '../../../x/b/c/', ), array( '/a/b/c/d/', '/a', - '../../../../a' + '../../../../a', ), array( '/special-chars/sp%20ce/1€/mäh/e=mc²', '/special-chars/sp%20ce/1€/<µ>/e=mc²', - '../<µ>/e=mc²' + '../<µ>/e=mc²', ), array( 'not-rooted', 'dir/file', - 'dir/file' + 'dir/file', ), array( '//dir/', '', - '../../' + '../../', ), array( '/dir/', '/dir/file:with-colon', - './file:with-colon' + './file:with-colon', ), array( '/dir/', '/dir/subdir/file:with-colon', - 'subdir/file:with-colon' + 'subdir/file:with-colon', ), array( '/dir/', '/dir/:subdir/', - './:subdir/' + './:subdir/', ), ); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index c60997902e0ef6f7d9f929e061f6037b21c21c8d..65d325c2d26b904a0069273946d99243285b6419 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -74,22 +74,22 @@ public function getLoadTests() array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1'), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3') + array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), ), array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1', 'defaults' => array('arg2' => 'foo')), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3') + array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), ), array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1', 'defaults' => array('arg2' => 'foobar')), - array('arg2' => 'defaultValue2', 'arg3' =>'defaultValue3') + array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), ), array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1', 'defaults' => array('arg2' => 'foo'), 'condition' => 'context.getMethod() == "GET"'), - array('arg2' => 'defaultValue2', 'arg3' =>'defaultValue3') + array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), ), ); } @@ -125,6 +125,32 @@ public function testLoad($className, $routeDatas = array(), $methodArgs = array( $this->assertEquals($routeDatas['condition'], $route->getCondition(), '->load preserves condition annotation'); } + public function testClassRouteLoad() + { + $classRouteDatas = array('path' => '/classRoutePrefix'); + + $routeDatas = array( + 'name' => 'route1', + 'path' => '/', + ); + + $this->reader + ->expects($this->once()) + ->method('getClassAnnotation') + ->will($this->returnValue($this->getAnnotatedRoute($classRouteDatas))) + ; + + $this->reader + ->expects($this->once()) + ->method('getMethodAnnotations') + ->will($this->returnValue(array($this->getAnnotatedRoute($routeDatas)))) + ; + $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass'); + $route = $routeCollection->get($routeDatas['name']); + + $this->assertSame($classRouteDatas['path'].$routeDatas['path'], $route->getPath(), '->load preserves class route path annotation'); + } + private function getAnnotatedRoute($datas) { return new Route($datas); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index c38adbd93838f3c5bb1cccc955e72eba16684ab2..c488c43bcc91b1e299c3fdbf37281f2476cb11c7 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -34,10 +34,12 @@ public function testLoadWithRoute() $routeCollection = $loader->load('validpattern.xml'); $routes = $routeCollection->all(); - $this->assertCount(2, $routes, 'Two routes are loaded'); + $this->assertCount(3, $routes, 'Three routes are loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - foreach ($routes as $route) { + $identicalRoutes = array_slice($routes, 0, 2); + + foreach ($identicalRoutes as $route) { $this->assertSame('/blog/{slug}', $route->getPath()); $this->assertSame('{locale}.example.com', $route->getHost()); $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); @@ -62,7 +64,7 @@ public function testLoadWithNamespacePrefix() $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); $this->assertSame('\w+', $route->getRequirement('slug')); $this->assertSame('en|fr|de', $route->getRequirement('_locale')); - $this->assertSame(null, $route->getDefault('slug')); + $this->assertNull($route->getDefault('slug')); $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); } @@ -72,7 +74,7 @@ public function testLoadWithImport() $routeCollection = $loader->load('validresource.xml'); $routes = $routeCollection->all(); - $this->assertCount(2, $routes, 'Two routes are loaded'); + $this->assertCount(3, $routes, 'Three routes are loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); foreach ($routes as $route) { @@ -81,6 +83,7 @@ public function testLoadWithImport() $this->assertSame('\d+', $route->getRequirement('foo')); $this->assertSame('bar', $route->getOption('foo')); $this->assertSame('', $route->getHost()); + $this->assertSame('context.getMethod() == "POST"', $route->getCondition()); } } @@ -118,4 +121,18 @@ public function testDocTypeIsNotAllowed() $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); $loader->load('withdoctype.xml'); } + + public function testNullValues() + { + $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); + $routeCollection = $loader->load('null_values.xml'); + $route = $routeCollection->get('blog_show'); + + $this->assertTrue($route->hasDefault('foo')); + $this->assertNull($route->getDefault('foo')); + $this->assertTrue($route->hasDefault('bar')); + $this->assertNull($route->getDefault('bar')); + $this->assertEquals('foo', $route->getDefault('foobar')); + $this->assertEquals('bar', $route->getDefault('baz')); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index f0301062055e8b1f150e500b252d0bd8ea201fa3..966768cf2ee4510af3983e18f5d98152b00bbfaf 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -68,10 +68,12 @@ public function testLoadWithRoute() $routeCollection = $loader->load('validpattern.yml'); $routes = $routeCollection->all(); - $this->assertCount(2, $routes, 'Two routes are loaded'); + $this->assertCount(3, $routes, 'Three routes are loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - foreach ($routes as $route) { + $identicalRoutes = array_slice($routes, 0, 2); + + foreach ($identicalRoutes as $route) { $this->assertSame('/blog/{slug}', $route->getPath()); $this->assertSame('{locale}.example.com', $route->getHost()); $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); @@ -89,7 +91,7 @@ public function testLoadWithResource() $routeCollection = $loader->load('validresource.yml'); $routes = $routeCollection->all(); - $this->assertCount(2, $routes, 'Two routes are loaded'); + $this->assertCount(3, $routes, 'Three routes are loaded'); $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); foreach ($routes as $route) { @@ -98,6 +100,7 @@ public function testLoadWithResource() $this->assertSame('\d+', $route->getRequirement('foo')); $this->assertSame('bar', $route->getOption('foo')); $this->assertSame('', $route->getHost()); + $this->assertSame('context.getMethod() == "POST"', $route->getCondition()); } } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php index 2810cbad51bdce30327c6fadefe6d91cb5519930..05e6261a5f737bd8cba54c0283a24c9c89941382 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php @@ -40,7 +40,7 @@ public function testMatch($name, $pathinfo, $server, $expect) $_SERVER = $server; - $result = $matcher->match($pathinfo, $server); + $result = $matcher->match($pathinfo); $this->assertSame(var_export($expect, true), var_export($result, true)); } @@ -103,7 +103,7 @@ public function getMatchData() 'ignoreAttributes' => array('attr_a', 'attr_b'), '_controller' => 'FrameworkBundle:Redirect:redirect', '_route' => 'product_view', - ) + ), ), array( 'REDIRECT_ envs', @@ -146,7 +146,7 @@ public function getMatchData() 'name' => 'world', '_route' => 'hello', ), - ) + ), ); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 473af6aa5cea39791d799f9fadec3df0a4855e09..7cf529c345c55c4ab6119df3e0e0874c7201bd11 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -258,7 +258,7 @@ public function getRouteCollections() return array( array($collection, 'url_matcher1.php', array()), array($redirectCollection, 'url_matcher2.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')), - array($rootprefixCollection, 'url_matcher3.php', array()) + array($rootprefixCollection, 'url_matcher3.php', array()), ); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index b03b0c3aa077a3f8f4b4b9d162b6de6358004bb2..8f5f332421cbbde9585732fe7ef33725fc530dc4 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -78,7 +78,8 @@ public function testMatch() try { $matcher->match('/no-match'); $this->fail(); - } catch (ResourceNotFoundException $e) {} + } catch (ResourceNotFoundException $e) { + } $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz'), $matcher->match('/foo/baz')); // test that defaults are merged @@ -98,7 +99,8 @@ public function testMatch() try { $matcher->match('/foo'); $this->fail(); - } catch (MethodNotAllowedException $e) {} + } catch (MethodNotAllowedException $e) { + } // route does match with GET or HEAD method context $matcher = new UrlMatcher($collection, new RequestContext()); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php index d663ae960b3dae70c66fa681525c752a18c983e2..ef26c87161a27f2f964af3490c4e620284049763 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -38,7 +38,7 @@ public function provideCompileData() array('/foo'), '/foo', '#^/foo$#s', array(), array( array('text', '/foo'), - )), + ),), array( 'Route with a variable', @@ -46,7 +46,7 @@ public function provideCompileData() '/foo', '#^/foo/(?P<bar>[^/]++)$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with a variable that has a default value', @@ -54,7 +54,7 @@ public function provideCompileData() '/foo', '#^/foo(?:/(?P<bar>[^/]++))?$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with several variables', @@ -63,7 +63,7 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with several variables that have default values', @@ -72,7 +72,7 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with several variables but some of them have no default values', @@ -81,28 +81,28 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with an optional variable as the first segment', array('/{bar}', array('bar' => 'bar')), '', '#^/(?P<bar>[^/]++)?$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), - )), + ),), array( 'Route with a requirement of 0', array('/{bar}', array('bar' => null), array('bar' => '0')), '', '#^/(?P<bar>0)?$#s', array('bar'), array( array('variable', '/', '0', 'bar'), - )), + ),), array( 'Route with an optional variable as the first segment with requirements', array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')), '', '#^/(?P<bar>(foo|bar))?$#s', array('bar'), array( array('variable', '/', '(foo|bar)', 'bar'), - )), + ),), array( 'Route with only optional variables', @@ -110,7 +110,7 @@ public function provideCompileData() '', '#^/(?P<foo>[^/]++)?(?:/(?P<bar>[^/]++))?$#s', array('foo', 'bar'), array( array('variable', '/', '[^/]++', 'bar'), array('variable', '/', '[^/]++', 'foo'), - )), + ),), array( 'Route with a variable in last position', @@ -118,7 +118,7 @@ public function provideCompileData() '/foo', '#^/foo\-(?P<bar>[^/]++)$#s', array('bar'), array( array('variable', '-', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with nested placeholders', @@ -127,7 +127,7 @@ public function provideCompileData() array('text', 'static}'), array('variable', '', '[^/]+', 'var'), array('text', '/{static'), - )), + ),), array( 'Route without separator between variables', @@ -138,7 +138,7 @@ public function provideCompileData() array('variable', '', '(y|Y)', 'y'), array('variable', '', '[^/\.]+', 'x'), array('variable', '/', '[^/\.]+', 'w'), - )), + ),), array( 'Route with a format', @@ -147,7 +147,7 @@ public function provideCompileData() array('variable', '.', '[^/]++', '_format'), array('variable', '/', '[^/\.]++', 'bar'), array('text', '/foo'), - )), + ),), ); } @@ -167,7 +167,7 @@ public function testRouteWithSameVariableTwice() */ public function testRouteWithNumericVariableName($name) { - $route = new Route('/{'. $name.'}'); + $route = new Route('/{'.$name.'}'); $route->compile(); } @@ -176,7 +176,7 @@ public function getNumericVariableNames() return array( array('09'), array('123'), - array('1e2') + array('1e2'), ); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php index cbd5ccb43b3f785feecfbeebd685f50ab783a63b..7ff4135583fc5d2418f2a7bc9170667bbf7e1b08 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php @@ -138,7 +138,7 @@ public function getInvalidRequirements() array(array()), array('^$'), array('^'), - array('$') + array('$'), ); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php index 42a344c74a73b353a7a9a1e3d1b8a2fcdef9b93a..9a1c568ee37cd1ebac7e32562b48dc8b213caeb8 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php @@ -31,7 +31,7 @@ public function testSetOptionsWithSupportedOptions() $this->router->setOptions(array( 'cache_dir' => './cache', 'debug' => true, - 'resource_type' => 'ResourceType' + 'resource_type' => 'ResourceType', )); $this->assertSame('./cache', $this->router->getOption('cache_dir')); @@ -49,7 +49,7 @@ public function testSetOptionsWithUnsupportedOptions() 'cache_dir' => './cache', 'option_foo' => true, 'option_bar' => 'baz', - 'resource_type' => 'ResourceType' + 'resource_type' => 'ResourceType', )); } @@ -103,14 +103,13 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option) ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); - } public function provideMatcherOptionsPreventingCaching() { return array( array('cache_dir'), - array('matcher_cache_class') + array('matcher_cache_class'), ); } @@ -126,14 +125,13 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); - } public function provideGeneratorOptionsPreventingCaching() { return array( array('cache_dir'), - array('generator_cache_class') + array('generator_cache_class'), ); } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json index 3517b23624045b9fecf30a6a986924d58af8ce5d..b4c04b6a1e66a776a87ba296a2751a31bba76903 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "symfony/config": "~2.2", + "symfony/http-foundation": "~2.3", "symfony/yaml": "~2.0", "symfony/expression-language": "~2.4", "doctrine/annotations": "~1.0", @@ -38,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist b/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist index 830066aab59b40c24f7ad4fdb7e1df750efc4236..8cf6352f3a5f7ea7685b5337720677f86705819c 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php index 8fb321fc69112439dbb524199ff3e1caa1752943..afb4e3ec843327951be55b21618b4f2d7a9058e6 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -132,7 +132,7 @@ private function resolveContext(array $context) $defaultOptions = array( 'json_decode_associative' => $this->associative, 'json_decode_recursion_depth' => $this->recursionDepth, - 'json_decode_options' => 0 + 'json_decode_options' => 0, ); return array_merge($defaultOptions, $context); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncode.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncode.php index 06edff5a455952462118b9ec868829f5ddec7c44..8b468bd14a87432a3cea5df968ec2188885036c5 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -20,7 +20,7 @@ */ class JsonEncode implements EncoderInterface { - private $options ; + private $options; private $lastError = JSON_ERROR_NONE; public function __construct($bitmask = 0) diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 9f2374266c6569590012fcb362aa3e0d98b44675..f4a1b9094bbddedfb7dad00026511ef42d3194e5 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -129,6 +129,18 @@ public function normalize($object, $format = null, array $context = array()) */ public function denormalize($data, $class, $format = null, array $context = array()) { + if (is_array($data) || is_object($data) && $data instanceof \ArrayAccess) { + $normalizedData = $data; + } elseif (is_object($data)) { + $normalizedData = array(); + + foreach ($data as $attribute => $value) { + $normalizedData[$attribute] = $value; + } + } else { + $normalizedData = array(); + } + $reflectionClass = new \ReflectionClass($class); $constructor = $reflectionClass->getConstructor(); @@ -139,10 +151,10 @@ public function denormalize($data, $class, $format = null, array $context = arra foreach ($constructorParameters as $constructorParameter) { $paramName = lcfirst($this->formatAttribute($constructorParameter->name)); - if (isset($data[$paramName])) { - $params[] = $data[$paramName]; + if (isset($normalizedData[$paramName])) { + $params[] = $normalizedData[$paramName]; // don't run set for a parameter passed to the constructor - unset($data[$paramName]); + unset($normalizedData[$paramName]); } elseif ($constructorParameter->isOptional()) { $params[] = $constructorParameter->getDefaultValue(); } else { @@ -156,10 +168,10 @@ public function denormalize($data, $class, $format = null, array $context = arra $object = $reflectionClass->newInstanceArgs($params); } else { - $object = new $class; + $object = new $class(); } - foreach ($data as $attribute => $value) { + foreach ($normalizedData as $attribute => $value) { $setter = 'set'.$this->formatAttribute($attribute); if (method_exists($object, $setter)) { diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php index 55fa0cd1ca68d91bf87c9b6c5ef767bb8d084426..c4052bcbcc5ee7e2bd22dde87473dac300edc4a8 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php @@ -164,7 +164,6 @@ public function supportsDenormalization($data, $type, $format = null) */ private function getNormalizer($data, $format) { - $class = get_class($data); if (isset($this->normalizerCache[$class][$format])) { return $this->normalizerCache[$class][$format]; diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 4f83c6f948a70432dd44df154aa0256f87562d00..f0c7b17e743665ef7d3ff2df0ade6c4812a69bd5 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -67,11 +67,11 @@ public function testAttributes() $obj->xmlFoo = array( 'foo-bar' => array( '@id' => 1, - '@name' => 'Bar' + '@name' => 'Bar', ), 'Foo' => array( 'Bar' => "Test", - '@Type' => 'test' + '@Type' => 'test', ), 'föo_bär' => 'a', "Bar" => array(1,2,3), @@ -141,7 +141,7 @@ public function testEncodeScalarRootAttributes() { $array = array( '#' => 'Paul', - '@gender' => 'm' + '@gender' => 'm', ); $expected = '<?xml version="1.0"?>'."\n". @@ -154,7 +154,7 @@ public function testEncodeRootAttributes() { $array = array( 'firstname' => 'Paul', - '@gender' => 'm' + '@gender' => 'm', ); $expected = '<?xml version="1.0"?>'."\n". @@ -272,7 +272,7 @@ public function testDecodeScalarRootAttributes() $expected = array( '#' => 'Peter', - '@gender' => 'M' + '@gender' => 'M', ); $this->assertEquals($expected, $this->encoder->decode($source, 'xml')); @@ -286,7 +286,7 @@ public function testDecodeRootAttributes() $expected = array( 'firstname' => 'Peter', 'lastname' => 'Mac Calloway', - '@gender' => 'M' + '@gender' => 'M', ); $this->assertEquals($expected, $this->encoder->decode($source, 'xml')); @@ -305,8 +305,8 @@ public function testDecodeArray() $expected = array( 'people' => array('person' => array( array('firstname' => 'Benjamin', 'lastname' => 'Alexandre'), - array('firstname' => 'Damien', 'lastname' => 'Clay') - )) + array('firstname' => 'Damien', 'lastname' => 'Clay'), + )), ); $this->assertEquals($expected, $this->encoder->decode($source, 'xml')); @@ -318,11 +318,11 @@ public function testDecodeWithoutItemHash() $obj->xmlFoo = array( 'foo-bar' => array( '@key' => "value", - 'item' => array("@key" => 'key', "key-val" => 'val') + 'item' => array("@key" => 'key', "key-val" => 'val'), ), 'Foo' => array( 'Bar' => "Test", - '@Type' => 'test' + '@Type' => 'test', ), 'föo_bär' => 'a', "Bar" => array(1,2,3), @@ -331,11 +331,11 @@ public function testDecodeWithoutItemHash() $expected = array( 'foo-bar' => array( '@key' => "value", - 'key' => array('@key' => 'key', "key-val" => 'val') + 'key' => array('@key' => 'key', "key-val" => 'val'), ), 'Foo' => array( 'Bar' => "Test", - '@Type' => 'test' + '@Type' => 'test', ), 'föo_bär' => 'a', "Bar" => array(1,2,3), diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php index 09b8a5281216d7d7798cf3e8ba8c4dfb899ada9d..d78f34a3cde71d95038d29d2ad1390d6284bb096 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php @@ -16,10 +16,7 @@ class DenormalizableDummy implements DenormalizableInterface { - public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array()) { - } - } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 2ec68c0a0d0e6cf2c3900d27aa704aecfe68af4c..cc8de241ca4a7c2cc642cd1e581553fa0c2bbcc8 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -17,6 +17,11 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase { + /** + * @var GetSetMethodNormalizer + */ + private $normalizer; + protected function setUp() { $this->serializer = $this->getMock(__NAMESPACE__.'\SerializerNormalizer'); @@ -66,6 +71,17 @@ public function testDenormalize() $this->assertTrue($obj->isBaz()); } + public function testDenormalizeWithObject() + { + $data = new \stdClass(); + $data->foo = 'foo'; + $data->bar = 'bar'; + $data->fooBar = 'foobar'; + $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetSetDummy', 'any'); + $this->assertEquals('foo', $obj->getFoo()); + $this->assertEquals('bar', $obj->getBar()); + } + public function testDenormalizeOnCamelCaseFormat() { $this->normalizer->setCamelizedAttributes(array('camel_case')); @@ -76,6 +92,11 @@ public function testDenormalizeOnCamelCaseFormat() $this->assertEquals('camelCase', $obj->getCamelCase()); } + public function testDenormalizeNull() + { + $this->assertEquals(new GetSetDummy(), $this->normalizer->denormalize(null, __NAMESPACE__.'\GetSetDummy')); + } + /** * @dataProvider attributeProvider */ @@ -119,6 +140,18 @@ public function testConstructorDenormalizeWithMissingOptionalArgument() $this->assertEquals(array(1, 2, 3), $obj->getBaz()); } + public function testConstructorWithObjectDenormalize() + { + $data = new \stdClass(); + $data->foo = 'foo'; + $data->bar = 'bar'; + $data->baz = true; + $data->fooBar = 'foobar'; + $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetConstructorDummy', 'any'); + $this->assertEquals('foo', $obj->getFoo()); + $this->assertEquals('bar', $obj->getBar()); + } + /** * @dataProvider provideCallbacks */ @@ -183,7 +216,7 @@ public function provideCallbacks() ), 'baz', array('foo' => '', 'bar' => null, 'baz' => true), - 'Null an item' + 'Null an item', ), array( array( diff --git a/core/vendor/symfony/translation/Symfony/Component/Translation/TranslatorInterface.php b/core/vendor/symfony/translation/Symfony/Component/Translation/TranslatorInterface.php index 3dcdd4fc375bc34925b126d0e834ff37bd12be57..fe1a8659e2c9377bf28612961656d39ea8459dfe 100644 --- a/core/vendor/symfony/translation/Symfony/Component/Translation/TranslatorInterface.php +++ b/core/vendor/symfony/translation/Symfony/Component/Translation/TranslatorInterface.php @@ -23,10 +23,12 @@ interface TranslatorInterface /** * Translates the given message. * - * @param string $id The message id (may also be an object that can be cast to string) - * @param array $parameters An array of parameters for the message - * @param string $domain The domain for the message - * @param string $locale The locale + * @param string $id The message id (may also be an object that can be cast to string) + * @param array $parameters An array of parameters for the message + * @param string|null $domain The domain for the message or null to use the default + * @param string|null $locale The locale or null to use the default + * + * @throws \InvalidArgumentException If the locale contains invalid characters * * @return string The translated string * @@ -37,11 +39,13 @@ public function trans($id, array $parameters = array(), $domain = null, $locale /** * Translates the given choice message by choosing a translation according to a number. * - * @param string $id The message id (may also be an object that can be cast to string) - * @param integer $number The number to use to find the indice of the message - * @param array $parameters An array of parameters for the message - * @param string $domain The domain for the message - * @param string $locale The locale + * @param string $id The message id (may also be an object that can be cast to string) + * @param int $number The number to use to find the indice of the message + * @param array $parameters An array of parameters for the message + * @param string|null $domain The domain for the message or null to use the default + * @param string|null $locale The locale or null to use the default + * + * @throws \InvalidArgumentException If the locale contains invalid characters * * @return string The translated string * @@ -54,6 +58,8 @@ public function transChoice($id, $number, array $parameters = array(), $domain = * * @param string $locale The locale * + * @throws \InvalidArgumentException If the locale contains invalid characters + * * @api */ public function setLocale($locale); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md b/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md index f5ae1ee39092a7ab1b4551005a7722ae98bb6445..34fe232dcfe78f625ebc65c958af231f4d2261c8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,66 @@ CHANGELOG ========= +2.5.0 +----- + + * deprecated `ApcCache` in favor of `DoctrineCache` + * added `DoctrineCache` to adapt any Doctrine cache + * `GroupSequence` now implements `ArrayAccess`, `Countable` and `Traversable` + * [BC BREAK] changed `ClassMetadata::getGroupSequence()` to return a `GroupSequence` instance instead of an array + * `Callback` can now be put onto properties (useful when you pass a closure to the constraint) + * deprecated `ClassBasedInterface` + * deprecated `MetadataInterface` + * deprecated `PropertyMetadataInterface` + * deprecated `PropertyMetadataContainerInterface` + * deprecated `Mapping\ElementMetadata` + * added `Mapping\MetadataInterface` + * added `Mapping\ClassMetadataInterface` + * added `Mapping\PropertyMetadataInterface` + * added `Mapping\GenericMetadata` + * added `Mapping\CascadingStrategy` + * added `Mapping\TraversalStrategy` + * deprecated `Mapping\ClassMetadata::accept()` + * deprecated `Mapping\MemberMetadata::accept()` + * removed array type hint of `Mapping\ClassMetadata::setGroupSequence()` + * deprecated `MetadataFactoryInterface` + * deprecated `Mapping\BlackholeMetadataFactory` + * deprecated `Mapping\ClassMetadataFactory` + * added `Mapping\Factory\MetadataFactoryInterface` + * added `Mapping\Factory\BlackHoleMetadataFactory` + * added `Mapping\Factory\LazyLoadingMetadataFactory` + * deprecated `ExecutionContextInterface` + * deprecated `ExecutionContext` + * deprecated `GlobalExecutionContextInterface` + * added `Context\ExecutionContextInterface` + * added `Context\ExecutionContext` + * added `Context\ExecutionContextFactoryInterface` + * added `Context\ExecutionContextFactory` + * deprecated `ValidatorInterface` + * deprecated `Validator` + * deprecated `ValidationVisitorInterface` + * deprecated `ValidationVisitor` + * added `Validator\ValidatorInterface` + * added `Validator\RecursiveValidator` + * added `Validator\ContextualValidatorInterface` + * added `Validator\RecursiveContextualValidator` + * added `Violation\ConstraintViolationBuilderInterface` + * added `Violation\ConstraintViolationBuilder` + * added `ConstraintViolation::getParameters()` + * added `ConstraintViolation::getPlural()` + * added `Constraints\Traverse` + * deprecated `$deep` property in `Constraints\Valid` + * added `ValidatorBuilderInterface::setApiVersion()` + * added `Validation::API_VERSION_2_4` + * added `Validation::API_VERSION_2_5` + * added `Exception\OutOfBoundsException` + * added `Exception\UnsupportedMetadataException` + * made `Exception\ValidatorException` extend `Exception\RuntimeException` + * added `Util\PropertyPath` + * made the PropertyAccess component an optional dependency + * deprecated `ValidatorBuilder::setPropertyAccessor()` + + 2.4.0 ----- diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ClassBasedInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ClassBasedInterface.php index c8fa25d43d79690fe7587e0ed0c99597f0d23e75..fe532efe5170227b0b3df213fa8d58a0106dfb76 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ClassBasedInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ClassBasedInterface.php @@ -15,6 +15,9 @@ * An object backed by a PHP class. * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Mapping\ClassMetadataInterface} instead. */ interface ClassBasedInterface { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php index 2f3cbdda5ad009c5e1a4ceef5521d6f444410f24..3608e48f07b11c51249c4149370466298f92c439 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\InvalidOptionsException; use Symfony\Component\Validator\Exception\MissingOptionsException; -use Symfony\Component\Validator\Exception\ConstraintDefinitionException; /** * Contains the properties of a constraint definition. @@ -78,7 +78,7 @@ abstract class Constraint * returned by getRequiredOptions() * @throws ConstraintDefinitionException When you don't pass an associative * array, but getDefaultOption() returns - * NULL + * null * * @api */ @@ -169,7 +169,6 @@ public function addImplicitGroupName($group) */ public function getDefaultOption() { - return null; } /** diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php index fec20a9c2b33dbf67d79ebf66f3b63a164b5ad2b..111c2b4bacec46134ab86714c7a6010ca7673384 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidator.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Validator\Context\ExecutionContextInterface as ExecutionContextInterface2Dot5; +use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface; +use Symfony\Component\Validator\Violation\LegacyConstraintViolationBuilder; + /** * Base class for constraint validators * @@ -20,16 +24,182 @@ */ abstract class ConstraintValidator implements ConstraintValidatorInterface { + /** + * Whether to format {@link \DateTime} objects as RFC-3339 dates + * ("Y-m-d H:i:s"). + * + * @var int + */ + const PRETTY_DATE = 1; + + /** + * Whether to cast objects with a "__toString()" method to strings. + * + * @var int + */ + const OBJECT_TO_STRING = 2; + /** * @var ExecutionContextInterface */ protected $context; /** - * {@inheritDoc} + * {@inheritdoc} */ public function initialize(ExecutionContextInterface $context) { $this->context = $context; } + + /** + * Wrapper for {@link ExecutionContextInterface::buildViolation} that + * supports the 2.4 context API. + * + * @param string $message The violation message + * @param array $parameters The message parameters + * + * @return ConstraintViolationBuilderInterface The violation builder + * + * @deprecated This method will be removed in Symfony 3.0. + */ + protected function buildViolation($message, array $parameters = array()) + { + if ($this->context instanceof ExecutionContextInterface2Dot5) { + return $this->context->buildViolation($message, $parameters); + } + + return new LegacyConstraintViolationBuilder($this->context, $message, $parameters); + } + + /** + * Wrapper for {@link ExecutionContextInterface::buildViolation} that + * supports the 2.4 context API. + * + * @param ExecutionContextInterface $context The context to use + * @param string $message The violation message + * @param array $parameters The message parameters + * + * @return ConstraintViolationBuilderInterface The violation builder + * + * @deprecated This method will be removed in Symfony 3.0. + */ + protected function buildViolationInContext(ExecutionContextInterface $context, $message, array $parameters = array()) + { + if ($context instanceof ExecutionContextInterface2Dot5) { + return $context->buildViolation($message, $parameters); + } + + return new LegacyConstraintViolationBuilder($context, $message, $parameters); + } + + /** + * Returns a string representation of the type of the value. + * + * This method should be used if you pass the type of a value as + * message parameter to a constraint violation. Note that such + * parameters should usually not be included in messages aimed at + * non-technical people. + * + * @param mixed $value The value to return the type of + * + * @return string The type of the value + */ + protected function formatTypeOf($value) + { + return is_object($value) ? get_class($value) : gettype($value); + } + + /** + * Returns a string representation of the value. + * + * This method returns the equivalent PHP tokens for most scalar types + * (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped + * in double quotes ("). Objects, arrays and resources are formatted as + * "object", "array" and "resource". If the parameter $prettyDateTime + * is set to true, {@link \DateTime} objects will be formatted as + * RFC-3339 dates ("Y-m-d H:i:s"). + * + * Be careful when passing message parameters to a constraint violation + * that (may) contain objects, arrays or resources. These parameters + * should only be displayed for technical users. Non-technical users + * won't know what an "object", "array" or "resource" is and will be + * confused by the violation message. + * + * @param mixed $value The value to format as string + * @param int $format A bitwise combination of the format + * constants in this class + * + * @return string The string representation of the passed value + */ + protected function formatValue($value, $format = 0) + { + if (($format & self::PRETTY_DATE) && $value instanceof \DateTime) { + if (class_exists('IntlDateFormatter')) { + $locale = \Locale::getDefault(); + $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT); + + return $formatter->format($value); + } + + return $value->format('Y-m-d H:i:s'); + } + + if (is_object($value)) { + if ($format & self::OBJECT_TO_STRING && method_exists($value, '__toString')) { + return $value->__toString(); + } + + return 'object'; + } + + if (is_array($value)) { + return 'array'; + } + + if (is_string($value)) { + return '"'.$value.'"'; + } + + if (is_resource($value)) { + return 'resource'; + } + + if (null === $value) { + return 'null'; + } + + if (false === $value) { + return 'false'; + } + + if (true === $value) { + return 'true'; + } + + return (string) $value; + } + + /** + * Returns a string representation of a list of values. + * + * Each of the values is converted to a string using + * {@link formatValue()}. The values are then concatenated with commas. + * + * @param array $values A list of values + * @param int $format A bitwise combination of the format + * constants in this class + * + * @return string The string representation of the value list + * + * @see formatValue() + */ + protected function formatValues(array $values, $format = 0) + { + foreach ($values as $key => $value) { + $values[$key] = $this->formatValue($value, $format); + } + + return implode(', ', $values); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php index 5cf36eccffc3ac02945238d8eee6805f0852d1bd..cc6981b9461cefbbfba3a82d172339b22e1dbcbd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Validator\Constraints\ExpressionValidator; /** @@ -28,33 +26,21 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface { protected $validators = array(); - /** - * @var PropertyAccessorInterface - */ private $propertyAccessor; - public function __construct(PropertyAccessorInterface $propertyAccessor = null) + public function __construct($propertyAccessor = null) { - $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); + $this->propertyAccessor = $propertyAccessor; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getInstance(Constraint $constraint) { $className = $constraint->validatedBy(); - // The second condition is a hack that is needed when CollectionValidator - // calls itself recursively (Collection constraints can be nested). - // Since the context of the validator is overwritten when initialize() - // is called for the nested constraint, the outer validator is - // acting on the wrong context when the nested validation terminates. - // - // A better solution - which should be approached in Symfony 3.0 - is to - // remove the initialize() method and pass the context as last argument - // to validate() instead. - if (!isset($this->validators[$className]) || 'Symfony\Component\Validator\Constraints\CollectionValidator' === $className) { + if (!isset($this->validators[$className])) { $this->validators[$className] = 'validator.expression' === $className ? new ExpressionValidator($this->propertyAccessor) : new $className(); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php index ca8d525f67da317fd10f9e82dd18d0c920e28b8c..d6a4e3095f424f9e387687f78b6cab4b5826510a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolation.php @@ -31,12 +31,12 @@ class ConstraintViolation implements ConstraintViolationInterface /** * @var array */ - private $messageParameters; + private $parameters; /** - * @var integer|null + * @var int|null */ - private $messagePluralization; + private $plural; /** * @var mixed @@ -61,27 +61,26 @@ class ConstraintViolation implements ConstraintViolationInterface /** * Creates a new constraint violation. * - * @param string $message The violation message. - * @param string $messageTemplate The raw violation message. - * @param array $messageParameters The parameters to substitute - * in the raw message. - * @param mixed $root The value originally passed - * to the validator. - * @param string $propertyPath The property path from the - * root value to the invalid - * value. - * @param mixed $invalidValue The invalid value causing the - * violation. - * @param integer|null $messagePluralization The pluralization parameter. - * @param mixed $code The error code of the - * violation, if any. - */ - public function __construct($message, $messageTemplate, array $messageParameters, $root, $propertyPath, $invalidValue, $messagePluralization = null, $code = null) + * @param string $message The violation message + * @param string $messageTemplate The raw violation message + * @param array $parameters The parameters to substitute in the + * raw violation message + * @param mixed $root The value originally passed to the + * validator + * @param string $propertyPath The property path from the root + * value to the invalid value + * @param mixed $invalidValue The invalid value that caused this + * violation + * @param int|null $plural The number for determining the plural + * form when translating the message + * @param mixed $code The error code of the violation + */ + public function __construct($message, $messageTemplate, array $parameters, $root, $propertyPath, $invalidValue, $plural = null, $code = null) { $this->message = $message; $this->messageTemplate = $messageTemplate; - $this->messageParameters = $messageParameters; - $this->messagePluralization = $messagePluralization; + $this->parameters = $parameters; + $this->plural = $plural; $this->root = $root; $this->propertyPath = $propertyPath; $this->invalidValue = $invalidValue; @@ -95,7 +94,14 @@ public function __construct($message, $messageTemplate, array $messageParameters */ public function __toString() { - $class = (string) (is_object($this->root) ? get_class($this->root) : $this->root); + if (is_object($this->root)) { + $class = 'Object('.get_class($this->root).')'; + } elseif (is_array($this->root)) { + $class = 'Array'; + } else { + $class = (string) $this->root; + } + $propertyPath = (string) $this->propertyPath; $code = $this->code; @@ -111,7 +117,7 @@ public function __toString() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getMessageTemplate() { @@ -119,23 +125,39 @@ public function getMessageTemplate() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getMessageParameters() { - return $this->messageParameters; + return $this->parameters; + } + + /** + * Alias of {@link getMessageParameters()}. + */ + public function getParameters() + { + return $this->parameters; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getMessagePluralization() { - return $this->messagePluralization; + return $this->plural; + } + + /** + * Alias of {@link getMessagePluralization()}. + */ + public function getPlural() + { + return $this->plural; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getMessage() { @@ -143,7 +165,7 @@ public function getMessage() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRoot() { @@ -151,7 +173,7 @@ public function getRoot() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getPropertyPath() { @@ -159,7 +181,7 @@ public function getPropertyPath() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getInvalidValue() { @@ -167,7 +189,7 @@ public function getInvalidValue() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getCode() { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationInterface.php index cf1d5b99671eb302f43a392f48724e3ef8c5c694..32be7c65506504d836379cc94c1795a686048f9b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationInterface.php @@ -85,7 +85,7 @@ public function getMessageParameters(); * This method returns the value of the parameter for choosing the right * pluralization form (in this case "choices"). * - * @return integer|null The number to use to pluralize of the message. + * @return int|null The number to use to pluralize of the message. */ public function getMessagePluralization(); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php index 84e0a6316dea467dd0b4a9eff1ce1fd20472aefe..cccfa86aea968c7f5601d5478bf0ba50b6394db6 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationList.php @@ -52,7 +52,7 @@ public function __toString() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function add(ConstraintViolationInterface $violation) { @@ -60,7 +60,7 @@ public function add(ConstraintViolationInterface $violation) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function addAll(ConstraintViolationListInterface $otherList) { @@ -70,7 +70,7 @@ public function addAll(ConstraintViolationListInterface $otherList) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function get($offset) { @@ -82,7 +82,7 @@ public function get($offset) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function has($offset) { @@ -90,7 +90,7 @@ public function has($offset) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function set($offset, ConstraintViolationInterface $violation) { @@ -98,7 +98,7 @@ public function set($offset, ConstraintViolationInterface $violation) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function remove($offset) { @@ -106,7 +106,7 @@ public function remove($offset) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator() { @@ -114,7 +114,7 @@ public function getIterator() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count() { @@ -122,7 +122,7 @@ public function count() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function offsetExists($offset) { @@ -130,7 +130,7 @@ public function offsetExists($offset) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function offsetGet($offset) { @@ -138,7 +138,7 @@ public function offsetGet($offset) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function offsetSet($offset, $violation) { @@ -150,7 +150,7 @@ public function offsetSet($offset, $violation) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function offsetUnset($offset) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationListInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationListInterface.php index 21b857ec09fb173326a0a972dfe31568e23702fc..6923519ff5468b5fb5fca960a271d91c343b8d00 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationListInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintViolationListInterface.php @@ -41,7 +41,7 @@ public function addAll(ConstraintViolationListInterface $otherList); /** * Returns the violation at a given offset. * - * @param integer $offset The offset of the violation. + * @param int $offset The offset of the violation. * * @return ConstraintViolationInterface The violation. * @@ -54,9 +54,9 @@ public function get($offset); /** * Returns whether the given offset exists. * - * @param integer $offset The violation offset. + * @param int $offset The violation offset. * - * @return Boolean Whether the offset exists. + * @return bool Whether the offset exists. * * @api */ @@ -65,7 +65,7 @@ public function has($offset); /** * Sets a violation at a given offset. * - * @param integer $offset The violation offset. + * @param int $offset The violation offset. * @param ConstraintViolationInterface $violation The violation. * * @api @@ -75,7 +75,7 @@ public function set($offset, ConstraintViolationInterface $violation); /** * Removes a violation at a given offset. * - * @param integer $offset The offset to remove. + * @param int $offset The offset to remove. * * @api */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php index b1d9ec67fe7a6b5276a7198115588340aea44b00..fb1f1f3ef7c758b5aea5698ebe2dce5495053d98 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparison.php @@ -25,11 +25,11 @@ abstract class AbstractComparison extends Constraint public $value; /** - * {@inheritDoc} + * {@inheritdoc} */ public function __construct($options = null) { - if (!isset($options['value'])) { + if (is_array($options) && !isset($options['value'])) { throw new ConstraintDefinitionException(sprintf( 'The %s constraint requires the "value" option to be set.', get_class($this) @@ -40,7 +40,7 @@ public function __construct($options = null) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getDefaultOption() { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index f6b919331fae7019dadf79bce936fa371062556a..ce7239d98ddf6137c9e401786bbe3504138dbf3d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -13,62 +13,38 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Provides a base class for the validation of property comparisons. * * @author Daniel Holmes <daniel@danielholmes.org> + * @author Bernhard Schussek <bschussek@gmail.com> */ abstract class AbstractComparisonValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof AbstractComparison) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\AbstractComparison'); + } + if (null === $value) { return; } - if (!$this->compareValues($value, $constraint->value, $constraint)) { - $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($constraint->value), - '{{ compared_value }}' => $this->valueToString($constraint->value), - '{{ compared_value_type }}' => $this->valueToType($constraint->value) - )); - } - } + $comparedValue = $constraint->value; - /** - * Returns a string representation of the type of the value. - * - * @param mixed $value - * - * @return string - */ - private function valueToType($value) - { - return is_object($value) ? get_class($value) : gettype($value); - } - - /** - * Returns a string representation of the value. - * - * @param mixed $value - * - * @return string - */ - private function valueToString($value) - { - if (is_object($value) && method_exists($value, '__toString')) { - return (string) $value; - } - - if ($value instanceof \DateTime) { - return $value->format('Y-m-d H:i:s'); + if (!$this->compareValues($value, $comparedValue)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING | self::PRETTY_DATE)) + ->setParameter('{{ compared_value }}', $this->formatValue($comparedValue, self::OBJECT_TO_STRING | self::PRETTY_DATE)) + ->setParameter('{{ compared_value_type }}', $this->formatTypeOf($comparedValue)) + ->addViolation(); } - - return var_export($value, true); } /** @@ -77,7 +53,7 @@ private function valueToString($value) * @param mixed $value1 The first value to compare * @param mixed $value2 The second value to compare * - * @return Boolean true if the relationship is valid, false otherwise + * @return bool true if the relationship is valid, false otherwise */ abstract protected function compareValues($value1, $value2); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php index 537168625ca0605103e10bd436b7e710cc277caf..95132971328fff8ce3d9b6559e10448b06e4f9a5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/All.php @@ -16,6 +16,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -26,7 +27,7 @@ class All extends Constraint public $constraints = array(); /** - * {@inheritDoc} + * {@inheritdoc} */ public function __construct($options = null) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AllValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AllValidator.php index c38f19a6669c0afe9cf2c54ed89db8378fce2125..29cf9859022cf783ba70891068d505a5f2b068c9 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AllValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AllValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -23,10 +24,14 @@ class AllValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof All) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\All'); + } + if (null === $value) { return; } @@ -35,11 +40,19 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'array or Traversable'); } - $group = $this->context->getGroup(); + $context = $this->context; + $group = $context->getGroup(); - foreach ($value as $key => $element) { - foreach ($constraint->constraints as $constr) { - $this->context->validateValue($element, $constr, '['.$key.']', $group); + if ($context instanceof ExecutionContextInterface) { + $validator = $context->getValidator()->inContext($context); + + foreach ($value as $key => $element) { + $validator->atPath('['.$key.']')->validate($element, $constraint->constraints, $group); + } + } else { + // 2.4 API + foreach ($value as $key => $element) { + $context->validateValue($element, $constraint->constraints, '['.$key.']', $group); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php index 509479d5e69d413d2a96deef82736d82664b07ef..766ce6c7bbbec50d5fd84671c9ca7e013dd2a6bc 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Blank.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/BlankValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/BlankValidator.php index 0a673588fc0f6509a4ed0b4c3977fd7f0e4f5087..031c7a581cd3a8595eb3e17f887fa32e1b30944f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/BlankValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/BlankValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,12 +23,18 @@ class BlankValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Blank) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Blank'); + } + if ('' !== $value && null !== $value) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php index 01aeb6ddb79828db593cf09433949214451029c7..312952a7fa2f8009656881a929dddf9ffa8c7782 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -71,6 +72,6 @@ public function getDefaultOption() */ public function getTargets() { - return self::CLASS_CONSTRAINT; + return array(self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CallbackValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CallbackValidator.php index 28b34250af6fccb5be862847846363b355eae9e3..a6a29e7e6e337a942b111cd5a9b20ed0e35bc6fd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -13,8 +13,8 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Validator for Callback constraint @@ -26,17 +26,17 @@ class CallbackValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($object, Constraint $constraint) { - if (null === $object) { - return; + if (!$constraint instanceof Callback) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Callback'); } if (null !== $constraint->callback && null !== $constraint->methods) { throw new ConstraintDefinitionException( - 'The Callback constraint supports either the option "callback" ' . + 'The Callback constraint supports either the option "callback" '. 'or "methods", but not both at the same time.' ); } @@ -56,18 +56,24 @@ public function validate($object, Constraint $constraint) } call_user_func($method, $object, $this->context); - } else { - if (!method_exists($object, $method)) { - throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method)); - } - $reflMethod = new \ReflectionMethod($object, $method); + continue; + } - if ($reflMethod->isStatic()) { - $reflMethod->invoke(null, $object, $this->context); - } else { - $reflMethod->invoke($object, $this->context); - } + if (null === $object) { + continue; + } + + if (!method_exists($object, $method)) { + throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method)); + } + + $reflMethod = new \ReflectionMethod($object, $method); + + if ($reflMethod->isStatic()) { + $reflMethod->invoke(null, $object, $this->context); + } else { + $reflMethod->invoke($object, $this->context); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardScheme.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardScheme.php index 0bc1c93afc7476f6aedc39249da898810673e92c..26a0e1c2fd466b4f0a4b75294dad3cea6f0d65df 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardScheme.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardScheme.php @@ -17,6 +17,9 @@ * Metadata for the CardSchemeValidator. * * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Tim Nagel <t.nagel@infinite.net.au> */ class CardScheme extends Constraint { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardSchemeValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardSchemeValidator.php index 1ece3fdd652757de6c2837bef05fe271ab9afc35..7cf7fa4bfe04cc1e2b2de1915b5be97c1118a4cc 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardSchemeValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CardSchemeValidator.php @@ -13,13 +13,16 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Validates that a card number belongs to a specified scheme. * + * @author Tim Nagel <t.nagel@infinite.net.au> + * @author Bernhard Schussek <bschussek@gmail.com> + * * @see http://en.wikipedia.org/wiki/Bank_card_number * @see http://www.regular-expressions.info/creditcard.html - * @author Tim Nagel <t.nagel@infinite.net.au> */ class CardSchemeValidator extends ConstraintValidator { @@ -28,14 +31,14 @@ class CardSchemeValidator extends ConstraintValidator * American Express card numbers start with 34 or 37 and have 15 digits. */ 'AMEX' => array( - '/^3[47][0-9]{13}$/' + '/^3[47][0-9]{13}$/', ), /** * China UnionPay cards start with 62 and have between 16 and 19 digits. * Please note that these cards do not follow Luhn Algorithm as a checksum. */ 'CHINA_UNIONPAY' => array( - '/^62[0-9]{14,17}$/' + '/^62[0-9]{14,17}$/', ), /** * Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. @@ -53,45 +56,45 @@ class CardSchemeValidator extends ConstraintValidator '/^6011[0-9]{12}$/', '/^64[4-9][0-9]{13}$/', '/^65[0-9]{14}$/', - '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/' + '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/', ), /** * InstaPayment cards begin with 637 through 639 and have 16 digits */ 'INSTAPAYMENT' => array( - '/^63[7-9][0-9]{13}$/' + '/^63[7-9][0-9]{13}$/', ), /** * JCB cards beginning with 2131 or 1800 have 15 digits. * JCB cards beginning with 35 have 16 digits. */ 'JCB' => array( - '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/' + '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/', ), /** * Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits */ 'LASER' => array( - '/^(6304|670[69]|6771)[0-9]{12,15}$/' + '/^(6304|670[69]|6771)[0-9]{12,15}$/', ), /** * Maestro cards begin with either 5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763 or 0604 * They have between 12 and 19 digits */ 'MAESTRO' => array( - '/^(5018|5020|5038|6304|6759|6761|676[23]|0604)[0-9]{8,15}$/' + '/^(5018|5020|5038|6304|6759|6761|676[23]|0604)[0-9]{8,15}$/', ), /** * All MasterCard numbers start with the numbers 51 through 55. All have 16 digits. */ 'MASTERCARD' => array( - '/^5[1-5][0-9]{14}$/' + '/^5[1-5][0-9]{14}$/', ), /** * All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13. */ 'VISA' => array( - '/^4([0-9]{12}|[0-9]{15})$/' + '/^4([0-9]{12}|[0-9]{15})$/', ), ); @@ -103,12 +106,18 @@ class CardSchemeValidator extends ConstraintValidator */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof CardScheme) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\CardScheme'); + } + if (null === $value || '' === $value) { return; } if (!is_numeric($value)) { - $this->context->addViolation($constraint->message); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); return; } @@ -124,6 +133,8 @@ public function validate($value, Constraint $constraint) } } - $this->context->addViolation($constraint->message); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php index 50508aeed2b6ad1917f92037f39ffabf27a5df66..c2b3436206f6fea1da8ba0822b1b146f56d34d0f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Choice.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -34,7 +35,7 @@ class Choice extends Constraint public $maxMessage = 'You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.'; /** - * {@inheritDoc} + * {@inheritdoc} */ public function getDefaultOption() { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 294e7dbfc931f5ff1d3ebea0eb8a418f7c9eafc9..5640c733173a5d5c93f5c871560e73f4c6ebad48 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -28,10 +28,14 @@ class ChoiceValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Choice) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Choice'); + } + if (!$constraint->choices && !$constraint->callback) { throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice'); } @@ -59,25 +63,38 @@ public function validate($value, Constraint $constraint) if ($constraint->multiple) { foreach ($value as $_value) { if (!in_array($_value, $choices, $constraint->strict)) { - $this->context->addViolation($constraint->multipleMessage, array('{{ value }}' => $_value)); + $this->buildViolation($constraint->multipleMessage) + ->setParameter('{{ value }}', $this->formatValue($_value)) + ->setInvalidValue($_value) + ->addViolation(); + + return; } } $count = count($value); if ($constraint->min !== null && $count < $constraint->min) { - $this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), null, (int) $constraint->min); + $this->buildViolation($constraint->minMessage) + ->setParameter('{{ limit }}', $constraint->min) + ->setPlural((int) $constraint->min) + ->addViolation(); return; } if ($constraint->max !== null && $count > $constraint->max) { - $this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), null, (int) $constraint->max); + $this->buildViolation($constraint->maxMessage) + ->setParameter('{{ limit }}', $constraint->max) + ->setPlural((int) $constraint->max) + ->addViolation(); return; } } elseif (!in_array($value, $choices, $constraint->strict)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php index 78fa5aee9dd5334d8529a36cc48ef5b0829aade7..1e9cb549de14fae57cdada101d42a903f1e8b180 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php @@ -16,6 +16,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -30,7 +31,7 @@ class Collection extends Constraint public $missingFieldsMessage = 'This field is missing.'; /** - * {@inheritDoc} + * {@inheritdoc} */ public function __construct($options = null) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php index 904d62e08f28256b10056d21cae2869b98280943..f7a9204eb66d699fc2db14546e5f2437ca513bbd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Optional.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php index 51af2de09ca8a3d96f3fdf9d65a49a88fe4d969a..e358343618bda66afc54608986093453dbb629ee 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection/Required.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php index f273ac40b95e5c72d18a74ad9915613f183fbfed..4289169b1606c30c2dde5ed7d4d5289d4245c80a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -23,10 +24,14 @@ class CollectionValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Collection) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Collection'); + } + if (null === $value) { return; } @@ -35,30 +40,52 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'array or Traversable and ArrayAccess'); } - $group = $this->context->getGroup(); + // We need to keep the initialized context when CollectionValidator + // calls itself recursively (Collection constraints can be nested). + // Since the context of the validator is overwritten when initialize() + // is called for the nested constraint, the outer validator is + // acting on the wrong context when the nested validation terminates. + // + // A better solution - which should be approached in Symfony 3.0 - is to + // remove the initialize() method and pass the context as last argument + // to validate() instead. + $context = $this->context; + $group = $context->getGroup(); foreach ($constraint->fields as $field => $fieldConstraint) { - if ( - // bug fix issue #2779 - (is_array($value) && array_key_exists($field, $value)) || - ($value instanceof \ArrayAccess && $value->offsetExists($field)) - ) { - foreach ($fieldConstraint->constraints as $constr) { - $this->context->validateValue($value[$field], $constr, '['.$field.']', $group); + // bug fix issue #2779 + $existsInArray = is_array($value) && array_key_exists($field, $value); + $existsInArrayAccess = $value instanceof \ArrayAccess && $value->offsetExists($field); + + if ($existsInArray || $existsInArrayAccess) { + if (count($fieldConstraint->constraints) > 0) { + if ($context instanceof ExecutionContextInterface) { + $context->getValidator() + ->inContext($context) + ->atPath('['.$field.']') + ->validate($value[$field], $fieldConstraint->constraints, $group); + } else { + // 2.4 API + $context->validateValue($value[$field], $fieldConstraint->constraints, '['.$field.']', $group); + } } } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) { - $this->context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array( - '{{ field }}' => $field - ), null); + $this->buildViolationInContext($context, $constraint->missingFieldsMessage) + ->atPath('['.$field.']') + ->setParameter('{{ field }}', $this->formatValue($field)) + ->setInvalidValue(null) + ->addViolation(); } } if (!$constraint->allowExtraFields) { foreach ($value as $field => $fieldValue) { if (!isset($constraint->fields[$field])) { - $this->context->addViolationAt('['.$field.']', $constraint->extraFieldsMessage, array( - '{{ field }}' => $field - ), $fieldValue); + $this->buildViolationInContext($context, $constraint->extraFieldsMessage) + ->atPath('['.$field.']') + ->setParameter('{{ field }}', $this->formatValue($field)) + ->setInvalidValue($fieldValue) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php index 4a233c19f6c5adf09ebea5c584f003d59c5e4076..1d64344b4ab6aa565d79d639928b33a71c1c6c14 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Count.php @@ -16,6 +16,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountValidator.php index 0a3be12f953cec6e2708ed42cb03ebd5662dd0b5..0f40a3f1e0deb60be44e86e420fc2ac6c6f1cf71 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountValidator.php @@ -21,7 +21,7 @@ class CountValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { @@ -35,29 +35,24 @@ public function validate($value, Constraint $constraint) $count = count($value); - if ($constraint->min == $constraint->max && $count != $constraint->min) { - $this->context->addViolation($constraint->exactMessage, array( - '{{ count }}' => $count, - '{{ limit }}' => $constraint->min, - ), $value, (int) $constraint->min); - - return; - } - if (null !== $constraint->max && $count > $constraint->max) { - $this->context->addViolation($constraint->maxMessage, array( - '{{ count }}' => $count, - '{{ limit }}' => $constraint->max, - ), $value, (int) $constraint->max); + $this->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->maxMessage) + ->setParameter('{{ count }}', $count) + ->setParameter('{{ limit }}', $constraint->max) + ->setInvalidValue($value) + ->setPlural((int) $constraint->max) + ->addViolation(); return; } if (null !== $constraint->min && $count < $constraint->min) { - $this->context->addViolation($constraint->minMessage, array( - '{{ count }}' => $count, - '{{ limit }}' => $constraint->min, - ), $value, (int) $constraint->min); + $this->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->minMessage) + ->setParameter('{{ count }}', $count) + ->setParameter('{{ limit }}', $constraint->min) + ->setInvalidValue($value) + ->setPlural((int) $constraint->min) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php index 81fa7e05fd858e62cf07d3091a6480ed55e4ef72..ff6f3d0e0a53979ed366e23c26f296c254d61bc1 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Country.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php index 1b3f8653e4ad6b9e6834775e2455be20f85bf7b2..a3ad1dc83bcaf51cb9cf69d6fd0ec0ea4e9390d7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -26,10 +26,14 @@ class CountryValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Country) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Country'); + } + if (null === $value || '' === $value) { return; } @@ -42,7 +46,9 @@ public function validate($value, Constraint $constraint) $countries = Intl::getRegionBundle()->getCountryNames(); if (!isset($countries[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php index b3bfc8f68b70c2eb56c7b7609edbf4e3ac40abe9..c09fe88bf27e9d7fca51db5b53c0acdc1a767241 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Currency.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Miha Vrhovnik <miha.vrhovnik@pagein.si> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php index 4465e46dfeecf79bbcf72eec0aeda6d6c615619f..ae3046f2eb1df394c07a60c6cad7ca19cf71e6e4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -26,10 +26,14 @@ class CurrencyValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Currency) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Currency'); + } + if (null === $value || '' === $value) { return; } @@ -42,7 +46,9 @@ public function validate($value, Constraint $constraint) $currencies = Intl::getCurrencyBundle()->getCurrencyNames(); if (!isset($currencies[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php index f9923052e0cf115967a4bc5e59fae4ed79cb6a5e..9e29168965153deacc8ffbdcd3e8556371e71d46 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Date.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php index 0618bc9b999230bb94076b92309d1cfff51fe079..1657f43afcd15a38b391543d5c63e0a7761f13c7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTime.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTimeValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTimeValidator.php index 49e04b94f2bd8e170f88412b473279ee1b17114a..88c8e2586229428fd099d332638d9069089e5439 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTimeValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateTimeValidator.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + /** * @author Bernhard Schussek <bschussek@gmail.com> * @@ -18,5 +21,45 @@ */ class DateTimeValidator extends DateValidator { - const PATTERN = '/^(\d{4})-(\d{2})-(\d{2}) (0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/'; + const PATTERN = '/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/'; + + /** + * {@inheritdoc} + */ + public function validate($value, Constraint $constraint) + { + if (!$constraint instanceof DateTime) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\DateTime'); + } + + if (null === $value || '' === $value || $value instanceof \DateTime) { + return; + } + + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + $value = (string) $value; + + if (!preg_match(static::PATTERN, $value, $matches)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + if (!DateValidator::checkDate($matches[1], $matches[2], $matches[3])) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + + if (!TimeValidator::checkTime($matches[4], $matches[5], $matches[6])) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateValidator.php index f891f9d621a9bef4ebefd58132aad50f42bf97fe..e1640b13b3858c2624ab09b3fd16507fb2bfc992 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/DateValidator.php @@ -25,10 +25,30 @@ class DateValidator extends ConstraintValidator const PATTERN = '/^(\d{4})-(\d{2})-(\d{2})$/'; /** - * {@inheritDoc} + * Checks whether a date is valid. + * + * @param int $year The year + * @param int $month The month + * @param int $day The day + * + * @return bool Whether the date is valid + * + * @internal + */ + public static function checkDate($year, $month, $day) + { + return checkdate($month, $day, $year); + } + + /** + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Date) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Date'); + } + if (null === $value || '' === $value || $value instanceof \DateTime) { return; } @@ -39,8 +59,18 @@ public function validate($value, Constraint $constraint) $value = (string) $value; - if (!preg_match(static::PATTERN, $value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + if (!preg_match(static::PATTERN, $value, $matches)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + if (!self::checkDate($matches[1], $matches[2], $matches[3])) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php index 581dfb985f721a39d0677c8b9abc8bfa3623ba0a..8d239a4a81e031207495ed78c4172180445bb870 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Email.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -25,4 +26,5 @@ class Email extends Constraint public $message = 'This value is not a valid email address.'; public $checkMX = false; public $checkHost = false; + public $strict = null; } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php index e0593102bc599accd8cdd8f3c6eb986d00b22bf0..1f487ca1c4a46d61d01b40ccf7e34d7e9f755ccc 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\RuntimeException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -23,10 +24,26 @@ class EmailValidator extends ConstraintValidator { /** - * {@inheritDoc} + * isStrict + * + * @var bool + */ + private $isStrict; + + public function __construct($strict = false) + { + $this->isStrict = $strict; + } + + /** + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Email) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Email'); + } + if (null === $value || '' === $value) { return; } @@ -36,21 +53,50 @@ public function validate($value, Constraint $constraint) } $value = (string) $value; - $valid = filter_var($value, FILTER_VALIDATE_EMAIL); - if ($valid) { - $host = substr($value, strpos($value, '@') + 1); + if (null === $constraint->strict) { + $constraint->strict = $this->isStrict; + } + + if ($constraint->strict) { + if (!class_exists('\Egulias\EmailValidator\EmailValidator')) { + throw new RuntimeException('Strict email validation requires egulias/email-validator'); + } + + $strictValidator = new \Egulias\EmailValidator\EmailValidator(); + + if (!$strictValidator->isValid($value, false, true)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); - // Check for host DNS resource records - if ($valid && $constraint->checkMX) { - $valid = $this->checkMX($host); - } elseif ($valid && $constraint->checkHost) { - $valid = $this->checkHost($host); + return; } + } elseif (!preg_match('/.+\@.+\..+/', $value)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + $host = substr($value, strpos($value, '@') + 1); + + // Check for host DNS resource records + if ($constraint->checkMX) { + if (!$this->checkMX($host)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + + return; } - if (!$valid) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + if ($constraint->checkHost && !$this->checkHost($host)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } @@ -59,7 +105,7 @@ public function validate($value, Constraint $constraint) * * @param string $host Host * - * @return Boolean + * @return bool */ private function checkMX($host) { @@ -71,7 +117,7 @@ private function checkMX($host) * * @param string $host Host * - * @return Boolean + * @return bool */ private function checkHost($host) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php index 3ae29a89fd201d4607388f5a3dfe3c0ea0804d98..8d3d7524ddf916344fd7288c9d8033c7037ca2bb 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualTo.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php index 2919f13633514bc065b160c8161c18ee53d00fce..3739dbebfe7a560ee632486ff9446e34e8f3327e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EqualToValidator.php @@ -19,7 +19,7 @@ class EqualToValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php index b845a32392b2c751ffbc57ee1b6738208551f982..dfa242c31a40c28296c30546e8520cd56e0f6da0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"}) * * @author Fabien Potencier <fabien@symfony.com> * @author Bernhard Schussek <bschussek@gmail.com> @@ -25,7 +26,7 @@ class Expression extends Constraint public $expression; /** - * {@inheritDoc} + * {@inheritdoc} */ public function getDefaultOption() { @@ -33,7 +34,7 @@ public function getDefaultOption() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRequiredOptions() { @@ -41,7 +42,7 @@ public function getRequiredOptions() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getTargets() { @@ -49,7 +50,7 @@ public function getTargets() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function validatedBy() { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php index e27859b08c19c97b3c560e35ab90307477927fa4..a20d1ac2518f431fbdf49b6bcb97fa3c39558481 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -11,12 +11,15 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; +use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\PropertyAccess\PropertyPath; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; +use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\RuntimeException; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Fabien Potencier <fabien@symfony.com> @@ -34,37 +37,61 @@ class ExpressionValidator extends ConstraintValidator */ private $expressionLanguage; - public function __construct(PropertyAccessorInterface $propertyAccessor) + /** + * @param PropertyAccessorInterface|null $propertyAccessor Optional as of Symfony 2.5 + * + * @throws UnexpectedTypeException If the property accessor is invalid + */ + public function __construct($propertyAccessor = null) { + if (null !== $propertyAccessor && !$propertyAccessor instanceof PropertyAccessorInterface) { + throw new UnexpectedTypeException($propertyAccessor, 'null or \Symfony\Component\PropertyAccess\PropertyAccessorInterface'); + } + $this->propertyAccessor = $propertyAccessor; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Expression) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Expression'); + } + if (null === $value || '' === $value) { return; } $variables = array(); - if (null === $this->context->getPropertyName()) { + // Symfony 2.5+ + if ($this->context instanceof ExecutionContextInterface) { + $variables['value'] = $value; + $variables['this'] = $this->context->getObject(); + } elseif (null === $this->context->getPropertyName()) { + $variables['value'] = $value; $variables['this'] = $value; } else { - // Extract the object that the property belongs to from the object - // graph - $path = new PropertyPath($this->context->getPropertyPath()); - $parentPath = $path->getParent(); $root = $this->context->getRoot(); - $variables['value'] = $value; - $variables['this'] = $parentPath ? $this->propertyAccessor->getValue($root, $parentPath) : $root; + + if (is_object($root)) { + // Extract the object that the property belongs to from the object + // graph + $path = new PropertyPath($this->context->getPropertyPath()); + $parentPath = $path->getParent(); + $variables['this'] = $parentPath ? $this->getPropertyAccessor()->getValue($root, $parentPath) : $root; + } else { + $variables['this'] = null; + } } if (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) { - $this->context->addViolation($constraint->message); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } @@ -79,4 +106,16 @@ private function getExpressionLanguage() return $this->expressionLanguage; } + + private function getPropertyAccessor() + { + if (null === $this->propertyAccessor) { + if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) { + throw new RuntimeException('Unable to use expressions as the Symfony PropertyAccess component is not installed.'); + } + $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); + } + + return $this->propertyAccessor; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php index fec54456fba0c6e4b083d0c0cddf0155358a2c1c..fc2e3e49cbd250d70e0cf49a7cd6e78531181c29 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/False.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FalseValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FalseValidator.php index 7cead615080a8ae0cfb6ee7fb11f272783340662..206780cefc73c1dbb24be1cb15c3c2a29adea29b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FalseValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FalseValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,14 +23,20 @@ class FalseValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof False) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\False'); + } + if (null === $value || false === $value || 0 === $value || '0' === $value) { return; } - $this->context->addViolation($constraint->message); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php index 9144c6047263114979dc40ad213e4678c8b3c062..80527171ecbef8cfbf63cae7afd656d6aa615033 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/File.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FileValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FileValidator.php index 06e16ebe2ca6838b026e79a641d6a5873309f0b2..acc80c9b079431f328caa24f4a3ef88f78ed32b4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/FileValidator.php @@ -11,12 +11,12 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\HttpFoundation\File\File as FileObject; +use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\HttpFoundation\File\File as FileObject; -use Symfony\Component\HttpFoundation\File\UploadedFile; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -25,11 +25,25 @@ */ class FileValidator extends ConstraintValidator { + const KB_BYTES = 1000; + + const MB_BYTES = 1000000; + + private static $suffices = array( + 1 => 'bytes', + self::KB_BYTES => 'kB', + self::MB_BYTES => 'MB', + ); + /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof File) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\File'); + } + if (null === $value || '' === $value) { return; } @@ -39,51 +53,59 @@ public function validate($value, Constraint $constraint) case UPLOAD_ERR_INI_SIZE: if ($constraint->maxSize) { if (ctype_digit((string) $constraint->maxSize)) { - $maxSize = (int) $constraint->maxSize; + $limitInBytes = (int) $constraint->maxSize; } elseif (preg_match('/^\d++k$/', $constraint->maxSize)) { - $maxSize = $constraint->maxSize * 1024; + $limitInBytes = $constraint->maxSize * self::KB_BYTES; } elseif (preg_match('/^\d++M$/', $constraint->maxSize)) { - $maxSize = $constraint->maxSize * 1048576; + $limitInBytes = $constraint->maxSize * self::MB_BYTES; } else { throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $constraint->maxSize)); } - $maxSize = min(UploadedFile::getMaxFilesize(), $maxSize); + $limitInBytes = min(UploadedFile::getMaxFilesize(), $limitInBytes); } else { - $maxSize = UploadedFile::getMaxFilesize(); + $limitInBytes = UploadedFile::getMaxFilesize(); } - $this->context->addViolation($constraint->uploadIniSizeErrorMessage, array( - '{{ limit }}' => $maxSize, - '{{ suffix }}' => 'bytes', - )); + $this->buildViolation($constraint->uploadIniSizeErrorMessage) + ->setParameter('{{ limit }}', $limitInBytes) + ->setParameter('{{ suffix }}', 'bytes') + ->addViolation(); return; case UPLOAD_ERR_FORM_SIZE: - $this->context->addViolation($constraint->uploadFormSizeErrorMessage); + $this->buildViolation($constraint->uploadFormSizeErrorMessage) + ->addViolation(); return; case UPLOAD_ERR_PARTIAL: - $this->context->addViolation($constraint->uploadPartialErrorMessage); + $this->buildViolation($constraint->uploadPartialErrorMessage) + ->addViolation(); return; case UPLOAD_ERR_NO_FILE: - $this->context->addViolation($constraint->uploadNoFileErrorMessage); + $this->buildViolation($constraint->uploadNoFileErrorMessage) + ->addViolation(); return; case UPLOAD_ERR_NO_TMP_DIR: - $this->context->addViolation($constraint->uploadNoTmpDirErrorMessage); + $this->buildViolation($constraint->uploadNoTmpDirErrorMessage) + ->addViolation(); return; case UPLOAD_ERR_CANT_WRITE: - $this->context->addViolation($constraint->uploadCantWriteErrorMessage); + $this->buildViolation($constraint->uploadCantWriteErrorMessage) + ->addViolation(); return; case UPLOAD_ERR_EXTENSION: - $this->context->addViolation($constraint->uploadExtensionErrorMessage); + $this->buildViolation($constraint->uploadExtensionErrorMessage) + ->addViolation(); return; default: - $this->context->addViolation($constraint->uploadErrorMessage); + $this->buildViolation($constraint->uploadErrorMessage) + ->setCode($value->getError()) + ->addViolation(); return; } @@ -96,41 +118,63 @@ public function validate($value, Constraint $constraint) $path = $value instanceof FileObject ? $value->getPathname() : (string) $value; if (!is_file($path)) { - $this->context->addViolation($constraint->notFoundMessage, array('{{ file }}' => $path)); + $this->buildViolation($constraint->notFoundMessage) + ->setParameter('{{ file }}', $this->formatValue($path)) + ->addViolation(); return; } if (!is_readable($path)) { - $this->context->addViolation($constraint->notReadableMessage, array('{{ file }}' => $path)); + $this->buildViolation($constraint->notReadableMessage) + ->setParameter('{{ file }}', $this->formatValue($path)) + ->addViolation(); return; } if ($constraint->maxSize) { - if (ctype_digit((string) $constraint->maxSize)) { - $size = filesize($path); - $limit = (int) $constraint->maxSize; - $suffix = 'bytes'; - } elseif (preg_match('/^\d++k$/', $constraint->maxSize)) { - $size = round(filesize($path) / 1000, 2); - $limit = (int) $constraint->maxSize; - $suffix = 'kB'; + $sizeInBytes = filesize($path); + $limitInBytes = (int) $constraint->maxSize; + + if (preg_match('/^\d++k$/', $constraint->maxSize)) { + $limitInBytes *= self::KB_BYTES; } elseif (preg_match('/^\d++M$/', $constraint->maxSize)) { - $size = round(filesize($path) / 1000000, 2); - $limit = (int) $constraint->maxSize; - $suffix = 'MB'; - } else { + $limitInBytes *= self::MB_BYTES; + } elseif (!ctype_digit((string) $constraint->maxSize)) { throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $constraint->maxSize)); } - if ($size > $limit) { - $this->context->addViolation($constraint->maxSizeMessage, array( - '{{ size }}' => $size, - '{{ limit }}' => $limit, - '{{ suffix }}' => $suffix, - '{{ file }}' => $path, - )); + if ($sizeInBytes > $limitInBytes) { + // Convert the limit to the smallest possible number + // (i.e. try "MB", then "kB", then "bytes") + $coef = self::MB_BYTES; + $limitAsString = (string) ($limitInBytes / $coef); + + // Restrict the limit to 2 decimals (without rounding! we + // need the precise value) + while (self::moreDecimalsThan($limitAsString, 2)) { + $coef /= 1000; + $limitAsString = (string) ($limitInBytes / $coef); + } + + // Convert size to the same measure, but round to 2 decimals + $sizeAsString = (string) round($sizeInBytes / $coef, 2); + + // If the size and limit produce the same string output + // (due to rounding), reduce the coefficient + while ($sizeAsString === $limitAsString) { + $coef /= 1000; + $limitAsString = (string) ($limitInBytes / $coef); + $sizeAsString = (string) round($sizeInBytes / $coef, 2); + } + + $this->buildViolation($constraint->maxSizeMessage) + ->setParameter('{{ file }}', $this->formatValue($path)) + ->setParameter('{{ size }}', $sizeAsString) + ->setParameter('{{ limit }}', $limitAsString) + ->setParameter('{{ suffix }}', self::$suffices[$coef]) + ->addViolation(); return; } @@ -143,29 +187,29 @@ public function validate($value, Constraint $constraint) $mimeTypes = (array) $constraint->mimeTypes; $mime = $value->getMimeType(); - $valid = false; foreach ($mimeTypes as $mimeType) { if ($mimeType === $mime) { - $valid = true; - break; + return; } if ($discrete = strstr($mimeType, '/*', true)) { if (strstr($mime, '/', true) === $discrete) { - $valid = true; - break; + return; } } } - if (false === $valid) { - $this->context->addViolation($constraint->mimeTypesMessage, array( - '{{ type }}' => '"'.$mime.'"', - '{{ types }}' => '"'.implode('", "', $mimeTypes) .'"', - '{{ file }}' => $path, - )); - } + $this->buildViolation($constraint->mimeTypesMessage) + ->setParameter('{{ file }}', $this->formatValue($path)) + ->setParameter('{{ type }}', $this->formatValue($mime)) + ->setParameter('{{ types }}', $this->formatValues($mimeTypes)) + ->addViolation(); } } + + private static function moreDecimalsThan($double, $numberOfDecimals) + { + return strlen((string) $double) > strlen(round($double, $numberOfDecimals)); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php index df911256604ed1143a9b3b639b6e7a67d1206d20..ec7fafb3a4cd61d6407bc3532871f87542dacfab 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThan.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php index 782893a04d5148cdca5eccd2e10c1f443164fdaf..36fdd9c0975d29c9ab226493d4030f027bf1d782 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqual.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php index f3b8210a3c398daa2d15da7dba7ab329dbe89687..23632041746424c15612634f89ba7bf7caeaa7a7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanOrEqualValidator.php @@ -19,7 +19,7 @@ class GreaterThanOrEqualValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php index c37ba44ddec44d6c1849e41c3abdf3864c3c4b54..fdcf0c1f94f6ca19fd4f2fd51082dece216a8629 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GreaterThanValidator.php @@ -19,7 +19,7 @@ class GreaterThanValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php index 304fab8c943b03d6c4c3220c6e2d19cbfc03eb39..9d50d486dc2ce236ef64704b5728717982c26cf1 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -11,25 +11,184 @@ namespace Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\Exception\OutOfBoundsException; + /** - * Annotation for group sequences + * A sequence of validation groups. + * + * When validating a group sequence, each group will only be validated if all + * of the previous groups in the sequence succeeded. For example: + * + * $validator->validate($address, null, new GroupSequence('Basic', 'Strict')); + * + * In the first step, all constraints that belong to the group "Basic" will be + * validated. If none of the constraints fail, the validator will then validate + * the constraints in group "Strict". This is useful, for example, if "Strict" + * contains expensive checks that require a lot of CPU or slow, external + * services. You usually don't want to run expensive checks if any of the cheap + * checks fail. + * + * When adding metadata to a class, you can override the "Default" group of + * that class with a group sequence: + * + * /** + * * @GroupSequence({"Address", "Strict"}) + * *\/ + * class Address + * { + * // ... + * } + * + * Whenever you validate that object in the "Default" group, the group sequence + * will be validated: + * + * $validator->validate($address); + * + * If you want to execute the constraints of the "Default" group for a class + * with an overridden default group, pass the class name as group name instead: + * + * $validator->validate($address, null, "Address") * * @Annotation + * @Target({"CLASS", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * * @api */ -class GroupSequence +class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable { /** - * The members of the sequence - * @var array + * The groups in the sequence + * + * @var string[]|GroupSequence[] */ public $groups; + /** + * The group in which cascaded objects are validated when validating + * this sequence. + * + * By default, cascaded objects are validated in each of the groups of + * the sequence. + * + * If a class has a group sequence attached, that sequence replaces the + * "Default" group. When validating that class in the "Default" group, the + * group sequence is used instead, but still the "Default" group should be + * cascaded to other objects. + * + * @var string|GroupSequence + */ + public $cascadedGroup; + + /** + * Creates a new group sequence. + * + * @param string[] $groups The groups in the sequence + */ public function __construct(array $groups) { - $this->groups = $groups['value']; + // Support for Doctrine annotations + $this->groups = isset($groups['value']) ? $groups['value'] : $groups; + } + + /** + * Returns an iterator for this group. + * + * @return \Traversable The iterator + * + * @see \IteratorAggregate::getIterator() + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ + public function getIterator() + { + return new \ArrayIterator($this->groups); + } + + /** + * Returns whether the given offset exists in the sequence. + * + * @param int $offset The offset + * + * @return bool Whether the offset exists + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ + public function offsetExists($offset) + { + return isset($this->groups[$offset]); + } + + /** + * Returns the group at the given offset. + * + * @param int $offset The offset + * + * @return string The group a the given offset + * + * @throws OutOfBoundsException If the object does not exist + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ + public function offsetGet($offset) + { + if (!isset($this->groups[$offset])) { + throw new OutOfBoundsException(sprintf( + 'The offset "%s" does not exist.', + $offset + )); + } + + return $this->groups[$offset]; + } + + /** + * Sets the group at the given offset. + * + * @param int $offset The offset + * @param string $value The group name + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ + public function offsetSet($offset, $value) + { + if (null !== $offset) { + $this->groups[$offset] = $value; + + return; + } + + $this->groups[] = $value; + } + + /** + * Removes the group at the given offset. + * + * @param int $offset The offset + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ + public function offsetUnset($offset) + { + unset($this->groups[$offset]); + } + + /** + * Returns the number of groups in the sequence. + * + * @return int The number of groups + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ + public function count() + { + return count($this->groups); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequenceProvider.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequenceProvider.php index 457155981a62ff39262cfe109dc0bfcc1c1d437a..f53f2b89860371c9236f85e7023c22e75722f500 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequenceProvider.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/GroupSequenceProvider.php @@ -15,8 +15,8 @@ * Annotation to define a group sequence provider * * @Annotation + * @Target({"CLASS", "ANNOTATION"}) */ class GroupSequenceProvider { - } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php index b1621959c91cd2946d90983e70ac4d3ab41264c5..895a93cd5860ea856d3aa853f7e0a9953007f1bd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Iban.php @@ -15,6 +15,10 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Manuel Reinhard <manu@sprain.ch> + * @author Michael Schummel */ class Iban extends Constraint { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php index 3ec4c6ea7a79a126e674179f440a1c5373d8a254..b66561dc2ade1d7fd5f24d05072a194ef6ae7405 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -13,58 +13,125 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Manuel Reinhard <manu@sprain.ch> * @author Michael Schummel + * @author Bernhard Schussek <bschussek@gmail.com> * @link http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/ */ class IbanValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Iban) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Iban'); + } + if (null === $value || '' === $value) { return; } - // An IBAN without a country code is not an IBAN. - if (0 === preg_match('/[A-Za-z]/', $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + $value = (string) $value; + + // Remove spaces + $canonicalized = str_replace(' ', '', $value); + + // The IBAN must have at least 4 characters... + if (strlen($canonicalized) < 4) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + // ...start with a country code... + if (!ctype_alpha($canonicalized{0}) || !ctype_alpha($canonicalized{1})) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); return; } - $teststring = preg_replace('/\s+/', '', $value); + // ...contain only digits and characters... + if (!ctype_alnum($canonicalized)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); - if (strlen($teststring) < 4) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + return; + } + + // ...and contain uppercase characters only + if ($canonicalized !== strtoupper($canonicalized)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); return; } - $teststring = substr($teststring, 4) - .strval(ord($teststring{0}) - 55) - .strval(ord($teststring{1}) - 55) - .substr($teststring, 2, 2); + // Move the first four characters to the end + // e.g. CH93 0076 2011 6238 5295 7 + // -> 0076 2011 6238 5295 7 CH93 + $canonicalized = substr($canonicalized, 4).substr($canonicalized, 0, 4); - $teststring = preg_replace_callback('/[A-Za-z]/', function ($letter) { - return intval(ord(strtolower($letter[0])) - 87); - }, $teststring); + // Convert all remaining letters to their ordinals + // The result is an integer, which is too large for PHP's int + // 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); - $rest = 0; - $strlen = strlen($teststring); - for ($pos = 0; $pos < $strlen; $pos += 7) { - $part = strval($rest).substr($teststring, $pos, 7); - $rest = intval($part) % 97; + // 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)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } + } + + private function toBigInt($string) + { + $chars = str_split($string); + $bigInt = ''; - if ($rest != 1) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + foreach ($chars as $char) { + // Convert uppercase characters to ordinals, starting with 10 for "A" + if (ctype_upper($char)) { + $bigInt .= (ord($char) - 55); - return; + continue; + } + + // Simply append digits + $bigInt .= $char; } + + return $bigInt; + } + + private function bigModulo97($bigInt) + { + $parts = str_split($bigInt, 7); + $rest = 0; + + foreach ($parts as $part) { + $rest = ($rest.$part) % 97; + } + + return $rest; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php index f4ae5becc3cf5c6a249a54154a7a610706150f64..6d00286d23d6ae4c2127265dcaabe549b068b384 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalTo.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php index 3d979513e3d2e575a5fd0fa8d360b9382a41c6f3..a1867262aa304b43bfe8c35e8b5754f46074d763 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IdenticalToValidator.php @@ -19,7 +19,7 @@ class IdenticalToValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Image.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Image.php index 9fa8725c6da155cac8e3629fd29c7c17be56a3cf..707e2af312e01ff845f36266f7a137b33422e588 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Image.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Image.php @@ -13,6 +13,9 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Benjamin Dulau <benjamin.dulau@gmail.com> * * @api */ @@ -29,6 +32,7 @@ class Image extends File public $allowLandscape = true; public $allowPortrait = true; + // The constant for a wrong MIME type is taken from the parent class. public $mimeTypesMessage = 'This file is not a valid image.'; public $sizeNotDetectedMessage = 'The size of the image could not be detected.'; public $maxWidthMessage = 'The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px.'; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ImageValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ImageValidator.php index 76ce8767fcea89bc752a3069c23690870d1cd1a0..4eaed687dc98548cfd15f6cb7e84381ec2d919f9 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ImageValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ImageValidator.php @@ -13,20 +13,26 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Validates whether a value is a valid image file and is valid * against minWidth, maxWidth, minHeight and maxHeight constraints * * @author Benjamin Dulau <benjamin.dulau@gmail.com> + * @author Bernhard Schussek <bschussek@gmail.com> */ class ImageValidator extends FileValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Image) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Image'); + } + $violations = count($this->context->getViolations()); parent::validate($value, $constraint); @@ -45,8 +51,10 @@ public function validate($value, Constraint $constraint) } $size = @getimagesize($value); + if (empty($size) || ($size[0] === 0) || ($size[1] === 0)) { - $this->context->addViolation($constraint->sizeNotDetectedMessage); + $this->buildViolation($constraint->sizeNotDetectedMessage) + ->addViolation(); return; } @@ -60,10 +68,10 @@ public function validate($value, Constraint $constraint) } if ($width < $constraint->minWidth) { - $this->context->addViolation($constraint->minWidthMessage, array( - '{{ width }}' => $width, - '{{ min_width }}' => $constraint->minWidth - )); + $this->buildViolation($constraint->minWidthMessage) + ->setParameter('{{ width }}', $width) + ->setParameter('{{ min_width }}', $constraint->minWidth) + ->addViolation(); return; } @@ -75,10 +83,10 @@ public function validate($value, Constraint $constraint) } if ($width > $constraint->maxWidth) { - $this->context->addViolation($constraint->maxWidthMessage, array( - '{{ width }}' => $width, - '{{ max_width }}' => $constraint->maxWidth - )); + $this->buildViolation($constraint->maxWidthMessage) + ->setParameter('{{ width }}', $width) + ->setParameter('{{ max_width }}', $constraint->maxWidth) + ->addViolation(); return; } @@ -90,10 +98,10 @@ public function validate($value, Constraint $constraint) } if ($height < $constraint->minHeight) { - $this->context->addViolation($constraint->minHeightMessage, array( - '{{ height }}' => $height, - '{{ min_height }}' => $constraint->minHeight - )); + $this->buildViolation($constraint->minHeightMessage) + ->setParameter('{{ height }}', $height) + ->setParameter('{{ min_height }}', $constraint->minHeight) + ->addViolation(); return; } @@ -105,14 +113,14 @@ public function validate($value, Constraint $constraint) } if ($height > $constraint->maxHeight) { - $this->context->addViolation($constraint->maxHeightMessage, array( - '{{ height }}' => $height, - '{{ max_height }}' => $constraint->maxHeight - )); + $this->buildViolation($constraint->maxHeightMessage) + ->setParameter('{{ height }}', $height) + ->setParameter('{{ max_height }}', $constraint->maxHeight) + ->addViolation(); } } - $ratio = $width / $height; + $ratio = round($width / $height, 2); if (null !== $constraint->minRatio) { if (!is_numeric((string) $constraint->minRatio)) { @@ -120,10 +128,10 @@ public function validate($value, Constraint $constraint) } if ($ratio < $constraint->minRatio) { - $this->context->addViolation($constraint->minRatioMessage, array( - '{{ ratio }}' => $ratio, - '{{ min_ratio }}' => $constraint->minRatio - )); + $this->buildViolation($constraint->minRatioMessage) + ->setParameter('{{ ratio }}', $ratio) + ->setParameter('{{ min_ratio }}', $constraint->minRatio) + ->addViolation(); } } @@ -133,33 +141,32 @@ public function validate($value, Constraint $constraint) } if ($ratio > $constraint->maxRatio) { - $this->context->addViolation($constraint->maxRatioMessage, array( - '{{ ratio }}' => $ratio, - '{{ max_ratio }}' => $constraint->maxRatio - )); + $this->buildViolation($constraint->maxRatioMessage) + ->setParameter('{{ ratio }}', $ratio) + ->setParameter('{{ max_ratio }}', $constraint->maxRatio) + ->addViolation(); } } if (!$constraint->allowSquare && $width == $height) { - $this->context->addViolation($constraint->allowSquareMessage, array( - '{{ width }}' => $width, - '{{ height }}' => $height - )); + $this->buildViolation($constraint->allowSquareMessage) + ->setParameter('{{ width }}', $width) + ->setParameter('{{ height }}', $height) + ->addViolation(); } if (!$constraint->allowLandscape && $width > $height) { - $this->context->addViolation($constraint->allowLandscapeMessage, array( - '{{ width }}' => $width, - '{{ height }}' => $height - )); + $this->buildViolation($constraint->allowLandscapeMessage) + ->setParameter('{{ width }}', $width) + ->setParameter('{{ height }}', $height) + ->addViolation(); } if (!$constraint->allowPortrait && $width < $height) { - $this->context->addViolation($constraint->allowPortraitMessage, array( - '{{ width }}' => $width, - '{{ height }}' => $height - )); + $this->buildViolation($constraint->allowPortraitMessage) + ->setParameter('{{ width }}', $width) + ->setParameter('{{ height }}', $height) + ->addViolation(); } - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php index 099f2aabd73482272a774f9746b1ccf372b7fa75..c059c69a6d3e479cda487e6ff2c1d785c5c593a1 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Ip.php @@ -11,13 +11,14 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; /** * Validates that a value is a valid IP address * * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @author Joseph Bielawski <stloyd@gmail.com> @@ -68,7 +69,7 @@ class Ip extends Constraint public $message = 'This is not a valid IP address.'; /** - * {@inheritDoc} + * {@inheritdoc} */ public function __construct($options = null) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IpValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IpValidator.php index 3358ec25c4d81d69eaf9251b443cd65c7af46094..8db2ddb062b039790d1871311ab7b72b9723af33 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IpValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IpValidator.php @@ -26,10 +26,14 @@ class IpValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Ip) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Ip'); + } + if (null === $value || '' === $value) { return; } @@ -91,7 +95,9 @@ public function validate($value, Constraint $constraint) } if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php index 4a11e2344852a3a2edee09a3ec077ecaf14dc451..90abedd2a8060929dd616f151ae8828f7e5cbf6e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Isbn.php @@ -12,34 +12,39 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Exception\MissingOptionsException; /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author The Whole Life To Learn <thewholelifetolearn@gmail.com> + * @author Manuel Reinhard <manu@sprain.ch> */ class Isbn extends Constraint { public $isbn10Message = 'This value is not a valid ISBN-10.'; public $isbn13Message = 'This value is not a valid ISBN-13.'; public $bothIsbnMessage = 'This value is neither a valid ISBN-10 nor a valid ISBN-13.'; - public $isbn10; - public $isbn13; + public $type; + public $message; - public function __construct($options = null) - { - if (null !== $options && !is_array($options)) { - $options = array( - 'isbn10' => $options, - 'isbn13' => $options, - ); - } + /** + * @deprecated Deprecated since version 2.5, to be removed in 3.0. Use option "type" instead. + * @var bool + */ + public $isbn10 = false; - parent::__construct($options); + /** + * @deprecated Deprecated since version 2.5, to be removed in 3.0. Use option "type" instead. + * @var bool + */ + public $isbn13 = false; - if (null === $this->isbn10 && null === $this->isbn13) { - throw new MissingOptionsException(sprintf('Either option "isbn10" or "isbn13" must be given for constraint "%s".', __CLASS__), array('isbn10', 'isbn13')); - } + /** + * {@inheritdoc} + */ + public function getDefaultOption() + { + return 'type'; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php index 62a3b0388e3b6a257d3966ed5a8056fa0e00aaeb..8972b91610406631a053ea491f110098c880226c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -16,19 +16,25 @@ 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 <thewholelifetolearn@gmail.com> + * @author Manuel Reinhard <manu@sprain.ch> + * @author Bernhard Schussek <bschussek@gmail.com> * * @see https://en.wikipedia.org/wiki/Isbn */ class IsbnValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Isbn) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Isbn'); + } + if (null === $value || '' === $value) { return; } @@ -37,53 +43,114 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'string'); } - if (!is_numeric($value)) { - $value = str_replace('-', '', $value); - } + $value = (string) $value; + $canonical = str_replace('-', '', $value); - $validation = 0; - $value = strtoupper($value); - $valueLength = strlen($value); - - if (10 === $valueLength && null !== $constraint->isbn10) { - for ($i = 0; $i < 10; $i++) { - if ($value[$i] == 'X') { - $validation += 10 * intval(10 - $i); - } else { - $validation += intval($value[$i]) * intval(10 - $i); - } + if (null == $constraint->type) { + if ($constraint->isbn10 && !$constraint->isbn13) { + $constraint->type = 'isbn10'; + } elseif ($constraint->isbn13 && !$constraint->isbn10) { + $constraint->type = 'isbn13'; } + } - if ($validation % 11 != 0) { - if (null !== $constraint->isbn13) { - $this->context->addViolation($constraint->bothIsbnMessage); - } else { - $this->context->addViolation($constraint->isbn10Message); - } - } - } elseif (13 === $valueLength && null !== $constraint->isbn13) { - for ($i = 0; $i < 13; $i += 2) { - $validation += intval($value[$i]); + // Explicitly validate against ISBN-10 + if ('isbn10' === $constraint->type) { + if (!$this->validateIsbn10($canonical)) { + $this->buildViolation($this->getMessage($constraint, $constraint->type)) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } - for ($i = 1; $i < 12; $i += 2) { - $validation += intval($value[$i]) * 3; + + return; + } + + // Explicitly validate against ISBN-13 + if ('isbn13' === $constraint->type) { + if (!$this->validateIsbn13($canonical)) { + $this->buildViolation($this->getMessage($constraint, $constraint->type)) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } - if ($validation % 10 != 0) { - if (null !== $constraint->isbn10) { - $this->context->addViolation($constraint->bothIsbnMessage); - } else { - $this->context->addViolation($constraint->isbn13Message); - } + return; + } + + // Try both ISBNs + if (!$this->validateIsbn10($canonical) && !$this->validateIsbn13($canonical)) { + $this->buildViolation($this->getMessage($constraint)) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + } + + protected function validateIsbn10($isbn) + { + $checkSum = 0; + + for ($i = 0; $i < 10; ++$i) { + if (!isset($isbn{$i})) { + return false; } - } else { - if (null !== $constraint->isbn10 && null !== $constraint->isbn13) { - $this->context->addViolation($constraint->bothIsbnMessage); - } elseif (null !== $constraint->isbn10) { - $this->context->addViolation($constraint->isbn10Message); + + if ('X' === $isbn{$i}) { + $digit = 10; + } elseif (ctype_digit($isbn{$i})) { + $digit = $isbn{$i}; } else { - $this->context->addViolation($constraint->isbn13Message); + return false; } + + $checkSum += $digit * intval(10 - $i); + } + + if (isset($isbn{$i})) { + return false; } + + return 0 === $checkSum % 11; + } + + protected function validateIsbn13($isbn) + { + if (!ctype_digit($isbn)) { + return false; + } + + $length = strlen($isbn); + + if ($length < 13) { + return false; + } + + if ($length > 13) { + return false; + } + + $checkSum = 0; + + for ($i = 0; $i < 13; $i += 2) { + $checkSum += $isbn{$i}; + } + + for ($i = 1; $i < 12; $i += 2) { + $checkSum += $isbn{$i} + * 3; + } + + return 0 === $checkSum % 10; + } + + protected function getMessage($constraint, $type = null) + { + if (null !== $constraint->message) { + return $constraint->message; + } elseif ('isbn10' === $type) { + return $constraint->isbn10Message; + } elseif ('isbn13' === $type) { + return $constraint->isbn13Message; + } + + return $constraint->bothIsbnMessage; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php index d7d77b65714620ef4d985757ef4d2c126897fe78..01a0f4315f6b2411fe3adeffb1a622481d3f30c7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Issn.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Antonio J. GarcÃa Lagar <aj@garcialagar.es> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php index 7e0baa876dceb528b1498b193507994a4bc1d50f..2ee8a53dfd7e5bb9bd45e038efc9cbe4ad871aee 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -19,16 +19,21 @@ * Validates whether the value is a valid ISSN. * * @author Antonio J. GarcÃa Lagar <aj@garcialagar.es> + * @author Bernhard Schussek <bschussek@gmail.com> * * @see https://en.wikipedia.org/wiki/Issn */ class IssnValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Issn) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Issn'); + } + if (null === $value || '' === $value) { return; } @@ -37,26 +42,84 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'string'); } - // Compose regex pattern - $digitsPattern = $constraint->requireHyphen ? '\d{4}-\d{3}' : '\d{4}-?\d{3}'; - $checksumPattern = $constraint->caseSensitive ? '[\d|X]' : '[\d|X|x]'; - $pattern = "/^".$digitsPattern.$checksumPattern."$/"; + $value = (string) $value; + $canonical = $value; + + // 1234-567X + // ^ + if (isset($canonical{4}) && '-' === $canonical{4}) { + // remove hyphen + $canonical = substr($canonical, 0, 4).substr($canonical, 5); + } elseif ($constraint->requireHyphen) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + $length = strlen($canonical); - if (!preg_match($pattern, $value)) { - $this->context->addViolation($constraint->message); - } else { - $digits = str_split(strtoupper(str_replace('-', '', $value))); + if ($length < 8) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + if ($length > 8) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } - $sum = 0; - for ($i = 8; $i > 1; $i--) { - $sum += $i * (int) array_shift($digits); - } + // 1234567X + // ^^^^^^^ digits only + if (!ctype_digit(substr($canonical, 0, 7))) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); - $checksum = 'X' == reset($digits) ? 10 : (int) reset($digits); + return; + } + + // 1234567X + // ^ digit, x or X + if (!ctype_digit($canonical{7}) && 'x' !== $canonical{7} && 'X' !== $canonical{7}) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + // 1234567X + // ^ case-sensitive? + if ($constraint->caseSensitive && 'x' === $canonical{7}) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + // Calculate a checksum. "X" equals 10. + $checkSum = 'X' === $canonical{7} || 'x' === $canonical{7} + ? 10 + : $canonical{7}; + + for ($i = 0; $i < 7; ++$i) { + // Multiply the first digit by 8, the second by 7, etc. + $checkSum += (8-$i) * $canonical{$i}; + } - if (0 != ($sum + $checksum) % 11) { - $this->context->addViolation($constraint->message); - } + if (0 !== $checkSum % 11) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php index d14bcd922b8d39edced2744468af8bbe04c57bb3..e7c29dc64b8caa887d66d905cb1061d352d5765f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php index 5c4dbed2980f55306628f5b4a7c73415fc9e43e6..1cc2a438197b29bd81a0f14f44e8ea95f199929f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -26,10 +26,14 @@ class LanguageValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Language) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Language'); + } + if (null === $value || '' === $value) { return; } @@ -42,7 +46,9 @@ public function validate($value, Constraint $constraint) $languages = Intl::getLanguageBundle()->getLanguageNames(); if (!isset($languages[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php index 84c7303e227bf26082a0689adc761309a71a9256..b353e9b24d3fb582a648dd1e4a894c040edc8fc3 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Length.php @@ -16,6 +16,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LengthValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LengthValidator.php index 8090a2c6a8aa6694cc4f34bb056dd071e935ab85..cdc5bea985df355792eb8268a5696d51550beea7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LengthValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LengthValidator.php @@ -21,10 +21,14 @@ class LengthValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Length) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Length'); + } + if (null === $value || '' === $value) { return; } @@ -43,29 +47,24 @@ public function validate($value, Constraint $constraint) $length = strlen($stringValue); } - if ($constraint->min == $constraint->max && $length != $constraint->min) { - $this->context->addViolation($constraint->exactMessage, array( - '{{ value }}' => $stringValue, - '{{ limit }}' => $constraint->min, - ), $value, (int) $constraint->min); - - return; - } - if (null !== $constraint->max && $length > $constraint->max) { - $this->context->addViolation($constraint->maxMessage, array( - '{{ value }}' => $stringValue, - '{{ limit }}' => $constraint->max, - ), $value, (int) $constraint->max); + $this->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->maxMessage) + ->setParameter('{{ value }}', $this->formatValue($stringValue)) + ->setParameter('{{ limit }}', $constraint->max) + ->setInvalidValue($value) + ->setPlural((int) $constraint->max) + ->addViolation(); return; } if (null !== $constraint->min && $length < $constraint->min) { - $this->context->addViolation($constraint->minMessage, array( - '{{ value }}' => $stringValue, - '{{ limit }}' => $constraint->min, - ), $value, (int) $constraint->min); + $this->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->minMessage) + ->setParameter('{{ value }}', $this->formatValue($stringValue)) + ->setParameter('{{ limit }}', $constraint->min) + ->setInvalidValue($value) + ->setPlural((int) $constraint->min) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php index 3d30ba25d3bd30822247e257bc9fa7dcdd55854b..b116320037d5dd1377ba71d63ac0dc02c13f5028 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThan.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php index 5171c359af614a64f61f5039a7f5bf94f41be9a7..7faca842215f976f2f2160a0b120b3f17990cd63 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqual.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php index 46204b41094a5152099f8038afb33d4b0501831d..dcc93b250379212a1b73d7dd89a6c69c7af622cf 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanOrEqualValidator.php @@ -19,7 +19,7 @@ class LessThanOrEqualValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php index 3d86ef366a43a5768e47e08daf1a4856360ad00a..081316a588c9098bc1fe926ad506d72615fe497d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LessThanValidator.php @@ -19,7 +19,7 @@ class LessThanValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php index 9cdd7880d047d094d88b49762063005bdd17127f..12a55464a6359ee8d70c7d3a1d09c96815b7dfd5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Locale.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php index 97c6aed97733af3f8398557b54e308686a2f7022..dadbebaf4297dc5e1fbbf09bcdf08163c7521ff0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -26,10 +26,14 @@ class LocaleValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Locale) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Locale'); + } + if (null === $value || '' === $value) { return; } @@ -42,7 +46,9 @@ public function validate($value, Constraint $constraint) $locales = Intl::getLocaleBundle()->getLocaleNames(); if (!isset($locales[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Luhn.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Luhn.php index f8fd35c6c80386de22547686262fa94a913ded39..e9b406adede159486fd9ce464203fcac17647720 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Luhn.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Luhn.php @@ -17,6 +17,10 @@ * Metadata for the LuhnValidator. * * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Tim Nagel <t.nagel@infinite.net.au> + * @author Greg Knapp http://gregk.me/2011/php-implementation-of-bank-card-luhn-algorithm/ */ class Luhn extends Constraint { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LuhnValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LuhnValidator.php index d3802fe99ae116432396ad201b231abddcb4a85a..c82d6d8917a07bed7f11c160b352423e909d24e7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LuhnValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LuhnValidator.php @@ -24,43 +24,70 @@ * @see http://en.wikipedia.org/wiki/Luhn_algorithm * @author Tim Nagel <t.nagel@infinite.net.au> * @author Greg Knapp http://gregk.me/2011/php-implementation-of-bank-card-luhn-algorithm/ + * @author Bernhard Schussek <bschussek@gmail.com> */ class LuhnValidator extends ConstraintValidator { /** - * Validates a creditcard number with the Luhn algorithm. + * Validates a credit card number with the Luhn algorithm. * * @param mixed $value * @param Constraint $constraint + * + * @throws UnexpectedTypeException when the given credit card number is no string */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Luhn) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Luhn'); + } + if (null === $value || '' === $value) { return; } - /** - * need to work with strings only because long numbers are treated as floats and don't work with strlen - */ - if (!is_string($value)) { + // Work with strings only, because long numbers are represented as floats + // internally and don't work with strlen() + if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedTypeException($value, 'string'); } - if (!is_numeric($value)) { - $this->context->addViolation($constraint->message); + $value = (string) $value; + + if (!ctype_digit($value)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); return; } + $checkSum = 0; $length = strlen($value); - $oddLength = $length % 2; - for ($sum = 0, $i = $length - 1; $i >= 0; $i--) { - $digit = (int) $value[$i]; - $sum += (($i % 2) === $oddLength) ? array_sum(str_split($digit * 2)) : $digit; + + // Starting with the last digit and walking left, add every second + // digit to the check sum + // e.g. 7 9 9 2 7 3 9 8 7 1 3 + // ^ ^ ^ ^ ^ ^ + // = 7 + 9 + 7 + 9 + 7 + 3 + for ($i = $length - 1; $i >= 0; $i -= 2) { + $checkSum += $value{$i}; + } + + // Starting with the second last digit and walking left, double every + // second digit and add it to the check sum + // For doubles greater than 9, sum the individual digits + // e.g. 7 9 9 2 7 3 9 8 7 1 3 + // ^ ^ ^ ^ ^ + // = 1+8 + 4 + 6 + 1+6 + 2 + for ($i = $length - 2; $i >= 0; $i -= 2) { + $checkSum += array_sum(str_split($value{$i} * 2)); } - if ($sum === 0 || ($sum % 10) !== 0) { - $this->context->addViolation($constraint->message); + if (0 === $checkSum || 0 !== $checkSum % 10) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php index 4365ca298ae816fc1616f2fa439b0bd6b09008ac..c578c6d81f3a011da9455e2332751fc18e79a538 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlank.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php index dd3dbdd8498a1680504d4f0f998de3656e52b8df..9deab1503b0266217f89e4ba50d1570142f5183e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,12 +23,18 @@ class NotBlankValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof NotBlank) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\NotBlank'); + } + if (false === $value || (empty($value) && '0' != $value)) { - $this->context->addViolation($constraint->message); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php index c532565978e58c6fd310b415835bf2e244399ad5..abd80920fb3b419d88624a7f1df7bb56206e164f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualTo.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php index 6618f31e402f3e69ae2ff7bbd77161abeba409c9..5710a85b93790e716c3a530a98ddbb0e216013c8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotEqualToValidator.php @@ -19,7 +19,7 @@ class NotEqualToValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php index 49da8586bbb5f2d215aed8961797fa155838f64a..fb4ef3f3c18369a83f85ee671cb7da6bef3845a2 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalTo.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Daniel Holmes <daniel@danielholmes.org> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php index ffcb8738dfa21b3c4c7b51165296d513e74cda78..ed8dc1c0dd3fcde3ce1d9b3d03d32d895ff97832 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotIdenticalToValidator.php @@ -19,7 +19,7 @@ class NotIdenticalToValidator extends AbstractComparisonValidator { /** - * @inheritDoc + * {@inheritdoc} */ protected function compareValues($value1, $value2) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php index 6b1c7c0836325aa385f83076352a721bdaf5ba80..60416c76ec2d411c1fdb1a1bb5c8c8afc2d4f9a8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNull.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNullValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNullValidator.php index 4ee65928ef0e0cf2563e6c3fc5ecb286549bff4a..a7a905ae149485c8486dfbb43cbb284ed741f5ab 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNullValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotNullValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,10 +23,14 @@ class NotNullValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof NotNull) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\NotNull'); + } + if (null === $value) { $this->context->addViolation($constraint->message); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php index e0a00221d19786738d9e2db68eb6ced30bd9ab3e..310455021bce6d868047c8b562cfb7691d0cafaa 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Null.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NullValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NullValidator.php index 9753f43315f37ae2eae03bae548aae267e17cd9c..1e6c3a53897abba0148da27ef713293cbf110b20 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NullValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,18 +23,18 @@ class NullValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { - if (null !== $value) { - if (is_object($value)) { - $value = get_class($value); - } elseif (is_array($value)) { - $value = 'Array'; - } + if (!$constraint instanceof Null) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Null'); + } - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + if (null !== $value) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php index 3f286e6340363b941295d11dde4372872c7a1140..dab8b4371f2c7ef6adaa3a793362efbf34f36039 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Optional.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php index e705175521bba9e089d0602ff888220ef7ae3578..067ffb8bf34dab3fd411f91e4e3eb9859705d00a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Range.php @@ -16,6 +16,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RangeValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RangeValidator.php index 1a8ba15ac35ee397bc78a3bd084291352115e5c6..0abd0cb449972d18814a5dae9d7540687871c729 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RangeValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RangeValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -20,36 +21,40 @@ class RangeValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Range) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Range'); + } + if (null === $value) { return; } if (!is_numeric($value)) { - $this->context->addViolation($constraint->invalidMessage, array( - '{{ value }}' => $value, - )); + $this->buildViolation($constraint->invalidMessage) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); return; } if (null !== $constraint->max && $value > $constraint->max) { - $this->context->addViolation($constraint->maxMessage, array( - '{{ value }}' => $value, - '{{ limit }}' => $constraint->max, - )); + $this->buildViolation($constraint->maxMessage) + ->setParameter('{{ value }}', $value) + ->setParameter('{{ limit }}', $constraint->max) + ->addViolation(); return; } if (null !== $constraint->min && $value < $constraint->min) { - $this->context->addViolation($constraint->minMessage, array( - '{{ value }}' => $value, - '{{ limit }}' => $constraint->min, - )); + $this->buildViolation($constraint->minMessage) + ->setParameter('{{ value }}', $value) + ->setParameter('{{ limit }}', $constraint->min) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php index beec99b1d1911ef25b8349fe1e3f35f51a86403c..aa4babba68e162295597332efb80ab6ea78d6b24 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Regex.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -28,7 +29,7 @@ class Regex extends Constraint public $match = true; /** - * {@inheritDoc} + * {@inheritdoc} */ public function getDefaultOption() { @@ -36,7 +37,7 @@ public function getDefaultOption() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRequiredOptions() { @@ -61,7 +62,7 @@ public function getHtmlPattern() } /** - * Convert the htmlPattern to a suitable format for HTML5 pattern. + * Converts the htmlPattern to a suitable format for HTML5 pattern. * Example: /^[a-z]+$/ would be converted to [a-z]+ * However, if options are specified, it cannot be converted * @@ -78,7 +79,7 @@ private function getNonDelimitedPattern() { // If match = false, pattern should not be added to HTML5 validation if (!$this->match) { - return null; + return; } if (preg_match('/^(.)(\^?)(.*?)(\$?)\1$/', $this->pattern, $matches)) { @@ -92,7 +93,5 @@ private function getNonDelimitedPattern() return $start.$pattern.$end; } - - return null; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RegexValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RegexValidator.php index c39869d2882b5106117a8c1dbb22590a9265a082..b18234454f095607f7af77ee820615ae7427a2fd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RegexValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/RegexValidator.php @@ -26,10 +26,14 @@ class RegexValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Regex) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Regex'); + } + if (null === $value || '' === $value) { return; } @@ -41,7 +45,9 @@ public function validate($value, Constraint $constraint) $value = (string) $value; if ($constraint->match xor preg_match($constraint->pattern, $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php index 609fffd84124d5cb3eaa7de46a231d67cfbf31f4..bd77a909f97fbadca4cf9bbc798d396988dc536c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Required.php @@ -13,6 +13,7 @@ /** * @Annotation + * @Target({"ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php index e7982ac6d6618889a1e4eb0020ad53425aa45200..42ede04325bea75c0f9b4e975ff17aab98770ec6 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Time.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TimeValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TimeValidator.php index 31259cc4b37738f73d1d027dba9692e37b7f5ce9..3d52fbe43585c8f158297c5b978c6d7d152844fd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -22,13 +22,33 @@ */ class TimeValidator extends ConstraintValidator { - const PATTERN = '/^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/'; + const PATTERN = '/^(\d{2}):(\d{2}):(\d{2})$/'; /** - * {@inheritDoc} + * Checks whether a time is valid. + * + * @param int $hour The hour + * @param int $minute The minute + * @param int $second The second + * + * @return bool Whether the time is valid + * + * @internal + */ + public static function checkTime($hour, $minute, $second) + { + return $hour >= 0 && $hour < 24 && $minute >= 0 && $minute < 60 && $second >= 0 && $second < 60; + } + + /** + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Time) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Time'); + } + if (null === $value || '' === $value || $value instanceof \DateTime) { return; } @@ -39,8 +59,18 @@ public function validate($value, Constraint $constraint) $value = (string) $value; - if (!preg_match(static::PATTERN, $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + if (!preg_match(static::PATTERN, $value, $matches)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + if (!self::checkTime($matches[1], $matches[2], $matches[3])) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Traverse.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Traverse.php new file mode 100644 index 0000000000000000000000000000000000000000..4abae6c67ab34d83525c73393b3cd7255ed2eb7a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Traverse.php @@ -0,0 +1,54 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; + +/** + * @Annotation + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class Traverse extends Constraint +{ + public $traverse = true; + + public function __construct($options = null) + { + if (is_array($options) && array_key_exists('groups', $options)) { + throw new ConstraintDefinitionException(sprintf( + 'The option "groups" is not supported by the constraint %s', + __CLASS__ + )); + } + + parent::__construct($options); + } + + /** + * {@inheritdoc} + */ + public function getDefaultOption() + { + return 'traverse'; + } + + /** + * {@inheritdoc} + */ + public function getTargets() + { + return self::CLASS_CONSTRAINT; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php index 9e1d994ba22e27f6ed7856c43f8b59260522750e..788e36a9ee2aade1295d4e0348c1d3b140b8ca73 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/True.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TrueValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TrueValidator.php index 2fbe0478ce1f00e5e62eca0ee5c06674b8b3b9f3..a01f5bb37deda3508fe00ae6612bbd5a7598f58b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TrueValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TrueValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,16 +23,22 @@ class TrueValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof True) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\True'); + } + if (null === $value) { return; } if (true !== $value && 1 !== $value && '1' !== $value) { - $this->context->addViolation($constraint->message); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php index cdcc10c91a39afaef7f5487d0fc230b048fb5bc2..fc4cc72eb685fab4ecd40b689efef8ca0bd1830b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Type.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -26,7 +27,7 @@ class Type extends Constraint public $type; /** - * {@inheritDoc} + * {@inheritdoc} */ public function getDefaultOption() { @@ -34,7 +35,7 @@ public function getDefaultOption() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRequiredOptions() { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TypeValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TypeValidator.php index ecc88dfbd16d19b1e559e44c604ba8ac48767594..ca6e5aa7ca0f41aadb7248d248fb0c227d0f5d02 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -22,10 +23,14 @@ class TypeValidator extends ConstraintValidator { /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Type) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Type'); + } + if (null === $value) { return; } @@ -43,9 +48,9 @@ public function validate($value, Constraint $constraint) return; } - $this->context->addViolation($constraint->message, array( - '{{ value }}' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value), - '{{ type }}' => $constraint->type, - )); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->setParameter('{{ type }}', $constraint->type) + ->addViolation(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php index 3585e1b0183eb52b22e579345481194face3bb7e..e867ee1f0a9c4934b14aa1c376891b20f42e46c2 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Url.php @@ -15,6 +15,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UrlValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UrlValidator.php index 1fc380ea9e7cd952650be57d4c148c097edee4ca..3d184775acd5df206bdbde350aeba716c7d08e00 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -24,11 +24,12 @@ class UrlValidator extends ConstraintValidator { const PATTERN = '~^ (%s):// # protocol + (([\pL\pN-]+:)?([\pL\pN-]+)@)? # basic auth ( - ([\pL\pN\pS-]+\.)+[\pL]+ # a domain name - | # or - \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address - | # or + ([\pL\pN\pS-\.])+(\.?([\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name + | # or + \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address + | # or \[ (?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,1}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,2}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,3}(?:(?:[0-9a-f]{1,4})))?::(?:(?:[0-9a-f]{1,4})):)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,4}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,5}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::)))) \] # a IPv6 address @@ -38,10 +39,14 @@ class UrlValidator extends ConstraintValidator $~ixu'; /** - * {@inheritDoc} + * {@inheritdoc} */ public function validate($value, Constraint $constraint) { + if (!$constraint instanceof Url) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Url'); + } + if (null === $value || '' === $value) { return; } @@ -51,11 +56,12 @@ public function validate($value, Constraint $constraint) } $value = (string) $value; - $pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols)); if (!preg_match($pattern, $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Uuid.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Uuid.php new file mode 100644 index 0000000000000000000000000000000000000000..dc73016401a1011021a38005eca0ffcf3aad4a22 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Uuid.php @@ -0,0 +1,60 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + * + * @author Colin O'Dell <colinodell@gmail.com> + */ +class Uuid extends Constraint +{ + // Possible versions defined by RFC 4122 + const V1_MAC = 1; + const V2_DCE = 2; + const V3_MD5 = 3; + const V4_RANDOM = 4; + const V5_SHA1 = 5; + + /** + * 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 + * + * Set this to `false` to allow legacy formats with different dash positioning or wrapping characters + * + * @var bool + */ + public $strict = true; + + /** + * Array of allowed versions (see version constants above) + * + * All UUID versions are allowed by default + * + * @var int[] + */ + public $versions = array( + self::V1_MAC, + self::V2_DCE, + self::V3_MD5, + self::V4_RANDOM, + self::V5_SHA1, + ); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UuidValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UuidValidator.php new file mode 100644 index 0000000000000000000000000000000000000000..5361f12de0f0aafbf2dbed00d1dcb8fa852248b1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/UuidValidator.php @@ -0,0 +1,107 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * Validates whether the value is a valid UUID per RFC 4122. + * + * @author Colin O'Dell <colinodell@gmail.com> + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see http://tools.ietf.org/html/rfc4122 + * @see https://en.wikipedia.org/wiki/Universally_unique_identifier + */ +class UuidValidator extends ConstraintValidator +{ + /** + * Regular expression which verifies allowed characters and the proper format. + * + * The strict pattern matches UUIDs like this: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx + * Roughly speaking: x = any hexadecimal character, M = any allowed version, N = any allowed variant. + */ + const STRICT_PATTERN = '/^[a-f0-9]{8}-[a-f0-9]{4}-[%s][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i'; + + /** + * The loose pattern validates similar yet non-compliant UUIDs. + * + * Dashes are completely optional. If present, they should only appear between every fourth character. + * The value can also be wrapped with characters like []{} for backwards-compatibility with other systems. + * Neither the version nor the variant is validated by this pattern. + */ + const LOOSE_PATTERN = '/^[a-f0-9]{4}(?:-?[a-f0-9]{4}){7}$/i'; + + /** + * Properly-formatted UUIDs contain 32 hex digits, separated by 4 dashes. + * We can use this fact to avoid performing a preg_match on strings of other sizes. + */ + const STRICT_UUID_LENGTH = 36; + + /** + * {@inheritdoc} + */ + public function validate($value, Constraint $constraint) + { + if (null === $value || '' === $value) { + return; + } + + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + $value = (string) $value; + + if ($constraint->strict) { + $length = strlen($value); + + if ($length < static::STRICT_UUID_LENGTH) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + if ($length > static::STRICT_UUID_LENGTH) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + + return; + } + + // Insert the allowed versions into the regular expression + $pattern = sprintf(static::STRICT_PATTERN, implode('', $constraint->versions)); + + if (!preg_match($pattern, $value)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + + return; + } + + // Trim any wrapping characters like [] or {} used by some legacy systems + $value = trim($value, '[]{}'); + + if (!preg_match(static::LOOSE_PATTERN, $value)) { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php index ab4676d3dfea74c222b29d3f9eefd31c0010f190..b0f518b8b82f84d201c7f073104f532cf415f108 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Valid.php @@ -16,6 +16,7 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) * * @author Bernhard Schussek <bschussek@gmail.com> * @@ -25,12 +26,18 @@ class Valid extends Constraint { public $traverse = true; - public $deep = false; + /** + * @deprecated Deprecated as of version 2.5, to be removed in Symfony 3.0. + */ + public $deep = true; public function __construct($options = null) { if (is_array($options) && array_key_exists('groups', $options)) { - throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint %s', __CLASS__)); + throw new ConstraintDefinitionException(sprintf( + 'The option "groups" is not supported by the constraint %s', + __CLASS__ + )); } parent::__construct($options); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php new file mode 100644 index 0000000000000000000000000000000000000000..a30382d3b7c2fdf6fb9e7d85510d72961d7a8fb0 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php @@ -0,0 +1,386 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Context; + +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\ClassBasedInterface; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\Exception\BadMethodCallException; +use Symfony\Component\Validator\Mapping\MetadataInterface; +use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; +use Symfony\Component\Validator\Util\PropertyPath; +use Symfony\Component\Validator\Validator\ValidatorInterface; +use Symfony\Component\Validator\Violation\ConstraintViolationBuilder; + +/** + * The context used and created by {@link ExecutionContextFactory}. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see ExecutionContextInterface + * + * @internal You should not instantiate or use this class. Code against + * {@link ExecutionContextInterface} instead. + */ +class ExecutionContext implements ExecutionContextInterface +{ + /** + * @var ValidatorInterface + */ + private $validator; + + /** + * The root value of the validated object graph. + * + * @var mixed + */ + private $root; + + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @var string + */ + private $translationDomain; + + /** + * The violations generated in the current context. + * + * @var ConstraintViolationList + */ + private $violations; + + /** + * The currently validated value. + * + * @var mixed + */ + private $value; + + /** + * The currently validated object. + * + * @var object|null + */ + private $object; + + /** + * The property path leading to the current value. + * + * @var string + */ + private $propertyPath = ''; + + /** + * The current validation metadata. + * + * @var MetadataInterface + */ + private $metadata; + + /** + * The currently validated group. + * + * @var string|null + */ + private $group; + + /** + * Stores which objects have been validated in which group. + * + * @var array + */ + private $validatedObjects = array(); + + /** + * Stores which class constraint has been validated for which object. + * + * @var array + */ + private $validatedConstraints = array(); + + /** + * Stores which objects have been initialized. + * + * @var array + */ + private $initializedObjects; + + /** + * Creates a new execution context. + * + * @param ValidatorInterface $validator The validator + * @param mixed $root The root value of the + * validated object graph + * @param TranslatorInterface $translator The translator + * @param string|null $translationDomain The translation domain to + * use for translating + * violation messages + * + * @internal Called by {@link ExecutionContextFactory}. Should not be used + * in user code. + */ + public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, $translationDomain = null) + { + $this->validator = $validator; + $this->root = $root; + $this->translator = $translator; + $this->translationDomain = $translationDomain; + $this->violations = new ConstraintViolationList(); + } + + /** + * {@inheritdoc} + */ + public function setNode($value, $object, MetadataInterface $metadata = null, $propertyPath) + { + $this->value = $value; + $this->object = $object; + $this->metadata = $metadata; + $this->propertyPath = (string) $propertyPath; + } + + /** + * {@inheritdoc} + */ + public function setGroup($group) + { + $this->group = $group; + } + + /** + * {@inheritdoc} + */ + public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) + { + // The parameters $invalidValue and following are ignored by the new + // API, as they are not present in the new interface anymore. + // You should use buildViolation() instead. + if (func_num_args() > 2) { + throw new BadMethodCallException( + 'The parameters $invalidValue, $pluralization and $code are '. + 'not supported anymore as of Symfony 2.5. Please use '. + 'buildViolation() instead or enable the legacy mode.' + ); + } + + $this->violations->add(new ConstraintViolation( + $this->translator->trans($message, $parameters, $this->translationDomain), + $message, + $parameters, + $this->root, + $this->propertyPath, + $this->value, + null, + null + )); + } + + /** + * {@inheritdoc} + */ + public function buildViolation($message, array $parameters = array()) + { + return new ConstraintViolationBuilder( + $this->violations, + $message, + $parameters, + $this->root, + $this->propertyPath, + $this->value, + $this->translator, + $this->translationDomain + ); + } + + /** + * {@inheritdoc} + */ + public function getViolations() + { + return $this->violations; + } + + /** + * {@inheritdoc} + */ + public function getValidator() + { + return $this->validator; + } + + /** + * {@inheritdoc} + */ + public function getRoot() + { + return $this->root; + } + + /** + * {@inheritdoc} + */ + public function getValue() + { + return $this->value; + } + + /** + * {@inheritdoc} + */ + public function getObject() + { + return $this->object; + } + + /** + * {@inheritdoc} + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * {@inheritdoc} + */ + public function getGroup() + { + return $this->group; + } + + /** + * {@inheritdoc} + */ + public function getClassName() + { + return $this->metadata instanceof ClassBasedInterface ? $this->metadata->getClassName() : null; + } + + /** + * {@inheritdoc} + */ + public function getPropertyName() + { + return $this->metadata instanceof PropertyMetadataInterface ? $this->metadata->getPropertyName() : null; + } + + /** + * {@inheritdoc} + */ + public function getPropertyPath($subPath = '') + { + return PropertyPath::append($this->propertyPath, $subPath); + } + + /** + * {@inheritdoc} + */ + public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) + { + throw new BadMethodCallException( + 'addViolationAt() is not supported anymore as of Symfony 2.5. '. + 'Please use buildViolation() instead or enable the legacy mode.' + ); + } + + /** + * {@inheritdoc} + */ + public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false) + { + throw new BadMethodCallException( + 'validate() is not supported anymore as of Symfony 2.5. '. + 'Please use getValidator() instead or enable the legacy mode.' + ); + } + + /** + * {@inheritdoc} + */ + public function validateValue($value, $constraints, $subPath = '', $groups = null) + { + throw new BadMethodCallException( + 'validateValue() is not supported anymore as of Symfony 2.5. '. + 'Please use getValidator() instead or enable the legacy mode.' + ); + } + + /** + * {@inheritdoc} + */ + public function getMetadataFactory() + { + throw new BadMethodCallException( + 'getMetadataFactory() is not supported anymore as of Symfony 2.5. '. + 'Please use getValidator() in combination with getMetadataFor() '. + 'or hasMetadataFor() instead or enable the legacy mode.' + ); + } + + /** + * {@inheritdoc} + */ + public function markGroupAsValidated($cacheKey, $groupHash) + { + if (!isset($this->validatedObjects[$cacheKey])) { + $this->validatedObjects[$cacheKey] = array(); + } + + $this->validatedObjects[$cacheKey][$groupHash] = true; + } + + /** + * {@inheritdoc} + */ + public function isGroupValidated($cacheKey, $groupHash) + { + return isset($this->validatedObjects[$cacheKey][$groupHash]); + } + + /** + * {@inheritdoc} + */ + public function markConstraintAsValidated($cacheKey, $constraintHash) + { + $this->validatedConstraints[$cacheKey.':'.$constraintHash] = true; + } + + /** + * {@inheritdoc} + */ + public function isConstraintValidated($cacheKey, $constraintHash) + { + return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]); + } + + /** + * {@inheritdoc} + */ + public function markObjectAsInitialized($cacheKey) + { + $this->initializedObjects[$cacheKey] = true; + } + + /** + * {@inheritdoc} + */ + public function isObjectInitialized($cacheKey) + { + return isset($this->initializedObjects[$cacheKey]); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..52bd1e6907cea2fda0109fbab85a70755a0b8b0a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextFactory.php @@ -0,0 +1,64 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Context; + +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * Creates new {@link ExecutionContext} instances. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @internal You should not instantiate or use this class. Code against + * {@link ExecutionContextFactoryInterface} instead. + */ +class ExecutionContextFactory implements ExecutionContextFactoryInterface +{ + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @var string|null + */ + private $translationDomain; + + /** + * Creates a new context factory. + * + * @param TranslatorInterface $translator The translator + * @param string|null $translationDomain The translation domain to + * use for translating + * violation messages + */ + public function __construct(TranslatorInterface $translator, $translationDomain = null) + { + $this->translator = $translator; + $this->translationDomain = $translationDomain; + } + + /** + * {@inheritdoc} + */ + public function createContext(ValidatorInterface $validator, $root) + { + return new ExecutionContext( + $validator, + $root, + $this->translator, + $this->translationDomain + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..f0ee00174f7c3c8c67600f7dd1faf2b61e6bf217 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextFactoryInterface.php @@ -0,0 +1,37 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Context; + +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * Creates instances of {@link ExecutionContextInterface}. + * + * You can use a custom factory if you want to customize the execution context + * that is passed through the validation run. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface ExecutionContextFactoryInterface +{ + /** + * Creates a new execution context. + * + * @param ValidatorInterface $validator The validator + * @param mixed $root The root value of the validated + * object graph + * + * @return ExecutionContextInterface The new execution context + */ + public function createContext(ValidatorInterface $validator, $root); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..f63ce15261298f4c6976dcdda964ec60b0a1812f --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/ExecutionContextInterface.php @@ -0,0 +1,215 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Context; + +use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface; +use Symfony\Component\Validator\Mapping\MetadataInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; +use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface; + +/** + * The context of a validation run. + * + * The context collects all violations generated during the validation. By + * default, validators execute all validations in a new context: + * + * $violations = $validator->validate($object); + * + * When you make another call to the validator, while the validation is in + * progress, the violations will be isolated from each other: + * + * public function validate($value, Constraint $constraint) + * { + * $validator = $this->context->getValidator(); + * + * // The violations are not added to $this->context + * $violations = $validator->validate($value); + * } + * + * However, if you want to add the violations to the current context, use the + * {@link ValidatorInterface::inContext()} method: + * + * public function validate($value, Constraint $constraint) + * { + * $validator = $this->context->getValidator(); + * + * // The violations are added to $this->context + * $validator + * ->inContext($this->context) + * ->validate($value) + * ; + * } + * + * Additionally, the context provides information about the current state of + * the validator, such as the currently validated class, the name of the + * currently validated property and more. These values change over time, so you + * cannot store a context and expect that the methods still return the same + * results later on. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface ExecutionContextInterface extends LegacyExecutionContextInterface +{ + /** + * Returns a builder for adding a violation with extended information. + * + * Call {@link ConstraintViolationBuilderInterface::addViolation()} to + * add the violation when you're done with the configuration: + * + * $context->buildViolation('Please enter a number between %min% and %max%.') + * ->setParameter('%min%', 3) + * ->setParameter('%max%', 10) + * ->setTranslationDomain('number_validation') + * ->addViolation(); + * + * @param string $message The error message + * @param array $parameters The parameters substituted in the error message + * + * @return ConstraintViolationBuilderInterface The violation builder + */ + public function buildViolation($message, array $parameters = array()); + + /** + * Returns the validator. + * + * Useful if you want to validate additional constraints: + * + * public function validate($value, Constraint $constraint) + * { + * $validator = $this->context->getValidator(); + * + * $violations = $validator->validateValue($value, new Length(array('min' => 3))); + * + * if (count($violations) > 0) { + * // ... + * } + * } + * + * @return ValidatorInterface + */ + public function getValidator(); + + /** + * Returns the currently validated object. + * + * If the validator is currently validating a class constraint, the + * object of that class is returned. If it is a validating a property or + * getter constraint, the object that the property/getter belongs to is + * returned. + * + * In other cases, null is returned. + * + * @return object|null The currently validated object or null. + */ + public function getObject(); + + /** + * Sets the currently validated value. + * + * @param mixed $value The validated value + * @param object|null $object The currently validated object + * @param MetadataInterface|null $metadata The validation metadata + * @param string $propertyPath The property path to the current value + * + * @internal Used by the validator engine. Should not be called by user + * code. + */ + public function setNode($value, $object, MetadataInterface $metadata = null, $propertyPath); + + /** + * Sets the currently validated group. + * + * @param string|null $group The validated group + * + * @internal Used by the validator engine. Should not be called by user + * code. + */ + public function setGroup($group); + + /** + * Marks an object as validated in a specific validation group. + * + * @param string $cacheKey The hash of the object + * @param string $groupHash The group's name or hash, if it is group + * sequence + * + * @internal Used by the validator engine. Should not be called by user + * code. + */ + public function markGroupAsValidated($cacheKey, $groupHash); + + /** + * Returns whether an object was validated in a specific validation group. + * + * @param string $cacheKey The hash of the object + * @param string $groupHash The group's name or hash, if it is group + * sequence + * + * @return bool Whether the object was already validated for that + * group + * + * @internal Used by the validator engine. Should not be called by user + * code. + */ + public function isGroupValidated($cacheKey, $groupHash); + + /** + * Marks a constraint as validated for an object. + * + * @param string $cacheKey The hash of the object + * @param string $constraintHash The hash of the constraint + * + * @internal Used by the validator engine. Should not be called by user + * code. + */ + public function markConstraintAsValidated($cacheKey, $constraintHash); + + /** + * Returns whether a constraint was validated for an object. + * + * @param string $cacheKey The hash of the object + * @param string $constraintHash The hash of the constraint + * + * @return bool Whether the constraint was already validated + * + * @internal Used by the validator engine. Should not be called by user + * code. + */ + public function isConstraintValidated($cacheKey, $constraintHash); + + /** + * Marks that an object was initialized. + * + * @param string $cacheKey The hash of the object + * + * @internal Used by the validator engine. Should not be called by user + * code. + * + * @see ObjectInitializerInterface + */ + public function markObjectAsInitialized($cacheKey); + + /** + * Returns whether an object was initialized. + * + * @param string $cacheKey The hash of the object + * + * @return bool Whether the object was already initialized + * + * @internal Used by the validator engine. Should not be called by user + * code. + * + * @see ObjectInitializerInterface + */ + public function isObjectInitialized($cacheKey); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContext.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContext.php new file mode 100644 index 0000000000000000000000000000000000000000..de34b1fc2cae6d542e3e6ce24d247d6981dcacb1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContext.php @@ -0,0 +1,156 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Context; + +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * An execution context that is compatible with the legacy API (< 2.5). + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ +class LegacyExecutionContext extends ExecutionContext +{ + /** + * @var MetadataFactoryInterface + */ + private $metadataFactory; + + /** + * Creates a new context. + * + * @see ExecutionContext::__construct() + * + * @internal Called by {@link LegacyExecutionContextFactory}. Should not be used + * in user code. + */ + public function __construct(ValidatorInterface $validator, $root, MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null) + { + parent::__construct( + $validator, + $root, + $translator, + $translationDomain + ); + + $this->metadataFactory = $metadataFactory; + } + + /** + * {@inheritdoc} + */ + public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) + { + if (func_num_args() > 2) { + $this + ->buildViolation($message, $parameters) + ->setInvalidValue($invalidValue) + ->setPlural($plural) + ->setCode($code) + ->addViolation() + ; + + return; + } + + parent::addViolation($message, $parameters); + } + + /** + * {@inheritdoc} + */ + public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) + { + if (func_num_args() > 2) { + $this + ->buildViolation($message, $parameters) + ->atPath($subPath) + ->setInvalidValue($invalidValue) + ->setPlural($plural) + ->setCode($code) + ->addViolation() + ; + + return; + } + + $this + ->buildViolation($message, $parameters) + ->atPath($subPath) + ->addViolation() + ; + } + + /** + * {@inheritdoc} + */ + public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false) + { + if (is_array($value)) { + // The $traverse flag is ignored for arrays + $constraint = new Valid(array('traverse' => true, 'deep' => $deep)); + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, $constraint, $groups) + ; + } + + if ($traverse && $value instanceof \Traversable) { + $constraint = new Valid(array('traverse' => true, 'deep' => $deep)); + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, $constraint, $groups) + ; + } + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, null, $groups) + ; + } + + /** + * {@inheritdoc} + */ + public function validateValue($value, $constraints, $subPath = '', $groups = null) + { + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, $constraints, $groups) + ; + } + + /** + * {@inheritdoc} + */ + public function getMetadataFactory() + { + return $this->metadataFactory; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..cf5cd07e9ef54beeaf2be6ef78f24c96b88f5e69 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php @@ -0,0 +1,73 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Context; + +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * Creates new {@link LegacyExecutionContext} instances. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ +class LegacyExecutionContextFactory implements ExecutionContextFactoryInterface +{ + /** + * @var MetadataFactoryInterface + */ + private $metadataFactory; + + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @var string|null + */ + private $translationDomain; + + /** + * Creates a new context factory. + * + * @param MetadataFactoryInterface $metadataFactory The metadata factory + * @param TranslatorInterface $translator The translator + * @param string|null $translationDomain The translation domain + * to use for translating + * violation messages + */ + public function __construct(MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null) + { + $this->metadataFactory = $metadataFactory; + $this->translator = $translator; + $this->translationDomain = $translationDomain; + } + + /** + * {@inheritdoc} + */ + public function createContext(ValidatorInterface $validator, $root) + { + return new LegacyExecutionContext( + $validator, + $root, + $this->metadataFactory, + $this->translator, + $this->translationDomain + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/DefaultTranslator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/DefaultTranslator.php index 20b2e11350839ef50799b0367b5ba7feb69a04f9..3c1171f160909be833216a5f9c7235798e58da75 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/DefaultTranslator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/DefaultTranslator.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Exception\BadMethodCallException; use Symfony\Component\Validator\Exception\InvalidArgumentException; -use Symfony\Component\Translation\TranslatorInterface; /** * Simple translator implementation that simply replaces the parameters in @@ -118,7 +118,7 @@ public function trans($id, array $parameters = array(), $domain = null, $locale * // -> These are 3 donkeys. * * @param string $id The message id - * @param integer $number The number to use to find the index of the message + * @param int $number The number to use to find the index of the message * @param array $parameters An array of parameters for the message * @param string $domain Ignored * @param string $locale Ignored diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/OutOfBoundsException.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/OutOfBoundsException.php similarity index 77% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/OutOfBoundsException.php rename to core/vendor/symfony/validator/Symfony/Component/Validator/Exception/OutOfBoundsException.php index a3c45597dabc19cac8bf51616eca6b2e6c45f991..30906e8a82ca06bf3b05bdf52c5fef8b30edd62e 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/OutOfBoundsException.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/OutOfBoundsException.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Validator\Exception; /** - * Base OutOfBoundsException for the PropertyAccess component. + * Base OutOfBoundsException for the Validator component. * * @author Bernhard Schussek <bschussek@gmail.com> */ diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php similarity index 68% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php rename to core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php index d1fcdac94253c2f8fa45418798ce45ee3e0ac4ab..c6ece50b700622fb2fce7225401e020e4d1d9ecc 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnsupportedMetadataException.php @@ -9,13 +9,12 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Validator\Exception; /** - * Marker interface for the PropertyAccess component. - * + * @since 2.5 * @author Bernhard Schussek <bschussek@gmail.com> */ -interface ExceptionInterface +class UnsupportedMetadataException extends InvalidArgumentException { } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/ValidatorException.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/ValidatorException.php index 6ee2416d848250b49c26aa75e821b9807e50dd56..28bd4704e8fdb732734e1cad622503a94dba2a05 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/ValidatorException.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/ValidatorException.php @@ -11,6 +11,6 @@ namespace Symfony\Component\Validator\Exception; -class ValidatorException extends \RuntimeException +class ValidatorException extends RuntimeException { } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php index 31a959187e354f2db6fae7c50f337cbd4c4db7ed..31911b8d712c6d122a70fd3739e3a009e7c1bf0c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContext.php @@ -20,6 +20,9 @@ * * @author Fabien Potencier <fabien@symfony.com> * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContext} instead. */ class ExecutionContext implements ExecutionContextInterface { @@ -87,13 +90,13 @@ public function __construct(GlobalExecutionContextInterface $globalContext, Tran /** * {@inheritdoc} */ - public function addViolation($message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null) + public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null) { - if (null === $pluralization) { + if (null === $plural) { $translatedMessage = $this->translator->trans($message, $params, $this->translationDomain); } else { try { - $translatedMessage = $this->translator->transChoice($message, $pluralization, $params, $this->translationDomain); + $translatedMessage = $this->translator->transChoice($message, $plural, $params, $this->translationDomain); } catch (\InvalidArgumentException $e) { $translatedMessage = $this->translator->trans($message, $params, $this->translationDomain); } @@ -107,7 +110,7 @@ public function addViolation($message, array $params = array(), $invalidValue = $this->propertyPath, // check using func_num_args() to allow passing null values func_num_args() >= 3 ? $invalidValue : $this->value, - $pluralization, + $plural, $code )); } @@ -115,19 +118,19 @@ public function addViolation($message, array $params = array(), $invalidValue = /** * {@inheritdoc} */ - public function addViolationAt($subPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null) + public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) { $this->globalContext->getViolations()->add(new ConstraintViolation( - null === $pluralization - ? $this->translator->trans($message, $params, $this->translationDomain) - : $this->translator->transChoice($message, $pluralization, $params, $this->translationDomain), + null === $plural + ? $this->translator->trans($message, $parameters, $this->translationDomain) + : $this->translator->transChoice($message, $plural, $parameters, $this->translationDomain), $message, - $params, + $parameters, $this->globalContext->getRoot(), $this->getPropertyPath($subPath), // check using func_num_args() to allow passing null values func_num_args() >= 4 ? $invalidValue : $this->value, - $pluralization, + $plural, $code )); } @@ -168,8 +171,6 @@ public function getClassName() if ($this->metadata instanceof ClassBasedInterface) { return $this->metadata->getClassName(); } - - return null; } /** @@ -180,8 +181,6 @@ public function getPropertyName() if ($this->metadata instanceof PropertyMetadataInterface) { return $this->metadata->getPropertyName(); } - - return null; } /** diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContextInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContextInterface.php index 0b6c86633d6e5293528fb670e7fd4d36fb9cfd11..375d8cfd52fddb05cc461d2a8b6a88beb29acecb 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContextInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ExecutionContextInterface.php @@ -82,36 +82,47 @@ * @author Bernhard Schussek <bschussek@gmail.com> * * @api + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContextInterface} instead. */ interface ExecutionContextInterface { /** * Adds a violation at the current node of the validation graph. * - * @param string $message The error message. - * @param array $params The parameters substituted in the error message. - * @param mixed $invalidValue The invalid, validated value. - * @param integer|null $pluralization The number to use to pluralize of the message. - * @param integer|null $code The violation code. + * @param string $message The error message + * @param array $params The parameters substituted in the error message + * @param mixed $invalidValue The invalid, validated value + * @param int|null $plural The number to use to pluralize of the message + * @param int|null $code The violation code * * @api + * + * @deprecated The parameters $invalidValue, $pluralization and $code are + * deprecated since version 2.5 and will be removed in + * Symfony 3.0. */ - public function addViolation($message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null); + public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null); /** * Adds a violation at the validation graph node with the given property * path relative to the current property path. * - * @param string $subPath The relative property path for the violation. - * @param string $message The error message. - * @param array $params The parameters substituted in the error message. - * @param mixed $invalidValue The invalid, validated value. - * @param integer|null $pluralization The number to use to pluralize of the message. - * @param integer|null $code The violation code. + * @param string $subPath The relative property path for the violation + * @param string $message The error message + * @param array $parameters The parameters substituted in the error message + * @param mixed $invalidValue The invalid, validated value + * @param int|null $plural The number to use to pluralize of the message + * @param int|null $code The violation code * * @api + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContextInterface::buildViolation()} + * instead. */ - public function addViolationAt($subPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null); + public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null); /** * Validates the given value within the scope of the current validation. @@ -147,10 +158,14 @@ public function addViolationAt($subPath, $message, array $params = array(), $inv * @param null|string|string[] $groups The groups to validate in. If you don't pass any * groups here, the current group of the context * will be used. - * @param Boolean $traverse Whether to traverse the value if it is an array + * @param bool $traverse Whether to traverse the value if it is an array * or an instance of <tt>\Traversable</tt>. - * @param Boolean $deep Whether to traverse the value recursively if + * @param bool $deep Whether to traverse the value recursively if * it is a collection of collections. + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContextInterface::getValidator()} + * instead. */ public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false); @@ -180,6 +195,10 @@ public function validate($value, $subPath = '', $groups = null, $traverse = fals * @param null|string|string[] $groups The groups to validate in. If you don't pass any * groups here, the current group of the context * will be used. + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContextInterface::getValidator()} + * instead. */ public function validateValue($value, $constraints, $subPath = '', $groups = null); @@ -237,6 +256,12 @@ public function getMetadata(); * Returns the used metadata factory. * * @return MetadataFactoryInterface The metadata factory. + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContextInterface::getValidator()} + * instead and call + * {@link Validator\ValidatorInterface::getMetadataFor()} or + * {@link Validator\ValidatorInterface::hasMetadataFor()} there. */ public function getMetadataFactory(); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/GlobalExecutionContextInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/GlobalExecutionContextInterface.php index aff44b350769fff478b0e3506e26cb7a3089134c..fb2aef3bd772d1577f87f420fa652829f92f0cf4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/GlobalExecutionContextInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/GlobalExecutionContextInterface.php @@ -26,6 +26,9 @@ * </ul> * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Context\ExecutionContextInterface} instead. */ interface GlobalExecutionContextInterface { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/LICENSE b/core/vendor/symfony/validator/Symfony/Component/Validator/LICENSE index 88a57f8d8da49126c6f7d225d567ad216ace4d83..0b3292cf9023507c2f1f93ddfee7dd8e15838048 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/LICENSE +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +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 diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php index 90dd282e08712fe246609a0e0ddf0867f000b253..7913e156254992224e5e05205966d5f0d099a66e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php @@ -11,28 +11,14 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\MetadataFactoryInterface; - /** - * Simple implementation of MetadataFactoryInterface that can be used when using ValidatorInterface::validateValue(). + * Alias of {@link Factory\BlackHoleMetadataFactory}. * * @author Fabien Potencier <fabien@symfony.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Factory\BlackHoleMetadataFactory} instead. */ -class BlackholeMetadataFactory implements MetadataFactoryInterface +class BlackholeMetadataFactory extends \Symfony\Component\Validator\Mapping\Factory\BlackHoleMetadataFactory { - /** - * @inheritdoc - */ - public function getMetadataFor($value) - { - throw new \LogicException('BlackholeClassMetadataFactory only works with ValidatorInterface::validateValue().'); - } - - /** - * @inheritdoc - */ - public function hasMetadataFor($value) - { - return false; - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/ApcCache.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/ApcCache.php index 226fab36e0c341169283df606913be9ade78af6d..64929b09663abcc788bf7d73710b1424d4bb9fe8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/ApcCache.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/ApcCache.php @@ -13,6 +13,10 @@ use Symfony\Component\Validator\Mapping\ClassMetadata; +/** + * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * Use DoctrineCache with Doctrine\Common\Cache\ApcCache instead. + */ class ApcCache implements CacheInterface { private $prefix; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php new file mode 100644 index 0000000000000000000000000000000000000000..6dd5447fedc88a98d44b935ac99ee278bc4464cd --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Cache/DoctrineCache.php @@ -0,0 +1,69 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping\Cache; + +use Doctrine\Common\Cache\Cache; +use Symfony\Component\Validator\Mapping\ClassMetadata; + +/** + * Adapts a Doctrine cache to a CacheInterface. + * + * @author Florian Voutzinos <florian@voutzinos.com> + */ +final class DoctrineCache implements CacheInterface +{ + private $cache; + + /** + * Creates a new Doctrine cache. + * + * @param Cache $cache The cache to adapt + */ + public function __construct(Cache $cache) + { + $this->cache = $cache; + } + + /** + * Sets the cache to adapt. + * + * @param Cache $cache The cache to adapt + */ + public function setCache(Cache $cache) + { + $this->cache = $cache; + } + + /** + * {@inheritdoc} + */ + public function has($class) + { + return $this->cache->contains($class); + } + + /** + * {@inheritdoc} + */ + public function read($class) + { + return $this->cache->fetch($class); + } + + /** + * {@inheritdoc} + */ + public function write(ClassMetadata $metadata) + { + $this->cache->save($metadata->getClassName(), $metadata); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/CascadingStrategy.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/CascadingStrategy.php new file mode 100644 index 0000000000000000000000000000000000000000..ff2853f4e0415a8384c202d4b61d465e64683041 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/CascadingStrategy.php @@ -0,0 +1,53 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping; + +/** + * Specifies whether an object should be cascaded. + * + * Cascading is relevant for any node type but class nodes. If such a node + * contains an object of value, and if cascading is enabled, then the node + * traverser will try to find class metadata for that object and validate the + * object against that metadata. + * + * If no metadata is found for a cascaded object, and if that object implements + * {@link \Traversable}, the node traverser will iterate over the object and + * cascade each object or collection contained within, unless iteration is + * prohibited by the specified {@link TraversalStrategy}. + * + * Although the constants currently represent a boolean switch, they are + * implemented as bit mask in order to allow future extensions. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see TraversalStrategy + */ +class CascadingStrategy +{ + /** + * Specifies that a node should not be cascaded. + */ + const NONE = 1; + + /** + * Specifies that a node should be cascaded. + */ + const CASCADE = 2; + + /** + * Not instantiable. + */ + private function __construct() + { + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php index b7e003ec3da400af524c9b00fb8f136bb2eb459d..07a2662ba19cb7a976540da074568ea8fa2fdec6 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -11,57 +11,100 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\ValidationVisitorInterface; -use Symfony\Component\Validator\PropertyMetadataContainerInterface; -use Symfony\Component\Validator\ClassBasedInterface; -use Symfony\Component\Validator\MetadataInterface; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\Traverse; +use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\GroupDefinitionException; +use Symfony\Component\Validator\ValidationVisitorInterface; /** - * Represents all the configured constraints on a given class. + * Default implementation of {@link ClassMetadataInterface}. + * + * This class supports serialization and cloning. * * @author Bernhard Schussek <bschussek@gmail.com> * @author Fabien Potencier <fabien@symfony.com> */ -class ClassMetadata extends ElementMetadata implements MetadataInterface, ClassBasedInterface, PropertyMetadataContainerInterface +class ClassMetadata extends ElementMetadata implements ClassMetadataInterface { /** * @var string + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getClassName()} instead. */ public $name; /** * @var string + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getDefaultGroup()} instead. */ public $defaultGroup; /** * @var MemberMetadata[] + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getPropertyMetadata()} instead. */ public $members = array(); /** * @var PropertyMetadata[] + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getPropertyMetadata()} instead. */ public $properties = array(); /** * @var GetterMetadata[] + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getPropertyMetadata()} instead. */ public $getters = array(); /** * @var array + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getGroupSequence()} instead. */ public $groupSequence = array(); /** - * @var Boolean + * @var bool + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link isGroupSequenceProvider()} instead. */ public $groupSequenceProvider = false; + /** + * The strategy for traversing traversable objects. + * + * By default, only instances of {@link \Traversable} are traversed. + * + * @var int + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getTraversalStrategy()} instead. + */ + public $traversalStrategy = TraversalStrategy::IMPLICIT; + /** * @var \ReflectionClass */ @@ -83,6 +126,11 @@ public function __construct($class) } } + /** + * {@inheritdoc} + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + */ public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null) { if (null === $propagatedGroup && Constraint::DEFAULT_GROUP === $group @@ -118,27 +166,28 @@ public function accept(ValidationVisitorInterface $visitor, $value, $group, $pro } /** - * Returns the properties to be serialized - * - * @return array + * {@inheritdoc} */ public function __sleep() { - return array_merge(parent::__sleep(), array( + $parentProperties = parent::__sleep(); + + // Don't store the cascading strategy. Classes never cascade. + unset($parentProperties[array_search('cascadingStrategy', $parentProperties)]); + + return array_merge($parentProperties, array( 'getters', 'groupSequence', 'groupSequenceProvider', 'members', 'name', 'properties', - 'defaultGroup' + 'defaultGroup', )); } /** - * Returns the fully qualified name of the class - * - * @return string The fully qualified class name + * {@inheritdoc} */ public function getClassName() { @@ -166,20 +215,42 @@ public function getDefaultGroup() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function addConstraint(Constraint $constraint) { if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) { throw new ConstraintDefinitionException(sprintf( - 'The constraint %s cannot be put on classes', + 'The constraint "%s" cannot be put on classes.', + get_class($constraint) + )); + } + + if ($constraint instanceof Valid) { + throw new ConstraintDefinitionException(sprintf( + 'The constraint "%s" cannot be put on classes.', get_class($constraint) )); } + if ($constraint instanceof Traverse) { + if ($constraint->traverse) { + // If traverse is true, traversal should be explicitly enabled + $this->traversalStrategy = TraversalStrategy::TRAVERSE; + } else { + // If traverse is false, traversal should be explicitly disabled + $this->traversalStrategy = TraversalStrategy::NONE; + } + + // The constraint is not added + return $this; + } + $constraint->addImplicitGroupName($this->getDefaultGroup()); parent::addConstraint($constraint); + + return $this; } /** @@ -282,7 +353,7 @@ protected function addMemberMetadata(MemberMetadata $metadata) * * @param string $property The name of the property * - * @return Boolean + * @return bool */ public function hasMemberMetadatas($property) { @@ -298,6 +369,10 @@ public function hasMemberMetadatas($property) */ public function getMemberMetadatas($property) { + if (!isset($this->members[$property])) { + return array(); + } + return $this->members[$property]; } @@ -314,13 +389,15 @@ public function hasPropertyMetadata($property) */ public function getPropertyMetadata($property) { + if (!isset($this->members[$property])) { + return array(); + } + return $this->members[$property]; } /** - * Returns all properties for which constraints are defined. - * - * @return array An array of property names + * {@inheritdoc} */ public function getConstrainedProperties() { @@ -330,35 +407,37 @@ public function getConstrainedProperties() /** * Sets the default group sequence for this class. * - * @param array $groups An array of group names + * @param array $groupSequence An array of group names * * @return ClassMetadata * * @throws GroupDefinitionException */ - public function setGroupSequence(array $groups) + public function setGroupSequence($groupSequence) { if ($this->isGroupSequenceProvider()) { throw new GroupDefinitionException('Defining a static group sequence is not allowed with a group sequence provider'); } - if (in_array(Constraint::DEFAULT_GROUP, $groups, true)) { + if (is_array($groupSequence)) { + $groupSequence = new GroupSequence($groupSequence); + } + + if (in_array(Constraint::DEFAULT_GROUP, $groupSequence->groups, true)) { throw new GroupDefinitionException(sprintf('The group "%s" is not allowed in group sequences', Constraint::DEFAULT_GROUP)); } - if (!in_array($this->getDefaultGroup(), $groups, true)) { + if (!in_array($this->getDefaultGroup(), $groupSequence->groups, true)) { throw new GroupDefinitionException(sprintf('The group "%s" is missing in the group sequence', $this->getDefaultGroup())); } - $this->groupSequence = $groups; + $this->groupSequence = $groupSequence; return $this; } /** - * Returns whether this class has an overridden default group sequence. - * - * @return Boolean + * {@inheritdoc} */ public function hasGroupSequence() { @@ -366,9 +445,7 @@ public function hasGroupSequence() } /** - * Returns the default group sequence for this class. - * - * @return array An array of group names + * {@inheritdoc} */ public function getGroupSequence() { @@ -392,7 +469,7 @@ public function getReflectionClass() /** * Sets whether a group sequence provider should be used. * - * @param Boolean $active + * @param bool $active * * @throws GroupDefinitionException */ @@ -410,12 +487,20 @@ public function setGroupSequenceProvider($active) } /** - * Returns whether the class is a group sequence provider. - * - * @return Boolean + * {@inheritdoc} */ public function isGroupSequenceProvider() { return $this->groupSequenceProvider; } + + /** + * Class nodes are never cascaded. + * + * {@inheritdoc} + */ + public function getCascadingStrategy() + { + return CascadingStrategy::NONE; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php index 77eb8b528f74571a7de4a4b0f9d843e2c2606770..9b05edde8f3cce976068133d0f2e7b8ff36ab027 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php @@ -11,102 +11,16 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\MetadataFactoryInterface; -use Symfony\Component\Validator\Exception\NoSuchMetadataException; -use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; -use Symfony\Component\Validator\Mapping\Cache\CacheInterface; +use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; /** - * A factory for creating metadata for PHP classes. + * Alias of {@link LazyLoadingMetadataFactory}. * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link LazyLoadingMetadataFactory} instead. */ -class ClassMetadataFactory implements MetadataFactoryInterface +class ClassMetadataFactory extends LazyLoadingMetadataFactory { - /** - * The loader for loading the class metadata - * @var LoaderInterface - */ - protected $loader; - - /** - * The cache for caching class metadata - * @var CacheInterface - */ - protected $cache; - - protected $loadedClasses = array(); - - public function __construct(LoaderInterface $loader = null, CacheInterface $cache = null) - { - $this->loader = $loader; - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFor($value) - { - if (!is_object($value) && !is_string($value)) { - throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', gettype($value))); - } - - $class = ltrim(is_object($value) ? get_class($value) : $value, '\\'); - - if (isset($this->loadedClasses[$class])) { - return $this->loadedClasses[$class]; - } - - if (null !== $this->cache && false !== ($this->loadedClasses[$class] = $this->cache->read($class))) { - return $this->loadedClasses[$class]; - } - - if (!class_exists($class) && !interface_exists($class)) { - throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class)); - } - - $metadata = new ClassMetadata($class); - - // Include constraints from the parent class - if ($parent = $metadata->getReflectionClass()->getParentClass()) { - $metadata->mergeConstraints($this->getMetadataFor($parent->name)); - } - - // Include constraints from all implemented interfaces - foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) { - if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) { - continue; - } - $metadata->mergeConstraints($this->getMetadataFor($interface->name)); - } - - if (null !== $this->loader) { - $this->loader->loadClassMetadata($metadata); - } - - if (null !== $this->cache) { - $this->cache->write($metadata); - } - - return $this->loadedClasses[$class] = $metadata; - } - - /** - * {@inheritdoc} - */ - public function hasMetadataFor($value) - { - if (!is_object($value) && !is_string($value)) { - return false; - } - - $class = ltrim(is_object($value) ? get_class($value) : $value, '\\'); - - if (class_exists($class) || interface_exists($class)) { - return true; - } - - return false; - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..bf1e36f666e904e89fcbe4a7fde132cd931d5215 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php @@ -0,0 +1,80 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping; + +use Symfony\Component\Validator\ClassBasedInterface; +use Symfony\Component\Validator\PropertyMetadataContainerInterface as LegacyPropertyMetadataContainerInterface; + +/** + * Stores all metadata needed for validating objects of specific class. + * + * Most importantly, the metadata stores the constraints against which an object + * and its properties should be validated. + * + * Additionally, the metadata stores whether the "Default" group is overridden + * by a group sequence for that class and whether instances of that class + * should be traversed or not. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see MetadataInterface + * @see \Symfony\Component\Validator\Constraints\GroupSequence + * @see \Symfony\Component\Validator\GroupSequenceProviderInterface + * @see TraversalStrategy + */ +interface ClassMetadataInterface extends MetadataInterface, LegacyPropertyMetadataContainerInterface, ClassBasedInterface +{ + /** + * Returns the names of all constrained properties. + * + * @return string[] A list of property names + */ + public function getConstrainedProperties(); + + /** + * Returns whether the "Default" group is overridden by a group sequence. + * + * If it is, you can access the group sequence with {@link getGroupSequence()}. + * + * @return bool Returns true if the "Default" group is overridden + * + * @see \Symfony\Component\Validator\Constraints\GroupSequence + */ + public function hasGroupSequence(); + + /** + * Returns the group sequence that overrides the "Default" group for this + * class. + * + * @return \Symfony\Component\Validator\Constraints\GroupSequence|null The group sequence or null + * + * @see \Symfony\Component\Validator\Constraints\GroupSequence + */ + public function getGroupSequence(); + + /** + * Returns whether the "Default" group is overridden by a dynamic group + * sequence obtained by the validated objects. + * + * If this method returns true, the class must implement + * {@link \Symfony\Component\Validator\GroupSequenceProviderInterface}. + * This interface will be used to obtain the group sequence when an object + * of this class is validated. + * + * @return bool Returns true if the "Default" group is overridden by + * a dynamic group sequence + * + * @see \Symfony\Component\Validator\GroupSequenceProviderInterface + */ + public function isGroupSequenceProvider(); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ElementMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ElementMetadata.php index 9dedb79fd95e4875a5ab4bd14f73131d38819c55..1b971c91803c1368cfcc07e5194074b26e5a85c7 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ElementMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ElementMetadata.php @@ -11,97 +11,14 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\Constraint; - -abstract class ElementMetadata +/** + * Contains the metadata of a structural element. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Extend {@link GenericMetadata} instead. + */ +abstract class ElementMetadata extends GenericMetadata { - /** - * @var Constraint[] - */ - public $constraints = array(); - - /** - * @var array - */ - public $constraintsByGroup = array(); - - /** - * Returns the names of the properties that should be serialized. - * - * @return array - */ - public function __sleep() - { - return array( - 'constraints', - 'constraintsByGroup', - ); - } - - /** - * Clones this object. - */ - public function __clone() - { - $constraints = $this->constraints; - - $this->constraints = array(); - $this->constraintsByGroup = array(); - - foreach ($constraints as $constraint) { - $this->addConstraint(clone $constraint); - } - } - - /** - * Adds a constraint to this element. - * - * @param Constraint $constraint - * - * @return ElementMetadata - */ - public function addConstraint(Constraint $constraint) - { - $this->constraints[] = $constraint; - - foreach ($constraint->groups as $group) { - $this->constraintsByGroup[$group][] = $constraint; - } - - return $this; - } - - /** - * Returns all constraints of this element. - * - * @return Constraint[] An array of Constraint instances - */ - public function getConstraints() - { - return $this->constraints; - } - - /** - * Returns whether this element has any constraints. - * - * @return Boolean - */ - public function hasConstraints() - { - return count($this->constraints) > 0; - } - - /** - * Returns the constraints of the given group and global ones (* group). - * - * @param string $group The group name - * - * @return array An array with all Constraint instances belonging to the group - */ - public function findConstraints($group) - { - return isset($this->constraintsByGroup[$group]) - ? $this->constraintsByGroup[$group] - : array(); - } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/BlackHoleMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/BlackHoleMetadataFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..5b38d0c98a775d65d4b5a6b515f3b5f9da767d40 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/BlackHoleMetadataFactory.php @@ -0,0 +1,40 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping\Factory; + +/** + * Metadata factory that does not store metadata. + * + * This implementation is useful if you want to validate values against + * constraints only and you don't need to add constraints to classes and + * properties. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class BlackHoleMetadataFactory implements MetadataFactoryInterface +{ + /** + * {@inheritdoc} + */ + public function getMetadataFor($value) + { + throw new \LogicException('This class does not support metadata.'); + } + + /** + * {@inheritdoc} + */ + public function hasMetadataFor($value) + { + return false; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..eb0f3c460e09f364bc9fa92f8c508d7dbd4db484 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -0,0 +1,165 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping\Factory; + +use Symfony\Component\Validator\Exception\NoSuchMetadataException; +use Symfony\Component\Validator\Mapping\Cache\CacheInterface; +use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; +use Symfony\Component\Validator\Mapping\MetadataInterface; + +/** + * Creates new {@link ClassMetadataInterface} instances. + * + * Whenever {@link getMetadataFor()} is called for the first time with a given + * class name or object of that class, a new metadata instance is created and + * returned. On subsequent requests for the same class, the same metadata + * instance will be returned. + * + * You can optionally pass a {@link LoaderInterface} instance to the constructor. + * Whenever a new metadata instance is created, it is passed to the loader, + * which can configure the metadata based on configuration loaded from the + * filesystem or a database. If you want to use multiple loaders, wrap them in a + * {@link Loader\LoaderChain}. + * + * You can also optionally pass a {@link CacheInterface} instance to the + * constructor. This cache will be used for persisting the generated metadata + * between multiple PHP requests. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LazyLoadingMetadataFactory implements MetadataFactoryInterface +{ + /** + * The loader for loading the class metadata + * + * @var LoaderInterface + */ + protected $loader; + + /** + * The cache for caching class metadata + * + * @var CacheInterface + */ + protected $cache; + + /** + * The loaded metadata, indexed by class name + * + * @var ClassMetadata[] + */ + protected $loadedClasses = array(); + + /** + * Creates a new metadata factory. + * + * @param LoaderInterface|null $loader The loader for configuring new metadata + * @param CacheInterface|null $cache The cache for persisting metadata + * between multiple PHP requests + */ + public function __construct(LoaderInterface $loader = null, CacheInterface $cache = null) + { + $this->loader = $loader; + $this->cache = $cache; + } + + /** + * Returns the metadata for the given class name or object. + * + * If the method was called with the same class name (or an object of that + * class) before, the same metadata instance is returned. + * + * If the factory was configured with a cache, this method will first look + * for an existing metadata instance in the cache. If an existing instance + * is found, it will be returned without further ado. + * + * Otherwise, a new metadata instance is created. If the factory was + * configured with a loader, the metadata is passed to the + * {@link LoaderInterface::loadClassMetadata()} method for further + * configuration. At last, the new object is returned. + * + * @param string|object $value A class name or an object + * + * @return MetadataInterface The metadata for the value + * + * @throws NoSuchMetadataException If no metadata exists for the given value + */ + public function getMetadataFor($value) + { + if (!is_object($value) && !is_string($value)) { + throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s', gettype($value))); + } + + $class = ltrim(is_object($value) ? get_class($value) : $value, '\\'); + + if (isset($this->loadedClasses[$class])) { + return $this->loadedClasses[$class]; + } + + if (null !== $this->cache && false !== ($this->loadedClasses[$class] = $this->cache->read($class))) { + return $this->loadedClasses[$class]; + } + + if (!class_exists($class) && !interface_exists($class)) { + throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class)); + } + + $metadata = new ClassMetadata($class); + + // Include constraints from the parent class + if ($parent = $metadata->getReflectionClass()->getParentClass()) { + $metadata->mergeConstraints($this->getMetadataFor($parent->name)); + } + + // Include constraints from all implemented interfaces + foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) { + if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) { + continue; + } + $metadata->mergeConstraints($this->getMetadataFor($interface->name)); + } + + if (null !== $this->loader) { + $this->loader->loadClassMetadata($metadata); + } + + if (null !== $this->cache) { + $this->cache->write($metadata); + } + + return $this->loadedClasses[$class] = $metadata; + } + + /** + * Returns whether the factory is able to return metadata for the given + * class name or object. + * + * @param string|object $value A class name or an object + * + * @return bool Whether metadata can be returned for that class + */ + public function hasMetadataFor($value) + { + if (!is_object($value) && !is_string($value)) { + return false; + } + + $class = ltrim(is_object($value) ? get_class($value) : $value, '\\'); + + if (class_exists($class) || interface_exists($class)) { + return true; + } + + return false; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..ef25174d0ecc200089437fa292dbaca8fc70be75 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping\Factory; + +use Symfony\Component\Validator\MetadataFactoryInterface as LegacyMetadataFactoryInterface; + +/** + * Returns {@link MetadataInterface} instances for values. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface MetadataFactoryInterface extends LegacyMetadataFactoryInterface +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GenericMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GenericMetadata.php new file mode 100644 index 0000000000000000000000000000000000000000..01a6c3226ac06c3deb8bb92f7f7df25b544e45a7 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -0,0 +1,248 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\Traverse; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\Exception\BadMethodCallException; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; +use Symfony\Component\Validator\ValidationVisitorInterface; + +/** + * A generic container of {@link Constraint} objects. + * + * This class supports serialization and cloning. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class GenericMetadata implements MetadataInterface +{ + /** + * @var Constraint[] + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getConstraints()} and {@link findConstraints()} instead. + */ + public $constraints = array(); + + /** + * @var array + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link findConstraints()} instead. + */ + public $constraintsByGroup = array(); + + /** + * The strategy for cascading objects. + * + * By default, objects are not cascaded. + * + * @var int + * + * @see CascadingStrategy + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getCascadingStrategy()} instead. + */ + public $cascadingStrategy = CascadingStrategy::NONE; + + /** + * The strategy for traversing traversable objects. + * + * By default, traversable objects are not traversed. + * + * @var int + * + * @see TraversalStrategy + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getTraversalStrategy()} instead. + */ + public $traversalStrategy = TraversalStrategy::NONE; + + /** + * Returns the names of the properties that should be serialized. + * + * @return string[] + */ + public function __sleep() + { + return array( + 'constraints', + 'constraintsByGroup', + 'cascadingStrategy', + 'traversalStrategy', + ); + } + + /** + * Clones this object. + */ + public function __clone() + { + $constraints = $this->constraints; + + $this->constraints = array(); + $this->constraintsByGroup = array(); + + foreach ($constraints as $constraint) { + $this->addConstraint(clone $constraint); + } + } + + /** + * Adds a constraint. + * + * If the constraint {@link Valid} is added, the cascading strategy will be + * changed to {@link CascadingStrategy::CASCADE}. Depending on the + * properties $traverse and $deep of that constraint, the traversal strategy + * will be set to one of the following: + * + * - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled and $deep + * is enabled + * - {@link TraversalStrategy::IMPLICIT} | {@link TraversalStrategy::STOP_RECURSION} + * if $traverse is enabled, but $deep is disabled + * - {@link TraversalStrategy::NONE} if $traverse is disabled + * + * @param Constraint $constraint The constraint to add + * + * @return GenericMetadata This object + * + * @throws ConstraintDefinitionException When trying to add the + * {@link Traverse} constraint + */ + public function addConstraint(Constraint $constraint) + { + if ($constraint instanceof Traverse) { + throw new ConstraintDefinitionException(sprintf( + 'The constraint "%s" can only be put on classes. Please use '. + '"Symfony\Component\Validator\Constraints\Valid" instead.', + get_class($constraint) + )); + } + + if ($constraint instanceof Valid) { + $this->cascadingStrategy = CascadingStrategy::CASCADE; + + if ($constraint->traverse) { + // Traverse unless the value is not traversable + $this->traversalStrategy = TraversalStrategy::IMPLICIT; + + if (!$constraint->deep) { + $this->traversalStrategy |= TraversalStrategy::STOP_RECURSION; + } + } else { + $this->traversalStrategy = TraversalStrategy::NONE; + } + + return $this; + } + + $this->constraints[] = $constraint; + + foreach ($constraint->groups as $group) { + $this->constraintsByGroup[$group][] = $constraint; + } + + return $this; + } + + /** + * Adds an list of constraints. + * + * @param Constraint[] $constraints The constraints to add + * + * @return GenericMetadata This object + */ + public function addConstraints(array $constraints) + { + foreach ($constraints as $constraint) { + $this->addConstraint($constraint); + } + + return $this; + } + + /** + * Returns all constraints of this element. + * + * @return Constraint[] A list of Constraint instances + */ + public function getConstraints() + { + return $this->constraints; + } + + /** + * Returns whether this element has any constraints. + * + * @return bool + */ + public function hasConstraints() + { + return count($this->constraints) > 0; + } + + /** + * Returns the constraints of the given group and global ones (* group). + * + * @param string $group The group name + * + * @return Constraint[] An list of all the Constraint instances belonging + * to the group + */ + public function findConstraints($group) + { + return isset($this->constraintsByGroup[$group]) + ? $this->constraintsByGroup[$group] + : array(); + } + + /** + * {@inheritdoc} + */ + public function getCascadingStrategy() + { + return $this->cascadingStrategy; + } + + /** + * {@inheritdoc} + */ + public function getTraversalStrategy() + { + return $this->traversalStrategy; + } + + /** + * Exists for compatibility with the deprecated + * {@link Symfony\Component\Validator\MetadataInterface}. + * + * Should not be used. + * + * @throws BadMethodCallException + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * Will be removed in Symfony 3.0. + */ + public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath) + { + throw new BadMethodCallException('Not supported.'); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php index 1e4406246372834f4363e5cd1fb45fa3f17e254f..0cf99927695ba17aa6a22b9756f80a628bac5515 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/GetterMetadata.php @@ -13,6 +13,23 @@ use Symfony\Component\Validator\Exception\ValidatorException; +/** + * Stores all metadata needed for validating a class property via its getter + * method. + * + * A property getter is any method that is equal to the property's name, + * prefixed with either "get" or "is". That method will be used to access the + * property's value. + * + * The getter will be invoked by reflection, so the access of private and + * protected getters is supported. + * + * This class supports serialization and cloning. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see PropertyMetadataInterface + */ class GetterMetadata extends MemberMetadata { /** @@ -27,20 +44,23 @@ public function __construct($class, $property) { $getMethod = 'get'.ucfirst($property); $isMethod = 'is'.ucfirst($property); + $hasMethod = 'has'.ucfirst($property); if (method_exists($class, $getMethod)) { $method = $getMethod; } elseif (method_exists($class, $isMethod)) { $method = $isMethod; + } elseif (method_exists($class, $hasMethod)) { + $method = $hasMethod; } else { - throw new ValidatorException(sprintf('Neither method %s nor %s exists in class %s', $getMethod, $isMethod, $class)); + throw new ValidatorException(sprintf('Neither of these methods exist in class %s: %s, %s, %s', $class, $getMethod, $isMethod, $hasMethod)); } parent::__construct($class, $method, $property); } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getPropertyValue($object) { @@ -48,7 +68,7 @@ public function getPropertyValue($object) } /** - * {@inheritDoc} + * {@inheritdoc} */ protected function newReflectionMember($objectOrClassName) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index 8deea4eba8c5140467a2be5870b30e9154780b82..24591d6be5487c9beccad8785ed41ef0d7084dde 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Validator\Mapping\Loader; -use Symfony\Component\Validator\Exception\MappingException; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\MappingException; abstract class AbstractLoader implements LoaderInterface { @@ -36,10 +36,10 @@ protected function addNamespaceAlias($alias, $namespace) /** * Creates a new constraint instance for the given constraint name. * - * @param string $name The constraint name. Either a constraint relative - * to the default constraint namespace, or a fully - * qualified class name - * @param array $options The constraint options + * @param string $name The constraint name. Either a constraint relative + * to the default constraint namespace, or a fully + * qualified class name + * @param mixed $options The constraint options * * @return Constraint * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php index 10745c72e7ffc611841769c60aa7a3d9ad03bc6a..2a1db47d6fcdf64eaeae53afa80d88edd78dca3d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php @@ -12,12 +12,12 @@ namespace Symfony\Component\Validator\Mapping\Loader; use Doctrine\Common\Annotations\Reader; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Callback; -use Symfony\Component\Validator\Exception\MappingException; -use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\GroupSequenceProvider; -use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Exception\MappingException; +use Symfony\Component\Validator\Mapping\ClassMetadata; class AnnotationLoader implements LoaderInterface { @@ -29,7 +29,7 @@ public function __construct(Reader $reader) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { @@ -70,10 +70,10 @@ public function loadClassMetadata(ClassMetadata $metadata) $metadata->addConstraint($constraint); } elseif ($constraint instanceof Constraint) { - if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) { + if (preg_match('/^(get|is|has)(.+)$/i', $method->name, $matches)) { $metadata->addGetterConstraint(lcfirst($matches[2]), $constraint); } else { - throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get" or "is".', $className, $method->name)); + throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get", "is" or "has".', $className, $method->name)); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php index a0c9ef127fa4b9a61bff862a998215a63c8a2180..7378daf5e80dbc5ca5789f7503ee2f02ff5fc63f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php @@ -47,7 +47,7 @@ public function __construct(array $loaders) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderInterface.php index bd679b0f71db5bfaedf2e9ac66841d6abef277a6..43358ad1d92f71ad3fa48e97d138dae80dff7461 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/LoaderInterface.php @@ -20,7 +20,7 @@ interface LoaderInterface * * @param ClassMetadata $metadata A metadata * - * @return Boolean + * @return bool */ public function loadClassMetadata(ClassMetadata $metadata); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php index d8086b2b9c8d30f6f191d73dd67357fa0cda8a8d..54dcc57cc7675b24b65c13a90be0bf7606496ff2 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php @@ -24,7 +24,7 @@ public function __construct($methodName = 'loadValidatorMetadata') } /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php index cad247e883ddd2c8f50e5c46f2677a8862c69443..b9ddaa3505a2993fd1a53241e7213db487f32d68 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Validator\Mapping\Loader; +use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\Validator\Exception\MappingException; use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Config\Util\XmlUtils; class XmlFileLoader extends FileLoader { @@ -25,7 +25,7 @@ class XmlFileLoader extends FileLoader protected $classes = null; /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { @@ -105,7 +105,7 @@ protected function parseConstraints(\SimpleXMLElement $nodes) $options = null; } - $constraints[] = $this->newConstraint($node['name'], $options); + $constraints[] = $this->newConstraint((string) $node['name'], $options); } return $constraints; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php index a4628cf07325039b50174ed48b1706e0a8c03a08..02989ffe89baa54744ddfea77d74f866528a4d35 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php @@ -21,7 +21,7 @@ class XmlFilesLoader extends FilesLoader { /** - * {@inheritDoc} + * {@inheritdoc} */ public function getFileLoaderInstance($file) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php index 9b3757d522f417ff007e4776be2ff477a2decd17..32d6c6ae7c5a6003ecbef04e8108fecdcea1d649 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php @@ -26,7 +26,7 @@ class YamlFileLoader extends FileLoader protected $classes = null; /** - * {@inheritDoc} + * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFilesLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFilesLoader.php index bfffacef5c6d3213b4b805b753dbcddf369965ea..12cd1a0af1274fde3d7cd057d14827e932b8d784 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFilesLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFilesLoader.php @@ -21,7 +21,7 @@ class YamlFilesLoader extends FilesLoader { /** - * {@inheritDoc} + * {@inheritdoc} */ public function getFileLoaderInstance($file) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php index c30a87ee0626939b44dbfddc30b2f97630cfd847..371772d150f1670afae7ef9d40489ec2f8e309ec 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -11,21 +11,54 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\ValidationVisitorInterface; -use Symfony\Component\Validator\ClassBasedInterface; -use Symfony\Component\Validator\PropertyMetadataInterface; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; +use Symfony\Component\Validator\ValidationVisitorInterface; -abstract class MemberMetadata extends ElementMetadata implements PropertyMetadataInterface, ClassBasedInterface +/** + * Stores all metadata needed for validating a class property. + * + * The method of accessing the property's value must be specified by subclasses + * by implementing the {@link newReflectionMember()} method. + * + * This class supports serialization and cloning. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see PropertyMetadataInterface + */ +abstract class MemberMetadata extends ElementMetadata implements PropertyMetadataInterface { + /** + * @var string + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getClassName()} instead. + */ public $class; + + /** + * @var string + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getName()} instead. + */ public $name; + + /** + * @var string + * + * @internal This property is public in order to reduce the size of the + * class' serialized representation. Do not access it. Use + * {@link getPropertyName()} instead. + */ public $property; - public $cascaded = false; - public $collectionCascaded = false; - public $collectionCascadedDeeply = false; + + /** + * @var \ReflectionMethod[]|\ReflectionProperty[] + */ private $reflMember = array(); /** @@ -42,6 +75,11 @@ public function __construct($class, $name, $property) $this->property = $property; } + /** + * {@inheritdoc} + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + */ public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null) { $visitor->visit($this, $value, $group, $propertyPath); @@ -52,7 +90,7 @@ public function accept(ValidationVisitorInterface $visitor, $value, $group, $pro } /** - * {@inheritDoc} + * {@inheritdoc} */ public function addConstraint(Constraint $constraint) { @@ -63,22 +101,13 @@ public function addConstraint(Constraint $constraint) )); } - if ($constraint instanceof Valid) { - $this->cascaded = true; - /* @var Valid $constraint */ - $this->collectionCascaded = $constraint->traverse; - $this->collectionCascadedDeeply = $constraint->deep; - } else { - parent::addConstraint($constraint); - } + parent::addConstraint($constraint); return $this; } /** - * Returns the names of the properties that should be serialized - * - * @return array + * {@inheritdoc} */ public function __sleep() { @@ -86,14 +115,11 @@ public function __sleep() 'class', 'name', 'property', - 'cascaded', - 'collectionCascaded', - 'collectionCascadedDeeply', )); } /** - * Returns the name of the member + * Returns the name of the member. * * @return string */ @@ -103,9 +129,7 @@ public function getName() } /** - * Returns the class this member is defined on - * - * @return string + * {@inheritdoc} */ public function getClassName() { @@ -113,9 +137,7 @@ public function getClassName() } /** - * Returns the name of the property this member belongs to - * - * @return string The property name + * {@inheritdoc} */ public function getPropertyName() { @@ -123,11 +145,11 @@ public function getPropertyName() } /** - * Returns whether this member is public + * Returns whether this member is public. * * @param object|string $objectOrClassName The object or the class name * - * @return Boolean + * @return bool */ public function isPublic($objectOrClassName) { @@ -139,7 +161,7 @@ public function isPublic($objectOrClassName) * * @param object|string $objectOrClassName The object or the class name * - * @return Boolean + * @return bool */ public function isProtected($objectOrClassName) { @@ -147,11 +169,11 @@ public function isProtected($objectOrClassName) } /** - * Returns whether this member is private + * Returns whether this member is private. * * @param object|string $objectOrClassName The object or the class name * - * @return Boolean + * @return bool */ public function isPrivate($objectOrClassName) { @@ -159,43 +181,52 @@ public function isPrivate($objectOrClassName) } /** - * Returns whether objects stored in this member should be validated + * Returns whether objects stored in this member should be validated. * - * @return Boolean + * @return bool + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link getCascadingStrategy()} instead. */ public function isCascaded() { - return $this->cascaded; + return (bool) ($this->cascadingStrategy & CascadingStrategy::CASCADE); } /** * Returns whether arrays or traversable objects stored in this member - * should be traversed and validated in each entry + * should be traversed and validated in each entry. + * + * @return bool * - * @return Boolean + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link getTraversalStrategy()} instead. */ public function isCollectionCascaded() { - return $this->collectionCascaded; + return (bool) ($this->traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE)); } /** * Returns whether arrays or traversable objects stored in this member - * should be traversed recursively for inner arrays/traversable objects + * should be traversed recursively for inner arrays/traversable objects. * - * @return Boolean + * @return bool + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link getTraversalStrategy()} instead. */ public function isCollectionCascadedDeeply() { - return $this->collectionCascadedDeeply; + return !($this->traversalStrategy & TraversalStrategy::STOP_RECURSION); } /** - * Returns the Reflection instance of the member + * Returns the reflection instance for accessing the member's value. * * @param object|string $objectOrClassName The object or the class name * - * @return object + * @return \ReflectionMethod|\ReflectionProperty The reflection instance */ public function getReflectionMember($objectOrClassName) { @@ -208,11 +239,13 @@ public function getReflectionMember($objectOrClassName) } /** - * Creates a new Reflection instance for the member + * Creates a new reflection instance for accessing the member's value. + * + * Must be implemented by subclasses. * * @param object|string $objectOrClassName The object or the class name * - * @return mixed Reflection class + * @return \ReflectionMethod|\ReflectionProperty The reflection instance */ abstract protected function newReflectionMember($objectOrClassName); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MetadataInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MetadataInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..a72d4a5801c92d0bbb3a2a4ba3262f41d1f13371 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/MetadataInterface.php @@ -0,0 +1,51 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping; + +use Symfony\Component\Validator\MetadataInterface as LegacyMetadataInterface; + +/** + * A container for validation metadata. + * + * Most importantly, the metadata stores the constraints against which an object + * and its properties should be validated. + * + * Additionally, the metadata stores whether objects should be validated + * against their class' metadata and whether traversable objects should be + * traversed or not. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see CascadingStrategy + * @see TraversalStrategy + */ +interface MetadataInterface extends LegacyMetadataInterface +{ + /** + * Returns the strategy for cascading objects. + * + * @return int The cascading strategy + * + * @see CascadingStrategy + */ + public function getCascadingStrategy(); + + /** + * Returns the strategy for traversing traversable objects. + * + * @return int The traversal strategy + * + * @see TraversalStrategy + */ + public function getTraversalStrategy(); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php index 468f196f04a8ebbcd2e984785afc276497055c8b..7319294e7ab2f65d183195705c7ffa428731ae3c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php @@ -13,6 +13,19 @@ use Symfony\Component\Validator\Exception\ValidatorException; +/** + * Stores all metadata needed for validating a class property. + * + * The value of the property is obtained by directly accessing the property. + * The property will be accessed by reflection, so the access of private and + * protected properties is supported. + * + * This class supports serialization and cloning. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see PropertyMetadataInterface + */ class PropertyMetadata extends MemberMetadata { /** @@ -33,7 +46,7 @@ public function __construct($class, $name) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getPropertyValue($object) { @@ -41,7 +54,7 @@ public function getPropertyValue($object) } /** - * {@inheritDoc} + * {@inheritdoc} */ protected function newReflectionMember($objectOrClassName) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..79e2c799de6021386aa058d448f5214cc57e919a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php @@ -0,0 +1,36 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping; + +use Symfony\Component\Validator\ClassBasedInterface; +use Symfony\Component\Validator\PropertyMetadataInterface as LegacyPropertyMetadataInterface; + +/** + * Stores all metadata needed for validating the value of a class property. + * + * Most importantly, the metadata stores the constraints against which the + * property's value should be validated. + * + * Additionally, the metadata stores whether objects stored in the property + * should be validated against their class' metadata and whether traversable + * objects should be traversed or not. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see MetadataInterface + * @see CascadingStrategy + * @see TraversalStrategy + */ +interface PropertyMetadataInterface extends MetadataInterface, LegacyPropertyMetadataInterface, ClassBasedInterface +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/TraversalStrategy.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/TraversalStrategy.php new file mode 100644 index 0000000000000000000000000000000000000000..d44733b61c5e71bc80130a29b9811b978f2543b4 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/TraversalStrategy.php @@ -0,0 +1,65 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Mapping; + +/** + * Specifies whether and how a traversable object should be traversed. + * + * If the node traverser traverses a node whose value is an instance of + * {@link \Traversable}, and if that node is either a class node or if + * cascading is enabled, then the node's traversal strategy will be checked. + * Depending on the requested traversal strategy, the node traverser will + * iterate over the object and cascade each object or collection returned by + * the iterator. + * + * The traversal strategy is ignored for arrays. Arrays are always iterated. + * + * @since 2.1 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see CascadingStrategy + */ +class TraversalStrategy +{ + /** + * Specifies that a node's value should be iterated only if it is an + * instance of {@link \Traversable}. + */ + const IMPLICIT = 1; + + /** + * Specifies that a node's value should never be iterated. + */ + const NONE = 2; + + /** + * Specifies that a node's value should always be iterated. If the value is + * not an instance of {@link \Traversable}, an exception should be thrown. + */ + const TRAVERSE = 4; + + /** + * Specifies that nested instances of {@link \Traversable} should never be + * iterated. Can be combined with {@link IMPLICIT} or {@link TRAVERSE}. + * + * @deprecated This constant was added for backwards compatibility only. + * It will be removed in Symfony 3.0. + */ + const STOP_RECURSION = 8; + + /** + * Not instantiable. + */ + private function __construct() + { + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataFactoryInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataFactoryInterface.php index 6dbab06ab74e200f048cb27499094c01b6bdae26..4c0cbad78b1ff605163850b1c962769eefacf11e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataFactoryInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataFactoryInterface.php @@ -15,26 +15,29 @@ * Returns {@link MetadataInterface} instances for values. * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Mapping\Factory\MetadataFactoryInterface} instead. */ interface MetadataFactoryInterface { /** * Returns the metadata for the given value. * - * @param mixed $value Some value. + * @param mixed $value Some value * - * @return MetadataInterface The metadata for the value. + * @return MetadataInterface The metadata for the value * - * @throws Exception\NoSuchMetadataException If no metadata exists for the value. + * @throws Exception\NoSuchMetadataException If no metadata exists for the given value */ public function getMetadataFor($value); /** - * Returns whether metadata exists for the given value. + * Returns whether the class is able to return metadata for the given value. * - * @param mixed $value Some value. + * @param mixed $value Some value * - * @return Boolean Whether metadata exists for the value. + * @return bool Whether metadata can be returned for that value */ public function hasMetadataFor($value); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataInterface.php index a5d65048b78160233ba9720e4210f724867ddc58..60abfeb42a9f00383bf0c3eaccd0b61961852515 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/MetadataInterface.php @@ -41,6 +41,9 @@ * again. * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Mapping\MetadataInterface} instead. */ interface MetadataInterface { @@ -50,19 +53,21 @@ interface MetadataInterface * Calls {@link ValidationVisitorInterface::visit} and then forwards the * <tt>accept()</tt>-call to all property metadata instances. * - * @param ValidationVisitorInterface $visitor The visitor implementing the validation logic. - * @param mixed $value The value to validate. - * @param string|string[] $group The validation group to validate in. - * @param string $propertyPath The current property path in the validation graph. + * @param ValidationVisitorInterface $visitor The visitor implementing the validation logic + * @param mixed $value The value to validate + * @param string|string[] $group The validation group to validate in + * @param string $propertyPath The current property path in the validation graph + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. */ public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath); /** * Returns all constraints for a given validation group. * - * @param string $group The validation group. + * @param string $group The validation group * - * @return Constraint[] A list of constraint instances. + * @return Constraint[] A list of constraint instances */ public function findConstraints($group); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataContainerInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataContainerInterface.php index 20bafb2950fd9c096fd40368ebaaf788a85e3819..91b286ab26e4be0a2d2265f37c92a534371c7815 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataContainerInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataContainerInterface.php @@ -15,6 +15,9 @@ * A container for {@link PropertyMetadataInterface} instances. * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Mapping\ClassMetadataInterface} instead. */ interface PropertyMetadataContainerInterface { @@ -23,7 +26,7 @@ interface PropertyMetadataContainerInterface * * @param string $property The property name. * - * @return Boolean + * @return bool */ public function hasPropertyMetadata($property); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataInterface.php index eaac1a71211035a305166598d1a4f9dba4ca4a9e..c18ae83a05e8168c41977346b0ebadc2225b9f66 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/PropertyMetadataInterface.php @@ -23,6 +23,9 @@ * @author Bernhard Schussek <bschussek@gmail.com> * * @see MetadataInterface + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Mapping\PropertyMetadataInterface} instead. */ interface PropertyMetadataInterface extends MetadataInterface { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/README.md b/core/vendor/symfony/validator/Symfony/Component/Validator/README.md index e1601cfe47ebb0e9f6f4f7a545e69bc1d5b9d960..6825a2feee19832cd86158ffe79eb306c1532d79 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/README.md +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/README.md @@ -107,7 +107,7 @@ https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/ValidatorServiceP Documentation: -http://symfony.com/doc/2.4/book/validation.html +http://symfony.com/doc/2.5/book/validation.html JSR-303 Specification: diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintTest.php index 015a6dab665e25aac4e7dc11562fb713ca50995d..24e84b919c4193aa453929873f419aa22507ff15 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintTest.php @@ -55,7 +55,7 @@ public function testInvalidAndRequiredOptionsPassed() new ConstraintC(array( 'option1' => 'default', - 'foo' => 'bar' + 'foo' => 'bar', )); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintViolationTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintViolationTest.php index e1f06c2428c160b775637f6091c67f1cd7f6bf1b..2ceb0169a10bd37d090285407f99e649cec60a21 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintViolationTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintViolationTest.php @@ -33,4 +33,23 @@ public function testToStringHandlesArrays() $this->assertSame($expected, (string) $violation); } + + public function testToStringHandlesArrayRoots() + { + $violation = new ConstraintViolation( + '42 cannot be used here', + 'this is the message template', + array(), + array('some_value' => 42), + 'some_value', + null + ); + + $expected = <<<EOF +Array.some_value: + 42 cannot be used here +EOF; + + $this->assertSame($expected, (string) $violation); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 36405e3de88e54396fda216f23135feb4bc9bcb7..b7117cc4ea1a7a4d8012292f6e9846674b67ca84 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; class ComparisonTest_Class { @@ -32,30 +32,15 @@ public function __toString() /** * @author Daniel Holmes <daniel@danielholmes.org> */ -abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_TestCase +abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintValidatorTest { - private $validator; - private $context; - - protected function setUp() - { - $this->validator = $this->createValidator(); - $this->context = $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext') - ->disableOriginalConstructor() - ->getMock(); - $this->validator->initialize($this->context); - } - /** - * @return AbstractComparisonValidator + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ - abstract protected function createValidator(); - public function testThrowsConstraintExceptionIfNoValueOrProperty() { - $this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); - $comparison = $this->createConstraint(array()); + $this->validator->validate('some value', $comparison); } @@ -66,16 +51,11 @@ public function testThrowsConstraintExceptionIfNoValueOrProperty() */ public function testValidComparisonToValue($dirtyValue, $comparisonValue) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = $this->createConstraint(array('value' => $comparisonValue)); - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('property1')); - $this->validator->validate($dirtyValue, $constraint); + + $this->assertNoViolation(); } /** @@ -86,28 +66,29 @@ abstract public function provideValidComparisons(); /** * @dataProvider provideInvalidComparisons * @param mixed $dirtyValue + * @param mixed $dirtyValueAsString * @param mixed $comparedValue * @param mixed $comparedValueString * @param string $comparedValueType */ - public function testInvalidComparisonToValue($dirtyValue, $comparedValue, $comparedValueString, $comparedValueType) + public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType) { + // Conversion of dates to string differs between ICU versions + // Make sure we have the correct version loaded + if ($dirtyValue instanceof \DateTime) { + IntlTestHelper::requireIntl($this); + } + $constraint = $this->createConstraint(array('value' => $comparedValue)); $constraint->message = 'Constraint Message'; - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('property1')); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Constraint Message', array( - '{{ value }}' => $comparedValueString, - '{{ compared_value }}' => $comparedValueString, - '{{ compared_value_type }}' => $comparedValueType - )); - $this->validator->validate($dirtyValue, $constraint); + + $this->buildViolation('Constraint Message') + ->setParameter('{{ value }}', $dirtyValueAsString) + ->setParameter('{{ compared_value }}', $comparedValueString) + ->setParameter('{{ compared_value_type }}', $comparedValueType) + ->assertRaised(); } /** diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..53a9f21aa86a3ee7d3a5849d394bbd035026dc46 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -0,0 +1,486 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\ConstraintValidatorInterface; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\Context\ExecutionContext; +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Context\LegacyExecutionContext; +use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface; +use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Mapping\PropertyMetadata; +use Symfony\Component\Validator\Tests\Fixtures\StubGlobalExecutionContext; +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ExecutionContextInterface + */ + protected $context; + + /** + * @var ConstraintValidatorInterface + */ + protected $validator; + + protected $group; + + protected $metadata; + + protected $object; + + protected $value; + + protected $root; + + protected $propertyPath; + + protected function setUp() + { + $this->group = 'MyGroup'; + $this->metadata = null; + $this->object = null; + $this->value = 'InvalidValue'; + $this->root = 'root'; + $this->propertyPath = 'property.path'; + $this->context = $this->createContext(); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + \Locale::setDefault('en'); + } + + protected function createContext() + { + $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); + + if (Validation::API_VERSION_2_4 === $this->getApiVersion()) { + return $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext') + ->setConstructorArgs(array( + new StubGlobalExecutionContext($this->root), + $translator, + null, + $this->metadata, + $this->value, + $this->group, + $this->propertyPath, + )) + ->setMethods(array('validate', 'validateValue')) + ->getMock(); + } + + $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); + $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); + + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_5: + $context = new ExecutionContext( + $validator, + $this->root, + $translator + ); + break; + case Validation::API_VERSION_2_5_BC: + $context = new LegacyExecutionContext( + $validator, + $this->root, + $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'), + $translator + ); + break; + default: + throw new \RuntimeException('Invalid API version'); + } + + $context->setGroup($this->group); + $context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); + + $validator->expects($this->any()) + ->method('inContext') + ->with($context) + ->will($this->returnValue($contextualValidator)); + + return $context; + } + + /** + * @param $message + * @param array $parameters + * @param string $propertyPath + * @param string $invalidValue + * @param null $plural + * @param null $code + * + * @return ConstraintViolation + * + * @deprecated To be removed in Symfony 3.0. Use + * {@link buildViolation()} instead. + */ + protected function createViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null) + { + return new ConstraintViolation( + null, + $message, + $parameters, + $this->root, + $propertyPath, + $invalidValue, + $plural, + $code + ); + } + + protected function setGroup($group) + { + $this->group = $group; + + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $this->context->setGroup($group); + break; + } + } + + protected function setObject($object) + { + $this->object = $object; + $this->metadata = is_object($object) + ? new ClassMetadata(get_class($object)) + : null; + + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); + break; + } + } + + protected function setProperty($object, $property) + { + $this->object = $object; + $this->metadata = is_object($object) + ? new PropertyMetadata(get_class($object), $property) + : null; + + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); + break; + } + } + + protected function setValue($value) + { + $this->value = $value; + + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); + break; + } + } + + protected function setRoot($root) + { + $this->root = $root; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function setPropertyPath($propertyPath) + { + $this->propertyPath = $propertyPath; + + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); + break; + } + } + + protected function expectNoValidate() + { + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context->expects($this->never()) + ->method('validate'); + $this->context->expects($this->never()) + ->method('validateValue'); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $validator = $this->context->getValidator()->inContext($this->context); + $validator->expects($this->never()) + ->method('atPath'); + $validator->expects($this->never()) + ->method('validate'); + break; + } + } + + protected function expectValidateAt($i, $propertyPath, $value, $group) + { + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context->expects($this->at($i)) + ->method('validate') + ->with($value, $propertyPath, $group); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $validator = $this->context->getValidator()->inContext($this->context); + $validator->expects($this->at(2 * $i)) + ->method('atPath') + ->with($propertyPath) + ->will($this->returnValue($validator)); + $validator->expects($this->at(2 * $i + 1)) + ->method('validate') + ->with($value, $this->logicalOr(null, array()), $group); + break; + } + } + + protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group) + { + switch ($this->getApiVersion()) { + case Validation::API_VERSION_2_4: + $this->context->expects($this->at($i)) + ->method('validateValue') + ->with($value, $constraints, $propertyPath, $group); + break; + case Validation::API_VERSION_2_5: + case Validation::API_VERSION_2_5_BC: + $contextualValidator = $this->context->getValidator()->inContext($this->context); + $contextualValidator->expects($this->at(2 * $i)) + ->method('atPath') + ->with($propertyPath) + ->will($this->returnValue($contextualValidator)); + $contextualValidator->expects($this->at(2 * $i + 1)) + ->method('validate') + ->with($value, $constraints, $group); + break; + } + } + + protected function assertNoViolation() + { + $this->assertCount(0, $this->context->getViolations()); + } + + /** + * @param $message + * @param array $parameters + * @param string $propertyPath + * @param string $invalidValue + * @param null $plural + * @param null $code + * + * @deprecated To be removed in Symfony 3.0. Use + * {@link buildViolation()} instead. + */ + protected function assertViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null) + { + $this->buildViolation($message) + ->setParameters($parameters) + ->atPath($propertyPath) + ->setInvalidValue($invalidValue) + ->setCode($code) + ->setPlural($plural) + ->assertRaised(); + } + + /** + * @param array $expected + * + * @deprecated To be removed in Symfony 3.0. Use + * {@link buildViolation()} instead. + */ + protected function assertViolations(array $expected) + { + $violations = $this->context->getViolations(); + + $this->assertCount(count($expected), $violations); + + $i = 0; + + foreach ($expected as $violation) { + $this->assertEquals($violation, $violations[$i++]); + } + } + + /** + * @param $message + * + * @return ConstraintViolationAssertion + */ + protected function buildViolation($message) + { + return new ConstraintViolationAssertion($this->context, $message); + } + + abstract protected function getApiVersion(); + + abstract protected function createValidator(); +} + +/** + * @internal + */ +class ConstraintViolationAssertion +{ + /** + * @var LegacyExecutionContextInterface + */ + private $context; + + /** + * @var ConstraintViolationAssertion[] + */ + private $assertions; + + private $message; + private $parameters = array(); + private $invalidValue = 'InvalidValue'; + private $propertyPath = 'property.path'; + private $translationDomain; + private $plural; + private $code; + + public function __construct(LegacyExecutionContextInterface $context, $message, array $assertions = array()) + { + $this->context = $context; + $this->message = $message; + $this->assertions = $assertions; + } + + public function atPath($path) + { + $this->propertyPath = $path; + + return $this; + } + + public function setParameter($key, $value) + { + $this->parameters[$key] = $value; + + return $this; + } + + public function setParameters(array $parameters) + { + $this->parameters = $parameters; + + return $this; + } + + public function setTranslationDomain($translationDomain) + { + $this->translationDomain = $translationDomain; + + return $this; + } + + public function setInvalidValue($invalidValue) + { + $this->invalidValue = $invalidValue; + + return $this; + } + + public function setPlural($number) + { + $this->plural = $number; + + return $this; + } + + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + public function buildNextViolation($message) + { + $assertions = $this->assertions; + $assertions[] = $this; + + return new self($this->context, $message, $assertions); + } + + public function assertRaised() + { + $expected = array(); + foreach ($this->assertions as $assertion) { + $expected[] = $assertion->getViolation(); + } + $expected[] = $this->getViolation(); + + $violations = iterator_to_array($this->context->getViolations()); + + \PHPUnit_Framework_Assert::assertCount(count($expected), $violations); + + reset($violations); + + foreach ($expected as $violation) { + \PHPUnit_Framework_Assert::assertEquals($violation, current($violations)); + next($violations); + } + } + + private function getViolation() + { + return new ConstraintViolation( + null, + $this->message, + $this->parameters, + $this->context->getRoot(), + $this->propertyPath, + $this->invalidValue, + $this->plural, + $this->code + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index eaa9044e9ef52f3b9e14ddaff0cbf68903443876..68011e8f5046cff555e10263f95d02218269d1c5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -11,40 +11,29 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\ExecutionContext; -use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\AllValidator; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Range; +use Symfony\Component\Validator\Validation; -class AllValidatorTest extends \PHPUnit_Framework_TestCase +class AllValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new AllValidator(); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getGroup') - ->will($this->returnValue('MyGroup')); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->validator = null; - $this->context = null; + return new AllValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new All(new Range(array('min' => 4)))); + + $this->assertNoViolation(); } /** @@ -62,18 +51,15 @@ public function testWalkSingleConstraint($array) { $constraint = new Range(array('min' => 4)); - $i = 1; + $i = 0; foreach ($array as $key => $value) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint, '['.$key.']', 'MyGroup'); + $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint), 'MyGroup'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($array, new All($constraint)); + + $this->assertNoViolation(); } /** @@ -85,21 +71,16 @@ public function testWalkMultipleConstraints($array) $constraint2 = new NotNull(); $constraints = array($constraint1, $constraint2); - $i = 1; + + $i = 0; foreach ($array as $key => $value) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint1, '['.$key.']', 'MyGroup'); - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint2, '['.$key.']', 'MyGroup'); + $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint1, $constraint2), 'MyGroup'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($array, new All($constraints)); + + $this->assertNoViolation(); } public function getValidArguments() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index 0fbe5e6fbb0d06815a2c77911563eb03c3f3bdc4..a7f3d7dd5840647bf8698825aa80c2682d668199 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -13,66 +13,57 @@ use Symfony\Component\Validator\Constraints\Blank; use Symfony\Component\Validator\Constraints\BlankValidator; +use Symfony\Component\Validator\Validation; -class BlankValidatorTest extends \PHPUnit_Framework_TestCase +class BlankValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new BlankValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new BlankValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Blank()); + + $this->assertNoViolation(); } public function testBlankIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Blank()); + + $this->assertNoViolation(); } /** * @dataProvider getInvalidValues */ - public function testInvalidValues($value) + public function testInvalidValues($value, $valueAsString) { $constraint = new Blank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $value, - )); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', $valueAsString) + ->assertRaised(); } public function getInvalidValues() { return array( - array('foobar'), - array(0), - array(false), - array(1234), + array('foobar', '"foobar"'), + array(0, '0'), + array(false, 'false'), + array(1234, '1234'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php index cdcd49bb58ed87be7954c8c348bc023cbc1dcc88..9bb12a25361b66416652fee10de5f89b21b9953e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php @@ -11,15 +11,17 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\ExecutionContext; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\CallbackValidator; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Validation; class CallbackValidatorTest_Class { - public static function validateCallback($object, ExecutionContext $context) + public static function validateCallback($object, ExecutionContextInterface $context) { - $context->addViolation('Callback message', array('{{ value }}' => 'foobar'), 'invalidValue'); + $context->addViolation('Callback message', array('{{ value }}' => 'foobar')); return false; } @@ -27,45 +29,38 @@ public static function validateCallback($object, ExecutionContext $context) class CallbackValidatorTest_Object { - public function validate(ExecutionContext $context) + public function validate(ExecutionContextInterface $context) { - $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); + $context->addViolation('My message', array('{{ value }}' => 'foobar')); return false; } - public static function validateStatic($object, ExecutionContext $context) + public static function validateStatic($object, ExecutionContextInterface $context) { - $context->addViolation('Static message', array('{{ value }}' => 'baz'), 'otherInvalidValue'); + $context->addViolation('Static message', array('{{ value }}' => 'baz')); return false; } } -class CallbackValidatorTest extends \PHPUnit_Framework_TestCase +class CallbackValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CallbackValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CallbackValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Callback(array('foo'))); + + $this->assertNoViolation(); } public function testSingleMethod() @@ -73,13 +68,11 @@ public function testSingleMethod() $object = new CallbackValidatorTest_Object(); $constraint = new Callback('validate'); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } public function testSingleMethodExplicitName() @@ -87,13 +80,11 @@ public function testSingleMethodExplicitName() $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array('callback' => 'validate')); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } public function testSingleStaticMethod() @@ -101,51 +92,60 @@ public function testSingleStaticMethod() $object = new CallbackValidatorTest_Object(); $constraint = new Callback('validateStatic'); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Static message', array( - '{{ value }}' => 'baz', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('Static message') + ->setParameter('{{ value }}', 'baz') + ->assertRaised(); } public function testClosure() { $object = new CallbackValidatorTest_Object(); - $constraint = new Callback(function ($object, ExecutionContext $context) { - $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); + $constraint = new Callback(function ($object, ExecutionContextInterface $context) { + $context->addViolation('My message', array('{{ value }}' => 'foobar')); return false; }); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); + } + + public function testClosureNullObject() + { + $constraint = new Callback(function ($object, ExecutionContextInterface $context) { + $context->addViolation('My message', array('{{ value }}' => 'foobar')); + + return false; + }); + + $this->validator->validate(null, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } public function testClosureExplicitName() { $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array( - 'callback' => function ($object, ExecutionContext $context) { - $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); + 'callback' => function ($object, ExecutionContextInterface $context) { + $context->addViolation('My message', array('{{ value }}' => 'foobar')); return false; }, )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } public function testArrayCallable() @@ -153,13 +153,22 @@ public function testArrayCallable() $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback')); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Callback message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('Callback message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); + } + + public function testArrayCallableNullObject() + { + $constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback')); + + $this->validator->validate(null, $constraint); + + $this->buildViolation('Callback message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } public function testArrayCallableExplicitName() @@ -169,13 +178,11 @@ public function testArrayCallableExplicitName() 'callback' => array(__CLASS__.'_Class', 'validateCallback'), )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Callback message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('Callback message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } // BC with Symfony < 2.4 @@ -184,13 +191,11 @@ public function testSingleMethodBc() $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array('validate')); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } // BC with Symfony < 2.4 @@ -199,13 +204,11 @@ public function testSingleMethodBcExplicitName() $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array('methods' => array('validate'))); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } // BC with Symfony < 2.4 @@ -214,18 +217,13 @@ public function testMultipleMethodsBc() $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array('validate', 'validateStatic')); - $this->context->expects($this->at(0)) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->context->expects($this->at(1)) - ->method('addViolation') - ->with('Static message', array( - '{{ value }}' => 'baz', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->buildNextViolation('Static message') + ->setParameter('{{ value }}', 'baz') + ->assertRaised(); } // BC with Symfony < 2.4 @@ -236,18 +234,13 @@ public function testMultipleMethodsBcExplicitName() 'methods' => array('validate', 'validateStatic'), )); - $this->context->expects($this->at(0)) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->context->expects($this->at(1)) - ->method('addViolation') - ->with('Static message', array( - '{{ value }}' => 'baz', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('My message') + ->setParameter('{{ value }}', 'foobar') + ->buildNextViolation('Static message') + ->setParameter('{{ value }}', 'baz') + ->assertRaised(); } // BC with Symfony < 2.4 @@ -255,16 +248,14 @@ public function testSingleStaticMethodBc() { $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array( - array(__CLASS__.'_Class', 'validateCallback') + array(__CLASS__.'_Class', 'validateCallback'), )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Callback message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('Callback message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } // BC with Symfony < 2.4 @@ -275,13 +266,11 @@ public function testSingleStaticMethodBcExplicitName() 'methods' => array(array(__CLASS__.'_Class', 'validateCallback')), )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Callback message', array( - '{{ value }}' => 'foobar', - )); - $this->validator->validate($object, $constraint); + + $this->buildViolation('Callback message') + ->setParameter('{{ value }}', 'foobar') + ->assertRaised(); } /** @@ -320,8 +309,9 @@ public function testExpectEitherCallbackOrMethods() public function testConstraintGetTargets() { $constraint = new Callback(array('foo')); + $targets = array(Constraint::CLASS_CONSTRAINT, Constraint::PROPERTY_CONSTRAINT); - $this->assertEquals('class', $constraint->getTargets()); + $this->assertEquals($targets, $constraint->getTargets()); } // Should succeed. Needed when defining constraints as annotations. diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index ee7cc7a60a3810bb8144a655293e632d0c1c66e4..40bba756c21ef2d6b69668bb9363adb9da38c358 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\CardScheme; use Symfony\Component\Validator\Constraints\CardSchemeValidator; +use Symfony\Component\Validator\Validation; -class CardSchemeValidatorTest extends \PHPUnit_Framework_TestCase +class CardSchemeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CardSchemeValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CardSchemeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new CardScheme(array('schemes' => array()))); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new CardScheme(array('schemes' => array()))); + + $this->assertNoViolation(); } /** @@ -53,10 +46,9 @@ public function testEmptyStringIsValid() */ public function testValidNumbers($scheme, $number) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($number, new CardScheme(array('schemes' => $scheme))); + + $this->assertNoViolation(); } /** @@ -64,10 +56,16 @@ public function testValidNumbers($scheme, $number) */ public function testInvalidNumbers($scheme, $number) { - $this->context->expects($this->once()) - ->method('addViolation'); + $constraint = new CardScheme(array( + 'schemes' => $scheme, + 'message' => 'myMessage', + )); - $this->validator->validate($number, new CardScheme(array('schemes' => $scheme))); + $this->validator->validate($number, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', is_string($number) ? '"'.$number.'"' : $number) + ->assertRaised(); } public function getValidNumbers() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index 9267fdb8726922f5a433965ca656e9a4c7768bbe..84b5bc3b0d63be2a1521ac9030a2ccd34e728ce8 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -13,37 +13,28 @@ use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\ChoiceValidator; +use Symfony\Component\Validator\Validation; function choice_callback() { return array('foo', 'bar'); } -class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase +class ChoiceValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - public static function staticCallback() + protected function getApiVersion() { - return array('foo', 'bar'); + return Validation::API_VERSION_2_5; } - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new ChoiceValidator(); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getClassName') - ->will($this->returnValue(__CLASS__)); + return new ChoiceValidator(); } - protected function tearDown() + public static function staticCallback() { - $this->context = null; - $this->validator = null; + return array('foo', 'bar'); } /** @@ -61,10 +52,9 @@ public function testExpectArrayIfMultipleIsTrue() public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Choice(array('choices' => array('foo', 'bar')))); + + $this->assertNoViolation(); } /** @@ -87,52 +77,50 @@ public function testValidChoiceArray() { $constraint = new Choice(array('choices' => array('foo', 'bar'))); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackFunction() { $constraint = new Choice(array('callback' => __NAMESPACE__.'\choice_callback')); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackClosure() { $constraint = new Choice(array('callback' => function () { return array('foo', 'bar'); - })); - - $this->context->expects($this->never()) - ->method('addViolation'); + },)); $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackStaticMethod() { $constraint = new Choice(array('callback' => array(__CLASS__, 'staticCallback'))); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackContextMethod() { - $constraint = new Choice(array('callback' => 'staticCallback')); + // search $this for "staticCallback" + $this->setObject($this); - $this->context->expects($this->never()) - ->method('addViolation'); + $constraint = new Choice(array('callback' => 'staticCallback')); $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testMultipleChoices() @@ -142,10 +130,9 @@ public function testMultipleChoices() 'multiple' => true, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(array('baz', 'bar'), $constraint); + + $this->assertNoViolation(); } public function testInvalidChoice() @@ -155,13 +142,11 @@ public function testInvalidChoice() 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 'baz', - ), null, null); - $this->validator->validate('baz', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"baz"') + ->assertRaised(); } public function testInvalidChoiceMultiple() @@ -172,13 +157,12 @@ public function testInvalidChoiceMultiple() 'multiple' => true, )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 'baz', - )); - $this->validator->validate(array('foo', 'baz'), $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"baz"') + ->setInvalidValue('baz') + ->assertRaised(); } public function testTooFewChoices() @@ -190,13 +174,17 @@ public function testTooFewChoices() 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => 2, - ), null, 2); + $value = array('foo'); + + $this->setValue($value); - $this->validator->validate(array('foo'), $constraint); + $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ limit }}', 2) + ->setInvalidValue($value) + ->setPlural(2) + ->assertRaised(); } public function testTooManyChoices() @@ -208,13 +196,17 @@ public function testTooManyChoices() 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => 2, - ), null, 2); + $value = array('foo', 'bar', 'moo'); + + $this->setValue($value); + + $this->validator->validate($value, $constraint); - $this->validator->validate(array('foo', 'bar', 'moo'), $constraint); + $this->buildViolation('myMessage') + ->setParameter('{{ limit }}', 2) + ->setInvalidValue($value) + ->setPlural(2) + ->assertRaised(); } public function testNonStrict() @@ -224,11 +216,10 @@ public function testNonStrict() 'strict' => false, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('2', $constraint); $this->validator->validate(2, $constraint); + + $this->assertNoViolation(); } public function testStrictAllowsExactValue() @@ -238,10 +229,9 @@ public function testStrictAllowsExactValue() 'strict' => true, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(2, $constraint); + + $this->assertNoViolation(); } public function testStrictDisallowsDifferentType() @@ -249,16 +239,14 @@ public function testStrictDisallowsDifferentType() $constraint = new Choice(array( 'choices' => array(1, 2), 'strict' => true, - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '2', - )); - $this->validator->validate('2', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"2"') + ->assertRaised(); } public function testNonStrictWithMultipleChoices() @@ -266,13 +254,12 @@ public function testNonStrictWithMultipleChoices() $constraint = new Choice(array( 'choices' => array(1, 2, 3), 'multiple' => true, - 'strict' => false + 'strict' => false, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(array('2', 3), $constraint); + + $this->assertNoViolation(); } public function testStrictWithMultipleChoices() @@ -284,12 +271,11 @@ public function testStrictWithMultipleChoices() 'multipleMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '3', - )); - $this->validator->validate(array(2, '3'), $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"3"') + ->setInvalidValue('3') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php index da868d3cfdd1fab40273feaef2f00e2e08135e74..4b485a9b108b7723bea747a41a97e74b57f42576 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\Collection; -use Symfony\Component\Validator\Constraints\Required; -use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Validator\Constraints\Optional; +use Symfony\Component\Validator\Constraints\Required; use Symfony\Component\Validator\Constraints\Valid; /** diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php index ebad849b8b3c3ff5d69c14bed0ac6defe7a60882..3d4c29681bf4725f3ce32bbc57ea0f6cd6c56560 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php @@ -11,63 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; -/** - * This class is a hand written simplified version of PHP native `ArrayObject` - * class, to show that it behaves differently than the PHP native implementation. - */ -class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable -{ - private $array; - - public function __construct(array $array = null) - { - $this->array = $array ?: array(); - } - - public function offsetExists($offset) - { - return array_key_exists($offset, $this->array); - } - - public function offsetGet($offset) - { - return $this->array[$offset]; - } - - public function offsetSet($offset, $value) - { - if (null === $offset) { - $this->array[] = $value; - } else { - $this->array[$offset] = $value; - } - } - - public function offsetUnset($offset) - { - unset($this->array[$offset]); - } - - public function getIterator() - { - return new \ArrayIterator($this->array); - } - - public function count() - { - return count($this->array); - } - - public function serialize() - { - return serialize($this->array); - } - - public function unserialize($serialized) - { - $this->array = (array) unserialize((string) $serialized); - } -} +use Symfony\Component\Validator\Tests\Fixtures\CustomArrayObject; class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTest { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index 4a13234b69550634e977b62a2ffb9eeeabbdf03e..93e9af5e8714a2c313070bdf0508ef18a904c62f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -11,57 +11,50 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\NotNull; -use Symfony\Component\Validator\Constraints\Required; -use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\CollectionValidator; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Optional; +use Symfony\Component\Validator\Constraints\Range; +use Symfony\Component\Validator\Constraints\Required; +use Symfony\Component\Validator\Validation; -abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase +abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CollectionValidator(); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getGroup') - ->will($this->returnValue('MyGroup')); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CollectionValidator(); } abstract protected function prepareTestData(array $contents); public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate(null, new Collection(array('fields' => array( 'foo' => new Range(array('min' => 4)), )))); + + $this->assertNoViolation(); } public function testFieldsAsDefaultOption() { + $constraint = new Range(array('min' => 4)); + $data = $this->prepareTestData(array('foo' => 'foobar')); - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); $this->validator->validate($data, new Collection(array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ))); + + $this->assertNoViolation(); } /** @@ -82,25 +75,23 @@ public function testWalkSingleConstraint() 'foo' => 3, 'bar' => 5, ); - $i = 1; + + $i = 0; foreach ($array as $key => $value) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint, '['.$key.']', 'MyGroup'); + $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint), 'MyGroup'); } $data = $this->prepareTestData($array); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'fields' => array( 'foo' => $constraint, 'bar' => $constraint, ), ))); + + $this->assertNoViolation(); } public function testWalkMultipleConstraints() @@ -114,48 +105,48 @@ public function testWalkMultipleConstraints() 'foo' => 3, 'bar' => 5, ); - $i = 1; + + $i = 0; foreach ($array as $key => $value) { - foreach ($constraints as $constraint) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint, '['.$key.']', 'MyGroup'); - } + $this->expectValidateValueAt($i++, '['.$key.']', $value, $constraints, 'MyGroup'); } $data = $this->prepareTestData($array); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'fields' => array( 'foo' => $constraints, 'bar' => $constraints, - ) + ), ))); + + $this->assertNoViolation(); } public function testExtraFieldsDisallowed() { + $constraint = new Range(array('min' => 4)); + $data = $this->prepareTestData(array( 'foo' => 5, 'baz' => 6, )); - $this->context->expects($this->once()) - ->method('addViolationAt') - ->with('[baz]', 'myMessage', array( - '{{ field }}' => 'baz' - )); + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'extraFieldsMessage' => 'myMessage', ))); + + $this->buildViolation('myMessage') + ->setParameter('{{ field }}', '"baz"') + ->atPath('property.path[baz]') + ->setInvalidValue(6) + ->assertRaised(); } // bug fix @@ -165,16 +156,17 @@ public function testNullNotConsideredExtraField() 'foo' => null, )); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), - )); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + ))); - $this->validator->validate($data, $constraint); + $this->assertNoViolation(); } public function testExtraFieldsAllowed() @@ -184,54 +176,54 @@ public function testExtraFieldsAllowed() 'bar' => 6, )); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'allowExtraFields' => true, - )); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + ))); - $this->validator->validate($data, $constraint); + $this->assertNoViolation(); } public function testMissingFieldsDisallowed() { $data = $this->prepareTestData(array()); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'missingFieldsMessage' => 'myMessage', - )); - - $this->context->expects($this->once()) - ->method('addViolationAt') - ->with('[foo]', 'myMessage', array( - '{{ field }}' => 'foo', - )); + ))); - $this->validator->validate($data, $constraint); + $this->buildViolation('myMessage') + ->setParameter('{{ field }}', '"foo"') + ->atPath('property.path[foo]') + ->setInvalidValue(null) + ->assertRaised(); } public function testMissingFieldsAllowed() { $data = $this->prepareTestData(array()); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'allowMissingFields' => true, - )); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + ))); - $this->validator->validate($data, $constraint); + $this->assertNoViolation(); } public function testOptionalFieldPresent() @@ -240,24 +232,22 @@ public function testOptionalFieldPresent() 'foo' => null, )); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'foo' => new Optional(), ))); + + $this->assertNoViolation(); } public function testOptionalFieldNotPresent() { $data = $this->prepareTestData(array()); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'foo' => new Optional(), ))); + + $this->assertNoViolation(); } public function testOptionalFieldSingleConstraint() @@ -268,18 +258,15 @@ public function testOptionalFieldSingleConstraint() $constraint = new Range(array('min' => 4)); - $this->context->expects($this->once()) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint), 'MyGroup'); $data = $this->prepareTestData($array); $this->validator->validate($data, new Collection(array( 'foo' => new Optional($constraint), ))); + + $this->assertNoViolation(); } public function testOptionalFieldMultipleConstraints() @@ -292,22 +279,16 @@ public function testOptionalFieldMultipleConstraints() new NotNull(), new Range(array('min' => 4)), ); - $i = 1; - - foreach ($constraints as $constraint) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - } - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints, 'MyGroup'); $data = $this->prepareTestData($array); $this->validator->validate($data, new Collection(array( 'foo' => new Optional($constraints), ))); + + $this->assertNoViolation(); } public function testRequiredFieldPresent() @@ -316,30 +297,29 @@ public function testRequiredFieldPresent() 'foo' => null, )); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'foo' => new Required(), ))); + + $this->assertNoViolation(); } public function testRequiredFieldNotPresent() { $data = $this->prepareTestData(array()); - $this->context->expects($this->once()) - ->method('addViolationAt') - ->with('[foo]', 'myMessage', array( - '{{ field }}' => 'foo', - )); - $this->validator->validate($data, new Collection(array( 'fields' => array( 'foo' => new Required(), ), 'missingFieldsMessage' => 'myMessage', ))); + + $this->buildViolation('myMessage') + ->setParameter('{{ field }}', '"foo"') + ->atPath('property.path[foo]') + ->setInvalidValue(null) + ->assertRaised(); } public function testRequiredFieldSingleConstraint() @@ -350,18 +330,15 @@ public function testRequiredFieldSingleConstraint() $constraint = new Range(array('min' => 4)); - $this->context->expects($this->once()) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint), 'MyGroup'); $data = $this->prepareTestData($array); $this->validator->validate($data, new Collection(array( 'foo' => new Required($constraint), ))); + + $this->assertNoViolation(); } public function testRequiredFieldMultipleConstraints() @@ -374,38 +351,36 @@ public function testRequiredFieldMultipleConstraints() new NotNull(), new Range(array('min' => 4)), ); - $i = 1; - foreach ($constraints as $constraint) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - } - - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints, 'MyGroup'); $data = $this->prepareTestData($array); - $this->validator->validate($array, new Collection(array( + $this->validator->validate($data, new Collection(array( 'foo' => new Required($constraints), ))); + + $this->assertNoViolation(); } public function testObjectShouldBeLeftUnchanged() { $value = new \ArrayObject(array( - 'foo' => 3 + 'foo' => 3, )); + $constraint = new Range(array('min' => 2)); + + $this->expectValidateValueAt(0, '[foo]', $value['foo'], array($constraint), 'MyGroup'); + $this->validator->validate($value, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 2)), - ) + 'foo' => $constraint, + ), ))); $this->assertEquals(array( - 'foo' => 3 + 'foo' => 3, ), (array) $value); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php index ec4d8dec7112c7a47dbf34010aed087ae144fbd6..7d46967bde483075d5ecb4f73238838860715629 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php @@ -11,20 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; -class CountValidatorCountableTest_Countable implements \Countable -{ - private $content; - - public function __construct(array $content) - { - $this->content = $content; - } - - public function count() - { - return count($this->content); - } -} +use Symfony\Component\Validator\Tests\Fixtures\Countable; /** * @author Bernhard Schussek <bschussek@gmail.com> @@ -33,6 +20,6 @@ class CountValidatorCountableTest extends CountValidatorTest { protected function createCollection(array $content) { - return new CountValidatorCountableTest_Countable($content); + return new Countable($content); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php index 9c4a38d56c7e3b1cafb59d77be5b093b701913ac..31c7c7856288cd910a247308a67d0402d6bff6dd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php @@ -13,36 +13,30 @@ use Symfony\Component\Validator\Constraints\Count; use Symfony\Component\Validator\Constraints\CountValidator; +use Symfony\Component\Validator\Validation; /** * @author Bernhard Schussek <bschussek@gmail.com> */ -abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase +abstract class CountValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CountValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CountValidator(); } abstract protected function createCollection(array $content); public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Count(6)); + + $this->assertNoViolation(); } /** @@ -71,14 +65,6 @@ public function getFourElements() ); } - public function getNotFourElements() - { - return array_merge( - $this->getThreeOrLessElements(), - $this->getFiveOrMoreElements() - ); - } - public function getFiveOrMoreElements() { return array( @@ -93,11 +79,10 @@ public function getFiveOrMoreElements() */ public function testValidValuesMax($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Count(array('max' => 3)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -105,11 +90,10 @@ public function testValidValuesMax($value) */ public function testValidValuesMin($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Count(array('min' => 5)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -117,72 +101,92 @@ public function testValidValuesMin($value) */ public function testValidValuesExact($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Count(4); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** * @dataProvider getFiveOrMoreElements */ - public function testInvalidValuesMax($value) + public function testTooManyValues($value) { $constraint = new Count(array( 'max' => 4, - 'maxMessage' => 'myMessage' + 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ count }}' => count($value), - '{{ limit }}' => 4, - )), $value, 4); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ count }}', count($value)) + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); } /** * @dataProvider getThreeOrLessElements */ - public function testInvalidValuesMin($value) + public function testTooFewValues($value) { $constraint = new Count(array( 'min' => 4, - 'minMessage' => 'myMessage' + 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ count }}' => count($value), - '{{ limit }}' => 4, - )), $value, 4); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ count }}', count($value)) + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); } /** - * @dataProvider getNotFourElements + * @dataProvider getFiveOrMoreElements */ - public function testInvalidValuesExact($value) + public function testTooManyValuesExact($value) { $constraint = new Count(array( 'min' => 4, 'max' => 4, - 'exactMessage' => 'myMessage' + 'exactMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ count }}' => count($value), - '{{ limit }}' => 4, - )), $value, 4); + $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ count }}', count($value)) + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); + } + + /** + * @dataProvider getThreeOrLessElements + */ + public function testTooFewValuesExact($value) + { + $constraint = new Count(array( + 'min' => 4, + 'max' => 4, + 'exactMessage' => 'myMessage', + )); $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ count }}', count($value)) + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); } public function testDefaultOption() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 95851e8097ad788e870badf1b6f833ae28afbd9a..b13351181a43fe381fb21c6d3e104fc7401cf2a5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -14,41 +14,39 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Country; use Symfony\Component\Validator\Constraints\CountryValidator; +use Symfony\Component\Validator\Validation; -class CountryValidatorTest extends \PHPUnit_Framework_TestCase +class CountryValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - protected function setUp() { - IntlTestHelper::requireIntl($this); + IntlTestHelper::requireFullIntl($this); - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CountryValidator(); - $this->validator->initialize($this->context); + parent::setUp(); } - protected function tearDown() + protected function getApiVersion() { - $this->context = null; - $this->validator = null; + return Validation::API_VERSION_2_5; } - public function testNullIsValid() + protected function createValidator() { - $this->context->expects($this->never()) - ->method('addViolation'); + return new CountryValidator(); + } + public function testNullIsValid() + { $this->validator->validate(null, new Country()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Country()); + + $this->assertNoViolation(); } /** @@ -64,10 +62,9 @@ public function testExpectsStringCompatibleType() */ public function testValidCountries($country) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($country, new Country()); + + $this->assertNoViolation(); } public function getValidCountries() @@ -85,16 +82,14 @@ public function getValidCountries() public function testInvalidCountries($country) { $constraint = new Country(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $country, - )); - $this->validator->validate($country, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$country.'"') + ->assertRaised(); } public function getInvalidCountries() @@ -107,11 +102,15 @@ public function getInvalidCountries() public function testValidateUsingCountrySpecificLocale() { + // in order to test with "en_GB" + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('en_GB'); + $existingCountry = 'GB'; - $this->context->expects($this->never()) - ->method('addViolation'); $this->validator->validate($existingCountry, new Country()); + + $this->assertNoViolation(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index ea6c2eb43ac029e06433106bd5097e2f1a224ec2..e5bb060d9c9038d0ebb919bf321d2cb229ba6f8d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -14,41 +14,39 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Currency; use Symfony\Component\Validator\Constraints\CurrencyValidator; +use Symfony\Component\Validator\Validation; -class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase +class CurrencyValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - protected function setUp() { - IntlTestHelper::requireIntl($this); + IntlTestHelper::requireFullIntl($this); - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CurrencyValidator(); - $this->validator->initialize($this->context); + parent::setUp(); } - protected function tearDown() + protected function getApiVersion() { - $this->context = null; - $this->validator = null; + return Validation::API_VERSION_2_5; } - public function testNullIsValid() + protected function createValidator() { - $this->context->expects($this->never()) - ->method('addViolation'); + return new CurrencyValidator(); + } + public function testNullIsValid() + { $this->validator->validate(null, new Currency()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Currency()); + + $this->assertNoViolation(); } /** @@ -64,10 +62,9 @@ public function testExpectsStringCompatibleType() */ public function testValidCurrencies($currency) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($currency, new Currency()); + + $this->assertNoViolation(); } /** @@ -76,10 +73,10 @@ public function testValidCurrencies($currency) public function testValidCurrenciesWithCountrySpecificLocale($currency) { \Locale::setDefault('en_GB'); - $this->context->expects($this->never()) - ->method('addViolation'); $this->validator->validate($currency, new Currency()); + + $this->assertNoViolation(); } public function getValidCurrencies() @@ -99,16 +96,14 @@ public function getValidCurrencies() public function testInvalidCurrencies($currency) { $constraint = new Currency(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $currency, - )); - $this->validator->validate($currency, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$currency.'"') + ->assertRaised(); } public function getInvalidCurrencies() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 0776848fdbd4769ba64957f4e083f9902fe5640b..89de5fd9a5153f4d9bb71ff5f49cf7a84b448efe 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -13,47 +13,39 @@ use Symfony\Component\Validator\Constraints\DateTime; use Symfony\Component\Validator\Constraints\DateTimeValidator; +use Symfony\Component\Validator\Validation; -class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase +class DateTimeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new DateTimeValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new DateTimeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new DateTime()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new DateTime()); + + $this->assertNoViolation(); } public function testDateTimeClassIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(new \DateTime(), new DateTime()); + + $this->assertNoViolation(); } /** @@ -69,10 +61,9 @@ public function testExpectsStringCompatibleType() */ public function testValidDateTimes($dateTime) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($dateTime, new DateTime()); + + $this->assertNoViolation(); } public function getValidDateTimes() @@ -90,16 +81,14 @@ public function getValidDateTimes() public function testInvalidDateTimes($dateTime) { $constraint = new DateTime(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $dateTime, - )); - $this->validator->validate($dateTime, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$dateTime.'"') + ->assertRaised(); } public function getInvalidDateTimes() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index b9cf8816b76a5c939a905c987d8ebf4dec3ddc24..352ded5422a5abaf44fa87009d78ca419fdaac54 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -13,47 +13,39 @@ use Symfony\Component\Validator\Constraints\Date; use Symfony\Component\Validator\Constraints\DateValidator; +use Symfony\Component\Validator\Validation; -class DateValidatorTest extends \PHPUnit_Framework_TestCase +class DateValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new DateValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new DateValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Date()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Date()); + + $this->assertNoViolation(); } public function testDateTimeClassIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(new \DateTime(), new Date()); + + $this->assertNoViolation(); } /** @@ -69,10 +61,9 @@ public function testExpectsStringCompatibleType() */ public function testValidDates($date) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($date, new Date()); + + $this->assertNoViolation(); } public function getValidDates() @@ -90,16 +81,14 @@ public function getValidDates() public function testInvalidDates($date) { $constraint = new Date(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $date, - )); - $this->validator->validate($date, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$date.'"') + ->assertRaised(); } public function getInvalidDates() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 701ab1f556df214f77d0df39ad7fa14bc3faacb8..fb39f8854052ea7c3c06e275bdde49010504f5c4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\EmailValidator; +use Symfony\Component\Validator\Validation; -class EmailValidatorTest extends \PHPUnit_Framework_TestCase +class EmailValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new EmailValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new EmailValidator(false); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Email()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Email()); + + $this->assertNoViolation(); } /** @@ -61,10 +54,9 @@ public function testExpectsStringCompatibleType() */ public function testValidEmails($email) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($email, new Email()); + + $this->assertNoViolation(); } public function getValidEmails() @@ -82,16 +74,14 @@ public function getValidEmails() public function testInvalidEmails($email) { $constraint = new Email(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $email, - )); - $this->validator->validate($email, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$email.'"') + ->assertRaised(); } public function getInvalidEmails() @@ -100,7 +90,15 @@ public function getInvalidEmails() array('example'), array('example@'), array('example@localhost'), - array('example@example.com@example.com'), ); } + + public function testStrict() + { + $constraint = new Email(array('strict' => true)); + + $this->validator->validate('example@localhost', $constraint); + + $this->assertNoViolation(); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index 6f8abc101250989cf88bc46c3e35575ce1b26e55..0fd4a044cb913c2ed857a3cd8d78b2796a358d58 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\EqualTo; use Symfony\Component\Validator\Constraints\EqualToValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class EqualToValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new EqualToValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -45,15 +51,15 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array('22', '333', "'333'", 'string'), - array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array(new ComparisonTest_Class(4), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array(1, '1', 2, '2', 'integer'), + array('22', '"22"', '333', '"333"', 'string'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index b71138e5f6bbdbd43707e035f4d00daa7610c578..378f531936373e285cf21238c404b58a050856c6 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -14,184 +14,187 @@ use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\Validator\Constraints\Expression; use Symfony\Component\Validator\Constraints\ExpressionValidator; +use Symfony\Component\Validator\Tests\Fixtures\Entity; +use Symfony\Component\Validator\Validation; -class ExpressionValidatorTest extends \PHPUnit_Framework_TestCase +class ExpressionValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new ExpressionValidator(PropertyAccess::createPropertyAccessor()); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getClassName') - ->will($this->returnValue(__CLASS__)); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new ExpressionValidator(PropertyAccess::createPropertyAccessor()); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Expression('value == 1')); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Expression('value == 1')); + + $this->assertNoViolation(); } public function testSucceedingExpressionAtObjectLevel() { - $constraint = new Expression('this.property == 1'); - - $object = (object) array('property' => '1'); + $constraint = new Expression('this.data == 1'); - $this->context->expects($this->any()) - ->method('getPropertyName') - ->will($this->returnValue(null)); + $object = new Entity(); + $object->data = '1'; - $this->context->expects($this->never()) - ->method('addViolation'); + $this->setObject($object); $this->validator->validate($object, $constraint); + + $this->assertNoViolation(); } public function testFailingExpressionAtObjectLevel() { $constraint = new Expression(array( - 'expression' => 'this.property == 1', + 'expression' => 'this.data == 1', 'message' => 'myMessage', )); - $object = (object) array('property' => '2'); + $object = new Entity(); + $object->data = '2'; - $this->context->expects($this->any()) - ->method('getPropertyName') - ->will($this->returnValue(null)); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); + $this->setObject($object); $this->validator->validate($object, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', 'object') + ->assertRaised(); } public function testSucceedingExpressionAtPropertyLevel() { - $constraint = new Expression('value == this.expected'); + $constraint = new Expression('value == this.data'); - $object = (object) array('expected' => '1'); + $object = new Entity(); + $object->data = '1'; - $this->context->expects($this->any()) - ->method('getPropertyName') - ->will($this->returnValue('property')); - - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('property')); - - $this->context->expects($this->any()) - ->method('getRoot') - ->will($this->returnValue($object)); - - $this->context->expects($this->never()) - ->method('addViolation'); + $this->setRoot($object); + $this->setPropertyPath('data'); + $this->setProperty($object, 'data'); $this->validator->validate('1', $constraint); + + $this->assertNoViolation(); } public function testFailingExpressionAtPropertyLevel() { $constraint = new Expression(array( - 'expression' => 'value == this.expected', + 'expression' => 'value == this.data', 'message' => 'myMessage', )); - $object = (object) array('expected' => '1'); - - $this->context->expects($this->any()) - ->method('getPropertyName') - ->will($this->returnValue('property')); + $object = new Entity(); + $object->data = '1'; - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('property')); - - $this->context->expects($this->any()) - ->method('getRoot') - ->will($this->returnValue($object)); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); + $this->setRoot($object); + $this->setPropertyPath('data'); + $this->setProperty($object, 'data'); $this->validator->validate('2', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"2"') + ->atPath('data') + ->assertRaised(); } public function testSucceedingExpressionAtNestedPropertyLevel() { - $constraint = new Expression('value == this.expected'); - - $object = (object) array('expected' => '1'); - $root = (object) array('nested' => $object); + $constraint = new Expression('value == this.data'); - $this->context->expects($this->any()) - ->method('getPropertyName') - ->will($this->returnValue('property')); + $object = new Entity(); + $object->data = '1'; - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('nested.property')); + $root = new Entity(); + $root->reference = $object; - $this->context->expects($this->any()) - ->method('getRoot') - ->will($this->returnValue($root)); - - $this->context->expects($this->never()) - ->method('addViolation'); + $this->setRoot($root); + $this->setPropertyPath('reference.data'); + $this->setProperty($object, 'data'); $this->validator->validate('1', $constraint); + + $this->assertNoViolation(); } public function testFailingExpressionAtNestedPropertyLevel() { $constraint = new Expression(array( - 'expression' => 'value == this.expected', + 'expression' => 'value == this.data', 'message' => 'myMessage', )); - $object = (object) array('expected' => '1'); - $root = (object) array('nested' => $object); + $object = new Entity(); + $object->data = '1'; + + $root = new Entity(); + $root->reference = $object; + + $this->setRoot($root); + $this->setPropertyPath('reference.data'); + $this->setProperty($object, 'data'); + + $this->validator->validate('2', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"2"') + ->atPath('reference.data') + ->assertRaised(); + } + + /** + * When validatePropertyValue() is called with a class name + * https://github.com/symfony/symfony/pull/11498 + */ + public function testSucceedingExpressionAtPropertyLevelWithoutRoot() + { + $constraint = new Expression('value == "1"'); - $this->context->expects($this->any()) - ->method('getPropertyName') - ->will($this->returnValue('property')); + $this->setRoot('1'); + $this->setPropertyPath(''); + $this->setProperty(null, 'property'); - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('nested.property')); + $this->validator->validate('1', $constraint); - $this->context->expects($this->any()) - ->method('getRoot') - ->will($this->returnValue($root)); + $this->assertNoViolation(); + } - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); + /** + * When validatePropertyValue() is called with a class name + * https://github.com/symfony/symfony/pull/11498 + */ + public function testFailingExpressionAtPropertyLevelWithoutRoot() + { + $constraint = new Expression(array( + 'expression' => 'value == "1"', + 'message' => 'myMessage', + )); + + $this->setRoot('2'); + $this->setPropertyPath(''); + $this->setProperty(null, 'property'); $this->validator->validate('2', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"2"') + ->atPath('') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php index 1bc16c20bd48a78728a587a79bac4a4281e39f13..479888e53b200f5f03afed0729629e2eeaf75fcb 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php @@ -13,51 +13,44 @@ use Symfony\Component\Validator\Constraints\False; use Symfony\Component\Validator\Constraints\FalseValidator; +use Symfony\Component\Validator\Validation; -class FalseValidatorTest extends \PHPUnit_Framework_TestCase +class FalseValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new FalseValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new FalseValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new False()); + + $this->assertNoViolation(); } public function testFalseIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(false, new False()); + + $this->assertNoViolation(); } public function testTrueIsInvalid() { $constraint = new False(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array()); - $this->validator->validate(true, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', 'true') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php index c4b93cdcd34248dd06c71c2d6a6122d5058d4346..25def64c19c95d99e82722e832cbe88c69b37912 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php @@ -26,12 +26,10 @@ public function testFileNotFound() 'notFoundMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ file }}' => 'foobar', - )); - $this->validator->validate('foobar', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ file }}', '"foobar"') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 0927aedacdd5c45159f6b359eedcb07fd552ea3c..fc39b64be5d96dfce1eb01117e40d026d7f9661c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -11,50 +11,63 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\Validator\Constraints\File; use Symfony\Component\Validator\Constraints\FileValidator; -use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\Validator\Validation; -abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase +abstract class FileValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; protected $path; + protected $file; + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + + protected function createValidator() + { + return new FileValidator(); + } + protected function setUp() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new FileValidator(); - $this->validator->initialize($this->context); + parent::setUp(); + $this->path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'FileValidatorTest'; $this->file = fopen($this->path, 'w'); } protected function tearDown() { - fclose($this->file); + parent::tearDown(); + + if (is_resource($this->file)) { + fclose($this->file); + } + + if (file_exists($this->path)) { + unlink($this->path); + } - $this->context = null; - $this->validator = null; $this->path = null; $this->file = null; } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new File()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new File()); + + $this->assertNoViolation(); } /** @@ -67,82 +80,129 @@ public function testExpectsStringCompatibleTypeOrFile() public function testValidFile() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($this->path, new File()); + + $this->assertNoViolation(); } public function testValidUploadedfile() { - $this->context->expects($this->never()) - ->method('addViolation'); - $file = new UploadedFile($this->path, 'originalName', null, null, null, true); $this->validator->validate($file, new File()); + + $this->assertNoViolation(); } - public function testTooLargeBytes() + public function provideMaxSizeExceededTests() { - fwrite($this->file, str_repeat('0', 11)); + // We have various interesting limit - size combinations to test. + // Assume a limit of 1000 bytes (1 kB). Then the following table + // lists the violation messages for different file sizes: + + // -----------+-------------------------------------------------------- + // Size | Violation Message + // -----------+-------------------------------------------------------- + // 1000 bytes | No violation + // 1001 bytes | "Size of 1001 bytes exceeded limit of 1000 bytes" + // 1004 bytes | "Size of 1004 bytes exceeded limit of 1000 bytes" + // | NOT: "Size of 1 kB exceeded limit of 1 kB" + // 1005 bytes | "Size of 1.01 kB exceeded limit of 1 kB" + // -----------+-------------------------------------------------------- + + // As you see, we have two interesting borders: + + // 1000/1001 - The border as of which a violation occurs + // 1004/1005 - The border as of which the message can be rounded to kB + + // Analogous for kB/MB. + + // Prior to Symfony 2.5, violation messages are always displayed in the + // same unit used to specify the limit. + + // As of Symfony 2.5, the above logic is implemented. + return array( + // limit in bytes + array(1001, 1000, '1001', '1000', 'bytes'), + array(1004, 1000, '1004', '1000', 'bytes'), + array(1005, 1000, '1.01', '1', 'kB'), + + array(1000001, 1000000, '1000001', '1000000', 'bytes'), + array(1004999, 1000000, '1005', '1000', 'kB'), + array(1005000, 1000000, '1.01', '1', 'MB'), + + // limit in kB + array(1001, '1k', '1001', '1000', 'bytes'), + array(1004, '1k', '1004', '1000', 'bytes'), + array(1005, '1k', '1.01', '1', 'kB'), + + array(1000001, '1000k', '1000001', '1000000', 'bytes'), + array(1004999, '1000k', '1005', '1000', 'kB'), + array(1005000, '1000k', '1.01', '1', 'MB'), + + // limit in MB + array(1000001, '1M', '1000001', '1000000', 'bytes'), + array(1004999, '1M', '1005', '1000', 'kB'), + array(1005000, '1M', '1.01', '1', 'MB'), + ); + } + + /** + * @dataProvider provideMaxSizeExceededTests + */ + public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limitAsString, $suffix) + { + fseek($this->file, $bytesWritten-1, SEEK_SET); + fwrite($this->file, '0'); + fclose($this->file); $constraint = new File(array( - 'maxSize' => 10, + 'maxSize' => $limit, 'maxSizeMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => '10', - '{{ size }}' => '11', - '{{ suffix }}' => 'bytes', - '{{ file }}' => $this->path, - )); - $this->validator->validate($this->getFile($this->path), $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ limit }}', $limitAsString) + ->setParameter('{{ size }}', $sizeAsString) + ->setParameter('{{ suffix }}', $suffix) + ->setParameter('{{ file }}', '"'.$this->path.'"') + ->assertRaised(); } - public function testTooLargeKiloBytes() + public function provideMaxSizeNotExceededTests() { - fwrite($this->file, str_repeat('0', 1400)); - - $constraint = new File(array( - 'maxSize' => '1k', - 'maxSizeMessage' => 'myMessage', - )); + return array( + // limit in bytes + array(1000, 1000), + array(1000000, 1000000), - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => '1', - '{{ size }}' => '1.4', - '{{ suffix }}' => 'kB', - '{{ file }}' => $this->path, - )); + // limit in kB + array(1000, '1k'), + array(1000000, '1000k'), - $this->validator->validate($this->getFile($this->path), $constraint); + // limit in MB + array(1000000, '1M'), + ); } - public function testTooLargeMegaBytes() + /** + * @dataProvider provideMaxSizeNotExceededTests + */ + public function testMaxSizeNotExceeded($bytesWritten, $limit) { - fwrite($this->file, str_repeat('0', 1400000)); + fseek($this->file, $bytesWritten-1, SEEK_SET); + fwrite($this->file, '0'); + fclose($this->file); $constraint = new File(array( - 'maxSize' => '1M', + 'maxSize' => $limit, 'maxSizeMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => '1', - '{{ size }}' => '1.4', - '{{ suffix }}' => 'MB', - '{{ file }}' => $this->path, - )); - $this->validator->validate($this->getFile($this->path), $constraint); + + $this->assertNoViolation(); } /** @@ -161,124 +221,106 @@ public function testValidMimeType() { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() - ->getMock() - ; + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) + ->getMock(); $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)) - ; + ->will($this->returnValue($this->path)); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('image/jpg')) - ; - - $this->context->expects($this->never()) - ->method('addViolation'); + ->will($this->returnValue('image/jpg')); $constraint = new File(array( 'mimeTypes' => array('image/png', 'image/jpg'), )); $this->validator->validate($file, $constraint); + + $this->assertNoViolation(); } public function testValidWildcardMimeType() { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() - ->getMock() - ; + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) + ->getMock(); $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)) - ; + ->will($this->returnValue($this->path)); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('image/jpg')) - ; - - $this->context->expects($this->never()) - ->method('addViolation'); + ->will($this->returnValue('image/jpg')); $constraint = new File(array( 'mimeTypes' => array('image/*'), )); $this->validator->validate($file, $constraint); + + $this->assertNoViolation(); } public function testInvalidMimeType() { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() - ->getMock() - ; + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) + ->getMock(); $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)) - ; + ->will($this->returnValue($this->path)); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')) - ; + ->will($this->returnValue('application/pdf')); $constraint = new File(array( 'mimeTypes' => array('image/png', 'image/jpg'), 'mimeTypesMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ type }}' => '"application/pdf"', - '{{ types }}' => '"image/png", "image/jpg"', - '{{ file }}' => $this->path, - )); - $this->validator->validate($file, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ type }}', '"application/pdf"') + ->setParameter('{{ types }}', '"image/png", "image/jpg"') + ->setParameter('{{ file }}', '"'.$this->path.'"') + ->assertRaised(); } public function testInvalidWildcardMimeType() { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() - ->getMock() - ; + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) + ->getMock(); $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)) - ; + ->will($this->returnValue($this->path)); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')) - ; + ->will($this->returnValue('application/pdf')); $constraint = new File(array( 'mimeTypes' => array('image/*', 'image/jpg'), 'mimeTypesMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ type }}' => '"application/pdf"', - '{{ types }}' => '"image/*", "image/jpg"', - '{{ file }}' => $this->path, - )); - $this->validator->validate($file, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ type }}', '"application/pdf"') + ->setParameter('{{ types }}', '"image/*", "image/jpg"') + ->setParameter('{{ file }}', '"'.$this->path.'"') + ->assertRaised(); } /** @@ -290,15 +332,14 @@ public function testUploadedFileError($error, $message, array $params = array(), $constraint = new File(array( $message => 'myMessage', - 'maxSize' => $maxSize + 'maxSize' => $maxSize, )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $params); - $this->validator->validate($file, $constraint); + $this->buildViolation('myMessage') + ->setParameters($params) + ->assertRaised(); } public function uploadedFileErrorProvider() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/foo b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/foo new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_4by3.gif b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_4by3.gif new file mode 100644 index 0000000000000000000000000000000000000000..64dd3ff96a22b811751dba118c240d0ccd4165f7 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_4by3.gif @@ -0,0 +1 @@ +GIF89a��€��ÿÿÿÿÿÿ!þCreated with GIMP�,�������„V�; \ No newline at end of file diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index 2f97b03eb4389b2b6cfc4cd5c519a5343c140d84..2c3f1e9f8b85acb3b096b3f10baa6cb9728797e0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new GreaterThanOrEqualValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -46,14 +52,14 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array(new \DateTime('2000/01/01'), new \DateTime('2005/01/01'), '2005-01-01 00:00:00', 'DateTime'), - array('b', 'c', "'c'", 'string') + array(1, '1', 2, '2', 'integer'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'), + array('b', '"b"', 'c', '"c"', 'string'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index 1fc5311cf53329bb496603873c80366dad493dea..6ac25965dfc51c485cc92268658d77b4ac063693 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\GreaterThanValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new GreaterThanValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -44,19 +50,19 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array(2, 2, '2', 'integer'), - array(new \DateTime('2000/01/01'), new \DateTime('2005/01/01'), '2005-01-01 00:00:00', 'DateTime'), - array(new \DateTime('2000/01/01'), new \DateTime('2000/01/01'), '2000-01-01 00:00:00', 'DateTime'), - array(new ComparisonTest_Class(4), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), - array(new ComparisonTest_Class(5), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), - array('22', '333', "'333'", 'string'), - array('22', '22', "'22'", 'string') + array(1, '1', 2, '2', 'integer'), + array(2, '2', 2, '2', 'integer'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array('22', '"22"', '333', '"333"', 'string'), + array('22', '"22"', '22', '"22"', 'string'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..85b60b5eee3d5ad252159cb1a91502115f123086 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php @@ -0,0 +1,84 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\GroupSequence; + +/** + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class GroupSequenceTest extends \PHPUnit_Framework_TestCase +{ + public function testCreate() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2')); + + $this->assertSame(array('Group 1', 'Group 2'), $sequence->groups); + } + + public function testCreateDoctrineStyle() + { + $sequence = new GroupSequence(array('value' => array('Group 1', 'Group 2'))); + + $this->assertSame(array('Group 1', 'Group 2'), $sequence->groups); + } + + public function testIterate() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2')); + + $this->assertSame(array('Group 1', 'Group 2'), iterator_to_array($sequence)); + } + + public function testCount() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2')); + + $this->assertCount(2, $sequence); + } + + public function testArrayAccess() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2')); + + $this->assertSame('Group 1', $sequence[0]); + $this->assertSame('Group 2', $sequence[1]); + $this->assertTrue(isset($sequence[0])); + $this->assertFalse(isset($sequence[2])); + unset($sequence[0]); + $this->assertFalse(isset($sequence[0])); + $sequence[] = 'Group 3'; + $this->assertTrue(isset($sequence[2])); + $this->assertSame('Group 3', $sequence[2]); + $sequence[0] = 'Group 1'; + $this->assertTrue(isset($sequence[0])); + $this->assertSame('Group 1', $sequence[0]); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\OutOfBoundsException + */ + public function testGetExpectsExistingKey() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2')); + + $sequence[2]; + } + + public function testUnsetIgnoresNonExistingKeys() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2')); + + // should not fail + unset($sequence[2]); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index fa3b0203b2e4ffda252502510c75035fc93a78ad..d2ecf8f51b80cd1c476dabe04f0a573992f3aa4d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -13,31 +13,32 @@ use Symfony\Component\Validator\Constraints\Iban; use Symfony\Component\Validator\Constraints\IbanValidator; +use Symfony\Component\Validator\Validation; -class IbanValidatorTest extends \PHPUnit_Framework_TestCase +class IbanValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IbanValidator(); - $this->validator->initialize($this->context); + return new IbanValidator(); } public function testNullIsValid() { - $this->context->expects($this->never())->method('addViolation'); - $this->validator->validate(null, new Iban()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never())->method('addViolation'); - $this->validator->validate('', new Iban()); + + $this->assertNoViolation(); } /** @@ -45,15 +46,16 @@ public function testEmptyStringIsValid() */ public function testValidIbans($iban) { - $this->context->expects($this->never())->method('addViolation'); - $this->validator->validate($iban, new Iban()); + + $this->assertNoViolation(); } public function getValidIbans() { return array( 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 @@ -157,16 +159,14 @@ public function getValidIbans() public function testInvalidIbans($iban) { $constraint = new Iban(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $iban, - )); - $this->validator->validate($iban, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$iban.'"') + ->assertRaised(); } public function getInvalidIbans() @@ -181,7 +181,12 @@ public function getInvalidIbans() array('CY170020 128 0000 0012 0052 7600'), array('foo'), array('123'), - array('0750447346') + array('0750447346'), + array('CH930076201162385295]'), + + //Ibans with lower case values are invalid + array('Ae260211000000230064016'), + array('ae260211000000230064016'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index 39234239c0958d3c7c11f2e1ce8266e94ae0d9fa..125a2844384efa3455d25d7248b392d34d79afdc 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\IdenticalTo; use Symfony\Component\Validator\Constraints\IdenticalToValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new IdenticalToValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -47,17 +53,17 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array(2, '2', "'2'", 'string'), - array('22', '333', "'333'", 'string'), - array(new \DateTime('2001-01-01'), new \DateTime('2001-01-01'), '2001-01-01 00:00:00', 'DateTime'), - array(new \DateTime('2001-01-01'), new \DateTime('1999-01-01'), '1999-01-01 00:00:00', 'DateTime'), - array(new ComparisonTest_Class(4), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array(1, '1', 2, '2', 'integer'), + array(2, '2', '2', '"2"', 'string'), + array('22', '"22"', '333', '"333"', 'string'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', 'DateTime'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999, 12:00 AM', 'DateTime'), + array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index 114c2d2f0499e7b54d596c9c614b379c1693ce5e..5d6c9a91ff4dc97f00184c1283a1c260ca5a0844 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -13,55 +13,66 @@ use Symfony\Component\Validator\Constraints\Image; use Symfony\Component\Validator\Constraints\ImageValidator; +use Symfony\Component\Validator\Validation; -class ImageValidatorTest extends \PHPUnit_Framework_TestCase +class ImageValidatorTest extends AbstractConstraintValidatorTest { protected $context; + + /** + * @var ImageValidator + */ protected $validator; + protected $path; protected $image; protected $imageLandscape; protected $imagePortrait; + protected $image4By3; + + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + + protected function createValidator() + { + return new ImageValidator(); + } protected function setUp() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new ImageValidator(); - $this->validator->initialize($this->context); + parent::setUp(); + $this->image = __DIR__.'/Fixtures/test.gif'; $this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif'; $this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif'; + $this->image4By3 = __DIR__.'/Fixtures/test_4by3.gif'; } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Image()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Image()); + + $this->assertNoViolation(); } public function testValidImage() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($this->image, new Image()); + + $this->assertNoViolation(); } public function testValidSize() { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Image(array( 'minWidth' => 1, 'maxWidth' => 2, @@ -70,6 +81,8 @@ public function testValidSize() )); $this->validator->validate($this->image, $constraint); + + $this->assertNoViolation(); } public function testWidthTooSmall() @@ -79,14 +92,12 @@ public function testWidthTooSmall() 'minWidthMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => '2', - '{{ min_width }}' => '3', - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ width }}', '2') + ->setParameter('{{ min_width }}', '3') + ->assertRaised(); } public function testWidthTooBig() @@ -96,14 +107,12 @@ public function testWidthTooBig() 'maxWidthMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => '2', - '{{ max_width }}' => '1', - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ width }}', '2') + ->setParameter('{{ max_width }}', '1') + ->assertRaised(); } public function testHeightTooSmall() @@ -113,14 +122,12 @@ public function testHeightTooSmall() 'minHeightMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ height }}' => '2', - '{{ min_height }}' => '3', - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ height }}', '2') + ->setParameter('{{ min_height }}', '3') + ->assertRaised(); } public function testHeightTooBig() @@ -130,14 +137,12 @@ public function testHeightTooBig() 'maxHeightMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ height }}' => '2', - '{{ max_height }}' => '1', - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ height }}', '2') + ->setParameter('{{ max_height }}', '1') + ->assertRaised(); } /** @@ -195,14 +200,12 @@ public function testRatioTooSmall() 'minRatioMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ ratio }}' => 1, - '{{ min_ratio }}' => 2, - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ ratio }}', 1) + ->setParameter('{{ min_ratio }}', 2) + ->assertRaised(); } public function testRatioTooBig() @@ -212,14 +215,23 @@ public function testRatioTooBig() 'maxRatioMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ ratio }}' => 1, - '{{ max_ratio }}' => 0.5, - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ ratio }}', 1) + ->setParameter('{{ max_ratio }}', 0.5) + ->assertRaised(); + } + + public function testMaxRatioUsesTwoDecimalsOnly() + { + $constraint = new Image(array( + 'maxRatio' => 1.33, + )); + + $this->validator->validate($this->image4By3, $constraint); + + $this->assertNoViolation(); } /** @@ -253,14 +265,12 @@ public function testSquareNotAllowed() 'allowSquareMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => 2, - '{{ height }}' => 2, - )); - $this->validator->validate($this->image, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ width }}', 2) + ->setParameter('{{ height }}', 2) + ->assertRaised(); } public function testLandscapeNotAllowed() @@ -270,14 +280,12 @@ public function testLandscapeNotAllowed() 'allowLandscapeMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => 2, - '{{ height }}' => 1, - )); - $this->validator->validate($this->imageLandscape, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ width }}', 2) + ->setParameter('{{ height }}', 1) + ->assertRaised(); } public function testPortraitNotAllowed() @@ -287,13 +295,11 @@ public function testPortraitNotAllowed() 'allowPortraitMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => 1, - '{{ height }}' => 2, - )); - $this->validator->validate($this->imagePortrait, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ width }}', 1) + ->setParameter('{{ height }}', 2) + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index bdf61928802f2cffc21b7925417d47da3c1b228d..fc40e6104e14b7d4e8b7e60294bfe7847c78769e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\Ip; use Symfony\Component\Validator\Constraints\IpValidator; +use Symfony\Component\Validator\Validation; -class IpValidatorTest extends \PHPUnit_Framework_TestCase +class IpValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IpValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new IpValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Ip()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Ip()); + + $this->assertNoViolation(); } /** @@ -61,7 +54,7 @@ public function testExpectsStringCompatibleType() */ public function testInvalidValidatorVersion() { - $ip = new Ip(array( + new Ip(array( 'version' => 666, )); } @@ -71,12 +64,11 @@ public function testInvalidValidatorVersion() */ public function testValidIpsV4($ip) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($ip, new Ip(array( 'version' => Ip::V4, ))); + + $this->assertNoViolation(); } public function getValidIpsV4() @@ -98,12 +90,11 @@ public function getValidIpsV4() */ public function testValidIpsV6($ip) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($ip, new Ip(array( 'version' => Ip::V6, ))); + + $this->assertNoViolation(); } public function getValidIpsV6() @@ -136,12 +127,11 @@ public function getValidIpsV6() */ public function testValidIpsAll($ip) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($ip, new Ip(array( 'version' => Ip::ALL, ))); + + $this->assertNoViolation(); } public function getValidIpsAll() @@ -159,13 +149,11 @@ public function testInvalidIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidIpsV4() @@ -193,13 +181,11 @@ public function testInvalidPrivateIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidPrivateIpsV4() @@ -221,13 +207,11 @@ public function testInvalidReservedIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidReservedIpsV4() @@ -249,13 +233,11 @@ public function testInvalidPublicIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidPublicIpsV4() @@ -273,13 +255,11 @@ public function testInvalidIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidIpsV6() @@ -311,13 +291,11 @@ public function testInvalidPrivateIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidPrivateIpsV6() @@ -339,13 +317,11 @@ public function testInvalidReservedIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidReservedIpsV6() @@ -366,13 +342,11 @@ public function testInvalidPublicIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidPublicIpsV6() @@ -390,13 +364,11 @@ public function testInvalidIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidIpsAll() @@ -414,13 +386,11 @@ public function testInvalidPrivateIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidPrivateIpsAll() @@ -438,13 +408,11 @@ public function testInvalidReservedIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidReservedIpsAll() @@ -462,13 +430,11 @@ public function testInvalidPublicIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $ip, - )); - $this->validator->validate($ip, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$ip.'"') + ->assertRaised(); } public function getInvalidPublicIpsAll() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index 7f0859b999e0865f93740847c4c6721cd4315a66..296ab7c94a3ab9d2f504cdbd69e891b4a7fc28c0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -13,20 +13,21 @@ use Symfony\Component\Validator\Constraints\Isbn; use Symfony\Component\Validator\Constraints\IsbnValidator; +use Symfony\Component\Validator\Validation; /** * @see https://en.wikipedia.org/wiki/Isbn */ -class IsbnValidatorTest extends \PHPUnit_Framework_TestCase +class IsbnValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } - public function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IsbnValidator(); - $this->validator->initialize($this->context); + return new IsbnValidator(); } public function getValidIsbn10() @@ -44,20 +45,27 @@ public function getValidIsbn10() array('0321812700'), array('0-45122-5244'), array('0-4712-92311'), + array('0-9752298-0-X'), ); } public function getInvalidIsbn10() { return array( + array('27234422841'), + array('272344228'), + array('0-4712-9231'), array('1234567890'), - array('987'), array('0987656789'), - array(0), array('7-35622-5444'), array('0-4X19-92611'), array('0_45122_5244'), array('2870#971#648'), + array('0-9752298-0-x'), + array('1A34567890'), + // chr(1) evaluates to 0 + // 2070546810 is valid + array('2'.chr(1).'70546810'), ); } @@ -82,16 +90,20 @@ public function getValidIsbn13() public function getInvalidIsbn13() { return array( - array('1234567890'), - array('987'), - array('0987656789'), - array(0), - array('0-4X19-9261981'), + array('978-27234422821'), + array('978-272344228'), + array('978-2723442-82'), + array('978-2723442281'), array('978-0321513774'), array('979-0431225385'), array('980-0474292319'), - array('978_0451225245'), - array('978#0471292319'), + array('0-4X19-92619812'), + array('978_2723442282'), + array('978#2723442282'), + array('978-272C442282'), + // chr(1) evaluates to 0 + // 978-2070546817 is valid + array('978-2'.chr(1).'70546817'), ); } @@ -114,21 +126,19 @@ public function getInvalidIsbn() public function testNullIsValid() { $constraint = new Isbn(true); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate(null, $constraint); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { $constraint = new Isbn(true); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate('', $constraint); + + $this->assertNoViolation(); } /** @@ -137,6 +147,7 @@ public function testEmptyStringIsValid() public function testExpectsStringCompatibleType() { $constraint = new Isbn(true); + $this->validator->validate(new \stdClass(), $constraint); } @@ -145,12 +156,13 @@ public function testExpectsStringCompatibleType() */ public function testValidIsbn10($isbn) { - $constraint = new Isbn(array('isbn10' => true)); - $this->context - ->expects($this->never()) - ->method('addViolation'); + $constraint = new Isbn(array( + 'type' => 'isbn10', + )); $this->validator->validate($isbn, $constraint); + + $this->assertNoViolation(); } /** @@ -158,13 +170,16 @@ public function testValidIsbn10($isbn) */ public function testInvalidIsbn10($isbn) { - $constraint = new Isbn(array('isbn10' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->isbn10Message); + $constraint = new Isbn(array( + 'type' => 'isbn10', + 'isbn10Message' => 'myMessage', + )); $this->validator->validate($isbn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$isbn.'"') + ->assertRaised(); } /** @@ -172,12 +187,11 @@ public function testInvalidIsbn10($isbn) */ public function testValidIsbn13($isbn) { - $constraint = new Isbn(array('isbn13' => true)); - $this->context - ->expects($this->never()) - ->method('addViolation'); + $constraint = new Isbn(array('type' => 'isbn13')); $this->validator->validate($isbn, $constraint); + + $this->assertNoViolation(); } /** @@ -185,39 +199,59 @@ public function testValidIsbn13($isbn) */ public function testInvalidIsbn13($isbn) { - $constraint = new Isbn(array('isbn13' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->isbn13Message); + $constraint = new Isbn(array( + 'type' => 'isbn13', + 'isbn13Message' => 'myMessage', + )); $this->validator->validate($isbn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$isbn.'"') + ->assertRaised(); } /** * @dataProvider getValidIsbn */ - public function testValidIsbn($isbn) + public function testValidIsbnAny($isbn) { - $constraint = new Isbn(array('isbn10' => true, 'isbn13' => true)); - $this->context - ->expects($this->never()) - ->method('addViolation'); + $constraint = new Isbn(); $this->validator->validate($isbn, $constraint); + + $this->assertNoViolation(); } /** - * @dataProvider getInvalidIsbn + * @dataProvider getInvalidIsbn10 */ - public function testInvalidIsbn($isbn) + public function testInvalidIsbnAnyIsbn10($isbn) { - $constraint = new Isbn(array('isbn10' => true, 'isbn13' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->bothIsbnMessage); + $constraint = new Isbn(array( + 'bothIsbnMessage' => 'myMessage', + )); $this->validator->validate($isbn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$isbn.'"') + ->assertRaised(); + } + + /** + * @dataProvider getInvalidIsbn13 + */ + public function testInvalidIsbnAnyIsbn13($isbn) + { + $constraint = new Isbn(array( + 'bothIsbnMessage' => 'myMessage', + )); + + $this->validator->validate($isbn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$isbn.'"') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php index d9e48846625ed629fde232dd31dd196647a295d5..cb7ae3d8925dce8fb0e58112f3944487205c74af 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -13,20 +13,21 @@ use Symfony\Component\Validator\Constraints\Issn; use Symfony\Component\Validator\Constraints\IssnValidator; +use Symfony\Component\Validator\Validation; /** * @see https://en.wikipedia.org/wiki/Issn */ -class IssnValidatorTest extends \PHPUnit_Framework_TestCase +class IssnValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } - public function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IssnValidator(); - $this->validator->initialize($this->context); + return new IssnValidator(); } public function getValidLowerCasedIssn() @@ -65,7 +66,7 @@ public function getFullValidIssn() array('1684-5315'), array('1996-0786'), array('1684-5374'), - array('1996-0794') + array('1996-0794'), ); } @@ -78,53 +79,36 @@ public function getValidIssn() ); } - public function getInvalidFormatedIssn() + public function getInvalidIssn() { return array( array(0), array('1539'), - array('2156-537A') - ); - } - - public function getInvalidValueIssn() - { - return array( + array('2156-537A'), array('1119-0231'), array('1684-5312'), array('1996-0783'), array('1684-537X'), - array('1996-0795') - ); - - } - - public function getInvalidIssn() - { - return array_merge( - $this->getInvalidFormatedIssn(), - $this->getInvalidValueIssn() + array('1996-0795'), ); } public function testNullIsValid() { $constraint = new Issn(); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate(null, $constraint); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { $constraint = new Issn(); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate('', $constraint); + + $this->assertNoViolation(); } /** @@ -141,13 +125,16 @@ public function testExpectsStringCompatibleType() */ public function testCaseSensitiveIssns($issn) { - $constraint = new Issn(array('caseSensitive' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Issn(array( + 'caseSensitive' => true, + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$issn.'"') + ->assertRaised(); } /** @@ -155,13 +142,16 @@ public function testCaseSensitiveIssns($issn) */ public function testRequireHyphenIssns($issn) { - $constraint = new Issn(array('requireHyphen' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Issn(array( + 'requireHyphen' => true, + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$issn.'"') + ->assertRaised(); } /** @@ -170,39 +160,10 @@ public function testRequireHyphenIssns($issn) public function testValidIssn($issn) { $constraint = new Issn(); - $this->context - ->expects($this->never()) - ->method('addViolation'); - - $this->validator->validate($issn, $constraint); - } - - /** - * @dataProvider getInvalidFormatedIssn - */ - public function testInvalidFormatIssn($issn) - { - $constraint = new Issn(); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); $this->validator->validate($issn, $constraint); - } - /** - * @dataProvider getInvalidValueIssn - */ - public function testInvalidValueIssn($issn) - { - $constraint = new Issn(); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); - - $this->validator->validate($issn, $constraint); + $this->assertNoViolation(); } /** @@ -210,11 +171,14 @@ public function testInvalidValueIssn($issn) */ public function testInvalidIssn($issn) { - $constraint = new Issn(); - $this->context - ->expects($this->once()) - ->method('addViolation'); + $constraint = new Issn(array( + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$issn.'"') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 3588887d74998092e9b7d957de4cbb5027cab3bc..6f7c3900e5351dd39c578b8b10859cb2a20fda98 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -14,41 +14,39 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Language; use Symfony\Component\Validator\Constraints\LanguageValidator; +use Symfony\Component\Validator\Validation; -class LanguageValidatorTest extends \PHPUnit_Framework_TestCase +class LanguageValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - IntlTestHelper::requireIntl($this); + return Validation::API_VERSION_2_5; + } - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LanguageValidator(); - $this->validator->initialize($this->context); + protected function createValidator() + { + return new LanguageValidator(); } - protected function tearDown() + protected function setUp() { - $this->context = null; - $this->validator = null; + IntlTestHelper::requireFullIntl($this); + + parent::setUp(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Language()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Language()); + + $this->assertNoViolation(); } /** @@ -64,10 +62,9 @@ public function testExpectsStringCompatibleType() */ public function testValidLanguages($language) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($language, new Language()); + + $this->assertNoViolation(); } public function getValidLanguages() @@ -85,16 +82,14 @@ public function getValidLanguages() public function testInvalidLanguages($language) { $constraint = new Language(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $language, - )); - $this->validator->validate($language, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$language.'"') + ->assertRaised(); } public function getInvalidLanguages() @@ -109,11 +104,11 @@ public function testValidateUsingCountrySpecificLocale() { \Locale::setDefault('fr_FR'); $existingLanguage = 'en'; - $this->context->expects($this->never()) - ->method('addViolation'); $this->validator->validate($existingLanguage, new Language(array( - 'message' => 'aMessage' + 'message' => 'aMessage', ))); + + $this->assertNoViolation(); } } diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/RuntimeException.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidator2Dot4ApiTest.php similarity index 52% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/RuntimeException.php rename to core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidator2Dot4ApiTest.php index 9fe843e309d8c87765efff1b4297b2d000d3ac54..2d2a1eb833df6f15f87595d973771858ce408359 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/RuntimeException.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidator2Dot4ApiTest.php @@ -9,13 +9,18 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; /** - * Base RuntimeException for the PropertyAccess component. - * + * @since 2.5.3 * @author Bernhard Schussek <bschussek@gmail.com> */ -class RuntimeException extends \RuntimeException implements ExceptionInterface +class LegacyAllValidator2Dot4ApiTest extends AllValidatorTest { + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..03cb48bb6ebeed24f5f6c10d9adf196f9433dba0 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyAllValidatorLegacyApiTest extends AllValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3c47b99b715bec62e75dac472d782c959c099d72 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyBlankValidator2Dot4ApiTest extends BlankValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..047113f1ca5decfb6160e5aab0add9e4f73ecde4 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyBlankValidatorLegacyApiTest extends BlankValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9cb42de80f4cc60ea1fabf85b581e1e705d7571e --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCallbackValidator2Dot4ApiTest extends CallbackValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ef19fa04c17e2f7d2844700a504ea8c55099c45d --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCallbackValidatorLegacyApiTest extends CallbackValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..37141dad43330ef96966282f43b463425e67ed41 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCardSchemeValidator2Dot4ApiTest extends CardSchemeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dab03e1df99b920df749cd0e396c8e7b7355bdc4 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCardSchemeValidatorLegacyApiTest extends CardSchemeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..725e574a231f53dee91b48750cb2f1cf83c1742e --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyChoiceValidator2Dot4ApiTest extends ChoiceValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a70c428ff28d7d8560f98dfc4cadd88831e7e39c --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyChoiceValidatorLegacyApiTest extends ChoiceValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArray2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArray2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9077936de9386378dcc8d6721a1013665303c925 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArray2Dot4ApiTest.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +class LegacyCollectionValidatorArray2Dot4ApiTest extends CollectionValidatorArrayTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..02ceb192a9682745f1e9d3c7b1e9b4c8f92bc27c --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +class LegacyCollectionValidatorArrayLegacyApiTest extends CollectionValidatorArrayTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObject2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObject2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..114650234163f2ea582b6a61e5e00137e1545d28 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObject2Dot4ApiTest.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +class LegacyCollectionValidatorArrayObject2Dot4ApiTest extends CollectionValidatorArrayObjectTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3a2dba99785b26f7726bbf50de5efa333fcc7728 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +class LegacyCollectionValidatorArrayObjectLegacyApiTest extends CollectionValidatorArrayObjectTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObject2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObject2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f5a9bd53cd8b21bd99d3699d22eda2e67e2f5f57 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObject2Dot4ApiTest.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +class LegacyCollectionValidatorCustomArrayObject2Dot4ApiTest extends CollectionValidatorCustomArrayObjectTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e65147fb215ace59e540cbddb45c9213edce4122 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +class LegacyCollectionValidatorCustomArrayObjectLegacyApiTest extends CollectionValidatorCustomArrayObjectTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArray2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArray2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..645d6b74dd7dff22a87d7b14428436c1f800c515 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArray2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCountValidatorArray2Dot4ApiTest extends CountValidatorArrayTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..43f18105ee6df305174a6ee0315b7e0094b68972 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCountValidatorArrayLegacyApiTest extends CountValidatorArrayTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountable2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountable2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f8531ba298d4a8e9ea7a2e854a7f6b5b1b79f9c2 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountable2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCountValidatorCountable2Dot4ApiTest extends CountValidatorCountableTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..89e0f3ed24926793e67a26cb5f2f396dc9277008 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCountValidatorCountableLegacyApiTest extends CountValidatorCountableTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5a042f0d5c3b7647fbdcc135ddfd3c18654652d1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCurrencyValidator2Dot4ApiTest extends CurrencyValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ba291920ef0c2b6cc6cffbfb7ca8646e2e48245d --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyCurrencyValidatorLegacyApiTest extends CurrencyValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..27d35a85d7b2b626a7caf5bad83d6d00da476317 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyDateTimeValidator2Dot4ApiTest extends DateTimeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..120d077280c72e345880412ca5611e270b2f36e7 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyDateTimeValidatorLegacyApiTest extends DateTimeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7d54e42839cd90e796bb5b1aa0bd7ca197d23238 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyDateValidator2Dot4ApiTest extends DateValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..03e329e048aa5038a50449e5c460fc8aa7cbdcf3 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyDateValidatorLegacyApiTest extends DateValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a29f918d15b428a3540617e82cb3acf0e74c7399 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyEmailValidator2Dot4ApiTest extends EmailValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..477ce14d40cbb9365c58b13d2eb481c604e1bc02 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyEmailValidatorLegacyApiTest extends EmailValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6f1d2ccbc1921cf6d912e7561b163f9d095fcd92 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyEqualToValidator2Dot4ApiTest extends EqualToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..16f71123efbe1dde53326e9607517e484330ccd1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyEqualToValidatorLegacyApiTest extends EqualToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5188c3696537b68870af1ecf9b832cea00197cb9 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyExpressionValidator2Dot4ApiTest extends ExpressionValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8b3ab71b5e6763195c7616fa7f740e91d12fb2f0 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyExpressionValidatorLegacyApiTest extends ExpressionValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cbd1791cc934267dd0542d44093515a57c10f3fe --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyFalseValidator2Dot4ApiTest extends FalseValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0fc46b4cb6d6672ec55de1b1fad14dc75558fc36 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyFalseValidatorLegacyApiTest extends FalseValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObject2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObject2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..27896a64455bfed54f11b56a8ca67fd4645d2f69 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObject2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyFileValidatorObject2Dot4ApiTest extends FileValidatorObjectTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0ff1e739ec9ef05b42c9ce26547b577b722becb8 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyFileValidatorObjectLegacyApiTest extends FileValidatorObjectTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPath2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPath2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c195a13d37103384cf9fa2735d51151186a7cbb0 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPath2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyFileValidatorPath2Dot4ApiTest extends FileValidatorPathTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c04544b53cbe56f5929d692f0fc3eb4254abcf74 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyFileValidatorPathLegacyApiTest extends FileValidatorPathTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..90ef99e8f25eaa9504ccfa54885dd1e7fb6c3175 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyGreaterThanOrEqualValidator2Dot4ApiTest extends GreaterThanOrEqualValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..99912358ca635e3eab504c2559078f996604d030 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyGreaterThanOrEqualValidatorLegacyApiTest extends GreaterThanOrEqualValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3edb2ffc17e0d2acce89150097e16804b187b7f5 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyGreaterThanValidator2Dot4ApiTest extends GreaterThanValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7d04e1e7e683647e81106e31b10b881a21c28311 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyGreaterThanValidatorLegacyApiTest extends GreaterThanValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b89c2f168c292c3796b0276f46cc5f1f6272519f --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIbanValidator2Dot4ApiTest extends IbanValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..97b322bd6738bbe16539117d828734e2b12f01f7 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIbanValidatorLegacyApiTest extends IbanValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2847e79623bede8992c191c7fde576f856cbd861 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIdenticalToValidator2Dot4ApiTest extends IdenticalToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c337f4927cd78853fd69a7bf47dc830409d57f43 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIdenticalToValidatorLegacyApiTest extends IdenticalToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c4b56aa65e1f20313024fc3980a0b4a4f8a1f94f --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyImageValidator2Dot4ApiTest extends ImageValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c8171232e0034ca08305ab0999325a8a8a6bfcfe --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyImageValidatorLegacyApiTest extends ImageValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/InvalidPropertyPathException.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidator2Dot4ApiTest.php similarity index 52% rename from core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/InvalidPropertyPathException.php rename to core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidator2Dot4ApiTest.php index 69de31cee49763485f0438d400e57b74cafc55ab..ca3b506449a2b56e89a21047b9b3f166e6d0b658 100644 --- a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/InvalidPropertyPathException.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidator2Dot4ApiTest.php @@ -9,13 +9,18 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\PropertyAccess\Exception; +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; /** - * Thrown when a property path is malformed. - * + * @since 2.5.3 * @author Bernhard Schussek <bschussek@gmail.com> */ -class InvalidPropertyPathException extends RuntimeException +class LegacyIpValidator2Dot4ApiTest extends IpValidatorTest { + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..edc2acc6f638ddbaeab622b6982476d98b838c91 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIpValidatorLegacyApiTest extends IpValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d2b6adfaf72e10869034ace80fb8c44f3c839e40 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIsbnValidator2Dot4ApiTest extends IsbnValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..33525c1398af4adee6cfb70052d7dfccfc19691a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIsbnValidatorLegacyApiTest extends IsbnValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1c37e381346bf18769091c77f22e8f5645a24110 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIssnValidator2Dot4ApiTest extends IssnValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0273310cd03482cabf3e5db3cda69b661cd7f9f4 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyIssnValidatorLegacyApiTest extends IssnValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4a08c77b9c422ea179670feffd5d112b9d46e8ca --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLanguageValidator2Dot4ApiTest extends LanguageValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f2f974fef814342f59eeb6d001de50cba732f1a1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLanguageValidatorLegacyApiTest extends LanguageValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7174c04c9408802dbd7721a47e8c347cb0cefd94 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLengthValidator2Dot4ApiTest extends LengthValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..784cd76493ee8d87e5b2225d1a06f7e5d3887967 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLengthValidatorLegacyApiTest extends LengthValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7a817fe795f0556fc497c16420082d18595c72d1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLessThanOrEqualValidator2Dot4ApiTest extends LessThanOrEqualValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d74d8e42d8da699b8724814f981d585af05e333a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLessThanOrEqualValidatorLegacyApiTest extends LessThanOrEqualValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4e11330d8ab7e47b0942e0f4c9697cc1e3bb3674 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLessThanValidator2Dot4ApiTest extends LessThanValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ef436fab08bd0236403d09011dc1e771148a5b78 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLessThanValidatorLegacyApiTest extends LessThanValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2120384dae99c4dbc62a5ae42d645890fd73cbe9 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLocaleValidator2Dot4ApiTest extends LocaleValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e95902efe781cc25ccfca56d437a9dfb6ec4b75c --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLocaleValidatorLegacyApiTest extends LocaleValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..49b2cebd6fb9bbf88aaa106ee177ec9ec51d6b0a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLuhnValidator2Dot4ApiTest extends LuhnValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fb8c31ca30e56b7b7a09445837d6b8a0dbd97bf9 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyLuhnValidatorLegacyApiTest extends LuhnValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f5ac29017ac13ab58546cee01d33ce207b6af513 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotBlankValidator2Dot4ApiTest extends NotBlankValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f34c6c7dbac19bf51677145e3bac78de97fe4706 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotBlankValidatorLegacyApiTest extends NotBlankValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f9e51a8ada396c01c29aeaa77aff3ce9151b7f49 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotEqualToValidator2Dot4ApiTest extends NotEqualToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7ea366085b1899ea629ba3fdf0de28658d6783c4 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotEqualToValidatorLegacyApiTest extends NotEqualToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9a38be7bb8d9603c43964e3663c97ac07a7193a5 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotIdenticalToValidator2Dot4ApiTest extends NotIdenticalToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ed1fbc7f0bd59b6628e4f783ca4afd6ebad89bff --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotIdenticalToValidatorLegacyApiTest extends NotIdenticalToValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..98197c74390b7c84d81ec50926296b06d557c289 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotNullValidator2Dot4ApiTest extends NotNullValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d40d75963566dfda0eaa1cefa982dfe3267b93df --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNotNullValidatorLegacyApiTest extends NotNullValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dacf1d202386d495ca0b48b76e305d72e7fcb483 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNullValidator2Dot4ApiTest extends NullValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..390e325394203136311ec7fc6f6181eba92c298e --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyNullValidatorLegacyApiTest extends NullValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a3df8dfefe7849d79b88c5879d4d85cd7c362cb2 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyRangeValidator2Dot4ApiTest extends RangeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..efe7f85c42e536dde960d7e27579f8b2eafe5f60 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyRangeValidatorLegacyApiTest extends RangeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..50f25f03039458026c5720f0d1c8f7ed3e495b2e --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyRegexValidator2Dot4ApiTest extends RegexValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c58b1a134f85c364c3a0904d0779435f7945df78 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyRegexValidatorLegacyApiTest extends RegexValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..318597590b18de21e5135bf41a93d180501da373 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyTimeValidator2Dot4ApiTest extends TimeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ba0e30d5534a5ed5812f5cd5a5b69a8d6d496724 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyTimeValidatorLegacyApiTest extends TimeValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8d8c54ceb981ceeea8e7fb2ac2874d4b8b4eec54 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyTrueValidator2Dot4ApiTest extends TrueValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8a199e0a98a342d4aa6a0191eca33ed4fda88d45 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyTrueValidatorLegacyApiTest extends TrueValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c249240e7f0f27dbecab66daecb5086c555a7a72 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidator2Dot4ApiTest.php @@ -0,0 +1,36 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyTypeValidator2Dot4ApiTest extends TypeValidatorTest +{ + /** + * PhpUnit calls data providers of test suites before launching the test + * suite. If this property is not replicated in every test class, only one + * file will ever be created and stored in TypeValidatorTest::$file. After + * the execution of the first TypeValidator test case, tearDownAfterClass() + * is called and closes the file. Hence the resource is not available + * anymore in the other TypeValidator test cases. + */ + protected static $file; + + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..808c37fab38b16ddc50fe6bdc4b89ae1eaa6853c --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php @@ -0,0 +1,28 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyTypeValidatorLegacyApiTest extends TypeValidatorTest +{ + protected static $file; + + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..55564c9f915f38f4addd24095a9d20b5e498b98d --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyUrlValidator2Dot4ApiTest extends UrlValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8e1eb208412e1ed10a0fa953ecaea99d63c8435a --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyUrlValidatorLegacyApiTest extends UrlValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidator2Dot4ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidator2Dot4ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c421404bfe6814cc2f0eff2e9275c03adc4fa02f --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidator2Dot4ApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyUuidValidator2Dot4ApiTest extends UrlValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_4; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1fd6f337af97fa86c47c24f33cceac9ec8a852f8 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Validation; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class LegacyUuidValidatorLegacyApiTest extends UuidValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5_BC; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index db6339449d90e8feba4a681af4b085e27ae71734..7674ae24272e32c53cf198cf5d64cb2bdddfdea5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\LengthValidator; +use Symfony\Component\Validator\Validation; -class LengthValidatorTest extends \PHPUnit_Framework_TestCase +class LengthValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LengthValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new LengthValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Length(6)); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Length(6)); + + $this->assertNoViolation(); } /** @@ -80,14 +73,6 @@ public function getFourCharacters() ); } - public function getNotFourCharacters() - { - return array_merge( - $this->getThreeOrLessCharacters(), - $this->getFiveOrMoreCharacters() - ); - } - public function getFiveOrMoreCharacters() { return array( @@ -111,11 +96,10 @@ public function testValidValuesMin($value, $mbOnly = false) $this->markTestSkipped('mb_strlen does not exist'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Length(array('min' => 5)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -127,11 +111,10 @@ public function testValidValuesMax($value, $mbOnly = false) $this->markTestSkipped('mb_strlen does not exist'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Length(array('max' => 3)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -143,11 +126,10 @@ public function testValidValuesExact($value, $mbOnly = false) $this->markTestSkipped('mb_strlen does not exist'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Length(4); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -161,17 +143,17 @@ public function testInvalidValuesMin($value, $mbOnly = false) $constraint = new Length(array( 'min' => 4, - 'minMessage' => 'myMessage' + 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, - '{{ limit }}' => 4, - )), $this->identicalTo($value), 4); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$value.'"') + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); } /** @@ -185,23 +167,23 @@ public function testInvalidValuesMax($value, $mbOnly = false) $constraint = new Length(array( 'max' => 4, - 'maxMessage' => 'myMessage' + 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, - '{{ limit }}' => 4, - )), $this->identicalTo($value), 4); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$value.'"') + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); } /** - * @dataProvider getNotFourCharacters + * @dataProvider getThreeOrLessCharacters */ - public function testInvalidValuesExact($value, $mbOnly = false) + public function testInvalidValuesExactLessThanFour($value, $mbOnly = false) { if ($mbOnly && !function_exists('mb_strlen')) { $this->markTestSkipped('mb_strlen does not exist'); @@ -210,17 +192,42 @@ public function testInvalidValuesExact($value, $mbOnly = false) $constraint = new Length(array( 'min' => 4, 'max' => 4, - 'exactMessage' => 'myMessage' + 'exactMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, - '{{ limit }}' => 4, - )), $this->identicalTo($value), 4); + $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$value.'"') + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); + } + + /** + * @dataProvider getFiveOrMoreCharacters + */ + public function testInvalidValuesExactMoreThanFour($value, $mbOnly = false) + { + if ($mbOnly && !function_exists('mb_strlen')) { + $this->markTestSkipped('mb_strlen does not exist'); + } + + $constraint = new Length(array( + 'min' => 4, + 'max' => 4, + 'exactMessage' => 'myMessage', + )); $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$value.'"') + ->setParameter('{{ limit }}', 4) + ->setInvalidValue($value) + ->setPlural(4) + ->assertRaised(); } public function testConstraintGetDefaultOption() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index 24ad0faf75b055391860c3c9643a6dcaef39e417..4b50259a88a9c8f7747c2d976e29cc37ba119dd4 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\LessThanOrEqual; use Symfony\Component\Validator\Constraints\LessThanOrEqualValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new LessThanOrEqualValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -48,15 +54,15 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(2, 1, '1', 'integer'), - array(new \DateTime('2010-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array(new ComparisonTest_Class(5), new ComparisonTest_Class(4), '4', __NAMESPACE__.'\ComparisonTest_Class'), - array('c', 'b', "'b'", 'string') + array(2, '2', 1, '1', 'integer'), + array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(4), '4', __NAMESPACE__.'\ComparisonTest_Class'), + array('c', '"c"', 'b', '"b"', 'string'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index da7070e762e99426c31633551863994a1a5d3e4b..eb534e58ba1638f53ce5d7ded6f1b91faa70c059 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\LessThan; use Symfony\Component\Validator\Constraints\LessThanValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class LessThanValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new LessThanValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -44,18 +50,18 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(3, 2, '2', 'integer'), - array(2, 2, '2', 'integer'), - array(new \DateTime('2010-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array(new ComparisonTest_Class(5), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), - array(new ComparisonTest_Class(6), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), - array('333', '22', "'22'", 'string') + array(3, '3', 2, '2', 'integer'), + array(2, '2', 2, '2', 'integer'), + array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array(new ComparisonTest_Class(6), '6', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array('333', '"333"', '22', '"22"', 'string'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 41feba0c7123a309f843d34c6593355c1da74d21..e5e2f3009f9f91d675fba6c3606815edc23d8a1e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -14,41 +14,39 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; +use Symfony\Component\Validator\Validation; -class LocaleValidatorTest extends \PHPUnit_Framework_TestCase +class LocaleValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - IntlTestHelper::requireIntl($this); + return Validation::API_VERSION_2_5; + } - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LocaleValidator(); - $this->validator->initialize($this->context); + protected function createValidator() + { + return new LocaleValidator(); } - protected function tearDown() + protected function setUp() { - $this->context = null; - $this->validator = null; + IntlTestHelper::requireIntl($this); + + parent::setUp(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Locale()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Locale()); + + $this->assertNoViolation(); } /** @@ -64,10 +62,9 @@ public function testExpectsStringCompatibleType() */ public function testValidLocales($locale) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($locale, new Locale()); + + $this->assertNoViolation(); } public function getValidLocales() @@ -87,16 +84,14 @@ public function getValidLocales() public function testInvalidLocales($locale) { $constraint = new Locale(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $locale, - )); - $this->validator->validate($locale, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$locale.'"') + ->assertRaised(); } public function getInvalidLocales() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php index 11c6a7cad529454fbf429483f59d8cdfeca83f1e..4ad3c736eb09dad7f5aa32895048ca6b6a22e76e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\Luhn; use Symfony\Component\Validator\Constraints\LuhnValidator; +use Symfony\Component\Validator\Validation; -class LuhnValidatorTest extends \PHPUnit_Framework_TestCase +class LuhnValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LuhnValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new LuhnValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Luhn()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Luhn()); + + $this->assertNoViolation(); } /** @@ -53,10 +46,9 @@ public function testEmptyStringIsValid() */ public function testValidNumbers($number) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($number, new Luhn()); + + $this->assertNoViolation(); } public function getValidNumbers() @@ -88,13 +80,15 @@ public function getValidNumbers() */ public function testInvalidNumbers($number) { - $constraint = new Luhn(); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Luhn(array( + 'message' => 'myMessage', + )); $this->validator->validate($number, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$number.'"') + ->assertRaised(); } public function getInvalidNumbers() @@ -103,6 +97,8 @@ public function getInvalidNumbers() array('1234567812345678'), array('4222222222222222'), array('0000000000000000'), + array('000000!000000000'), + array('42-22222222222222'), ); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php index 85db95ddca6f13c06d9d6e56f5e3132586ccf082..c248246e4383eb7697baffc5cd47c6500f5539df 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php @@ -13,34 +13,28 @@ use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlankValidator; +use Symfony\Component\Validator\Validation; -class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase +class NotBlankValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new NotBlankValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new NotBlankValidator(); } /** * @dataProvider getValidValues */ - public function testValidValues($date) + public function testValidValues($value) { - $this->context->expects($this->never()) - ->method('addViolation'); + $this->validator->validate($value, new NotBlank()); - $this->validator->validate($date, new NotBlank()); + $this->assertNoViolation(); } public function getValidValues() @@ -57,52 +51,52 @@ public function getValidValues() public function testNullIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate(null, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', 'null') + ->assertRaised(); } public function testBlankIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate('', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '""') + ->assertRaised(); } public function testFalseIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate(false, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', 'false') + ->assertRaised(); } public function testEmptyArrayIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate(array(), $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', 'array') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index dcf46a668d81e4d3a85114554f6f9dbc5a95e75d..836d01848ace000a6e03da4ab46a4fd92394125b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\NotEqualTo; use Symfony\Component\Validator\Constraints\NotEqualToValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new NotEqualToValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -44,16 +50,16 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { return array( - array(3, 3, '3', 'integer'), - array('2', 2, '2', 'integer'), - array('a', 'a', "'a'", 'string'), - array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array(new ComparisonTest_Class(5), new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), + array(3, '3', 3, '3', 'integer'), + array('2', '"2"', 2, '2', 'integer'), + array('a', '"a"', 'a', '"a"', 'string'), + array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 28026c08745c71aa80696562a38fb18348ac7707..de676d43707e77b5794e9894884d899bf761a81c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -13,12 +13,18 @@ use Symfony\Component\Validator\Constraints\NotIdenticalTo; use Symfony\Component\Validator\Constraints\NotIdenticalToValidator; +use Symfony\Component\Validator\Validation; /** * @author Daniel Holmes <daniel@danielholmes.org> */ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase { + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + protected function createValidator() { return new NotIdenticalToValidator(); @@ -30,7 +36,7 @@ protected function createConstraint(array $options) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideValidComparisons() { @@ -45,7 +51,7 @@ public function provideValidComparisons() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function provideInvalidComparisons() { @@ -53,10 +59,10 @@ public function provideInvalidComparisons() $object = new ComparisonTest_Class(2); return array( - array(3, 3, '3', 'integer'), - array('a', 'a', "'a'", 'string'), - array($date, $date, '2000-01-01 00:00:00', 'DateTime'), - array($object, $object, '2', __NAMESPACE__.'\ComparisonTest_Class'), + array(3, '3', 3, '3', 'integer'), + array('a', '"a"', 'a', '"a"', 'string'), + array($date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php index 96f74a1ba02ac28fa244501340c4e724129848d8..d338f31f797b2ba52a755bc5f9bec4ffb6bd2977 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php @@ -13,23 +13,18 @@ use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotNullValidator; +use Symfony\Component\Validator\Validation; -class NotNullValidatorTest extends \PHPUnit_Framework_TestCase +class NotNullValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new NotNullValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new NotNullValidator(); } /** @@ -37,10 +32,9 @@ protected function tearDown() */ public function testValidValues($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($value, new NotNull()); + + $this->assertNoViolation(); } public function getValidValues() @@ -56,14 +50,11 @@ public function getValidValues() public function testNullIsInvalid() { $constraint = new NotNull(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - )); - $this->validator->validate(null, $constraint); + + $this->buildViolation('myMessage')->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php index d343c869fdf8773d9b57f31a2a6f0ddbf323bf20..85df90a8ae09ce11d997ecd328d46caf9c0eda2d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php @@ -13,61 +13,54 @@ use Symfony\Component\Validator\Constraints\Null; use Symfony\Component\Validator\Constraints\NullValidator; +use Symfony\Component\Validator\Validation; -class NullValidatorTest extends \PHPUnit_Framework_TestCase +class NullValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new NullValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new NullValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Null()); + + $this->assertNoViolation(); } /** * @dataProvider getInvalidValues */ - public function testInvalidValues($value, $readableValue) + public function testInvalidValues($value, $valueAsString) { $constraint = new Null(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $readableValue, - )); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', $valueAsString) + ->assertRaised(); } public function getInvalidValues() { return array( - array(0, 0), - array(false, false), - array(true, true), - array('', ''), - array('foo bar', 'foo bar'), - array(new \DateTime(), 'DateTime'), - array(array(), 'Array'), + array(0, '0'), + array(false, 'false'), + array(true, 'true'), + array('', '""'), + array('foo bar', '"foo bar"'), + array(new \DateTime(), 'object'), + array(new \stdClass(), 'object'), + array(array(), 'array'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index c44b0ea6ce43913d942628166eb727899028bc3f..81f3ce624dfb221aab5331435b3cc7955bf81043 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -13,25 +13,25 @@ use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\RangeValidator; +use Symfony\Component\Validator\Validation; -class RangeValidatorTest extends \PHPUnit_Framework_TestCase +class RangeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new RangeValidator(); - $this->validator->initialize($this->context); + return new RangeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Range(array('min' => 10, 'max' => 20))); + + $this->assertNoViolation(); } public function getTenToTwenty() @@ -73,11 +73,10 @@ public function getMoreThanTwenty() */ public function testValidValuesMin($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Range(array('min' => 10)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -85,11 +84,10 @@ public function testValidValuesMin($value) */ public function testValidValuesMax($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Range(array('max' => 20)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -97,11 +95,10 @@ public function testValidValuesMax($value) */ public function testValidValuesMinMax($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Range(array('min' => 10, 'max' => 20)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -114,14 +111,12 @@ public function testInvalidValuesMin($value) 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 10, - ))); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', $value) + ->setParameter('{{ limit }}', 10) + ->assertRaised(); } /** @@ -134,14 +129,12 @@ public function testInvalidValuesMax($value) 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 20, - ))); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', $value) + ->setParameter('{{ limit }}', 20) + ->assertRaised(); } /** @@ -156,14 +149,12 @@ public function testInvalidValuesCombinedMax($value) 'maxMessage' => 'myMaxMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMaxMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 20, - ))); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMaxMessage') + ->setParameter('{{ value }}', $value) + ->setParameter('{{ limit }}', 20) + ->assertRaised(); } /** @@ -178,14 +169,12 @@ public function testInvalidValuesCombinedMin($value) 'maxMessage' => 'myMaxMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMinMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 10, - ))); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMinMessage') + ->setParameter('{{ value }}', $value) + ->setParameter('{{ limit }}', 10) + ->assertRaised(); } public function getInvalidValues() @@ -199,39 +188,16 @@ public function getInvalidValues() ); } - public function testMinMessageIsSet() + public function testNonNumeric() { - $constraint = new Range(array( + $this->validator->validate('abcd', new Range(array( 'min' => 10, 'max' => 20, - 'minMessage' => 'myMessage', - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 9, - '{{ limit }}' => 10, - )); - - $this->validator->validate(9, $constraint); - } - - public function testMaxMessageIsSet() - { - $constraint = new Range(array( - 'min' => 10, - 'max' => 20, - 'maxMessage' => 'myMessage', - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 21, - '{{ limit }}' => 20, - )); + 'invalidMessage' => 'myMessage', + ))); - $this->validator->validate(21, $constraint); + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"abcd"') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 1ea79fb8e29b170fae37e97390a013b13874e10b..88e565c01321b487e2a982b9f2ec6cf582a05f72 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\Regex; use Symfony\Component\Validator\Constraints\RegexValidator; +use Symfony\Component\Validator\Validation; -class RegexValidatorTest extends \PHPUnit_Framework_TestCase +class RegexValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new RegexValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new RegexValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Regex(array('pattern' => '/^[0-9]+$/'))); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Regex(array('pattern' => '/^[0-9]+$/'))); + + $this->assertNoViolation(); } /** @@ -61,11 +54,10 @@ public function testExpectsStringCompatibleType() */ public function testValidValues($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Regex(array('pattern' => '/^[0-9]+$/')); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } public function getValidValues() @@ -85,16 +77,14 @@ public function testInvalidValues($value) { $constraint = new Regex(array( 'pattern' => '/^[0-9]+$/', - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $value, - )); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$value.'"') + ->assertRaised(); } public function getInvalidValues() @@ -166,7 +156,7 @@ public function testHtmlPattern() // Dropped because of match=false $constraint = new Regex(array( 'pattern' => '/[a-z]+/', - 'match' => false + 'match' => false, )); $this->assertNull($constraint->getHtmlPattern()); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index ba398ab373b162e76b63e94c8234bb668cf08842..23aed04c0f33156455463aa394862e90aa4cfe3a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -13,47 +13,39 @@ use Symfony\Component\Validator\Constraints\Time; use Symfony\Component\Validator\Constraints\TimeValidator; +use Symfony\Component\Validator\Validation; -class TimeValidatorTest extends \PHPUnit_Framework_TestCase +class TimeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new TimeValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new TimeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Time()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Time()); + + $this->assertNoViolation(); } public function testDateTimeClassIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(new \DateTime(), new Time()); + + $this->assertNoViolation(); } /** @@ -69,10 +61,9 @@ public function testExpectsStringCompatibleType() */ public function testValidTimes($time) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($time, new Time()); + + $this->assertNoViolation(); } public function getValidTimes() @@ -90,16 +81,14 @@ public function getValidTimes() public function testInvalidTimes($time) { $constraint = new Time(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $time, - )); - $this->validator->validate($time, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$time.'"') + ->assertRaised(); } public function getInvalidTimes() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php index 25901793a07bb73109da06dbf68d18453d77ff61..2cdc703183d013e5ea3bfed21290b3d3f8976dae 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php @@ -13,52 +13,44 @@ use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Constraints\TrueValidator; +use Symfony\Component\Validator\Validation; -class TrueValidatorTest extends \PHPUnit_Framework_TestCase +class TrueValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new TrueValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new TrueValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new True()); + + $this->assertNoViolation(); } public function testTrueIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(true, new True()); + + $this->assertNoViolation(); } public function testFalseIsInvalid() { $constraint = new True(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - )); - $this->validator->validate(false, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', 'false') + ->assertRaised(); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index e5e6d0bf025e7cf6ed6fbbdedb1e1bfd145f76c7..4836928014edd230202a8ec82797dab6305f8dbf 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -13,49 +13,53 @@ use Symfony\Component\Validator\Constraints\Type; use Symfony\Component\Validator\Constraints\TypeValidator; +use Symfony\Component\Validator\Validation; -class TypeValidatorTest extends \PHPUnit_Framework_TestCase +class TypeValidatorTest extends AbstractConstraintValidatorTest { protected static $file; - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new TypeValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new TypeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); + $constraint = new Type(array('type' => 'integer')); + + $this->validator->validate(null, $constraint); - $this->validator->validate(null, new Type(array('type' => 'integer'))); + $this->assertNoViolation(); } public function testEmptyIsValidIfString() { - $this->context->expects($this->never()) - ->method('addViolation'); + $constraint = new Type(array('type' => 'string')); + + $this->validator->validate('', $constraint); - $this->validator->validate('', new Type(array('type' => 'string'))); + $this->assertNoViolation(); } public function testEmptyIsInvalidIfNoString() { - $this->context->expects($this->once()) - ->method('addViolation'); + $constraint = new Type(array( + 'type' => 'integer', + 'message' => 'myMessage', + )); - $this->validator->validate('', new Type(array('type' => 'integer'))); + $this->validator->validate('', $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '""') + ->setParameter('{{ type }}', 'integer') + ->assertRaised(); } /** @@ -63,12 +67,11 @@ public function testEmptyIsInvalidIfNoString() */ public function testValidValues($value, $type) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Type(array('type' => $type)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } public function getValidValues() @@ -115,17 +118,15 @@ public function testInvalidValues($value, $type, $valueAsString) { $constraint = new Type(array( 'type' => $type, - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $valueAsString, - '{{ type }}' => $type, - )); - $this->validator->validate($value, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', $valueAsString) + ->setParameter('{{ type }}', $type) + ->assertRaised(); } public function getInvalidValues() @@ -134,50 +135,51 @@ public function getInvalidValues() $file = $this->createFile(); return array( - array('foobar', 'numeric', 'foobar'), - array('foobar', 'boolean', 'foobar'), - array('0', 'integer', '0'), - array('1.5', 'float', '1.5'), + array('foobar', 'numeric', '"foobar"'), + array('foobar', 'boolean', '"foobar"'), + array('0', 'integer', '"0"'), + array('1.5', 'float', '"1.5"'), array(12345, 'string', '12345'), - array($object, 'boolean', 'stdClass'), - array($object, 'numeric', 'stdClass'), - array($object, 'integer', 'stdClass'), - array($object, 'float', 'stdClass'), - array($object, 'string', 'stdClass'), - array($object, 'resource', 'stdClass'), - array($file, 'boolean', (string) $file), - array($file, 'numeric', (string) $file), - array($file, 'integer', (string) $file), - array($file, 'float', (string) $file), - array($file, 'string', (string) $file), - array($file, 'object', (string) $file), - array('12a34', 'digit', '12a34'), - array('1a#23', 'alnum', '1a#23'), - array('abcd1', 'alpha', 'abcd1'), - array("\nabc", 'cntrl', "\nabc"), - array("abc\n", 'graph', "abc\n"), - array('abCDE', 'lower', 'abCDE'), - array('ABcde', 'upper', 'ABcde'), - array("\nabc", 'print', "\nabc"), - array('abc&$!', 'punct', 'abc&$!'), - array("\nabc", 'space', "\nabc"), - array('AR1012', 'xdigit', 'AR1012'), + array($object, 'boolean', 'object'), + array($object, 'numeric', 'object'), + array($object, 'integer', 'object'), + array($object, 'float', 'object'), + array($object, 'string', 'object'), + array($object, 'resource', 'object'), + array($file, 'boolean', 'resource'), + array($file, 'numeric', 'resource'), + array($file, 'integer', 'resource'), + array($file, 'float', 'resource'), + array($file, 'string', 'resource'), + array($file, 'object', 'resource'), + array('12a34', 'digit', '"12a34"'), + array('1a#23', 'alnum', '"1a#23"'), + array('abcd1', 'alpha', '"abcd1"'), + array("\nabc", 'cntrl', "\"\nabc\""), + array("abc\n", 'graph', "\"abc\n\""), + array('abCDE', 'lower', '"abCDE"'), + array('ABcde', 'upper', '"ABcde"'), + array("\nabc", 'print', "\"\nabc\""), + array('abc&$!', 'punct', '"abc&$!"'), + array("\nabc", 'space', "\"\nabc\""), + array('AR1012', 'xdigit', '"AR1012"'), ); } protected function createFile() { - if (!self::$file) { - self::$file = fopen(__FILE__, 'r'); + if (!static::$file) { + static::$file = fopen(__FILE__, 'r'); } - return self::$file; + return static::$file; } public static function tearDownAfterClass() { - if (self::$file) { - fclose(self::$file); + if (static::$file) { + fclose(static::$file); + static::$file = null; } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index b335ae30a82f3e73fbbd6b4e2d8e39ec6e169363..3358c7923a98d15d0f0beb146868d1ffa35aac66 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -13,39 +13,32 @@ use Symfony\Component\Validator\Constraints\Url; use Symfony\Component\Validator\Constraints\UrlValidator; +use Symfony\Component\Validator\Validation; -class UrlValidatorTest extends \PHPUnit_Framework_TestCase +class UrlValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function getApiVersion() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new UrlValidator(); - $this->validator->initialize($this->context); + return Validation::API_VERSION_2_5; } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new UrlValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Url()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Url()); + + $this->assertNoViolation(); } /** @@ -61,10 +54,9 @@ public function testExpectsStringCompatibleType() */ public function testValidUrls($url) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($url, new Url()); + + $this->assertNoViolation(); } public function getValidUrls() @@ -72,6 +64,7 @@ public function getValidUrls() return array( array('http://a.pl'), array('http://www.google.com'), + array('http://www.google.com.'), array('http://www.google.museum'), array('https://google.com/'), array('https://google.com:80/'), @@ -85,22 +78,38 @@ public function getValidUrls() array('http://symfony.com/#?'), array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'), array('http://very.long.domain.name.com/'), + array('http://localhost/'), array('http://127.0.0.1/'), array('http://127.0.0.1:80/'), array('http://[::1]/'), array('http://[::1]:80/'), array('http://[1:2:3::4:5:6:7]/'), array('http://sãopaulo.com/'), + array('http://xn--sopaulo-xwa.com/'), array('http://sãopaulo.com.br/'), + array('http://xn--sopaulo-xwa.com.br/'), array('http://пример.иÑпытание/'), + array('http://xn--e1afmkfd.xn--80akhbyknj4f/'), array('http://مثال.إختبار/'), + array('http://xn--mgbh0fb.xn--kgbechtv/'), array('http://例å.测试/'), + array('http://xn--fsqu00a.xn--0zwm56d/'), array('http://例å.測試/'), + array('http://xn--fsqu00a.xn--g6w251d/'), array('http://例ãˆ.テスト/'), + array('http://xn--r8jz45g.xn--zckzah/'), array('http://مثال.آزمایشی/'), + array('http://xn--mgbh0fb.xn--hgbk6aj7f53bba/'), array('http://실례.테스트/'), + array('http://xn--9n2bp8q.xn--9t4b11yi5a/'), array('http://العربية.idn.icann.org/'), + array('http://xn--ogb.idn.icann.org/'), + array('http://xn--e1afmkfd.xn--80akhbyknj4f.xn--e1afmkfd/'), + array('http://xn--espaa-rta.xn--ca-ol-fsay5a/'), + array('http://xn--d1abbgf6aiiy.xn--p1ai/'), array('http://☎.com/'), + array('http://username:password@symfony.com'), + array('http://user-name@symfony.com'), ); } @@ -110,16 +119,14 @@ public function getValidUrls() public function testInvalidUrls($url) { $constraint = new Url(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $url, - )); - $this->validator->validate($url, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$url.'"') + ->assertRaised(); } public function getInvalidUrls() @@ -139,6 +146,11 @@ public function getInvalidUrls() array('http://127.0.0.1:aa/'), array('ftp://[::1]/'), array('http://[::1'), + array('http://hello.☎/'), + array('http://:password@symfony.com'), + array('http://:password@@symfony.com'), + array('http://username:passwordsymfony.com'), + array('http://usern@me:password@symfony.com'), ); } @@ -147,14 +159,13 @@ public function getInvalidUrls() */ public function testCustomProtocolIsValid($url) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Url(array( - 'protocols' => array('ftp', 'file', 'git') + 'protocols' => array('ftp', 'file', 'git'), )); $this->validator->validate($url, $constraint); + + $this->assertNoViolation(); } public function getValidCustomUrls() diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b34ce8138b7072d6ba283842ef7e1bb447ed53f0 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php @@ -0,0 +1,194 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\Uuid; +use Symfony\Component\Validator\Constraints\UuidValidator; +use Symfony\Component\Validator\Validation; + +/** + * @author Colin O'Dell <colinodell@gmail.com> + */ +class UuidValidatorTest extends AbstractConstraintValidatorTest +{ + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + + protected function createValidator() + { + return new UuidValidator(); + } + + public function testNullIsValid() + { + $this->validator->validate(null, new Uuid()); + + $this->assertNoViolation(); + } + + public function testEmptyStringIsValid() + { + $this->validator->validate('', new Uuid()); + + $this->assertNoViolation(); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException + */ + public function testExpectsStringCompatibleType() + { + $this->validator->validate(new \stdClass(), new Uuid()); + } + + /** + * @dataProvider getValidStrictUuids + */ + public function testValidStrictUuids($uuid) + { + $this->validator->validate($uuid, new Uuid()); + + $this->assertNoViolation(); + } + + public function getValidStrictUuids() + { + return array( + array('216fff40-98d9-11e3-a5e2-0800200c9a66'), // Version 1 UUID in lowercase + array('216FFF40-98D9-11E3-A5E2-0800200C9A66'), // Version 1 UUID in UPPERCASE + array('456daefb-5aa6-41b5-8dbc-068b05a8b201'), // Version 4 UUID in lowercase + array('456DAEFb-5AA6-41B5-8DBC-068B05A8B201'), // Version 4 UUID in UPPERCASE + ); + } + + /** + * @dataProvider getInvalidStrictUuids + */ + public function testInvalidStrictUuids($uuid) + { + $constraint = new Uuid(array( + 'message' => 'testMessage', + )); + + $this->validator->validate($uuid, $constraint); + + $this->buildViolation('testMessage') + ->setParameter('{{ value }}', '"'.$uuid.'"') + ->assertRaised(); + } + + public function getInvalidStrictUuids() + { + return array( + array('216fff40-98d9-11e3-a5e2-0800200c9a6'), // Too few characters + array('216fff40-98d9-11e3-a5e2-0800200c9a666'), // Too many characters + array('V16fff40-98d9-11e3-a5e2-0800200c9a66'), // Invalid character 'V' + array('2-16fff-4098d-911e3a5e20-800-200c9-a66'), // Non-standard dash positions (randomly placed) + + // Non-standard UUIDs allowed by some other systems + array('216f-ff40-98d9-11e3-a5e2-0800-200c-9a66'), // Non-standard dash positions (every 4 chars) + array('216fff40-98d911e3-a5e20800-200c9a66'), // Non-standard dash positions (every 8 chars) + array('216fff4098d911e3a5e20800200c9a66'), // No dashes at all + array('{216fff40-98d9-11e3-a5e2-0800200c9a66}'), // Wrapped with curly braces + ); + } + + /** + * @dataProvider getValidStrictUuids + */ + public function testVersionConstraintIsValid($uuid) + { + $constraint = new Uuid(array( + 'versions' => array(Uuid::V1_MAC, Uuid::V4_RANDOM), + )); + + $this->validator->validate($uuid, $constraint); + + $this->assertNoViolation(); + } + + /** + * @dataProvider getValidStrictUuids + */ + public function testVersionConstraintIsInvalid($uuid) + { + $constraint = new Uuid(array( + 'versions' => array(Uuid::V2_DCE, Uuid::V3_MD5), + 'message' => 'myMessage', + )); + + $this->validator->validate($uuid, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$uuid.'"') + ->assertRaised(); + } + + /** + * @dataProvider getValidNonStrictUuids + */ + public function testValidNonStrictUuids($uuid) + { + $constraint = new Uuid(array( + 'strict' => false, + )); + + $this->validator->validate($uuid, $constraint); + + $this->assertNoViolation(); + } + + public function getValidNonStrictUuids() + { + return array( + array('216fff40-98d9-11e3-a5e2-0800200c9a66'), // Version 1 UUID in lowercase + array('216FFF40-98D9-11E3-A5E2-0800200C9A66'), // Version 1 UUID in UPPERCASE + array('456daefb-5aa6-41b5-8dbc-068b05a8b201'), // Version 4 UUID in lowercase + array('456DAEFb-5AA6-41B5-8DBC-068B05A8B201'), // Version 4 UUID in UPPERCASE + + // Non-standard UUIDs allowed by some other systems + array('216f-ff40-98d9-11e3-a5e2-0800-200c-9a66'), // Non-standard dash positions (every 4 chars) + array('216fff40-98d911e3-a5e20800-200c9a66'), // Non-standard dash positions (every 8 chars) + array('216fff4098d911e3a5e20800200c9a66'), // No dashes at all + array('{216fff40-98d9-11e3-a5e2-0800200c9a66}'), // Wrapped with curly braces + ); + } + + /** + * @dataProvider getInvalidNonStrictUuids + */ + public function testInvalidNonStrictUuids($uuid) + { + $constraint = new Uuid(array( + 'strict' => false, + 'message' => 'myMessage', + )); + + $this->validator->validate($uuid, $constraint); + + $this->buildViolation('myMessage') + ->setParameter('{{ value }}', '"'.$uuid.'"') + ->assertRaised(); + } + + public function getInvalidNonStrictUuids() + { + return array( + array('216fff40-98d9-11e3-a5e2-0800200c9a6'), // Too few characters + array('216fff40-98d9-11e3-a5e2-0800200c9a666'), // Too many characters + array('V16fff40-98d9-11e3-a5e2-0800200c9a66'), // Invalid character 'V' + array('2-16fff-4098d-911e3a5e20-800-200c9-a66'), // Non-standard dash positions (randomly placed) + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php index dcc9c027bf75b014252f86058ae0c9920a2ef1b3..c0828d4add067422cc7c1d541db77351b0a8f3b3 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ExecutionContextTest.php @@ -11,13 +11,14 @@ namespace Symfony\Component\Validator\Tests; +use Symfony\Component\Validator\Constraints\Collection; +use Symfony\Component\Validator\Constraints\All; +use Symfony\Component\Validator\ConstraintValidatorFactory; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\ExecutionContext; -use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; use Symfony\Component\Validator\ValidationVisitor; -use Symfony\Component\Validator\ConstraintValidatorFactory; class ExecutionContextTest extends \PHPUnit_Framework_TestCase { @@ -277,22 +278,50 @@ public function testGetPropertyPathWithEmptyCurrentPropertyPath() $this->assertEquals('bam.baz', $this->context->getPropertyPath('bam.baz')); } - public function testGetPropertyPathWithNestedCollectionsMixed() + public function testGetPropertyPathWithNestedCollectionsAndAllMixed() { $constraints = new Collection(array( - 'foo' => new Collection(array( - 'foo' => new ConstraintA(), - 'bar' => new ConstraintA(), - )), - 'name' => new ConstraintA() + 'shelves' => new All(array('constraints' => array( + new Collection(array( + 'name' => new ConstraintA(), + 'books' => new All(array('constraints' => array( + new ConstraintA(), + ))), + )), + ))), + 'name' => new ConstraintA(), )); + $data = array( + 'shelves' => array( + array( + 'name' => 'Research', + 'books' => array('foo', 'bar'), + ), + array( + 'name' => 'VALID', + 'books' => array('foozy', 'VALID', 'bazzy'), + ), + ), + 'name' => 'Library', + ); + $expectedViolationPaths = array( + '[shelves][0][name]', + '[shelves][0][books][0]', + '[shelves][0][books][1]', + '[shelves][1][books][0]', + '[shelves][1][books][2]', + '[name]', + ); $visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), $this->translator); $context = new ExecutionContext($visitor, $this->translator, self::TRANS_DOMAIN); - $context->validateValue(array('foo' => array('foo' => 'VALID')), $constraints); - $violations = $context->getViolations(); + $context->validateValue($data, $constraints); + + foreach ($context->getViolations() as $violation) { + $violationPaths[] = $violation->getPropertyPath(); + } - $this->assertEquals('[name]', $violations[1]->getPropertyPath()); + $this->assertEquals($expectedViolationPaths, $violationPaths); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php index 787c78c69148514ef6c2040211bb4137ef4272e9..b3b85c895b016e5b5b3e2580ae40f86fba2e4562 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php @@ -33,7 +33,5 @@ public function validate($value, Constraint $constraint) return; } - - return; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Countable.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Countable.php new file mode 100644 index 0000000000000000000000000000000000000000..282d78d45a67222a7910102ad02d69969d703187 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Countable.php @@ -0,0 +1,27 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +class Countable implements \Countable +{ + private $content; + + public function __construct(array $content) + { + $this->content = $content; + } + + public function count() + { + return count($this->content); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php new file mode 100644 index 0000000000000000000000000000000000000000..41eac961acf91ed0cb88c2c1bc9427491e8c9343 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php @@ -0,0 +1,70 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +/** + * This class is a hand written simplified version of PHP native `ArrayObject` + * class, to show that it behaves differently than the PHP native implementation. + */ +class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable +{ + private $array; + + public function __construct(array $array = null) + { + $this->array = $array ?: array(); + } + + public function offsetExists($offset) + { + return array_key_exists($offset, $this->array); + } + + public function offsetGet($offset) + { + return $this->array[$offset]; + } + + public function offsetSet($offset, $value) + { + if (null === $offset) { + $this->array[] = $value; + } else { + $this->array[$offset] = $value; + } + } + + public function offsetUnset($offset) + { + unset($this->array[$offset]); + } + + public function getIterator() + { + return new \ArrayIterator($this->array); + } + + public function count() + { + return count($this->array); + } + + public function serialize() + { + return serialize($this->array); + } + + public function unserialize($serialized) + { + $this->array = (array) unserialize((string) $serialized); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php index 70bdc5aec699868b2dd3c3a23f6386f1a7fc6cd8..2230d304244752c4e30fdfec46396d0978c01f85 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Entity.php @@ -32,11 +32,13 @@ class Entity extends EntityParent implements EntityInterface * }) * @Assert\Choice(choices={"A", "B"}, message="Must be one of %choices%") */ - protected $firstName; + public $firstName; protected $lastName; public $reference; + public $reference2; private $internal; public $data = 'Overridden data'; + public $initialized = false; public function __construct($internal = null) { @@ -48,6 +50,11 @@ public function getInternal() return $this->internal.' from getter'; } + public function setLastName($lastName) + { + $this->lastName = $lastName; + } + /** * @Assert\NotNull */ @@ -56,6 +63,22 @@ public function getLastName() return $this->lastName; } + /** + * @Assert\True + */ + public function isValid() + { + return 'valid'; + } + + /** + * @Assert\True + */ + public function hasPermissions() + { + return 'permissions'; + } + public function getData() { return 'Overridden data'; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php index 854e80f35d2c0d8cd61a32a77a8888576866332b..a019dd6f836c20fbf06c2a3ad12b620c91a3ef06 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php @@ -19,7 +19,5 @@ class FailingConstraintValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { $this->context->addViolation($constraint->message, array()); - - return; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeClassMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeClassMetadata.php new file mode 100644 index 0000000000000000000000000000000000000000..5ae0e68a777e879c9acce9981b4d67cf12b386ae --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeClassMetadata.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +use Symfony\Component\Validator\Mapping\ClassMetadata; + +class FakeClassMetadata extends ClassMetadata +{ + public function addPropertyMetadata($propertyName, $metadata) + { + if (!isset($this->members[$propertyName])) { + $this->members[$propertyName] = array(); + } + + $this->members[$propertyName][] = $metadata; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php index ba39823be6e169cd2cfb7dbead0dab901ff15971..e3f0d9a0078001a623abc98dc04e0863cbd7e36a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Validator\Tests\Fixtures; -use Symfony\Component\Validator\MetadataFactoryInterface; use Symfony\Component\Validator\Exception\NoSuchMetadataException; -use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\MetadataInterface; class FakeMetadataFactory implements MetadataFactoryInterface { @@ -21,7 +21,10 @@ class FakeMetadataFactory implements MetadataFactoryInterface public function getMetadataFor($class) { + $hash = null; + if (is_object($class)) { + $hash = spl_object_hash($class); $class = get_class($class); } @@ -30,6 +33,10 @@ public function getMetadataFor($class) } if (!isset($this->metadatas[$class])) { + if (isset($this->metadatas[$hash])) { + return $this->metadatas[$hash]; + } + throw new NoSuchMetadataException(sprintf('No metadata for "%s"', $class)); } @@ -38,7 +45,10 @@ public function getMetadataFor($class) public function hasMetadataFor($class) { + $hash = null; + if (is_object($class)) { + $hash = spl_object_hash($class); $class = get_class($class); } @@ -46,11 +56,17 @@ public function hasMetadataFor($class) return false; } - return isset($this->metadatas[$class]); + return isset($this->metadatas[$class]) || isset($this->metadatas[$hash]); } - public function addMetadata(ClassMetadata $metadata) + public function addMetadata($metadata) { $this->metadatas[$metadata->getClassName()] = $metadata; } + + public function addMetadataForValue($value, MetadataInterface $metadata) + { + $key = is_object($value) ? spl_object_hash($value) : $value; + $this->metadatas[$key] = $metadata; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/GroupSequenceProviderEntity.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/GroupSequenceProviderEntity.php index ef3711104ad437745d9006fefdf15d98bae8b1ad..2b0beaf9adf986ee2bea1073506b44693e9b6a11 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/GroupSequenceProviderEntity.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/GroupSequenceProviderEntity.php @@ -22,15 +22,15 @@ class GroupSequenceProviderEntity implements GroupSequenceProviderInterface public $firstName; public $lastName; - protected $groups = array(); + protected $sequence = array(); - public function setGroups($groups) + public function __construct($sequence) { - $this->groups = $groups; + $this->sequence = $sequence; } public function getGroupSequence() { - return $this->groups; + return $this->sequence; } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraint.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraint.php index d8df639a807465d7108c0fee8bf65c8bdac82ae5..6a9eaa797a874ce768287daf249944142bb98d91 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraint.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraint.php @@ -13,4 +13,6 @@ use Symfony\Component\Validator\Constraint; -class InvalidConstraint extends Constraint {} +class InvalidConstraint extends Constraint +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraintValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraintValidator.php index f6ebb3ba4a59656881cf9e304e4d8441c62aa534..bd9a5cf6c32dce5147afb3bcee1a8a380be6bdbe 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraintValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/InvalidConstraintValidator.php @@ -11,4 +11,6 @@ namespace Symfony\Component\Validator\Tests\Fixtures; -class InvalidConstraintValidator {} +class InvalidConstraintValidator +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/LegacyClassMetadata.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/LegacyClassMetadata.php new file mode 100644 index 0000000000000000000000000000000000000000..6a832a109f99e118a948511acaaac71c899b64f9 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/LegacyClassMetadata.php @@ -0,0 +1,20 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +use Symfony\Component\Validator\ClassBasedInterface; +use Symfony\Component\Validator\MetadataInterface; +use Symfony\Component\Validator\PropertyMetadataContainerInterface; + +interface LegacyClassMetadata extends MetadataInterface, PropertyMetadataContainerInterface, ClassBasedInterface +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Reference.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Reference.php index f8ea173e019aa8b830760a60a30dc1e9601780cc..af2973592437919d5be38b1f7e3931a57bf7f919 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Reference.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/Reference.php @@ -13,4 +13,17 @@ class Reference { + public $value; + + private $privateValue; + + public function setPrivateValue($privateValue) + { + $this->privateValue = $privateValue; + } + + public function getPrivateValue() + { + return $this->privateValue; + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php new file mode 100644 index 0000000000000000000000000000000000000000..53bd10d43bdd2cffd41fc21ad0017a97a5851c03 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php @@ -0,0 +1,71 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\GlobalExecutionContextInterface; +use Symfony\Component\Validator\ValidationVisitorInterface; + +/** + * @since 2.5.3 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated + */ +class StubGlobalExecutionContext implements GlobalExecutionContextInterface +{ + private $violations; + + private $root; + + private $visitor; + + public function __construct($root = null, ValidationVisitorInterface $visitor = null) + { + $this->violations = new ConstraintViolationList(); + $this->root = $root; + $this->visitor = $visitor; + } + + public function getViolations() + { + return $this->violations; + } + + public function setRoot($root) + { + $this->root = $root; + } + + public function getRoot() + { + return $this->root; + } + + public function setVisitor(ValidationVisitorInterface $visitor) + { + $this->visitor = $visitor; + } + + public function getVisitor() + { + return $this->visitor; + } + + public function getValidatorFactory() + { + } + + public function getMetadataFactory() + { + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Cache/DoctrineCacheTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Cache/DoctrineCacheTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a2de306a2f46dddeed4837936b665a34099b5e4f --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Cache/DoctrineCacheTest.php @@ -0,0 +1,84 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Mapping\Cache; + +use Doctrine\Common\Cache\ArrayCache; +use Symfony\Component\Validator\Mapping\Cache\DoctrineCache; + +class DoctrineCacheTest extends \PHPUnit_Framework_TestCase +{ + private $cache; + + public function testWrite() + { + $meta = $this->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata') + ->disableOriginalConstructor() + ->setMethods(array('getClassName')) + ->getMock(); + + $meta->expects($this->once()) + ->method('getClassName') + ->will($this->returnValue('bar')); + + $this->cache->write($meta); + + $this->assertInstanceOf( + 'Symfony\\Component\\Validator\\Mapping\\ClassMetadata', + $this->cache->read('bar'), + 'write() stores metadata' + ); + } + + public function testHas() + { + $meta = $this->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata') + ->disableOriginalConstructor() + ->setMethods(array('getClassName')) + ->getMock(); + + $meta->expects($this->once()) + ->method('getClassName') + ->will($this->returnValue('bar')); + + $this->assertFalse($this->cache->has('bar'), 'has() returns false when there is no entry'); + + $this->cache->write($meta); + $this->assertTrue($this->cache->has('bar'), 'has() returns true when the is an entry'); + } + + public function testRead() + { + $meta = $this->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata') + ->disableOriginalConstructor() + ->setMethods(array('getClassName')) + ->getMock(); + + $meta->expects($this->once()) + ->method('getClassName') + ->will($this->returnValue('bar')); + + $this->assertFalse($this->cache->read('bar'), 'read() returns false when there is no entry'); + + $this->cache->write($meta); + + $this->assertInstanceOf( + 'Symfony\\Component\\Validator\\Mapping\\ClassMetadata', + $this->cache->read('bar'), + 'read() returns metadata' + ); + } + + protected function setUp() + { + $this->cache = new DoctrineCache(new ArrayCache()); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php index bee4025d0d279828815ceedf3882c736b342c1bb..aee137a1f8c029592de836e9632dab1d7a80ca39 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php @@ -11,11 +11,10 @@ namespace Symfony\Component\Validator\Tests\Mapping; -use Symfony\Component\Validator\Tests\Fixtures\Entity; -use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; -use Symfony\Component\Validator\Mapping\ClassMetadataFactory; use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Mapping\ClassMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; +use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 9ead7d134eb60357e136682214a722e4ef4cf3ee..b9f6faee5abe97602fc3ad90bf6b231cd0909c31 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -14,8 +14,6 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Exception\GroupDefinitionException; -use Symfony\Component\Validator\Tests\Fixtures\Entity; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; use Symfony\Component\Validator\Tests\Fixtures\PropertyConstraint; @@ -222,4 +220,20 @@ public function testGroupSequenceProvider() $metadata->setGroupSequenceProvider(true); $this->assertTrue($metadata->isGroupSequenceProvider()); } + + /** + * https://github.com/symfony/symfony/issues/11604 + */ + public function testGetMemberMetadatasReturnsEmptyArrayWithoutConfiguredMetadata() + { + $this->assertCount(0, $this->metadata->getMemberMetadatas('foo'), '->getMemberMetadatas() returns an empty collection if no metadata is configured for the given property'); + } + + /** + * https://github.com/symfony/symfony/issues/11604 + */ + public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadata() + { + $this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property'); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php index eb01d118a74a8f7974a561e8ec3602ae11e8de95..c2eb4cee79f6ef8f1793f4620c69958771034402 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Validator\Tests\Mapping; +use Symfony\Component\Validator\Mapping\ElementMetadata; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; -use Symfony\Component\Validator\Mapping\ElementMetadata; class ElementMetadataTest extends \PHPUnit_Framework_TestCase { @@ -21,7 +21,7 @@ class ElementMetadataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->metadata = new TestElementMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity'); + $this->metadata = new TestElementMetadata(); } protected function tearDown() @@ -70,4 +70,6 @@ public function testSerialize() } } -class TestElementMetadata extends ElementMetadata {} +class TestElementMetadata extends ElementMetadata +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php index 1ce83e9159768b89a8738cfe107cdf16163d95a7..078159971af838431678223d0eaf2a967e4f7699 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php @@ -43,4 +43,20 @@ public function testGetPropertyValueFromOverriddenPublicGetter() $this->assertEquals('Overridden data', $metadata->getPropertyValue($entity)); } + + public function testGetPropertyValueFromIsser() + { + $entity = new Entity(); + $metadata = new GetterMetadata(self::CLASSNAME, 'valid'); + + $this->assertEquals('valid', $metadata->getPropertyValue($entity)); + } + + public function testGetPropertyValueFromHasser() + { + $entity = new Entity(); + $metadata = new GetterMetadata(self::CLASSNAME, 'permissions'); + + $this->assertEquals('permissions', $metadata->getPropertyValue($entity)); + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractMethodStaticLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractStaticMethodLoader.php similarity index 82% rename from core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractMethodStaticLoader.php rename to core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractStaticMethodLoader.php index 7c6f362abb537418f4b3fc0da86a7392b5b3cfe2..08f219d0a412b2a34613b0302ae9dd2b7847567f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractMethodStaticLoader.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractStaticMethodLoader.php @@ -4,7 +4,7 @@ use Symfony\Component\Validator\Mapping\ClassMetadata; -abstract class AbstractMethodStaticLoader +abstract class AbstractStaticMethodLoader { abstract public static function loadMetadata(ClassMetadata $metadata); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php index 0d255b8fcad0d63ccc40f946612507883239903d..ad98aa126a5e0347ea56918fd2e5ee4f8ff5c153 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -14,14 +14,25 @@ use Doctrine\Common\Annotations\AnnotationReader; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\Choice; +use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; +require_once __DIR__.'/../../../Constraints/All.php'; +require_once __DIR__.'/../../../Constraints/Callback.php'; +require_once __DIR__.'/../../../Constraints/Choice.php'; +require_once __DIR__.'/../../../Constraints/Collection.php'; +require_once __DIR__.'/../../../Constraints/GroupSequence.php'; +require_once __DIR__.'/../../../Constraints/GroupSequenceProvider.php'; +require_once __DIR__.'/../../../Constraints/NotNull.php'; +require_once __DIR__.'/../../../Constraints/Range.php'; +require_once __DIR__.'/../../Fixtures/ConstraintA.php'; + class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase { public function testLoadClassMetadataReturnsTrueIfSuccessful() @@ -67,6 +78,8 @@ public function testLoadClassMetadata() 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); + $expected->addGetterConstraint('valid', new True()); + $expected->addGetterConstraint('permissions', new True()); // load reflection class so that the comparison passes $expected->getReflectionClass(); @@ -134,6 +147,8 @@ public function testLoadClassMetadataAndMerge() 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); + $expected->addGetterConstraint('valid', new True()); + $expected->addGetterConstraint('permissions', new True()); // load reflection class so that the comparison passes $expected->getReflectionClass(); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php index 7723349e94d8e5825b9050a84ab15ce719391a48..09e6e449e03099dcb3e5d9fd08fc6808379289fc 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Validator\Tests\Mapping\Loader; -use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; class FilesLoaderTest extends \PHPUnit_Framework_TestCase { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php index f90310cd2687542e788687dfffbc84a7b0fcf34f..0c9690f4e350887d00cd12e5ff6e021c6c2ca434 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php @@ -17,6 +17,18 @@ class StaticMethodLoaderTest extends \PHPUnit_Framework_TestCase { + private $errorLevel; + + protected function setUp() + { + $this->errorLevel = error_reporting(); + } + + protected function tearDown() + { + error_reporting($this->errorLevel); + } + public function testLoadClassMetadataReturnsTrueIfSuccessful() { $loader = new StaticMethodLoader('loadMetadata'); @@ -78,14 +90,19 @@ public function testLoadClassMetadataInAbstractClasses() public function testLoadClassMetadataIgnoresAbstractMethods() { - $loader = new StaticMethodLoader('loadMetadata'); - try { - include __DIR__ . '/AbstractMethodStaticLoader.php'; - $this->fail('AbstractMethodStaticLoader should produce a strict standard error.'); - } catch (\Exception $e) { + // Disable error reporting, as AbstractStaticMethodLoader produces a + // strict standards error + error_reporting(0); + + if (0 !== error_reporting()) { + $this->markTestSkipped('Could not disable error reporting'); } - $metadata = new ClassMetadata(__NAMESPACE__.'\AbstractMethodStaticLoader'); + include __DIR__.'/AbstractStaticMethodLoader.php'; + + $metadata = new ClassMetadata(__NAMESPACE__.'\AbstractStaticMethodLoader'); + + $loader = new StaticMethodLoader('loadMetadata'); $loader->loadClassMetadata($metadata); $this->assertCount(0, $metadata->getConstraints()); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php index 82195405e6614206dffd53f7f050e5f7ba661552..e2b27f0bb6107ed4ff432f08da45beb26f6bfd67 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -13,11 +13,12 @@ use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Regex; +use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; @@ -69,6 +70,8 @@ public function testLoadClassMetadata() 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); + $expected->addGetterConstraint('valid', new True()); + $expected->addGetterConstraint('permissions', new True()); $this->assertEquals($expected, $metadata); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php index 0d9a0b62c31221d11ac4cd06634b58e0e7f1340a..aeccf0c2836ab948d297cd09332983db70b18bcd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -13,10 +13,11 @@ use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\Choice; +use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; @@ -86,6 +87,8 @@ public function testLoadClassMetadata() 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); + $expected->addGetterConstraint('valid', new True()); + $expected->addGetterConstraint('permissions', new True()); $this->assertEquals($expected, $metadata); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml index 1eee1cb18036a2f6c001e59232a6475c8ddd1770..9b637e9a427fabd6fd6ada0aa208a32ba63e7606 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml @@ -102,6 +102,12 @@ <getter property="lastName"> <constraint name="NotNull" /> </getter> + <getter property="valid"> + <constraint name="True" /> + </getter> + <getter property="permissions"> + <constraint name="True" /> + </getter> </class> <class name="Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity"> diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml index e52d3f04b2ced3bd759d5bb9d03b5fa3f33f369f..e96c5e08663a1fea2bfcb7ae6968c01f38ca68ab 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml @@ -53,6 +53,10 @@ Symfony\Component\Validator\Tests\Fixtures\Entity: getters: lastName: - NotNull: ~ + valid: + - "True": ~ + permissions: + - "True": ~ Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity: group_sequence_provider: true diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php index bfb402cdee2bea2a5db1b85363af26bfd9fba652..f91088de0b016116a060f8f9fe4621d2f6ae2a21 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Validator\Tests\Mapping; -use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; -use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; -use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\MemberMetadata; +use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint; +use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; +use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; class MemberMetadataTest extends \PHPUnit_Framework_TestCase { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php new file mode 100644 index 0000000000000000000000000000000000000000..94802b66ec61c9408a12744004ec990bff274c10 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Util/PropertyPathTest.php @@ -0,0 +1,35 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Util; + +use Symfony\Component\Validator\Util\PropertyPath; + +class PropertyPathTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideAppendPaths + */ + public function testAppend($basePath, $subPath, $expectedPath, $message) + { + $this->assertSame($expectedPath, PropertyPath::append($basePath, $subPath), $message); + } + + public function provideAppendPaths() + { + return array( + array('foo', '', 'foo', 'It returns the basePath if subPath is empty'), + array('', 'bar', 'bar', 'It returns the subPath if basePath is empty'), + array('foo', 'bar', 'foo.bar', 'It append the subPath to the basePath'), + array('foo', '[bar]', 'foo[bar]', 'It does not include the dot separator if subPath uses the array notation'), + ); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidationVisitorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidationVisitorTest.php deleted file mode 100644 index 2868f57a82cd6e39c104442a6ff61fb7e02353f1..0000000000000000000000000000000000000000 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidationVisitorTest.php +++ /dev/null @@ -1,564 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests; - -use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; -use Symfony\Component\Validator\Constraints\Valid; -use Symfony\Component\Validator\Tests\Fixtures\Reference; -use Symfony\Component\Validator\DefaultTranslator; -use Symfony\Component\Validator\ConstraintViolation; -use Symfony\Component\Validator\ConstraintViolationList; -use Symfony\Component\Validator\Tests\Fixtures\FailingConstraint; -use Symfony\Component\Validator\Tests\Fixtures\ConstraintAValidator; -use Symfony\Component\Validator\Tests\Fixtures\Entity; -use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\ConstraintValidatorFactory; -use Symfony\Component\Validator\ValidationVisitor; - -/** - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class ValidationVisitorTest extends \PHPUnit_Framework_TestCase -{ - const CLASS_NAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity'; - - /** - * @var ValidationVisitor - */ - private $visitor; - - /** - * @var FakeMetadataFactory - */ - private $metadataFactory; - - /** - * @var ClassMetadata - */ - private $metadata; - - protected function setUp() - { - $this->metadataFactory = new FakeMetadataFactory(); - $this->visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator()); - $this->metadata = new ClassMetadata(self::CLASS_NAME); - $this->metadataFactory->addMetadata($this->metadata); - } - - protected function tearDown() - { - $this->metadataFactory = null; - $this->visitor = null; - $this->metadata = null; - } - - public function testValidatePassesCorrectClassAndProperty() - { - $this->metadata->addConstraint(new ConstraintA()); - - $entity = new Entity(); - $this->visitor->validate($entity, 'Default', ''); - - $context = ConstraintAValidator::$passedContext; - - $this->assertEquals('Symfony\Component\Validator\Tests\Fixtures\Entity', $context->getClassName()); - $this->assertNull($context->getPropertyName()); - } - - public function testValidateConstraints() - { - $this->metadata->addConstraint(new ConstraintA()); - - $this->visitor->validate(new Entity(), 'Default', ''); - - $this->assertCount(1, $this->visitor->getViolations()); - } - - public function testValidateTwiceValidatesConstraintsOnce() - { - $this->metadata->addConstraint(new ConstraintA()); - - $entity = new Entity(); - - $this->visitor->validate($entity, 'Default', ''); - $this->visitor->validate($entity, 'Default', ''); - - $this->assertCount(1, $this->visitor->getViolations()); - } - - public function testValidateDifferentObjectsValidatesTwice() - { - $this->metadata->addConstraint(new ConstraintA()); - - $this->visitor->validate(new Entity(), 'Default', ''); - $this->visitor->validate(new Entity(), 'Default', ''); - - $this->assertCount(2, $this->visitor->getViolations()); - } - - public function testValidateTwiceInDifferentGroupsValidatesTwice() - { - $this->metadata->addConstraint(new ConstraintA()); - $this->metadata->addConstraint(new ConstraintA(array('groups' => 'Custom'))); - - $entity = new Entity(); - - $this->visitor->validate($entity, 'Default', ''); - $this->visitor->validate($entity, 'Custom', ''); - - $this->assertCount(2, $this->visitor->getViolations()); - } - - public function testValidatePropertyConstraints() - { - $this->metadata->addPropertyConstraint('firstName', new ConstraintA()); - - $this->visitor->validate(new Entity(), 'Default', ''); - - $this->assertCount(1, $this->visitor->getViolations()); - } - - public function testValidateGetterConstraints() - { - $this->metadata->addGetterConstraint('lastName', new ConstraintA()); - - $this->visitor->validate(new Entity(), 'Default', ''); - - $this->assertCount(1, $this->visitor->getViolations()); - } - - public function testValidateInDefaultGroupTraversesGroupSequence() - { - $entity = new Entity(); - - $this->metadata->addPropertyConstraint('firstName', new FailingConstraint(array( - 'groups' => 'First', - ))); - $this->metadata->addGetterConstraint('lastName', new FailingConstraint(array( - 'groups' => 'Default', - ))); - $this->metadata->setGroupSequence(array('First', $this->metadata->getDefaultGroup())); - - $this->visitor->validate($entity, 'Default', ''); - - // After validation of group "First" failed, no more group was - // validated - $violations = new ConstraintViolationList(array( - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'firstName', - '' - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateInGroupSequencePropagatesDefaultGroup() - { - $entity = new Entity(); - $entity->reference = new Reference(); - - $this->metadata->addPropertyConstraint('reference', new Valid()); - $this->metadata->setGroupSequence(array($this->metadata->getDefaultGroup())); - - $referenceMetadata = new ClassMetadata(get_class($entity->reference)); - $referenceMetadata->addConstraint(new FailingConstraint(array( - // this constraint is only evaluated if group "Default" is - // propagated to the reference - 'groups' => 'Default', - ))); - $this->metadataFactory->addMetadata($referenceMetadata); - - $this->visitor->validate($entity, 'Default', ''); - - // The validation of the reference's FailingConstraint in group - // "Default" was launched - $violations = new ConstraintViolationList(array( - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference', - $entity->reference - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateInOtherGroupTraversesNoGroupSequence() - { - $entity = new Entity(); - - $this->metadata->addPropertyConstraint('firstName', new FailingConstraint(array( - 'groups' => 'First', - ))); - $this->metadata->addGetterConstraint('lastName', new FailingConstraint(array( - 'groups' => $this->metadata->getDefaultGroup(), - ))); - $this->metadata->setGroupSequence(array('First', $this->metadata->getDefaultGroup())); - - $this->visitor->validate($entity, $this->metadata->getDefaultGroup(), ''); - - // Only group "Second" was validated - $violations = new ConstraintViolationList(array( - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'lastName', - '' - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyValidatesReferences() - { - $entity = new Entity(); - $entity->reference = new Entity(); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate entity when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - // invoke validation on an object - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // generated by the reference - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference', - $entity->reference - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyValidatesArraysByDefault() - { - $entity = new Entity(); - $entity->reference = array('key' => new Entity()); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // generated by the reference - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference[key]', - $entity->reference['key'] - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyValidatesTraversableByDefault() - { - $entity = new Entity(); - $entity->reference = new \ArrayIterator(array('key' => new Entity())); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // generated by the reference - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference[key]', - $entity->reference['key'] - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyDoesNotValidateTraversableIfDisabled() - { - $entity = new Entity(); - $entity->reference = new \ArrayIterator(array('key' => new Entity())); - - $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid(array( - 'traverse' => false, - ))); - - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // nothing generated by the reference! - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testMetadataMayNotExistIfTraversalIsEnabled() - { - $entity = new Entity(); - $entity->reference = new \ArrayIterator(); - - $this->metadata->addPropertyConstraint('reference', new Valid(array( - 'traverse' => true, - ))); - - $this->visitor->validate($entity, 'Default', ''); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException - */ - public function testMetadataMustExistIfTraversalIsDisabled() - { - $entity = new Entity(); - $entity->reference = new \ArrayIterator(); - - $this->metadata->addPropertyConstraint('reference', new Valid(array( - 'traverse' => false, - ))); - - $this->visitor->validate($entity, 'Default', ''); - } - - public function testValidateCascadedPropertyDoesNotRecurseByDefault() - { - $entity = new Entity(); - $entity->reference = new \ArrayIterator(array( - // The inner iterator should not be traversed by default - 'key' => new \ArrayIterator(array( - 'nested' => new Entity(), - )), - )); - - $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate iterator when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // nothing generated by the reference! - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - // https://github.com/symfony/symfony/issues/6246 - public function testValidateCascadedPropertyRecursesArraysByDefault() - { - $entity = new Entity(); - $entity->reference = array( - 'key' => array( - 'nested' => new Entity(), - ), - ); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate iterator when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // nothing generated by the reference! - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference[key][nested]', - $entity->reference['key']['nested'] - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyRecursesIfDeepIsSet() - { - $entity = new Entity(); - $entity->reference = new \ArrayIterator(array( - // The inner iterator should now be traversed - 'key' => new \ArrayIterator(array( - 'nested' => new Entity(), - )), - )); - - // add a constraint for the entity that always fails - $this->metadata->addConstraint(new FailingConstraint()); - - // validate iterator when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid(array( - 'deep' => true, - ))); - - $this->visitor->validate($entity, 'Default', ''); - - $violations = new ConstraintViolationList(array( - // generated by the root object - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - '', - $entity - ), - // nothing generated by the reference! - new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Root', - 'reference[key][nested]', - $entity->reference['key']['nested'] - ), - )); - - $this->assertEquals($violations, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyDoesNotValidateNestedScalarValues() - { - $entity = new Entity(); - $entity->reference = array('scalar', 'values'); - - // validate array when validating the property "reference" - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - - $this->assertCount(0, $this->visitor->getViolations()); - } - - public function testValidateCascadedPropertyDoesNotValidateNullValues() - { - $entity = new Entity(); - $entity->reference = null; - - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - - $this->assertCount(0, $this->visitor->getViolations()); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException - */ - public function testValidateCascadedPropertyRequiresObjectOrArray() - { - $entity = new Entity(); - $entity->reference = 'no object'; - - $this->metadata->addPropertyConstraint('reference', new Valid()); - - $this->visitor->validate($entity, 'Default', ''); - } -} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..62fa87ccf7f5cd9940767c255b17d18438a6d5ba --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php @@ -0,0 +1,763 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Validator; + +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Traverse; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\ConstraintViolationInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Tests\Fixtures\Entity; +use Symfony\Component\Validator\Tests\Fixtures\FakeClassMetadata; +use Symfony\Component\Validator\Tests\Fixtures\Reference; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +/** + * Verifies that a validator satisfies the API of Symfony 2.5+. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest +{ + /** + * @var ValidatorInterface + */ + protected $validator; + + /** + * @param MetadataFactoryInterface $metadataFactory + * + * @return ValidatorInterface + */ + abstract protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()); + + protected function setUp() + { + parent::setUp(); + + $this->validator = $this->createValidator($this->metadataFactory); + } + + protected function validate($value, $constraints = null, $groups = null) + { + return $this->validator->validate($value, $constraints, $groups); + } + + protected function validateProperty($object, $propertyName, $groups = null) + { + return $this->validator->validateProperty($object, $propertyName, $groups); + } + + protected function validatePropertyValue($object, $propertyName, $value, $groups = null) + { + return $this->validator->validatePropertyValue($object, $propertyName, $value, $groups); + } + + public function testValidateConstraintWithoutGroup() + { + $violations = $this->validator->validate(null, new NotNull()); + + $this->assertCount(1, $violations); + } + + public function testGroupSequenceAbortsAfterFailedGroup() + { + $entity = new Entity(); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message 1'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message 2'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => function () {}, + 'groups' => 'Group 1', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group 2', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 3', + ))); + + $sequence = new GroupSequence(array('Group 1', 'Group 2', 'Group 3')); + $violations = $this->validator->validate($entity, new Valid(), $sequence); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Message 1', $violations[0]->getMessage()); + } + + public function testGroupSequenceIncludesReferences() + { + $entity = new Entity(); + $entity->reference = new Reference(); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Reference violation 1'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Reference violation 2'); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group 1', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 2', + ))); + + $sequence = new GroupSequence(array('Group 1', 'Entity')); + $violations = $this->validator->validate($entity, new Valid(), $sequence); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Reference violation 1', $violations[0]->getMessage()); + } + + public function testValidateInSeparateContext() + { + $test = $this; + $entity = new Entity(); + $entity->reference = new Reference(); + + $callback1 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { + $violations = $context + ->getValidator() + // Since the validator is not context aware, the group must + // be passed explicitly + ->validate($value->reference, new Valid(), 'Group') + ; + + /** @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()); + // 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()); + + // 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validator->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $test->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) { + $previousValue = $context->getValue(); + $previousObject = $context->getObject(); + $previousMetadata = $context->getMetadata(); + $previousPath = $context->getPropertyPath(); + $previousGroup = $context->getGroup(); + + $context + ->getValidator() + ->inContext($context) + ->atPath('subpath') + ->validate($value->reference) + ; + + // 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()); + }; + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validator->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('subpath', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testValidateArrayInContext() + { + $test = $this; + $entity = new Entity(); + $entity->reference = new Reference(); + + $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $previousValue = $context->getValue(); + $previousObject = $context->getObject(); + $previousMetadata = $context->getMetadata(); + $previousPath = $context->getPropertyPath(); + $previousGroup = $context->getGroup(); + + $context + ->getValidator() + ->inContext($context) + ->atPath('subpath') + ->validate(array('key' => $value->reference)) + ; + + // 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()); + }; + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validator->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('subpath[key]', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($traversable, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('[key]', $violations[0]->getPropertyPath()); + $this->assertSame($traversable, $violations[0]->getRoot()); + $this->assertSame($entity, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testTraversalEnabledOnClass() + { + $entity = new Entity(); + $traversable = new \ArrayIterator(array('key' => $entity)); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(true)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($traversable, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + 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'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(false)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($traversable, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + */ + public function testExpectTraversableIfTraversalEnabledOnClass() + { + $entity = new Entity(); + + $this->metadata->addConstraint(new Traverse(true)); + + $this->validator->validate($entity); + } + + 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'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(false)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('reference', new Valid()); + + $violations = $this->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + 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'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(false)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'traverse' => true, + ))); + + $violations = $this->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + 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'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(true)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'traverse' => false, + ))); + + $violations = $this->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + public function testReferenceTraversalRecursionEnabledOnReferenceTraversalEnabledOnClass() + { + $entity = new Entity(); + $entity->reference = new \ArrayIterator(array( + 2 => new \ArrayIterator(array('key' => new Reference())), + )); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(true)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'deep' => true, + ))); + + $violations = $this->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + 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'); + }; + + $traversableMetadata = new ClassMetadata('ArrayIterator'); + $traversableMetadata->addConstraint(new Traverse(true)); + + $this->metadataFactory->addMetadata($traversableMetadata); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'deep' => false, + ))); + + $violations = $this->validate($entity, new Valid(), 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + public function testAddCustomizedViolation() + { + $entity = new Entity(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->buildViolation('Message %param%') + ->setParameter('%param%', 'value') + ->setInvalidValue('Invalid value') + ->setPlural(2) + ->setCode('Code') + ->addViolation(); + }; + + $this->metadata->addConstraint(new Callback($callback)); + + $violations = $this->validator->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $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()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Invalid value', $violations[0]->getInvalidValue()); + $this->assertSame(2, $violations[0]->getMessagePluralization()); + $this->assertSame('Code', $violations[0]->getCode()); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException + */ + public function testMetadataMustImplementClassMetadataInterface() + { + $entity = new Entity(); + + $metadata = $this->getMock('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata'); + $metadata->expects($this->any()) + ->method('getClassName') + ->will($this->returnValue(get_class($entity))); + + $this->metadataFactory->addMetadata($metadata); + + $this->validator->validate($entity); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException + */ + public function testReferenceMetadataMustImplementClassMetadataInterface() + { + $entity = new Entity(); + $entity->reference = new Reference(); + + $metadata = $this->getMock('Symfony\Component\Validator\Tests\Fixtures\LegacyClassMetadata'); + $metadata->expects($this->any()) + ->method('getClassName') + ->will($this->returnValue(get_class($entity->reference))); + + $this->metadataFactory->addMetadata($metadata); + + $this->metadata->addPropertyConstraint('reference', new Valid()); + + $this->validator->validate($entity); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException + */ + public function testPropertyMetadataMustImplementPropertyMetadataInterface() + { + $entity = new Entity(); + + // Legacy interface + $propertyMetadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); + $metadata = new FakeClassMetadata(get_class($entity)); + $metadata->addPropertyMetadata('firstName', $propertyMetadata); + + $this->metadataFactory->addMetadata($metadata); + + $this->validator->validate($entity); + } + + public function testNoDuplicateValidationIfClassConstraintInMultipleGroups() + { + $entity = new Entity(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => array('Group 1', 'Group 2'), + ))); + + $violations = $this->validator->validate($entity, new Valid(), array('Group 1', 'Group 2')); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + public function testNoDuplicateValidationIfPropertyConstraintInMultipleGroups() + { + $entity = new Entity(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $this->metadata->addPropertyConstraint('firstName', new Callback(array( + 'callback' => $callback, + 'groups' => array('Group 1', 'Group 2'), + ))); + + $violations = $this->validator->validate($entity, new Valid(), array('Group 1', 'Group 2')); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\RuntimeException + */ + public function testValidateFailsIfNoConstraintsAndNoObjectOrArray() + { + $this->validate('Foobar'); + } + + public function testAccessCurrentObject() + { + $test = $this; + $called = false; + $entity = new Entity(); + $entity->firstName = 'Bernhard'; + + $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, &$called) { + $called = true; + $test->assertSame($entity, $context->getObject()); + }; + + $this->metadata->addConstraint(new Callback($callback)); + $this->metadata->addPropertyConstraint('firstName', new Callback($callback)); + + $this->validator->validate($entity); + + $this->assertTrue($called); + } + + public function testInitializeObjectsOnFirstValidation() + { + $test = $this; + $entity = new Entity(); + $entity->initialized = false; + + // prepare initializers that set "initialized" to true + $initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + $initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + + $initializer1->expects($this->once()) + ->method('initialize') + ->with($entity) + ->will($this->returnCallback(function ($object) { + $object->initialized = true; + })); + + $initializer2->expects($this->once()) + ->method('initialize') + ->with($entity); + + $this->validator = $this->createValidator($this->metadataFactory, array( + $initializer1, + $initializer2, + )); + + // 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); + + // validate again in same group + $validator = $context->getValidator()->inContext($context); + + $validator->validate($object); + + // validate again in other group + $validator->validate($object, null, 'SomeGroup'); + }; + + $this->metadata->addConstraint(new Callback($callback)); + + $this->validate($entity); + + $this->assertTrue($entity->initialized); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..748e106d402ec9255a0d76b40b58db8a0ac69566 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php @@ -0,0 +1,313 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Validator; + +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\ConstraintViolationInterface; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Tests\Fixtures\Entity; +use Symfony\Component\Validator\Tests\Fixtures\Reference; +use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; + +/** + * Verifies that a validator satisfies the API of Symfony < 2.5. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +abstract class AbstractLegacyApiTest extends AbstractValidatorTest +{ + /** + * @var LegacyValidatorInterface + */ + protected $validator; + + /** + * @param MetadataFactoryInterface $metadataFactory + * + * @return LegacyValidatorInterface + */ + abstract protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()); + + protected function setUp() + { + parent::setUp(); + + $this->validator = $this->createValidator($this->metadataFactory); + } + + protected function validate($value, $constraints = null, $groups = null) + { + if (null === $constraints) { + $constraints = new Valid(); + } + + if ($constraints instanceof Valid) { + return $this->validator->validate($value, $groups, $constraints->traverse, $constraints->deep); + } + + return $this->validator->validateValue($value, $constraints, $groups); + } + + protected function validateProperty($object, $propertyName, $groups = null) + { + return $this->validator->validateProperty($object, $propertyName, $groups); + } + + protected function validatePropertyValue($object, $propertyName, $value, $groups = null) + { + return $this->validator->validatePropertyValue($object, $propertyName, $value, $groups); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException + */ + public function testTraversableTraverseDisabled() + { + $test = $this; + $entity = new Entity(); + $traversable = new \ArrayIterator(array('key' => $entity)); + + $callback = function () use ($test) { + $test->fail('Should not be called'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $this->validator->validate($traversable, 'Group'); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException + */ + 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'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $this->validator->validate($traversable, 'Group'); + } + + public function testValidateInContext() + { + $test = $this; + $entity = new Entity(); + $entity->reference = new Reference(); + + $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $previousValue = $context->getValue(); + $previousMetadata = $context->getMetadata(); + $previousPath = $context->getPropertyPath(); + $previousGroup = $context->getGroup(); + + $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()); + }; + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validator->validate($entity, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('subpath', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testValidateArrayInContext() + { + $test = $this; + $entity = new Entity(); + $entity->reference = new Reference(); + + $callback1 = function ($value, ExecutionContextInterface $context) use ($test) { + $previousValue = $context->getValue(); + $previousMetadata = $context->getMetadata(); + $previousPath = $context->getPropertyPath(); + $previousGroup = $context->getGroup(); + + $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()); + }; + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validator->validate($entity, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('subpath[key]', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testAddCustomizedViolation() + { + $entity = new Entity(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation( + 'Message %param%', + array('%param%' => 'value'), + 'Invalid value', + 2, + 'Code' + ); + }; + + $this->metadata->addConstraint(new Callback($callback)); + + $violations = $this->validator->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $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()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Invalid value', $violations[0]->getInvalidValue()); + $this->assertSame(2, $violations[0]->getMessagePluralization()); + $this->assertSame('Code', $violations[0]->getCode()); + } + + public function testInitializeObjectsOnFirstValidation() + { + $test = $this; + $entity = new Entity(); + $entity->initialized = false; + + // prepare initializers that set "initialized" to true + $initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + $initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + + $initializer1->expects($this->once()) + ->method('initialize') + ->with($entity) + ->will($this->returnCallback(function ($object) { + $object->initialized = true; + })); + + $initializer2->expects($this->once()) + ->method('initialize') + ->with($entity); + + $this->validator = $this->createValidator($this->metadataFactory, array( + $initializer1, + $initializer2, + )); + + // 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); + + // validate again in same group + $context->validate($object); + + // validate again in other group + $context->validate($object, '', 'SomeGroup'); + }; + + $this->metadata->addConstraint(new Callback($callback)); + + $this->validate($entity); + + $this->assertTrue($entity->initialized); + } + + public function testGetMetadataFactory() + { + $this->assertSame($this->metadataFactory, $this->validator->getMetadataFactory()); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2236d6cb02cd3f4c116ca5574656d18a0ed0b9a7 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php @@ -0,0 +1,1282 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Validator; + +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\ConstraintViolationInterface; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Tests\Fixtures\Entity; +use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; +use Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity; +use Symfony\Component\Validator\Tests\Fixtures\Reference; + +/** + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase +{ + const ENTITY_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\Entity'; + + const REFERENCE_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\Reference'; + + /** + * @var FakeMetadataFactory + */ + public $metadataFactory; + + /** + * @var ClassMetadata + */ + public $metadata; + + /** + * @var ClassMetadata + */ + public $referenceMetadata; + + protected function setUp() + { + $this->metadataFactory = new FakeMetadataFactory(); + $this->metadata = new ClassMetadata(self::ENTITY_CLASS); + $this->referenceMetadata = new ClassMetadata(self::REFERENCE_CLASS); + $this->metadataFactory->addMetadata($this->metadata); + $this->metadataFactory->addMetadata($this->referenceMetadata); + } + + protected function tearDown() + { + $this->metadataFactory = null; + $this->metadata = null; + $this->referenceMetadata = null; + } + + abstract protected function validate($value, $constraints = null, $groups = null); + + abstract protected function validateProperty($object, $propertyName, $groups = null); + + abstract protected function validatePropertyValue($object, $propertyName, $value, $groups = null); + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $constraint = new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + )); + + $violations = $this->validate('Bernhard', $constraint, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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()); + $this->assertSame('Bernhard', $violations[0]->getRoot()); + $this->assertSame('Bernhard', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testPropertyConstraint() + { + $test = $this; + $entity = new Entity(); + $entity->firstName = 'Bernhard'; + + $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { + $propertyMetadatas = $test->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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('firstName', new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('firstName', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Bernhard', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testGetterConstraint() + { + $test = $this; + $entity = new Entity(); + $entity->setLastName('Schussek'); + + $callback = function ($value, ExecutionContextInterface $context) use ($test, $entity) { + $propertyMetadatas = $test->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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addGetterConstraint('lastName', new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('lastName', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Schussek', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($array, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('[key]', $violations[0]->getPropertyPath()); + $this->assertSame($array, $violations[0]->getRoot()); + $this->assertSame($entity, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($array, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('[2][key]', $violations[0]->getPropertyPath()); + $this->assertSame($array, $violations[0]->getRoot()); + $this->assertSame($entity, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($traversable, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('[key]', $violations[0]->getPropertyPath()); + $this->assertSame($traversable, $violations[0]->getRoot()); + $this->assertSame($entity, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($traversable, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('[2][key]', $violations[0]->getPropertyPath()); + $this->assertSame($traversable, $violations[0]->getRoot()); + $this->assertSame($entity, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference, $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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'); + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addPropertyConstraint('value', new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference.value', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Foobar', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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'); + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addPropertyConstraint('privateValue', new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference.privateValue', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Bamboo', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testsIgnoreNullReference() + { + $entity = new Entity(); + $entity->reference = null; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException + */ + public function testFailOnScalarReferences() + { + $entity = new Entity(); + $entity->reference = 'string'; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + + $this->validate($entity); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference[key]', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference['key'], $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + // 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference[2][key]', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference[2]['key'], $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testArrayTraversalCannotBeDisabled() + { + $entity = new Entity(); + $entity->reference = array('key' => new Reference()); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'traverse' => false, + ))); + $this->referenceMetadata->addConstraint(new Callback($callback)); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + public function testRecursiveArrayTraversalCannotBeDisabled() + { + $entity = new Entity(); + $entity->reference = array(2 => array('key' => new Reference())); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'traverse' => false, + ))); + $this->referenceMetadata->addConstraint(new Callback($callback)); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + public function testIgnoreScalarsDuringArrayTraversal() + { + $entity = new Entity(); + $entity->reference = array('string', 1234); + + $this->metadata->addPropertyConstraint('reference', new Valid()); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + public function testIgnoreNullDuringArrayTraversal() + { + $entity = new Entity(); + $entity->reference = array(null); + + $this->metadata->addPropertyConstraint('reference', new Valid()); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference[key]', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference['key'], $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + public function testDisableTraversableTraversal() + { + $entity = new Entity(); + $entity->reference = new \ArrayIterator(array('key' => new Reference())); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadataFactory->addMetadata(new ClassMetadata('ArrayIterator')); + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'traverse' => false, + ))); + $this->referenceMetadata->addConstraint(new Callback($callback)); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(0, $violations); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException + */ + public function testMetadataMustExistIfTraversalIsDisabled() + { + $entity = new Entity(); + $entity->reference = new \ArrayIterator(); + + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'traverse' => false, + ))); + + $this->validate($entity); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid(array( + 'deep' => true, + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group', + ))); + + $violations = $this->validate($entity, null, 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('reference[2][key]', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame($entity->reference[2]['key'], $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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'); + + $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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Other violation'); + }; + + $this->metadata->addPropertyConstraint('firstName', new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('lastName', new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validateProperty($entity, 'firstName', 'Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $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('firstName', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Bernhard', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + /** + * Cannot be UnsupportedMetadataException for BC with Symfony < 2.5. + * + * @expectedException \Symfony\Component\Validator\Exception\ValidatorException + */ + public function testValidatePropertyFailsIfPropertiesNotSupported() + { + // $metadata does not implement PropertyMetadataContainerInterface + $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); + + $this->metadataFactory->addMetadataForValue('VALUE', $metadata); + + $this->validateProperty('VALUE', 'someProperty'); + } + + /** + * https://github.com/symfony/symfony/issues/11604 + */ + public function testValidatePropertyWithoutConstraints() + { + $entity = new Entity(); + $violations = $this->validateProperty($entity, 'lastName'); + + $this->assertCount(0, $violations, '->validateProperty() returns no violations if no constraints have been configured for the property being validated'); + } + + public function testValidatePropertyValue() + { + $test = $this; + $entity = new Entity(); + $entity->setLastName('Schussek'); + + $callback1 = function ($value, ExecutionContextInterface $context) use ($test, $entity) { + $propertyMetadatas = $test->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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Other violation'); + }; + + $this->metadata->addPropertyConstraint('firstName', new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('lastName', new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validatePropertyValue( + $entity, + 'firstName', + 'Bernhard', + 'Group' + ); + + /** @var ConstraintViolationInterface[] $violations */ + $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('firstName', $violations[0]->getPropertyPath()); + $this->assertSame($entity, $violations[0]->getRoot()); + $this->assertSame('Bernhard', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + 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); + + $context->addViolation('Message %param%', array('%param%' => 'value')); + }; + + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Other violation'); + }; + + $this->metadata->addPropertyConstraint('firstName', new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group', + ))); + $this->metadata->addPropertyConstraint('lastName', new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group', + ))); + + $violations = $this->validatePropertyValue( + self::ENTITY_CLASS, + 'firstName', + 'Bernhard', + 'Group' + ); + + /** @var ConstraintViolationInterface[] $violations */ + $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()); + $this->assertSame('Bernhard', $violations[0]->getRoot()); + $this->assertSame('Bernhard', $violations[0]->getInvalidValue()); + $this->assertNull($violations[0]->getMessagePluralization()); + $this->assertNull($violations[0]->getCode()); + } + + /** + * Cannot be UnsupportedMetadataException for BC with Symfony < 2.5. + * + * @expectedException \Symfony\Component\Validator\Exception\ValidatorException + */ + public function testValidatePropertyValueFailsIfPropertiesNotSupported() + { + // $metadata does not implement PropertyMetadataContainerInterface + $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); + + $this->metadataFactory->addMetadataForValue('VALUE', $metadata); + + $this->validatePropertyValue('VALUE', 'someProperty', 'someValue'); + } + + /** + * https://github.com/symfony/symfony/issues/11604 + */ + public function testValidatePropertyValueWithoutConstraints() + { + $entity = new Entity(); + $violations = $this->validatePropertyValue($entity, 'lastName', 'foo'); + + $this->assertCount(0, $violations, '->validatePropertyValue() returns no violations if no constraints have been configured for the property being validated'); + } + + public function testValidateObjectOnlyOncePerGroup() + { + $entity = new Entity(); + $entity->reference = new Reference(); + $entity->reference2 = $entity->reference; + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->metadata->addPropertyConstraint('reference2', new Valid()); + $this->referenceMetadata->addConstraint(new Callback($callback)); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + public function testValidateDifferentObjectsSeparately() + { + $entity = new Entity(); + $entity->reference = new Reference(); + $entity->reference2 = new Reference(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->metadata->addPropertyConstraint('reference2', new Valid()); + $this->referenceMetadata->addConstraint(new Callback($callback)); + + $violations = $this->validate($entity); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(2, $violations); + } + + public function testValidateSingleGroup() + { + $entity = new Entity(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group 1', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group 2', + ))); + + $violations = $this->validate($entity, null, 'Group 2'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + } + + public function testValidateMultipleGroups() + { + $entity = new Entity(); + + $callback = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Message'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group 1', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback, + 'groups' => 'Group 2', + ))); + + $violations = $this->validate($entity, null, array('Group 1', 'Group 2')); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(2, $violations); + } + + public function testReplaceDefaultGroupByGroupSequenceObject() + { + $entity = new Entity(); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 2'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 3'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => function () {}, + 'groups' => 'Group 1', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group 2', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 3', + ))); + + $sequence = new GroupSequence(array('Group 1', 'Group 2', 'Group 3', 'Entity')); + $this->metadata->setGroupSequence($sequence); + + $violations = $this->validate($entity, null, 'Default'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); + } + + public function testReplaceDefaultGroupByGroupSequenceArray() + { + $entity = new Entity(); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 2'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 3'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => function () {}, + 'groups' => 'Group 1', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group 2', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 3', + ))); + + $sequence = array('Group 1', 'Group 2', 'Group 3', 'Entity'); + $this->metadata->setGroupSequence($sequence); + + $violations = $this->validate($entity, null, 'Default'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); + } + + public function testPropagateDefaultGroupToReferenceWhenReplacingDefaultGroup() + { + $entity = new Entity(); + $entity->reference = new Reference(); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Default group'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in group sequence'); + }; + + $this->metadata->addPropertyConstraint('reference', new Valid()); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Default', + ))); + $this->referenceMetadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 1', + ))); + + $sequence = new GroupSequence(array('Group 1', 'Entity')); + $this->metadata->setGroupSequence($sequence); + + $violations = $this->validate($entity, null, 'Default'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Violation in Default group', $violations[0]->getMessage()); + } + + public function testValidateCustomGroupWhenDefaultGroupWasReplaced() + { + $entity = new Entity(); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in other group'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in group sequence'); + }; + + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Other Group', + ))); + $this->metadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 1', + ))); + + $sequence = new GroupSequence(array('Group 1', 'Entity')); + $this->metadata->setGroupSequence($sequence); + + $violations = $this->validate($entity, null, 'Other Group'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Violation in other group', $violations[0]->getMessage()); + } + + public function testReplaceDefaultGroupWithObjectFromGroupSequenceProvider() + { + $sequence = new GroupSequence(array('Group 1', 'Group 2', 'Group 3', 'Entity')); + $entity = new GroupSequenceProviderEntity($sequence); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 2'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 3'); + }; + + $metadata = new ClassMetadata(get_class($entity)); + $metadata->addConstraint(new Callback(array( + 'callback' => function () {}, + 'groups' => 'Group 1', + ))); + $metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group 2', + ))); + $metadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 3', + ))); + $metadata->setGroupSequenceProvider(true); + + $this->metadataFactory->addMetadata($metadata); + + $violations = $this->validate($entity, null, 'Default'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); + } + + public function testReplaceDefaultGroupWithArrayFromGroupSequenceProvider() + { + $sequence = array('Group 1', 'Group 2', 'Group 3', 'Entity'); + $entity = new GroupSequenceProviderEntity($sequence); + + $callback1 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 2'); + }; + $callback2 = function ($value, ExecutionContextInterface $context) { + $context->addViolation('Violation in Group 3'); + }; + + $metadata = new ClassMetadata(get_class($entity)); + $metadata->addConstraint(new Callback(array( + 'callback' => function () {}, + 'groups' => 'Group 1', + ))); + $metadata->addConstraint(new Callback(array( + 'callback' => $callback1, + 'groups' => 'Group 2', + ))); + $metadata->addConstraint(new Callback(array( + 'callback' => $callback2, + 'groups' => 'Group 3', + ))); + $metadata->setGroupSequenceProvider(true); + + $this->metadataFactory->addMetadata($metadata); + + $violations = $this->validate($entity, null, 'Default'); + + /** @var ConstraintViolationInterface[] $violations */ + $this->assertCount(1, $violations); + $this->assertSame('Violation in Group 2', $violations[0]->getMessage()); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7a00da64199ee837a57740308a12a1d260a1345d --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php @@ -0,0 +1,38 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Validator; + +use Symfony\Component\Validator\ConstraintValidatorFactory; +use Symfony\Component\Validator\Context\LegacyExecutionContextFactory; +use Symfony\Component\Validator\DefaultTranslator; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Validator\LegacyValidator; + +class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest +{ + protected function setUp() + { + if (version_compare(PHP_VERSION, '5.3.9', '<')) { + $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()); + $validatorFactory = new ConstraintValidatorFactory(); + + return new LegacyValidator($contextFactory, $metadataFactory, $validatorFactory, $objectInitializers); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f803c636b93162623edd201e0f3ab7d8d17270f1 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php @@ -0,0 +1,38 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Validator; + +use Symfony\Component\Validator\ConstraintValidatorFactory; +use Symfony\Component\Validator\Context\LegacyExecutionContextFactory; +use Symfony\Component\Validator\DefaultTranslator; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Validator\LegacyValidator; + +class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest +{ + protected function setUp() + { + if (version_compare(PHP_VERSION, '5.3.9', '<')) { + $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()); + $validatorFactory = new ConstraintValidatorFactory(); + + return new LegacyValidator($contextFactory, $metadataFactory, $validatorFactory, $objectInitializers); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6235fda9022fc606beed77e1ff8b33649997837c --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php @@ -0,0 +1,29 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Validator; + +use Symfony\Component\Validator\ConstraintValidatorFactory; +use Symfony\Component\Validator\Context\ExecutionContextFactory; +use Symfony\Component\Validator\DefaultTranslator; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Validator\RecursiveValidator; + +class RecursiveValidator2Dot5ApiTest extends Abstract2Dot5ApiTest +{ + protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) + { + $contextFactory = new ExecutionContextFactory(new DefaultTranslator()); + $validatorFactory = new ConstraintValidatorFactory(); + + return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $objectInitializers); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index 900243f31ad6518dc80044af9e4eb38f39abc437..ed914d1394904e2b947e02d716adcb55749c1901 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests; +use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\ValidatorBuilder; use Symfony\Component\Validator\ValidatorBuilderInterface; @@ -108,4 +109,37 @@ public function testSetTranslationDomain() { $this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN')); } + + public function testDefaultApiVersion() + { + if (version_compare(PHP_VERSION, '5.3.9', '<')) { + // 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()); + } + } + + public function testSetApiVersion24() + { + $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_4)); + $this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator()); + } + + public function testSetApiVersion25() + { + $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5)); + $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); + } + + public function testSetApiVersion24And25() + { + if (version_compare(PHP_VERSION, '5.3.9', '<')) { + $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/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php index 85a61e4816da819dcf02eda113507851cdc7af9b..3cc36f5e23ad793b8485b9cef766a7f58ed44a1c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php @@ -11,213 +11,19 @@ namespace Symfony\Component\Validator\Tests; -use Symfony\Component\Validator\Tests\Fixtures\Entity; -use Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity; -use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; -use Symfony\Component\Validator\Tests\Fixtures\FailingConstraint; -use Symfony\Component\Validator\Validator; -use Symfony\Component\Validator\DefaultTranslator; -use Symfony\Component\Validator\ConstraintViolation; -use Symfony\Component\Validator\ConstraintViolationList; -use Symfony\Component\Validator\ConstraintValidatorFactory; use Symfony\Component\Validator\Constraints\Valid; -use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\ConstraintValidatorFactory; +use Symfony\Component\Validator\DefaultTranslator; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Tests\Fixtures\Entity; +use Symfony\Component\Validator\Tests\Validator\AbstractLegacyApiTest; +use Symfony\Component\Validator\Validator as LegacyValidator; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends AbstractLegacyApiTest { - /** - * @var FakeMetadataFactory - */ - private $metadataFactory; - - /** - * @var Validator - */ - private $validator; - - protected function setUp() - { - $this->metadataFactory = new FakeMetadataFactory(); - $this->validator = new Validator($this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator()); - } - - protected function tearDown() + protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) { - $this->metadataFactory = null; - $this->validator = null; - } - - public function testValidateDefaultGroup() - { - $entity = new Entity(); - $metadata = new ClassMetadata(get_class($entity)); - $metadata->addPropertyConstraint('firstName', new FailingConstraint()); - $metadata->addPropertyConstraint('lastName', new FailingConstraint(array( - 'groups' => 'Custom', - ))); - $this->metadataFactory->addMetadata($metadata); - - // Only the constraint of group "Default" failed - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - $entity, - 'firstName', - '' - )); - - $this->assertEquals($violations, $this->validator->validate($entity)); - } - - public function testValidateOneGroup() - { - $entity = new Entity(); - $metadata = new ClassMetadata(get_class($entity)); - $metadata->addPropertyConstraint('firstName', new FailingConstraint()); - $metadata->addPropertyConstraint('lastName', new FailingConstraint(array( - 'groups' => 'Custom', - ))); - $this->metadataFactory->addMetadata($metadata); - - // Only the constraint of group "Custom" failed - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - $entity, - 'lastName', - '' - )); - - $this->assertEquals($violations, $this->validator->validate($entity, 'Custom')); - } - - public function testValidateMultipleGroups() - { - $entity = new Entity(); - $metadata = new ClassMetadata(get_class($entity)); - $metadata->addPropertyConstraint('firstName', new FailingConstraint(array( - 'groups' => 'First', - ))); - $metadata->addPropertyConstraint('lastName', new FailingConstraint(array( - 'groups' => 'Second', - ))); - $this->metadataFactory->addMetadata($metadata); - - // The constraints of both groups failed - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - $entity, - 'firstName', - '' - )); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - $entity, - 'lastName', - '' - )); - - $result = $this->validator->validate($entity, array('First', 'Second')); - - $this->assertEquals($violations, $result); - } - - public function testValidateGroupSequenceProvider() - { - $entity = new GroupSequenceProviderEntity(); - $metadata = new ClassMetadata(get_class($entity)); - $metadata->addPropertyConstraint('firstName', new FailingConstraint(array( - 'groups' => 'First', - ))); - $metadata->addPropertyConstraint('lastName', new FailingConstraint(array( - 'groups' => 'Second', - ))); - $metadata->setGroupSequenceProvider(true); - $this->metadataFactory->addMetadata($metadata); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - $entity, - 'firstName', - '' - )); - - $entity->setGroups(array('First')); - $result = $this->validator->validate($entity); - $this->assertEquals($violations, $result); - - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - $entity, - 'lastName', - '' - )); - - $entity->setGroups(array('Second')); - $result = $this->validator->validate($entity); - $this->assertEquals($violations, $result); - - $entity->setGroups(array()); - $result = $this->validator->validate($entity); - $this->assertEquals(new ConstraintViolationList(), $result); - } - - public function testValidateProperty() - { - $entity = new Entity(); - $metadata = new ClassMetadata(get_class($entity)); - $metadata->addPropertyConstraint('firstName', new FailingConstraint()); - $this->metadataFactory->addMetadata($metadata); - - $result = $this->validator->validateProperty($entity, 'firstName'); - - $this->assertCount(1, $result); - - $result = $this->validator->validateProperty($entity, 'lastName'); - - $this->assertCount(0, $result); - } - - public function testValidatePropertyValue() - { - $entity = new Entity(); - $metadata = new ClassMetadata(get_class($entity)); - $metadata->addPropertyConstraint('firstName', new FailingConstraint()); - $this->metadataFactory->addMetadata($metadata); - - $result = $this->validator->validatePropertyValue(get_class($entity), 'firstName', 'Bernhard'); - - $this->assertCount(1, $result); - } - - public function testValidateValue() - { - $violations = new ConstraintViolationList(); - $violations->add(new ConstraintViolation( - 'Failed', - 'Failed', - array(), - 'Bernhard', - '', - 'Bernhard' - )); - - $this->assertEquals($violations, $this->validator->validateValue('Bernhard', new FailingConstraint())); + return new LegacyValidator($metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator(), 'validators', $objectInitializers); } /** @@ -225,52 +31,6 @@ public function testValidateValue() */ public function testValidateValueRejectsValid() { - $entity = new Entity(); - $metadata = new ClassMetadata(get_class($entity)); - $this->metadataFactory->addMetadata($metadata); - - $this->validator->validateValue($entity, new Valid()); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\ValidatorException - */ - public function testValidatePropertyFailsIfPropertiesNotSupported() - { - // $metadata does not implement PropertyMetadataContainerInterface - $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); - $this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $this->metadataFactory->expects($this->any()) - ->method('getMetadataFor') - ->with('VALUE') - ->will($this->returnValue($metadata)); - $this->validator = new Validator($this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator()); - - $this->validator->validateProperty('VALUE', 'someProperty'); - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\ValidatorException - */ - public function testValidatePropertyValueFailsIfPropertiesNotSupported() - { - // $metadata does not implement PropertyMetadataContainerInterface - $metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface'); - $this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $this->metadataFactory->expects($this->any()) - ->method('getMetadataFor') - ->with('VALUE') - ->will($this->returnValue($metadata)); - $this->validator = new Validator($this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator()); - - $this->validator->validatePropertyValue('VALUE', 'someProperty', 'propertyValue'); - } - - public function testGetMetadataFactory() - { - $this->assertInstanceOf( - 'Symfony\Component\Validator\MetadataFactoryInterface', - $this->validator->getMetadataFactory() - ); + $this->validator->validateValue(new Entity(), new Valid()); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Util/PropertyPath.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Util/PropertyPath.php new file mode 100644 index 0000000000000000000000000000000000000000..4d397a9124d9988ca1c7f8f6af12e715b708a390 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Util/PropertyPath.php @@ -0,0 +1,57 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Util; + +/** + * Contains utility methods for dealing with property paths. + * + * For more extensive functionality, use Symfony's PropertyAccess component. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class PropertyPath +{ + /** + * Appends a path to a given property path. + * + * If the base path is empty, the appended path will be returned unchanged. + * If the base path is not empty, and the appended path starts with a + * squared opening bracket ("["), the concatenation of the two paths is + * returned. Otherwise, the concatenation of the two paths is returned, + * separated by a dot ("."). + * + * @param string $basePath The base path + * @param string $subPath The path to append + * + * @return string The concatenation of the two property paths + */ + public static function append($basePath, $subPath) + { + if ('' !== (string) $subPath) { + if ('[' === $subPath{0}) { + return $basePath.$subPath; + } + + return $basePath ? $basePath.'.'.$subPath : $subPath; + } + + return $basePath; + } + + /** + * Not instantiable. + */ + private function __construct() + { + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validation.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validation.php index de77e838fb6ffe458a3592b38e61e94d3df219aa..b304dbb935bb9b97cb39092009b8602590529581 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Validation.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validation.php @@ -18,6 +18,22 @@ */ final class Validation { + /** + * The Validator API provided by Symfony 2.4 and older. + */ + const API_VERSION_2_4 = 1; + + /** + * The Validator API provided by Symfony 2.5 and newer. + */ + const API_VERSION_2_5 = 2; + + /** + * The Validator API provided by Symfony 2.5 and newer with a backwards + * compatibility layer for 2.4 and older. + */ + const API_VERSION_2_5_BC = 3; + /** * Creates a new validator. * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php index ddff8adc6038289b2b7a5a720288c3aeb451cce5..3af82496a1c07c8f4ede1605c23d9e08dc0dfbdf 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitor.php @@ -11,15 +11,17 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Exception\NoSuchMetadataException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Translation\TranslatorInterface; /** * Default implementation of {@link ValidationVisitorInterface} and * {@link GlobalExecutionContextInterface}. * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. */ class ValidationVisitor implements ValidationVisitorInterface, GlobalExecutionContextInterface { @@ -127,16 +129,19 @@ public function validate($value, $group, $propertyPath, $traverse = false, $deep return; } + // Initialize if the object wasn't initialized before + if (!isset($this->validatedObjects[$hash])) { + foreach ($this->objectInitializers as $initializer) { + if (!$initializer instanceof ObjectInitializerInterface) { + throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.'); + } + $initializer->initialize($value); + } + } + // Remember validating this object before starting and possibly // traversing the object graph $this->validatedObjects[$hash][$group] = true; - - foreach ($this->objectInitializers as $initializer) { - if (!$initializer instanceof ObjectInitializerInterface) { - throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.'); - } - $initializer->initialize($value); - } } // Validate arrays recursively by default, otherwise every driver needs diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php index e4163718b30d0f7829b96bb85426a80ea83710b5..531e6d431d9eeea5e88c69915bb83caf5bde588c 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidationVisitorInterface.php @@ -33,6 +33,8 @@ * </ol> * * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. */ interface ValidationVisitorInterface { @@ -57,11 +59,13 @@ interface ValidationVisitorInterface * @param mixed $value The value to validate. * @param string $group The validation group to validate. * @param string $propertyPath The current property path in the validation graph. - * @param Boolean $traverse Whether to traverse the value if it is traversable. - * @param Boolean $deep Whether to traverse nested traversable values recursively. + * @param bool $traverse Whether to traverse the value if it is traversable. + * @param bool $deep Whether to traverse nested traversable values recursively. * * @throws Exception\NoSuchMetadataException If no metadata can be found for * the given value. + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. */ public function validate($value, $group, $propertyPath, $traverse = false, $deep = false); @@ -75,6 +79,8 @@ public function validate($value, $group, $propertyPath, $traverse = false, $deep * @param mixed $value The value to validate. * @param string $group The validation group to validate. * @param string $propertyPath The current property path in the validation graph. + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. */ public function visit(MetadataInterface $metadata, $value, $group, $propertyPath); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php index 476c8141bc949aee91e68b3de6e274aab3d93d06..6edbb7ac566a5937b5de2d40d9f2bcd110c1e37a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php @@ -11,17 +11,20 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Exception\ValidatorException; -use Symfony\Component\Translation\TranslatorInterface; /** * Default implementation of {@link ValidatorInterface}. * * @author Fabien Potencier <fabien@symfony.com> * @author Bernhard Schussek <bschussek@gmail.com> + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Validator\RecursiveValidator} instead. */ -class Validator implements ValidatorInterface +class Validator implements ValidatorInterface, Mapping\Factory\MetadataFactoryInterface { /** * @var MetadataFactoryInterface @@ -54,8 +57,7 @@ public function __construct( TranslatorInterface $translator, $translationDomain = 'validators', array $objectInitializers = array() - ) - { + ) { $this->metadataFactory = $metadataFactory; $this->validatorFactory = $validatorFactory; $this->translator = $translator; @@ -72,7 +74,7 @@ public function getMetadataFactory() } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getMetadataFor($value) { @@ -80,7 +82,15 @@ public function getMetadataFor($value) } /** - * {@inheritDoc} + * {@inheritdoc} + */ + public function hasMetadataFor($value) + { + return $this->metadataFactory->hasMetadataFor($value); + } + + /** + * {@inheritdoc} */ public function validate($value, $groups = null, $traverse = false, $deep = false) { @@ -94,7 +104,7 @@ public function validate($value, $groups = null, $traverse = false, $deep = fals } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws ValidatorException If the metadata for the value does not support properties. */ @@ -108,7 +118,7 @@ public function validateProperty($containingValue, $property, $groups = null) ? '"'.$containingValue.'"' : 'the value of type '.gettype($containingValue); - throw new ValidatorException(sprintf('The metadata for '.$valueAsString.' does not support properties.')); + throw new ValidatorException(sprintf('The metadata for %s does not support properties.', $valueAsString)); } foreach ($this->resolveGroups($groups) as $group) { @@ -125,13 +135,13 @@ public function validateProperty($containingValue, $property, $groups = null) } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws ValidatorException If the metadata for the value does not support properties. */ public function validatePropertyValue($containingValue, $property, $value, $groups = null) { - $visitor = $this->createVisitor($containingValue); + $visitor = $this->createVisitor(is_object($containingValue) ? $containingValue : $value); $metadata = $this->metadataFactory->getMetadataFor($containingValue); if (!$metadata instanceof PropertyMetadataContainerInterface) { @@ -142,13 +152,17 @@ public function validatePropertyValue($containingValue, $property, $value, $grou throw new ValidatorException(sprintf('The metadata for '.$valueAsString.' does not support properties.')); } + // If $containingValue is passed as class name, take $value as root + // and start the traversal with an empty property path + $propertyPath = is_object($containingValue) ? $property : ''; + foreach ($this->resolveGroups($groups) as $group) { if (!$metadata->hasPropertyMetadata($property)) { continue; } foreach ($metadata->getPropertyMetadata($property) as $propMeta) { - $propMeta->accept($visitor, $value, $group, $property); + $propMeta->accept($visitor, $value, $group, $propertyPath); } } @@ -156,7 +170,7 @@ public function validatePropertyValue($containingValue, $property, $value, $grou } /** - * {@inheritDoc} + * {@inheritdoc} */ public function validateValue($value, $constraints, $groups = null) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..767f89585f95054b29c321075fbae6b829e5e6f3 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php @@ -0,0 +1,89 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Validator; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintViolationListInterface; + +/** + * A validator in a specific execution context. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface ContextualValidatorInterface +{ + /** + * Appends the given path to the property path of the context. + * + * If called multiple times, the path will always be reset to the context's + * original path with the given path appended to it. + * + * @param string $path The path to append + * + * @return ContextualValidatorInterface This validator + */ + public function atPath($path); + + /** + * Validates a value against a constraint or a list of constraints. + * + * If no constraint is passed, the constraint + * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. + * + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate + * against + * @param array|null $groups The validation groups to + * validate. If none is given, + * "Default" is assumed + * + * @return ContextualValidatorInterface This validator + */ + public function validate($value, $constraints = null, $groups = null); + + /** + * Validates a property of an object against the constraints specified + * for this property. + * + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param array|null $groups The validation groups to validate. If + * none is given, "Default" is assumed + * + * @return ContextualValidatorInterface This validator + */ + public function validateProperty($object, $propertyName, $groups = null); + + /** + * Validates a value against the constraints specified for an object's + * property. + * + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the + * property's constraints + * @param array|null $groups The validation groups to validate. If + * none is given, "Default" is assumed + * + * @return ContextualValidatorInterface This validator + */ + public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); + + /** + * Returns the violations that have been generated so far in the context + * of the validator. + * + * @return ConstraintViolationListInterface The constraint violations + */ + public function getViolations(); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/LegacyValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/LegacyValidator.php new file mode 100644 index 0000000000000000000000000000000000000000..ce3501f216116b5d06f38869b2e7bd453e8e0dfa --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/LegacyValidator.php @@ -0,0 +1,79 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Validator; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; + +/** + * A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+. + * + * This class is incompatible with PHP versions < 5.3.9, because it implements + * two different interfaces specifying the same method validate(): + * + * - {@link \Symfony\Component\Validator\ValidatorInterface} + * - {@link \Symfony\Component\Validator\Validator\ValidatorInterface} + * + * In PHP versions prior to 5.3.9, either use {@link RecursiveValidator} or the + * deprecated class {@link \Symfony\Component\Validator\Validator} instead. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @see \Symfony\Component\Validator\ValidatorInterface + * @see \Symfony\Component\Validator\Validator\ValidatorInterface + * + * @deprecated Implemented for backwards compatibility with Symfony < 2.5. + * To be removed in Symfony 3.0. + */ +class LegacyValidator extends RecursiveValidator implements LegacyValidatorInterface +{ + public function validate($value, $groups = null, $traverse = false, $deep = false) + { + $numArgs = func_num_args(); + + // Use new signature if constraints are given in the second argument + if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) { + // Rename to avoid total confusion ;) + $constraints = $groups; + $groups = $traverse; + + return parent::validate($value, $constraints, $groups); + } + + $constraint = new Valid(array('traverse' => $traverse, 'deep' => $deep)); + + return parent::validate($value, $constraint, $groups); + } + + public function validateValue($value, $constraints, $groups = null) + { + return parent::validate($value, $constraints, $groups); + } + + public function getMetadataFactory() + { + return $this->metadataFactory; + } + + private static function testConstraints($constraints) + { + return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); + } + + private static function testGroups($groups) + { + return null === $groups || is_string($groups) || $groups instanceof GroupSequence || (is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence)); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php new file mode 100644 index 0000000000000000000000000000000000000000..29d0c6c00c71c06a19c50c8558986cd0ab05a7ba --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -0,0 +1,864 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Validator; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; +use Symfony\Component\Validator\Exception\NoSuchMetadataException; +use Symfony\Component\Validator\Exception\RuntimeException; +use Symfony\Component\Validator\Exception\UnsupportedMetadataException; +use Symfony\Component\Validator\Exception\ValidatorException; +use Symfony\Component\Validator\Mapping\CascadingStrategy; +use Symfony\Component\Validator\Mapping\ClassMetadataInterface; +use Symfony\Component\Validator\Mapping\GenericMetadata; +use Symfony\Component\Validator\Mapping\MetadataInterface; +use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; +use Symfony\Component\Validator\Mapping\TraversalStrategy; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\ObjectInitializerInterface; +use Symfony\Component\Validator\Util\PropertyPath; + +/** + * Recursive implementation of {@link ContextualValidatorInterface}. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class RecursiveContextualValidator implements ContextualValidatorInterface +{ + /** + * @var ExecutionContextInterface + */ + private $context; + + /** + * @var MetadataFactoryInterface + */ + private $metadataFactory; + + /** + * @var ConstraintValidatorFactoryInterface + */ + private $validatorFactory; + + /** + * @var ObjectInitializerInterface[] + */ + private $objectInitializers; + + /** + * Creates a validator for the given context. + * + * @param ExecutionContextInterface $context The execution context + * @param MetadataFactoryInterface $metadataFactory The factory for + * fetching the metadata + * of validated objects + * @param ConstraintValidatorFactoryInterface $validatorFactory The factory for creating + * constraint validators + * @param ObjectInitializerInterface[] $objectInitializers The object initializers + */ + public function __construct(ExecutionContextInterface $context, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array()) + { + $this->context = $context; + $this->defaultPropertyPath = $context->getPropertyPath(); + $this->defaultGroups = array($context->getGroup() ?: Constraint::DEFAULT_GROUP); + $this->metadataFactory = $metadataFactory; + $this->validatorFactory = $validatorFactory; + $this->objectInitializers = $objectInitializers; + } + + /** + * {@inheritdoc} + */ + public function atPath($path) + { + $this->defaultPropertyPath = $this->context->getPropertyPath($path); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function validate($value, $constraints = null, $groups = null) + { + $groups = $groups ? $this->normalizeGroups($groups) : $this->defaultGroups; + + $previousValue = $this->context->getValue(); + $previousObject = $this->context->getObject(); + $previousMetadata = $this->context->getMetadata(); + $previousPath = $this->context->getPropertyPath(); + $previousGroup = $this->context->getGroup(); + + // If explicit constraints are passed, validate the value against + // those constraints + if (null !== $constraints) { + // You can pass a single constraint or an array of constraints + // Make sure to deal with an array in the rest of the code + if (!is_array($constraints)) { + $constraints = array($constraints); + } + + $metadata = new GenericMetadata(); + $metadata->addConstraints($constraints); + + $this->validateGenericNode( + $value, + null, + is_object($value) ? spl_object_hash($value) : null, + $metadata, + $this->defaultPropertyPath, + $groups, + null, + TraversalStrategy::IMPLICIT, + $this->context + ); + + $this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath); + $this->context->setGroup($previousGroup); + + return $this; + } + + // If an object is passed without explicit constraints, validate that + // object against the constraints defined for the object's class + if (is_object($value)) { + $this->validateObject( + $value, + $this->defaultPropertyPath, + $groups, + TraversalStrategy::IMPLICIT, + $this->context + ); + + $this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath); + $this->context->setGroup($previousGroup); + + return $this; + } + + // If an array is passed without explicit constraints, validate each + // object in the array + if (is_array($value)) { + $this->validateEachObjectIn( + $value, + $this->defaultPropertyPath, + $groups, + true, + $this->context + ); + + $this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath); + $this->context->setGroup($previousGroup); + + return $this; + } + + throw new RuntimeException(sprintf( + 'Cannot validate values of type "%s" automatically. Please '. + 'provide a constraint.', + gettype($value) + )); + } + + /** + * {@inheritdoc} + */ + public function validateProperty($object, $propertyName, $groups = null) + { + $classMetadata = $this->metadataFactory->getMetadataFor($object); + + if (!$classMetadata instanceof ClassMetadataInterface) { + // Cannot be UnsupportedMetadataException because of BC with + // Symfony < 2.5 + throw new ValidatorException(sprintf( + 'The metadata factory should return instances of '. + '"\Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. + 'got: "%s".', + is_object($classMetadata) ? get_class($classMetadata) : gettype($classMetadata) + )); + } + + $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); + $groups = $groups ? $this->normalizeGroups($groups) : $this->defaultGroups; + $cacheKey = spl_object_hash($object); + $propertyPath = PropertyPath::append($this->defaultPropertyPath, $propertyName); + + $previousValue = $this->context->getValue(); + $previousObject = $this->context->getObject(); + $previousMetadata = $this->context->getMetadata(); + $previousPath = $this->context->getPropertyPath(); + $previousGroup = $this->context->getGroup(); + + foreach ($propertyMetadatas as $propertyMetadata) { + $propertyValue = $propertyMetadata->getPropertyValue($object); + + $this->validateGenericNode( + $propertyValue, + $object, + $cacheKey.':'.$propertyName, + $propertyMetadata, + $propertyPath, + $groups, + null, + TraversalStrategy::IMPLICIT, + $this->context + ); + } + + $this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath); + $this->context->setGroup($previousGroup); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) + { + $classMetadata = $this->metadataFactory->getMetadataFor($objectOrClass); + + if (!$classMetadata instanceof ClassMetadataInterface) { + // Cannot be UnsupportedMetadataException because of BC with + // Symfony < 2.5 + throw new ValidatorException(sprintf( + 'The metadata factory should return instances of '. + '"\Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. + 'got: "%s".', + is_object($classMetadata) ? get_class($classMetadata) : gettype($classMetadata) + )); + } + + $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); + $groups = $groups ? $this->normalizeGroups($groups) : $this->defaultGroups; + + if (is_object($objectOrClass)) { + $object = $objectOrClass; + $cacheKey = spl_object_hash($objectOrClass); + $propertyPath = PropertyPath::append($this->defaultPropertyPath, $propertyName); + } else { + // $objectOrClass contains a class name + $object = null; + $cacheKey = null; + $propertyPath = $this->defaultPropertyPath; + } + + $previousValue = $this->context->getValue(); + $previousObject = $this->context->getObject(); + $previousMetadata = $this->context->getMetadata(); + $previousPath = $this->context->getPropertyPath(); + $previousGroup = $this->context->getGroup(); + + foreach ($propertyMetadatas as $propertyMetadata) { + $this->validateGenericNode( + $value, + $object, + $cacheKey.':'.$propertyName, + $propertyMetadata, + $propertyPath, + $groups, + null, + TraversalStrategy::IMPLICIT, + $this->context + ); + } + + $this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath); + $this->context->setGroup($previousGroup); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getViolations() + { + return $this->context->getViolations(); + } + + /** + * Normalizes the given group or list of groups to an array. + * + * @param mixed $groups The groups to normalize + * + * @return array A group array + */ + protected function normalizeGroups($groups) + { + if (is_array($groups)) { + return $groups; + } + + return array($groups); + } + /** + * Validates an object against the constraints defined for its class. + * + * If no metadata is available for the class, but the class is an instance + * of {@link \Traversable} and the selected traversal strategy allows + * traversal, the object will be iterated and each nested object will be + * validated instead. + * + * @param object $object The object to cascade + * @param string $propertyPath The current property path + * @param string[] $groups The validated groups + * @param int $traversalStrategy The strategy for traversing the + * cascaded object + * @param ExecutionContextInterface $context The current execution context + * + * @throws NoSuchMetadataException If the object has no associated metadata + * and does not implement {@link \Traversable} + * or if traversal is disabled via the + * $traversalStrategy argument + * @throws UnsupportedMetadataException If the metadata returned by the + * metadata factory does not implement + * {@link ClassMetadataInterface} + */ + private function validateObject($object, $propertyPath, array $groups, $traversalStrategy, ExecutionContextInterface $context) + { + try { + $classMetadata = $this->metadataFactory->getMetadataFor($object); + + if (!$classMetadata instanceof ClassMetadataInterface) { + throw new UnsupportedMetadataException(sprintf( + 'The metadata factory should return instances of '. + '"Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. + 'got: "%s".', + is_object($classMetadata) ? get_class($classMetadata) : gettype($classMetadata) + )); + } + + $this->validateClassNode( + $object, + spl_object_hash($object), + $classMetadata, + $propertyPath, + $groups, + null, + $traversalStrategy, + $context + ); + } catch (NoSuchMetadataException $e) { + // Rethrow if not Traversable + if (!$object instanceof \Traversable) { + throw $e; + } + + // Rethrow unless IMPLICIT or TRAVERSE + if (!($traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE))) { + throw $e; + } + + $this->validateEachObjectIn( + $object, + $propertyPath, + $groups, + $traversalStrategy & TraversalStrategy::STOP_RECURSION, + $context + ); + } + } + + /** + * Validates each object in a collection against the constraints defined + * for their classes. + * + * If the parameter $recursive is set to true, nested {@link \Traversable} + * objects are iterated as well. Nested arrays are always iterated, + * regardless of the value of $recursive. + * + * @param array|\Traversable $collection The collection + * @param string $propertyPath The current property path + * @param string[] $groups The validated groups + * @param bool $stopRecursion Whether to disable + * recursive iteration. For + * backwards compatibility + * with Symfony < 2.5. + * @param ExecutionContextInterface $context The current execution context + * + * @see ClassNode + * @see CollectionNode + */ + private function validateEachObjectIn($collection, $propertyPath, array $groups, $stopRecursion, ExecutionContextInterface $context) + { + if ($stopRecursion) { + $traversalStrategy = TraversalStrategy::NONE; + } else { + $traversalStrategy = TraversalStrategy::IMPLICIT; + } + + foreach ($collection as $key => $value) { + if (is_array($value)) { + // Arrays are always cascaded, independent of the specified + // traversal strategy + // (BC with Symfony < 2.5) + $this->validateEachObjectIn( + $value, + $propertyPath.'['.$key.']', + $groups, + $stopRecursion, + $context + ); + + continue; + } + + // Scalar and null values in the collection are ignored + // (BC with Symfony < 2.5) + if (is_object($value)) { + $this->validateObject( + $value, + $propertyPath.'['.$key.']', + $groups, + $traversalStrategy, + $context + ); + } + } + } + + /** + * Validates a class node. + * + * A class node is a combination of an object with a {@link ClassMetadataInterface} + * instance. Each class node (conceptionally) has zero or more succeeding + * property nodes: + * + * (Article:class node) + * \ + * ($title:property node) + * + * This method validates the passed objects against all constraints defined + * at class level. It furthermore triggers the validation of each of the + * class' properties against the constraints for that property. + * + * If the selected traversal strategy allows traversal, the object is + * iterated and each nested object is validated against its own constraints. + * The object is not traversed if traversal is disabled in the class + * metadata. + * + * If the passed groups contain the group "Default", the validator will + * check whether the "Default" group has been replaced by a group sequence + * in the class metadata. If this is the case, the group sequence is + * validated instead. + * + * @param object $object The validated object + * @param string $cacheKey The key for caching + * the validated object + * @param ClassMetadataInterface $metadata The class metadata of + * the object + * @param string $propertyPath The property path leading + * to the object + * @param string[] $groups The groups in which the + * object should be validated + * @param string[]|null $cascadedGroups The groups in which + * cascaded objects should + * be validated + * @param int $traversalStrategy The strategy used for + * traversing the object + * @param ExecutionContextInterface $context The current execution context + * + * @throws UnsupportedMetadataException If a property metadata does not + * implement {@link PropertyMetadataInterface} + * @throws ConstraintDefinitionException If traversal was enabled but the + * object does not implement + * {@link \Traversable} + * + * @see TraversalStrategy + */ + private function validateClassNode($object, $cacheKey, ClassMetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context) + { + $context->setNode($object, $object, $metadata, $propertyPath); + + if (!$context->isObjectInitialized($cacheKey)) { + foreach ($this->objectInitializers as $initializer) { + $initializer->initialize($object); + } + + $context->markObjectAsInitialized($cacheKey); + } + + foreach ($groups as $key => $group) { + // If the "Default" group is replaced by a group sequence, remember + // to cascade the "Default" group when traversing the group + // sequence + $defaultOverridden = false; + + // Use the object hash for group sequences + $groupHash = is_object($group) ? spl_object_hash($group) : $group; + + if ($context->isGroupValidated($cacheKey, $groupHash)) { + // Skip this group when validating the properties and when + // traversing the object + unset($groups[$key]); + + continue; + } + + $context->markGroupAsValidated($cacheKey, $groupHash); + + // Replace the "Default" group by the group sequence defined + // for the class, if applicable. + // This is done after checking the cache, so that + // spl_object_hash() isn't called for this sequence and + // "Default" is used instead in the cache. This is useful + // if the getters below return different group sequences in + // every call. + if (Constraint::DEFAULT_GROUP === $group) { + if ($metadata->hasGroupSequence()) { + // The group sequence is statically defined for the class + $group = $metadata->getGroupSequence(); + $defaultOverridden = true; + } elseif ($metadata->isGroupSequenceProvider()) { + // The group sequence is dynamically obtained from the validated + // object + /** @var \Symfony\Component\Validator\GroupSequenceProviderInterface $object */ + $group = $object->getGroupSequence(); + $defaultOverridden = true; + + if (!$group instanceof GroupSequence) { + $group = new GroupSequence($group); + } + } + } + + // If the groups (=[<G1,G2>,G3,G4]) contain a group sequence + // (=<G1,G2>), then call validateClassNode() with each entry of the + // group sequence and abort if necessary (G1, G2) + if ($group instanceof GroupSequence) { + $this->stepThroughGroupSequence( + $object, + $object, + $cacheKey, + $metadata, + $propertyPath, + $traversalStrategy, + $group, + $defaultOverridden ? Constraint::DEFAULT_GROUP : null, + $context + ); + + // Skip the group sequence when validating properties, because + // stepThroughGroupSequence() already validates the properties + unset($groups[$key]); + + continue; + } + + $this->validateInGroup($object, $cacheKey, $metadata, $group, $context); + } + + // If no more groups should be validated for the property nodes, + // we can safely quit + if (0 === count($groups)) { + return; + } + + // Validate all properties against their constraints + foreach ($metadata->getConstrainedProperties() as $propertyName) { + // If constraints are defined both on the getter of a property as + // well as on the property itself, then getPropertyMetadata() + // returns two metadata objects, not just one + foreach ($metadata->getPropertyMetadata($propertyName) as $propertyMetadata) { + if (!$propertyMetadata instanceof PropertyMetadataInterface) { + throw new UnsupportedMetadataException(sprintf( + 'The property metadata instances should implement '. + '"Symfony\Component\Validator\Mapping\PropertyMetadataInterface", '. + 'got: "%s".', + is_object($propertyMetadata) ? get_class($propertyMetadata) : gettype($propertyMetadata) + )); + } + + $propertyValue = $propertyMetadata->getPropertyValue($object); + + $this->validateGenericNode( + $propertyValue, + $object, + $cacheKey.':'.$propertyName, + $propertyMetadata, + $propertyPath + ? $propertyPath.'.'.$propertyName + : $propertyName, + $groups, + $cascadedGroups, + TraversalStrategy::IMPLICIT, + $context + ); + } + } + + // If no specific traversal strategy was requested when this method + // was called, use the traversal strategy of the class' metadata + if ($traversalStrategy & TraversalStrategy::IMPLICIT) { + // Keep the STOP_RECURSION flag, if it was set + $traversalStrategy = $metadata->getTraversalStrategy() + | ($traversalStrategy & TraversalStrategy::STOP_RECURSION); + } + + // Traverse only if IMPLICIT or TRAVERSE + if (!($traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE))) { + return; + } + + // If IMPLICIT, stop unless we deal with a Traversable + if ($traversalStrategy & TraversalStrategy::IMPLICIT && !$object instanceof \Traversable) { + return; + } + + // If TRAVERSE, fail if we have no Traversable + if (!$object instanceof \Traversable) { + // Must throw a ConstraintDefinitionException for backwards + // compatibility reasons with Symfony < 2.5 + throw new ConstraintDefinitionException(sprintf( + 'Traversal was enabled for "%s", but this class '. + 'does not implement "\Traversable".', + get_class($object) + )); + } + + $this->validateEachObjectIn( + $object, + $propertyPath, + $groups, + $traversalStrategy & TraversalStrategy::STOP_RECURSION, + $context + ); + } + + /** + * Validates a node that is not a class node. + * + * Currently, two such node types exist: + * + * - property nodes, which consist of the value of an object's + * property together with a {@link PropertyMetadataInterface} instance + * - generic nodes, which consist of a value and some arbitrary + * constraints defined in a {@link MetadataInterface} container + * + * In both cases, the value is validated against all constraints defined + * in the passed metadata object. Then, if the value is an instance of + * {@link \Traversable} and the selected traversal strategy permits it, + * the value is traversed and each nested object validated against its own + * constraints. Arrays are always traversed. + * + * @param mixed $value The validated value + * @param object|null $object The current object + * @param string $cacheKey The key for caching + * the validated value + * @param MetadataInterface $metadata The metadata of the + * value + * @param string $propertyPath The property path leading + * to the value + * @param string[] $groups The groups in which the + * value should be validated + * @param string[]|null $cascadedGroups The groups in which + * cascaded objects should + * be validated + * @param int $traversalStrategy The strategy used for + * traversing the value + * @param ExecutionContextInterface $context The current execution context + * + * @see TraversalStrategy + */ + private function validateGenericNode($value, $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context) + { + $context->setNode($value, $object, $metadata, $propertyPath); + + foreach ($groups as $key => $group) { + if ($group instanceof GroupSequence) { + $this->stepThroughGroupSequence( + $value, + $object, + $cacheKey, + $metadata, + $propertyPath, + $traversalStrategy, + $group, + null, + $context + ); + + // Skip the group sequence when cascading, as the cascading + // logic is already done in stepThroughGroupSequence() + unset($groups[$key]); + + continue; + } + + $this->validateInGroup($value, $cacheKey, $metadata, $group, $context); + } + + if (0 === count($groups)) { + return; + } + + if (null === $value) { + return; + } + + $cascadingStrategy = $metadata->getCascadingStrategy(); + + // Quit unless we have an array or a cascaded object + if (!is_array($value) && !($cascadingStrategy & CascadingStrategy::CASCADE)) { + return; + } + + // If no specific traversal strategy was requested when this method + // was called, use the traversal strategy of the node's metadata + if ($traversalStrategy & TraversalStrategy::IMPLICIT) { + // Keep the STOP_RECURSION flag, if it was set + $traversalStrategy = $metadata->getTraversalStrategy() + | ($traversalStrategy & TraversalStrategy::STOP_RECURSION); + } + + // The $cascadedGroups property is set, if the "Default" group is + // overridden by a group sequence + // See validateClassNode() + $cascadedGroups = count($cascadedGroups) > 0 + ? $cascadedGroups + : $groups; + + if (is_array($value)) { + // Arrays are always traversed, independent of the specified + // traversal strategy + // (BC with Symfony < 2.5) + $this->validateEachObjectIn( + $value, + $propertyPath, + $cascadedGroups, + $traversalStrategy & TraversalStrategy::STOP_RECURSION, + $context + ); + + return; + } + + // If the value is a scalar, pass it anyway, because we want + // a NoSuchMetadataException to be thrown in that case + // (BC with Symfony < 2.5) + $this->validateObject( + $value, + $propertyPath, + $cascadedGroups, + $traversalStrategy, + $context + ); + + // Currently, the traversal strategy can only be TRAVERSE for a + // generic node if the cascading strategy is CASCADE. Thus, traversable + // objects will always be handled within validateObject() and there's + // nothing more to do here. + + // see GenericMetadata::addConstraint() + } + + /** + * Sequentially validates a node's value in each group of a group sequence. + * + * If any of the constraints generates a violation, subsequent groups in the + * group sequence are skipped. + * + * @param mixed $value The validated value + * @param object|null $object The current object + * @param string $cacheKey The key for caching + * the validated value + * @param MetadataInterface $metadata The metadata of the + * value + * @param string $propertyPath The property path leading + * to the value + * @param int $traversalStrategy The strategy used for + * traversing the value + * @param GroupSequence $groupSequence The group sequence + * @param string[]|null $cascadedGroup The group that should + * be passed to cascaded + * objects instead of + * the group sequence + * @param ExecutionContextInterface $context The execution context + */ + private function stepThroughGroupSequence($value, $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, $traversalStrategy, GroupSequence $groupSequence, $cascadedGroup, ExecutionContextInterface $context) + { + $violationCount = count($context->getViolations()); + $cascadedGroups = $cascadedGroup ? array($cascadedGroup) : null; + + foreach ($groupSequence->groups as $groupInSequence) { + $groups = array($groupInSequence); + + if ($metadata instanceof ClassMetadataInterface) { + $this->validateClassNode( + $value, + $cacheKey, + $metadata, + $propertyPath, + $groups, + $cascadedGroups, + $traversalStrategy, + $context + ); + } else { + $this->validateGenericNode( + $value, + $object, + $cacheKey, + $metadata, + $propertyPath, + $groups, + $cascadedGroups, + $traversalStrategy, + $context + ); + } + + // Abort sequence validation if a violation was generated + if (count($context->getViolations()) > $violationCount) { + break; + } + } + } + + /** + * Validates a node's value against all constraints in the given group. + * + * @param mixed $value The validated value + * @param string $cacheKey The key for caching the + * validated value + * @param MetadataInterface $metadata The metadata of the value + * @param string $group The group to validate + * @param ExecutionContextInterface $context The execution context + */ + private function validateInGroup($value, $cacheKey, MetadataInterface $metadata, $group, ExecutionContextInterface $context) + { + $context->setGroup($group); + + foreach ($metadata->findConstraints($group) as $constraint) { + // Prevent duplicate validation of constraints, in the case + // that constraints belong to multiple validated groups + if (null !== $cacheKey) { + $constraintHash = spl_object_hash($constraint); + + if ($context->isConstraintValidated($cacheKey, $constraintHash)) { + continue; + } + + $context->markConstraintAsValidated($cacheKey, $constraintHash); + } + + $validator = $this->validatorFactory->getInstance($constraint); + $validator->initialize($context); + $validator->validate($value, $constraint); + } + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/RecursiveValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/RecursiveValidator.php new file mode 100644 index 0000000000000000000000000000000000000000..ddf0850c1cf2a449a85f4d6f260445544f02c344 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/RecursiveValidator.php @@ -0,0 +1,140 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Validator; + +use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; +use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\ObjectInitializerInterface; + +/** + * Recursive implementation of {@link ValidatorInterface}. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class RecursiveValidator implements ValidatorInterface +{ + /** + * @var ExecutionContextFactoryInterface + */ + protected $contextFactory; + + /** + * @var MetadataFactoryInterface + */ + protected $metadataFactory; + + /** + * @var ConstraintValidatorFactoryInterface + */ + protected $validatorFactory; + + /** + * @var ObjectInitializerInterface[] + */ + protected $objectInitializers; + + /** + * Creates a new validator. + * + * @param ExecutionContextFactoryInterface $contextFactory The factory for + * creating new contexts + * @param MetadataFactoryInterface $metadataFactory The factory for + * fetching the metadata + * of validated objects + * @param ConstraintValidatorFactoryInterface $validatorFactory The factory for creating + * constraint validators + * @param ObjectInitializerInterface[] $objectInitializers The object initializers + */ + public function __construct(ExecutionContextFactoryInterface $contextFactory, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array()) + { + $this->contextFactory = $contextFactory; + $this->metadataFactory = $metadataFactory; + $this->validatorFactory = $validatorFactory; + $this->objectInitializers = $objectInitializers; + } + + /** + * {@inheritdoc} + */ + public function startContext($root = null) + { + return new RecursiveContextualValidator( + $this->contextFactory->createContext($this, $root), + $this->metadataFactory, + $this->validatorFactory, + $this->objectInitializers + ); + } + + /** + * {@inheritdoc} + */ + public function inContext(ExecutionContextInterface $context) + { + return new RecursiveContextualValidator( + $context, + $this->metadataFactory, + $this->validatorFactory, + $this->objectInitializers + ); + } + + /** + * {@inheritdoc} + */ + public function getMetadataFor($object) + { + return $this->metadataFactory->getMetadataFor($object); + } + + /** + * {@inheritdoc} + */ + public function hasMetadataFor($object) + { + return $this->metadataFactory->hasMetadataFor($object); + } + + /** + * {@inheritdoc} + */ + public function validate($value, $constraints = null, $groups = null) + { + return $this->startContext($value) + ->validate($value, $constraints, $groups) + ->getViolations(); + } + + /** + * {@inheritdoc} + */ + public function validateProperty($object, $propertyName, $groups = null) + { + return $this->startContext($object) + ->validateProperty($object, $propertyName, $groups) + ->getViolations(); + } + + /** + * {@inheritdoc} + */ + public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) + { + // If a class name is passed, take $value as root + return $this->startContext(is_object($objectOrClass) ? $objectOrClass : $value) + ->validatePropertyValue($objectOrClass, $propertyName, $value, $groups) + ->getViolations(); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/ValidatorInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/ValidatorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..2582bf65c85c41bf999cc10d8e6805d9ad3cb357 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Validator/ValidatorInterface.php @@ -0,0 +1,100 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Validator; + +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintViolationListInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; + +/** + * Validates PHP values against constraints. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface ValidatorInterface extends MetadataFactoryInterface +{ + /** + * Validates a value against a constraint or a list of constraints. + * + * If no constraint is passed, the constraint + * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. + * + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate + * against + * @param array|null $groups The validation groups to + * validate. If none is given, + * "Default" is assumed + * + * @return ConstraintViolationListInterface A list of constraint violations. + * If the list is empty, validation + * succeeded + */ + public function validate($value, $constraints = null, $groups = null); + + /** + * Validates a property of an object against the constraints specified + * for this property. + * + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param array|null $groups The validation groups to validate. If + * none is given, "Default" is assumed + * + * @return ConstraintViolationListInterface A list of constraint violations. + * If the list is empty, validation + * succeeded + */ + public function validateProperty($object, $propertyName, $groups = null); + + /** + * Validates a value against the constraints specified for an object's + * property. + * + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the + * property's constraints + * @param array|null $groups The validation groups to validate. If + * none is given, "Default" is assumed + * + * @return ConstraintViolationListInterface A list of constraint violations. + * If the list is empty, validation + * succeeded + */ + public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); + + /** + * Starts a new validation context and returns a validator for that context. + * + * The returned validator collects all violations generated within its + * context. You can access these violations with the + * {@link ContextualValidatorInterface::getViolations()} method. + * + * @return ContextualValidatorInterface The validator for the new context + */ + public function startContext(); + + /** + * Returns a validator in the given execution context. + * + * The returned validator adds all generated violations to the given + * context. + * + * @param ExecutionContextInterface $context The execution context + * + * @return ContextualValidatorInterface The validator for that context + */ + public function inContext(ExecutionContextInterface $context); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php index e24a7071662e22a5a5662321d57146af81cc6571..ba6fa0c805fac3d72476d9217603d83b9fa2554e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php @@ -11,23 +11,28 @@ namespace Symfony\Component\Validator; -use Symfony\Component\PropertyAccess\PropertyAccess; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\CachedReader; +use Doctrine\Common\Annotations\Reader; +use Doctrine\Common\Cache\ArrayCache; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; -use Symfony\Component\Validator\Mapping\ClassMetadataFactory; +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Context\ExecutionContextFactory; +use Symfony\Component\Validator\Context\LegacyExecutionContextFactory; +use Symfony\Component\Validator\Exception\InvalidArgumentException; use Symfony\Component\Validator\Exception\ValidatorException; -use Symfony\Component\Validator\Mapping\Loader\LoaderChain; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; -use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; -use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; +use Symfony\Component\Validator\Mapping\ClassMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; -use Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader; +use Symfony\Component\Validator\Mapping\Loader\LoaderChain; +use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; use Symfony\Component\Validator\Mapping\Loader\XmlFilesLoader; -use Symfony\Component\Translation\TranslatorInterface; -use Doctrine\Common\Annotations\Reader; -use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\CachedReader; -use Doctrine\Common\Cache\ArrayCache; +use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; +use Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader; +use Symfony\Component\Validator\Validator\LegacyValidator; +use Symfony\Component\Validator\Validator\RecursiveValidator; +use Symfony\Component\Validator\Validator as ValidatorV24; /** * The default implementation of {@link ValidatorBuilderInterface}. @@ -91,6 +96,11 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ private $propertyAccessor; + /** + * @var int + */ + private $apiVersion; + /** * {@inheritdoc} */ @@ -303,6 +313,32 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) return $this; } + /** + * {@inheritdoc} + */ + public function setApiVersion($apiVersion) + { + if (!in_array($apiVersion, array(Validation::API_VERSION_2_4, Validation::API_VERSION_2_5, Validation::API_VERSION_2_5_BC))) { + throw new InvalidArgumentException(sprintf( + 'The requested API version is invalid: "%s"', + $apiVersion + )); + } + + if (version_compare(PHP_VERSION, '5.3.9', '<') && $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; + } + /** * {@inheritdoc} */ @@ -344,10 +380,28 @@ public function getValidator() $metadataFactory = new ClassMetadataFactory($loader, $this->metadataCache); } - $propertyAccessor = $this->propertyAccessor ?: PropertyAccess::createPropertyAccessor(); - $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($propertyAccessor); + $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($this->propertyAccessor); $translator = $this->translator ?: new DefaultTranslator(); + $apiVersion = $this->apiVersion; + + if (null === $apiVersion) { + $apiVersion = version_compare(PHP_VERSION, '5.3.9', '<') + ? Validation::API_VERSION_2_4 + : Validation::API_VERSION_2_5_BC; + } + + if (Validation::API_VERSION_2_4 === $apiVersion) { + return new ValidatorV24($metadataFactory, $validatorFactory, $translator, $this->translationDomain, $this->initializers); + } + + if (Validation::API_VERSION_2_5 === $apiVersion) { + $contextFactory = new ExecutionContextFactory($translator, $this->translationDomain); + + return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers); + } + + $contextFactory = new LegacyExecutionContextFactory($metadataFactory, $translator, $this->translationDomain); - return new Validator($metadataFactory, $validatorFactory, $translator, $this->translationDomain, $this->initializers); + return new LegacyValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php index 92aaca756a3bcddb907a4e82e754428a375357e1..c5420c8c9fc061a8a1a6e9bc763e28245b6259cd 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -11,10 +11,10 @@ namespace Symfony\Component\Validator; +use Doctrine\Common\Annotations\Reader; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; -use Symfony\Component\Validator\Mapping\Cache\CacheInterface; use Symfony\Component\Translation\TranslatorInterface; -use Doctrine\Common\Annotations\Reader; +use Symfony\Component\Validator\Mapping\Cache\CacheInterface; /** * A configurable builder for ValidatorInterface objects. @@ -26,124 +26,124 @@ interface ValidatorBuilderInterface /** * Adds an object initializer to the validator. * - * @param ObjectInitializerInterface $initializer The initializer. + * @param ObjectInitializerInterface $initializer The initializer * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addObjectInitializer(ObjectInitializerInterface $initializer); /** * Adds a list of object initializers to the validator. * - * @param array $initializers The initializer. + * @param array $initializers The initializer * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addObjectInitializers(array $initializers); /** * Adds an XML constraint mapping file to the validator. * - * @param string $path The path to the mapping file. + * @param string $path The path to the mapping file * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addXmlMapping($path); /** * Adds a list of XML constraint mapping files to the validator. * - * @param array $paths The paths to the mapping files. + * @param array $paths The paths to the mapping files * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addXmlMappings(array $paths); /** * Adds a YAML constraint mapping file to the validator. * - * @param string $path The path to the mapping file. + * @param string $path The path to the mapping file * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addYamlMapping($path); /** * Adds a list of YAML constraint mappings file to the validator. * - * @param array $paths The paths to the mapping files. + * @param array $paths The paths to the mapping files * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addYamlMappings(array $paths); /** * Enables constraint mapping using the given static method. * - * @param string $methodName The name of the method. + * @param string $methodName The name of the method * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addMethodMapping($methodName); /** * Enables constraint mapping using the given static methods. * - * @param array $methodNames The names of the methods. + * @param array $methodNames The names of the methods * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function addMethodMappings(array $methodNames); /** * Enables annotation based constraint mapping. * - * @param Reader $annotationReader The annotation reader to be used. + * @param Reader $annotationReader The annotation reader to be used * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function enableAnnotationMapping(Reader $annotationReader = null); /** * Disables annotation based constraint mapping. * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function disableAnnotationMapping(); /** * Sets the class metadata factory used by the validator. * - * @param MetadataFactoryInterface $metadataFactory The metadata factory. + * @param MetadataFactoryInterface $metadataFactory The metadata factory * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function setMetadataFactory(MetadataFactoryInterface $metadataFactory); /** * Sets the cache for caching class metadata. * - * @param CacheInterface $cache The cache instance. + * @param CacheInterface $cache The cache instance * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function setMetadataCache(CacheInterface $cache); /** * Sets the constraint validator factory used by the validator. * - * @param ConstraintValidatorFactoryInterface $validatorFactory The validator factory. + * @param ConstraintValidatorFactoryInterface $validatorFactory The validator factory * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory); /** * Sets the translator used for translating violation messages. * - * @param TranslatorInterface $translator The translator instance. + * @param TranslatorInterface $translator The translator instance * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function setTranslator(TranslatorInterface $translator); @@ -154,21 +154,36 @@ public function setTranslator(TranslatorInterface $translator); * Pass the domain that is used for violation messages by default to this * method. * - * @param string $translationDomain The translation domain of the violation messages. + * @param string $translationDomain The translation domain of the violation messages * - * @return ValidatorBuilderInterface The builder object. + * @return ValidatorBuilderInterface The builder object */ public function setTranslationDomain($translationDomain); /** * Sets the property accessor for resolving property paths. * - * @param PropertyAccessorInterface $propertyAccessor The property accessor. + * @param PropertyAccessorInterface $propertyAccessor The property accessor + * + * @return ValidatorBuilderInterface The builder object * - * @return ValidatorBuilderInterface The builder object. + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. */ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor); + /** + * Sets the API version that the returned validator should support. + * + * @param int $apiVersion The required API version + * + * @return ValidatorBuilderInterface The builder object + * + * @see Validation::API_VERSION_2_4 + * @see Validation::API_VERSION_2_5 + * @see Validation::API_VERSION_2_5_BC + */ + public function setApiVersion($apiVersion); + /** * Builds and returns a new validator object. * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorInterface.php index 98e02d90cf4d8085a7baec19a376250bd0b9f27a..03c8921bb281cf42320dfd7077a9558b7aa4fb91 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorInterface.php @@ -17,6 +17,9 @@ * @author Bernhard Schussek <bschussek@gmail.com> * * @api + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Validator\ValidatorInterface} instead. */ interface ValidatorInterface { @@ -26,10 +29,14 @@ interface ValidatorInterface * The accepted values depend on the {@link MetadataFactoryInterface} * implementation. * + * The signature changed with Symfony 2.5 (see + * {@link Validator\ValidatorInterface::validate()}. This signature will be + * disabled in Symfony 3.0. + * * @param mixed $value The value to validate * @param array|null $groups The validation groups to validate. - * @param Boolean $traverse Whether to traverse the value if it is traversable. - * @param Boolean $deep Whether to traverse nested traversable values recursively. + * @param bool $traverse Whether to traverse the value if it is traversable. + * @param bool $deep Whether to traverse nested traversable values recursively. * * @return ConstraintViolationListInterface A list of constraint violations. If the * list is empty, validation succeeded. @@ -61,7 +68,7 @@ public function validateProperty($containingValue, $property, $groups = null); * The accepted values depend on the {@link MetadataFactoryInterface} * implementation. * - * @param string $containingValue The value containing the property. + * @param mixed $containingValue The value containing the property. * @param string $property The name of the property to validate * @param string $value The value to validate against the * constraints of the property. @@ -85,6 +92,9 @@ public function validatePropertyValue($containingValue, $property, $value, $grou * list is empty, validation succeeded. * * @api + * + * @deprecated Renamed to {@link Validator\ValidatorInterface::validate()} + * in Symfony 2.5. Will be removed in Symfony 3.0. */ public function validateValue($value, $constraints, $groups = null); @@ -94,6 +104,11 @@ public function validateValue($value, $constraints, $groups = null); * @return MetadataFactoryInterface The metadata factory. * * @api + * + * @deprecated Deprecated since version 2.5, to be removed in Symfony 3.0. + * Use {@link Validator\ValidatorInterface::getMetadataFor()} or + * {@link Validator\ValidatorInterface::hasMetadataFor()} + * instead. */ public function getMetadataFactory(); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..969b79cdeddd5c9f238e9ecd4d699068900376b0 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php @@ -0,0 +1,201 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Violation; + +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\Util\PropertyPath; + +/** + * Default implementation of {@link ConstraintViolationBuilderInterface}. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @internal You should not instantiate or use this class. Code against + * {@link ConstraintViolationBuilderInterface} instead. + */ +class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface +{ + /** + * @var ConstraintViolationList + */ + private $violations; + + /** + * @var string + */ + private $message; + + /** + * @var array + */ + private $parameters; + + /** + * @var mixed + */ + private $root; + + /** + * @var mixed + */ + private $invalidValue; + + /** + * @var string + */ + private $propertyPath; + + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @var string|null + */ + private $translationDomain; + + /** + * @var int|null + */ + private $plural; + + /** + * @var mixed + */ + private $code; + + public function __construct(ConstraintViolationList $violations, $message, array $parameters, $root, $propertyPath, $invalidValue, TranslatorInterface $translator, $translationDomain = null) + { + $this->violations = $violations; + $this->message = $message; + $this->parameters = $parameters; + $this->root = $root; + $this->propertyPath = $propertyPath; + $this->invalidValue = $invalidValue; + $this->translator = $translator; + $this->translationDomain = $translationDomain; + } + + /** + * {@inheritdoc} + */ + public function atPath($path) + { + $this->propertyPath = PropertyPath::append($this->propertyPath, $path); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setParameter($key, $value) + { + $this->parameters[$key] = $value; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setParameters(array $parameters) + { + $this->parameters = $parameters; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setTranslationDomain($translationDomain) + { + $this->translationDomain = $translationDomain; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setInvalidValue($invalidValue) + { + $this->invalidValue = $invalidValue; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setPlural($number) + { + $this->plural = $number; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function addViolation() + { + if (null === $this->plural) { + $translatedMessage = $this->translator->trans( + $this->message, + $this->parameters, + $this->translationDomain + ); + } else { + try { + $translatedMessage = $this->translator->transChoice( + $this->message, + $this->plural, + $this->parameters, + $this->translationDomain# + ); + } catch (\InvalidArgumentException $e) { + $translatedMessage = $this->translator->trans( + $this->message, + $this->parameters, + $this->translationDomain + ); + } + } + + $this->violations->add(new ConstraintViolation( + $translatedMessage, + $this->message, + $this->parameters, + $this->root, + $this->propertyPath, + $this->invalidValue, + $this->plural, + $this->code + )); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..84cd4d32548ddf6517aafe55426d28d9ad16cc30 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/ConstraintViolationBuilderInterface.php @@ -0,0 +1,108 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Violation; + +/** + * Builds {@link \Symfony\Component\Validator\ConstraintViolationInterface} + * objects. + * + * Use the various methods on this interface to configure the built violation. + * Finally, call {@link addViolation()} to add the violation to the current + * execution context. + * + * @since 2.5 + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface ConstraintViolationBuilderInterface +{ + /** + * Stores the property path at which the violation should be generated. + * + * The passed path will be appended to the current property path of the + * execution context. + * + * @param string $path The property path + * + * @return ConstraintViolationBuilderInterface This builder + */ + public function atPath($path); + + /** + * Sets a parameter to be inserted into the violation message. + * + * @param string $key The name of the parameter + * @param string $value The value to be inserted in the parameter's place + * + * @return ConstraintViolationBuilderInterface This builder + */ + public function setParameter($key, $value); + + /** + * Sets all parameters to be inserted into the violation message. + * + * @param array $parameters An array with the parameter names as keys and + * the values to be inserted in their place as + * values + * + * @return ConstraintViolationBuilderInterface This builder + */ + public function setParameters(array $parameters); + + /** + * Sets the translation domain which should be used for translating the + * violation message. + * + * @param string $translationDomain The translation domain + * + * @return ConstraintViolationBuilderInterface This builder + * + * @see \Symfony\Component\Translation\TranslatorInterface + */ + public function setTranslationDomain($translationDomain); + + /** + * Sets the invalid value that caused this violation. + * + * @param mixed $invalidValue The invalid value + * + * @return ConstraintViolationBuilderInterface This builder + */ + public function setInvalidValue($invalidValue); + + /** + * Sets the number which determines how the plural form of the violation + * message is chosen when it is translated. + * + * @param int $number The number for determining the plural form + * + * @return ConstraintViolationBuilderInterface This builder + * + * @see \Symfony\Component\Translation\TranslatorInterface::transChoice() + */ + public function setPlural($number); + + /** + * Sets the violation code. + * + * @param mixed $code The violation code + * + * @return ConstraintViolationBuilderInterface This builder + * + * @internal This method is internal and should not be used by user code + */ + public function setCode($code); + + /** + * Adds the violation to the current execution context. + */ + public function addViolation(); +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..06cfdb60fbd5b24ea8d5d980eaf5e204390fdd4b --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php @@ -0,0 +1,165 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Violation; + +use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Util\PropertyPath; + +/** + * Backwards-compatible implementation of {@link ConstraintViolationBuilderInterface}. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * + * @internal You should not instantiate or use this class. Code against + * {@link ConstraintViolationBuilderInterface} instead. + * + * @deprecated This class will be removed in Symfony 3.0. + */ +class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInterface +{ + /** + * @var ExecutionContextInterface + */ + private $context; + + /** + * @var string + */ + private $message; + + /** + * @var array + */ + private $parameters; + + /** + * @var mixed + */ + private $root; + + /** + * @var mixed + */ + private $invalidValue; + + /** + * @var string + */ + private $propertyPath; + + /** + * @var int|null + */ + private $plural; + + /** + * @var mixed + */ + private $code; + + public function __construct(ExecutionContextInterface $context, $message, array $parameters) + { + $this->context = $context; + $this->message = $message; + $this->parameters = $parameters; + $this->root = $context->getRoot(); + $this->invalidValue = $context->getValue(); + } + + /** + * {@inheritdoc} + */ + public function atPath($path) + { + $this->propertyPath = $path; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setParameter($key, $value) + { + $this->parameters[$key] = $value; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setParameters(array $parameters) + { + $this->parameters = $parameters; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setTranslationDomain($translationDomain) + { + // can't be set in the old API + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setInvalidValue($invalidValue) + { + $this->invalidValue = $invalidValue; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setPlural($number) + { + $this->plural = $number; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function addViolation() + { + if ($this->propertyPath) { + $this->context->addViolationAt($this->propertyPath, $this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code); + + return; + } + + $this->context->addViolation($this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json b/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json index 1b4b6a69078223bfa33aedb6d2dee35e8060efc3..299603b3a678c96dd92b723457475ba7666b4d30 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json @@ -17,24 +17,30 @@ ], "require": { "php": ">=5.3.3", - "symfony/translation": "~2.0", - "symfony/property-access": "~2.2" + "symfony/translation": "~2.0" }, "require-dev": { "symfony/http-foundation": "~2.1", "symfony/intl": "~2.3", "symfony/yaml": "~2.0", "symfony/config": "~2.2", + "symfony/property-access": "~2.2", + "symfony/expression-language": "~2.4", "doctrine/annotations": "~1.0", - "doctrine/cache": "~1.0" + "doctrine/cache": "~1.0", + "egulias/email-validator": "~1.0", + "symfony/expression-language": "~2.4" }, "suggest": { "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader", + "doctrine/cache": "For using the default cached annotation reader and metadata cache.", "symfony/http-foundation": "", "symfony/intl": "", "symfony/yaml": "", - "symfony/config": "" + "symfony/config": "", + "egulias/email-validator": "Strict (RFC compliant) email validation", + "symfony/property-access": "For using the 2.4 Validator API", + "symfony/expression-language": "For using the 2.4 Expression validator" }, "autoload": { "psr-0": { "Symfony\\Component\\Validator\\": "" } @@ -43,7 +49,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/phpunit.xml.dist b/core/vendor/symfony/validator/Symfony/Component/Validator/phpunit.xml.dist index c7f1cef07028a0952d725c0f2e2153faf7f5a545..3713ca85ada70e128ea9d4726629fa8c8eb7875a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/phpunit.xml.dist +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites> diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php index 8709f8b7e462807183167208f400cfc15e2c1e2f..26103c88ece9f2d2f878b9964cc4f24833e8c078 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php @@ -21,14 +21,14 @@ class Dumper /** * The amount of spaces to use for indentation of nested nodes. * - * @var integer + * @var int */ protected $indentation = 4; /** * Sets the indentation. * - * @param integer $num The amount of spaces to use for indentation of nested nodes. + * @param int $num The amount of spaces to use for indentation of nested nodes. */ public function setIndentation($num) { @@ -39,10 +39,10 @@ public function setIndentation($num) * Dumps a PHP value to YAML. * * @param mixed $input The PHP value - * @param integer $inline The level where you switch to inline YAML - * @param integer $indent The level of indentation (used internally) - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param int $inline The level where you switch to inline YAML + * @param int $indent The level of indentation (used internally) + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string The YAML representation of the PHP value */ diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php index 3576e9ae6faa4be62804c174c6b695dda80bd37f..7f6ec2bef297d300bf533b79eaba5f1b6ed3cebe 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php @@ -26,25 +26,25 @@ class Escaper // first to ensure proper escaping because str_replace operates iteratively // on the input arrays. This ordering of the characters avoids the use of strtr, // which performs more slowly. - private static $escapees = array('\\\\', '\\"', '"', + private static $escapees = array('\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", - "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); - private static $escaped = array('\\"', '\\\\', '\\"', + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",); + private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", - "\\N", "\\_", "\\L", "\\P"); + "\\N", "\\_", "\\L", "\\P",); /** * Determines if a PHP value would require double quoting in YAML. * * @param string $value A PHP value * - * @return Boolean True if the value would require double quotes. + * @return bool True if the value would require double quotes. */ public static function requiresDoubleQuoting($value) { @@ -68,7 +68,7 @@ public static function escapeWithDoubleQuotes($value) * * @param string $value A PHP value * - * @return Boolean True if the value would require single quotes. + * @return bool True if the value would require single quotes. */ public static function requiresSingleQuoting($value) { diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php index 938097b8b3e597f964ac76d29690a5ac098b905e..ff01d6b9a69cc9ebeecc6e52dec586936551c8f3 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php @@ -34,8 +34,8 @@ class ParseException extends RuntimeException * Constructor. * * @param string $message The error message - * @param integer $parsedLine The line where the error occurred - * @param integer $snippet The snippet of code near the problem + * @param int $parsedLine The line where the error occurred + * @param int $snippet The snippet of code near the problem * @param string $parsedFile The file name where the error occurred * @param \Exception $previous The previous exception */ @@ -100,7 +100,7 @@ public function setParsedFile($parsedFile) /** * Gets the line where the error occurred. * - * @return integer The file line + * @return int The file line */ public function getParsedLine() { @@ -110,7 +110,7 @@ public function getParsedLine() /** * Sets the line where the error occurred. * - * @param integer $parsedLine The file line + * @param int $parsedLine The file line */ public function setParsedLine($parsedLine) { diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php index 7a8f051e6460a01f00c8eda7c062265f0a9584a8..8fec216dde139c7bc3caca24ad349339d97d79c8 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php @@ -30,14 +30,15 @@ class Inline * Converts a YAML string to a PHP array. * * @param string $value A YAML string - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise + * @param array $references Mapping of variable names to values * * @return array A PHP array representing the YAML string * * @throws ParseException */ - public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) + public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $references = array()) { self::$exceptionOnInvalidType = $exceptionOnInvalidType; self::$objectSupport = $objectSupport; @@ -56,15 +57,15 @@ public static function parse($value, $exceptionOnInvalidType = false, $objectSup $i = 0; switch ($value[0]) { case '[': - $result = self::parseSequence($value, $i); + $result = self::parseSequence($value, $i, $references); ++$i; break; case '{': - $result = self::parseMapping($value, $i); + $result = self::parseMapping($value, $i, $references); ++$i; break; default: - $result = self::parseScalar($value, null, array('"', "'"), $i); + $result = self::parseScalar($value, null, array('"', "'"), $i, true, $references); } // some comments are allowed at the end @@ -83,8 +84,8 @@ public static function parse($value, $exceptionOnInvalidType = false, $objectSup * Dumps a given PHP variable to a YAML string. * * @param mixed $value The PHP variable to convert - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string The YAML string representing the PHP array * @@ -149,8 +150,8 @@ public static function dump($value, $exceptionOnInvalidType = false, $objectSupp * Dumps a PHP array to a YAML string. * * @param array $value The PHP array to dump - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string The YAML string representing the PHP array */ @@ -159,7 +160,7 @@ private static function dumpArray($value, $exceptionOnInvalidType, $objectSuppor // array $keys = array_keys($value); if ((1 == count($keys) && '0' == $keys[0]) - || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) + || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) ) { $output = array(); foreach ($value as $val) { @@ -184,14 +185,15 @@ private static function dumpArray($value, $exceptionOnInvalidType, $objectSuppor * @param scalar $scalar * @param string $delimiters * @param array $stringDelimiters - * @param integer &$i - * @param Boolean $evaluate + * @param int &$i + * @param bool $evaluate + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) + public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true, $references = array()) { if (in_array($scalar[$i], $stringDelimiters)) { // quoted scalar @@ -220,7 +222,9 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar)); } - $output = $evaluate ? self::evaluateScalar($output) : $output; + if ($evaluate) { + $output = self::evaluateScalar($output, $references); + } } return $output; @@ -230,7 +234,7 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter * Parses a quoted scalar to YAML. * * @param string $scalar - * @param integer &$i + * @param int &$i * * @return string A YAML string * @@ -260,13 +264,14 @@ private static function parseQuotedScalar($scalar, &$i) * Parses a sequence to a YAML string. * * @param string $sequence - * @param integer &$i + * @param int &$i + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseSequence($sequence, &$i = 0) + private static function parseSequence($sequence, &$i = 0, $references = array()) { $output = array(); $len = strlen($sequence); @@ -277,11 +282,11 @@ private static function parseSequence($sequence, &$i = 0) switch ($sequence[$i]) { case '[': // nested sequence - $output[] = self::parseSequence($sequence, $i); + $output[] = self::parseSequence($sequence, $i, $references); break; case '{': // nested mapping - $output[] = self::parseMapping($sequence, $i); + $output[] = self::parseMapping($sequence, $i, $references); break; case ']': return $output; @@ -290,12 +295,14 @@ private static function parseSequence($sequence, &$i = 0) break; default: $isQuoted = in_array($sequence[$i], array('"', "'")); - $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); + $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i, true, $references); - if (!$isQuoted && false !== strpos($value, ': ')) { + // the value can be an array if a reference has been resolved to an array var + if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { - $value = self::parseMapping('{'.$value.'}'); + $pos = 0; + $value = self::parseMapping('{'.$value.'}', $pos, $references); } catch (\InvalidArgumentException $e) { // no, it's not } @@ -316,13 +323,14 @@ private static function parseSequence($sequence, &$i = 0) * Parses a mapping to a YAML string. * * @param string $mapping - * @param integer &$i + * @param int &$i + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseMapping($mapping, &$i = 0) + private static function parseMapping($mapping, &$i = 0, $references = array()) { $output = array(); $len = strlen($mapping); @@ -348,19 +356,37 @@ private static function parseMapping($mapping, &$i = 0) switch ($mapping[$i]) { case '[': // nested sequence - $output[$key] = self::parseSequence($mapping, $i); + $value = self::parseSequence($mapping, $i, $references); + // Spec: Keys MUST be unique; first one wins. + // Parser cannot abort this mapping earlier, since lines + // are processed sequentially. + if (!isset($output[$key])) { + $output[$key] = $value; + } $done = true; break; case '{': // nested mapping - $output[$key] = self::parseMapping($mapping, $i); + $value = self::parseMapping($mapping, $i, $references); + // Spec: Keys MUST be unique; first one wins. + // Parser cannot abort this mapping earlier, since lines + // are processed sequentially. + if (!isset($output[$key])) { + $output[$key] = $value; + } $done = true; break; case ':': case ' ': break; default: - $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); + $value = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i, true, $references); + // Spec: Keys MUST be unique; first one wins. + // Parser cannot abort this mapping earlier, since lines + // are processed sequentially. + if (!isset($output[$key])) { + $output[$key] = $value; + } $done = true; --$i; } @@ -380,18 +406,41 @@ private static function parseMapping($mapping, &$i = 0) * Evaluates scalars and replaces magic values. * * @param string $scalar + * @param array $references * * @return string A YAML string + * + * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved */ - private static function evaluateScalar($scalar) + private static function evaluateScalar($scalar, $references = array()) { $scalar = trim($scalar); $scalarLower = strtolower($scalar); + + if (0 === strpos($scalar, '*')) { + if (false !== $pos = strpos($scalar, '#')) { + $value = substr($scalar, 1, $pos - 2); + } else { + $value = substr($scalar, 1); + } + + // an unquoted * + if (false === $value || '' === $value) { + throw new ParseException('A reference must contain at least one character.'); + } + + if (!array_key_exists($value, $references)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $value)); + } + + return $references[$value]; + } + switch (true) { - case 'null' == $scalarLower: - case '' == $scalar: - case '~' == $scalar: - return null; + case 'null' === $scalarLower: + case '' === $scalar: + case '~' === $scalar: + return; case 'true' === $scalarLower: return true; case 'false' === $scalarLower: @@ -412,7 +461,7 @@ private static function evaluateScalar($scalar) throw new ParseException('Object support when parsing a YAML file has been disabled.'); } - return null; + return; case ctype_digit($scalar): $raw = $scalar; $cast = intval($scalar); @@ -425,10 +474,10 @@ private static function evaluateScalar($scalar) return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); case is_numeric($scalar): return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); - case 0 == strcasecmp($scalar, '.inf'): - case 0 == strcasecmp($scalar, '.NaN'): + case '.inf' === $scalarLower: + case '.nan' === $scalarLower: return -log(0); - case 0 == strcasecmp($scalar, '-.inf'): + case '-.inf' === $scalarLower: return log(0); case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): return floatval(str_replace(',', '', $scalar)); diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php index 36aa9b0ace2f3e34f71866eef8ecba62e9cd4ae1..fd9afafe36b4dbdb3edd96423b68dccf8f627fd5 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -31,7 +31,7 @@ class Parser /** * Constructor * - * @param integer $offset The offset of YAML document (used for line numbers in error messages) + * @param int $offset The offset of YAML document (used for line numbers in error messages) */ public function __construct($offset = 0) { @@ -42,8 +42,8 @@ public function __construct($offset = 0) * Parses a YAML string to a PHP value. * * @param string $value A YAML string - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return mixed A PHP value * @@ -55,7 +55,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $this->currentLine = ''; $this->lines = explode("\n", $this->cleanup($value)); - if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { + if (!preg_match('//u', $value)) { throw new ParseException('The YAML value does not appear to be valid UTF-8.'); } @@ -66,6 +66,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data = array(); $context = null; + $allowOverwrite = false; while ($this->moveToNextLine()) { if ($this->isCurrentLineEmpty()) { continue; @@ -76,7 +77,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } - $isRef = $isInPlace = $isProcessed = false; + $isRef = $mergeNode = false; if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { if ($context && 'mapping' == $context) { throw new ParseException('You cannot define a sequence item when in a mapping'); @@ -92,8 +93,8 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; - $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + $parser->refs = & $this->refs; + $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] @@ -102,7 +103,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = // this is a compact notation element, add to next block and parse $c = $this->getRealCurrentLineNb(); $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $block = $values['value']; if ($this->isNextLineIndented()) { @@ -114,14 +115,14 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } - } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) { + } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\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'); } $context = 'mapping'; // force correct settings - Inline::parse(null, $exceptionOnInvalidType, $objectSupport); + Inline::parse(null, $exceptionOnInvalidType, $objectSupport, $this->refs); try { $key = Inline::parseScalar($values['key']); } catch (ParseException $e) { @@ -132,10 +133,24 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = } if ('<<' === $key) { + $mergeNode = true; + $allowOverwrite = true; if (isset($values['value']) && 0 === strpos($values['value'], '*')) { - $isInPlace = substr($values['value'], 1); - if (!array_key_exists($isInPlace, $this->refs)) { - throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine); + $refName = substr($values['value'], 1); + if (!array_key_exists($refName, $this->refs)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + $refValue = $this->refs[$refName]; + + if (!is_array($refValue)) { + throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + foreach ($refValue as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } } } else { if (isset($values['value']) && $values['value'] !== '') { @@ -145,51 +160,71 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = } $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); - $merged = array(); if (!is_array($parsed)) { throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); - } elseif (isset($parsed[0])) { - // Numeric array, merge individual elements - foreach (array_reverse($parsed) as $parsedItem) { + } + + if (isset($parsed[0])) { + // If the value associated with the merge key is a sequence, then this sequence is expected to contain mapping nodes + // and each of these nodes is merged in turn according to its order in the sequence. Keys in mapping nodes earlier + // in the sequence override keys specified in later mapping nodes. + foreach ($parsed as $parsedItem) { if (!is_array($parsedItem)) { throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem); } - $merged = array_merge($parsedItem, $merged); + + foreach ($parsedItem as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } + } } } else { - // Associative array, merge - $merged = array_merge($merged, $parsed); + // If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the + // current mapping, unless the key already exists in it. + foreach ($parsed as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } + } } - - $isProcessed = $merged; } } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } - if ($isProcessed) { + if ($mergeNode) { // Merge keys - $data = $isProcessed; - // hash } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + // hash // if next line is less indented or equal, then it means that the current value is null if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { - $data[$key] = null; + // Spec: Keys MUST be unique; first one wins. + // But overwriting is allowed when a merge node is used in current block. + if ($allowOverwrite || !isset($data[$key])) { + $data[$key] = null; + } } else { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; - $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + $parser->refs = & $this->refs; + $value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + // Spec: Keys MUST be unique; first one wins. + // But overwriting is allowed when a merge node is used in current block. + if ($allowOverwrite || !isset($data[$key])) { + $data[$key] = $value; + } } } else { - if ($isInPlace) { - $data = $this->refs[$isInPlace]; - } else { - $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); + $value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); + // Spec: Keys MUST be unique; first one wins. + // But overwriting is allowed when a merge node is used in current block. + if ($allowOverwrite || !isset($data[$key])) { + $data[$key] = $value; } } } else { @@ -197,7 +232,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $lineCount = count($this->lines); if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { try { - $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); + $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $this->refs); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); @@ -261,7 +296,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = /** * Returns the current line number (takes the offset into account). * - * @return integer The current line number + * @return int The current line number */ private function getRealCurrentLineNb() { @@ -271,7 +306,7 @@ private function getRealCurrentLineNb() /** * Returns the current line indentation. * - * @return integer The current line indentation + * @return int The current line indentation */ private function getCurrentLineIndentation() { @@ -281,15 +316,20 @@ private function getCurrentLineIndentation() /** * Returns the next embed block of YAML. * - * @param integer $indentation The indent level at which the block is to be read, or null for default + * @param int $indentation The indent level at which the block is to be read, or null for default + * @param bool $inSequence True if the enclosing data structure is a sequence * * @return string A YAML string * * @throws ParseException When indentation problem are detected */ - private function getNextEmbedBlock($indentation = null) + private function getNextEmbedBlock($indentation = null, $inSequence = false) { - $this->moveToNextLine(); + $oldLineIndentation = $this->getCurrentLineIndentation(); + + if (!$this->moveToNextLine()) { + return; + } if (null === $indentation) { $newIndent = $this->getCurrentLineIndentation(); @@ -305,6 +345,14 @@ private function getNextEmbedBlock($indentation = null) $data = array(substr($this->currentLine, $newIndent)); + if ($inSequence && $oldLineIndentation === $newIndent && '-' === $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(); + + return; + } + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); // Comments must not be removed inside a string block (ie. after a line ending with "|") @@ -349,7 +397,7 @@ private function getNextEmbedBlock($indentation = null) /** * Moves the parser to the next line. * - * @return Boolean + * @return bool */ private function moveToNextLine() { @@ -374,8 +422,8 @@ private function moveToPreviousLine() * Parses a YAML value. * * @param string $value A YAML value - * @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise - * @param Boolean $objectSupport True if object support is enabled, false otherwise + * @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 * * @return mixed A PHP value * @@ -404,7 +452,7 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport) } try { - return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); + return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $this->refs); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); @@ -418,7 +466,7 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport) * * @param string $separator The separator that was used to begin this folded scalar (| or >) * @param string $indicator The indicator that was used to begin this folded scalar (+ or -) - * @param integer $indentation The indentation that was used to begin this folded scalar + * @param int $indentation The indentation that was used to begin this folded scalar * * @return string The text value */ @@ -497,7 +545,7 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0 /** * Returns true if the next line is indented. * - * @return Boolean Returns true if the next line is indented, false otherwise + * @return bool Returns true if the next line is indented, false otherwise */ private function isNextLineIndented() { @@ -525,7 +573,7 @@ private function isNextLineIndented() /** * Returns true if the current line is blank or if it is a comment line. * - * @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise + * @return bool Returns true if the current line is empty or if it is a comment line, false otherwise */ private function isCurrentLineEmpty() { @@ -535,7 +583,7 @@ private function isCurrentLineEmpty() /** * Returns true if the current line is blank. * - * @return Boolean Returns true if the current line is blank, false otherwise + * @return bool Returns true if the current line is blank, false otherwise */ private function isCurrentLineBlank() { @@ -545,7 +593,7 @@ private function isCurrentLineBlank() /** * Returns true if the current line is a comment line. * - * @return Boolean Returns true if the current line is a comment line, false otherwise + * @return bool Returns true if the current line is a comment line, false otherwise */ private function isCurrentLineComment() { @@ -596,7 +644,7 @@ private function cleanup($value) /** * Returns true if the next line starts unindented collection * - * @return Boolean Returns true if the next line starts unindented collection, false otherwise + * @return bool Returns true if the next line starts unindented collection, false otherwise */ private function isNextLineUnIndentedCollection() { @@ -628,11 +676,10 @@ private function isNextLineUnIndentedCollection() /** * Returns true if the string is un-indented collection item * - * @return Boolean Returns true if the string is un-indented collection item, false otherwise + * @return bool Returns true if the string is un-indented collection item, false otherwise */ private function isStringUnIndentedCollectionItem() { return (0 === strpos($this->currentLine, '- ')); } - } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php index c51a257dc08f315c2211cc89c3b8ca00a9241de5..51e12d41f545843de87ec9bf0a7292480b009001 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php @@ -55,7 +55,7 @@ public function testSetIndentation() { $this->dumper->setIndentation(7); -$expected = <<<EOF + $expected = <<<EOF '': bar foo: '#bar' 'foo''bar': { } @@ -95,7 +95,7 @@ public function testSpecifications() } elseif (isset($test['todo']) && $test['todo']) { // TODO } else { - $expected = eval('return '.trim($test['php']).';'); + eval('$expected = '.trim($test['php']).';'); $this->assertEquals($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']); } @@ -108,10 +108,10 @@ public function testInlineLevel() $expected = <<<EOF { '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } } EOF; -$this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument'); -$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument'); -$expected = <<<EOF + $expected = <<<EOF '': bar foo: '#bar' 'foo''bar': { } @@ -199,6 +199,37 @@ public function testObjectSupportDisabledWithExceptions() { $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false); } + + /** + * @dataProvider getEscapeSequences + */ + public function testEscapedEscapeSequencesInQuotedScalar($input, $expected) + { + $this->assertEquals($expected, $this->dumper->dump($input)); + } + + public function getEscapeSequences() + { + return array( + 'null' => array("\t\\0", '"\t\\\\0"'), + 'bell' => array("\t\\a", '"\t\\\\a"'), + 'backspace' => array("\t\\b", '"\t\\\\b"'), + 'horizontal-tab' => array("\t\\t", '"\t\\\\t"'), + 'line-feed' => array("\t\\n", '"\t\\\\n"'), + 'vertical-tab' => array("\t\\v", '"\t\\\\v"'), + 'form-feed' => array("\t\\f", '"\t\\\\f"'), + 'carriage-return' => array("\t\\r", '"\t\\\\r"'), + 'escape' => array("\t\\e", '"\t\\\\e"'), + 'space' => array("\t\\ ", '"\t\\\\ "'), + 'double-quote' => array("\t\\\"", '"\t\\\\\\""'), + 'slash' => array("\t\\/", '"\t\\\\/"'), + 'backslash' => array("\t\\\\", '"\t\\\\\\\\"'), + 'next-line' => array("\t\\N", '"\t\\\\N"'), + 'non-breaking-space' => array("\t\\�", '"\t\\\\�"'), + 'line-separator' => array("\t\\L", '"\t\\\\L"'), + 'paragraph-separator' => array("\t\\P", '"\t\\\\P"'), + ); + } } class A diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml index ac0efa88d1a1bb7d510c54338a37e4905df68c4a..dfd93021d18cee7d51b8fc1f0c551e2712c1b63a 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml @@ -11,6 +11,30 @@ yaml: | php: | array('apple', 'banana', 'carrot') --- +test: Sequence With Item Being Null In The Middle +brief: | + You can specify a list in YAML by placing each + member of the list on a new line with an opening + dash. These lists are called sequences. +yaml: | + - apple + - + - carrot +php: | + array('apple', null, 'carrot') +--- +test: Sequence With Last Item Being Null +brief: | + You can specify a list in YAML by placing each + member of the list on a new line with an opening + dash. These lists are called sequences. +yaml: | + - apple + - banana + - +php: | + array('apple', 'banana', null) +--- test: Nested Sequences brief: | You can include a sequence within another diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml index 46addfcd3da0493e6630933eb4dbd4f1c6192b0f..6a7ffeca46f3b9491c1d4731feaa5eb02802a7c7 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml @@ -63,3 +63,11 @@ brief: > yaml: 'foo#bar: baz' php: | array('foo#bar' => 'baz') +--- +test: 'Hash key ending with a space and a #' +brief: > + 'Hash key ending with a space and a #' +yaml: | + 'foo #': baz +php: | + array('foo #' => 'baz') diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml index 3eec4f877daacadc07c9eb068d9c448152d40b47..fd9910174dade40eeaa1557a7bcbd94b29a5425e 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml @@ -10,9 +10,19 @@ yaml: | a: Steve b: Clark c: Brian - bar: &bar + bar: + a: before + d: other <<: *foo + b: new x: Oren + c: + foo: bar + foo: ignore + bar: foo + duplicate: + foo: bar + foo: ignore foo2: &foo2 a: Ballmer ding: &dong [ fi, fei, fo, fam] @@ -24,4 +34,12 @@ yaml: | head: <<: [ *foo , *dong , *foo2 ] php: | - array('foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'), 'bar' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'x' => 'Oren'), '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' => 'Ballmer', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam')) + array( + 'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'), + 'bar' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'), + 'duplicate' => array('foo' => 'bar'), + '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') + ) diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php index dc497ca21c7c81b83ef4c45938633797f0268b6d..96afb6bb2256f1ff57b7c19b7fc74452540b6b1c 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php @@ -115,6 +115,56 @@ public function testParseScalarWithCorrectlyQuotedStringShouldReturnString() $this->assertSame($expect, Inline::parseScalar($value)); } + /** + * @dataProvider getDataForParseReferences + */ + public function testParseReferences($yaml, $expected) + { + $this->assertSame($expected, Inline::parse($yaml, false, false, array('var' => 'var-value'))); + } + + public function getDataForParseReferences() + { + return array( + 'scalar' => array('*var', 'var-value'), + 'list' => array('[ *var ]', array('var-value')), + 'list-in-list' => array('[[ *var ]]', array(array('var-value'))), + 'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))), + 'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))), + 'map' => array('{ key: *var }', array('key' => 'var-value')), + 'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))), + 'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))), + ); + } + + public function testParseMapReferenceInSequence() + { + $foo = array( + 'a' => 'Steve', + 'b' => 'Clark', + 'c' => 'Brian', + ); + $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, array('foo' => $foo))); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage A reference must contain at least one character. + */ + public function testParseUnquotedAsterisk() + { + Inline::parse('{ foo: * }'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage A reference must contain at least one character. + */ + public function testParseUnquotedAsteriskFollowedByAComment() + { + Inline::parse('{ foo: * #foo }'); + } + protected function getTestsForParse() { return array( @@ -178,7 +228,7 @@ protected function getTestsForParse() '[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))), - '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',), + '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container'), ); } @@ -225,7 +275,7 @@ protected function getTestsForDump() '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), - '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',), + '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container'), ); } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php index c7d3b071e6dbe91bb2305c2df684bdd9fdba64e9..da248d7dec0dfd33252c8e858983df520f1dcc32 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php @@ -33,12 +33,6 @@ protected function tearDown() */ public function testSpecifications($file, $expected, $yaml, $comment) { - if ('escapedCharacters' == $file) { - if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) { - $this->markTestSkipped('The iconv and mbstring extensions are not available.'); - } - } - $this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment); } @@ -62,9 +56,9 @@ public function getDataFormSpecifications() if (isset($test['todo']) && $test['todo']) { // TODO } else { - $expected = var_export(eval('return '.trim($test['php']).';'), true); + eval('$expected = '.trim($test['php']).';'); - $tests[] = array($file, $expected, $test['yaml'], $test['test']); + $tests[] = array($file, var_export($expected, true), $test['yaml'], $test['test']); } } } @@ -411,7 +405,7 @@ public function testBlockLiteralWithLeadingNewlines() EOF; $expected = array( - 'foo' => "\n\nbar" + 'foo' => "\n\nbar", ); $this->assertSame($expected, $this->parser->parse($yaml)); @@ -446,8 +440,8 @@ public function testObjectsSupportDisabledWithExceptions() public function testNonUtf8Exception() { - if (!function_exists('mb_detect_encoding') || !function_exists('iconv')) { - $this->markTestSkipped('Exceptions for non-utf8 charsets require the mb_detect_encoding() and iconv() functions.'); + if (!function_exists('iconv')) { + $this->markTestSkipped('Exceptions for non-utf8 charsets require the iconv() function.'); return; } @@ -455,7 +449,7 @@ public function testNonUtf8Exception() $yamls = array( iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"), iconv("UTF-8", "ISO-8859-15", "euro: '€'"), - iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'") + iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'"), ); foreach ($yamls as $yaml) { @@ -464,7 +458,7 @@ public function testNonUtf8Exception() $this->fail('charsets other than UTF-8 are rejected.'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.'); + $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.'); } } } @@ -514,6 +508,53 @@ public function testMappingInASequence() ); } + /** + * > It is an error for two equal keys to appear in the same mapping node. + * > In such a case the YAML processor may continue, ignoring the second + * > `key: value` pair and issuing an appropriate warning. This strategy + * > preserves a consistent information model for one-pass and random access + * > applications. + * + * @see http://yaml.org/spec/1.2/spec.html#id2759572 + * @see http://yaml.org/spec/1.1/#id932806 + * + * @covers \Symfony\Component\Yaml\Parser::parse + */ + public function testMappingDuplicateKeyBlock() + { + $input = <<<EOD +parent: + child: first + child: duplicate +parent: + child: duplicate + child: duplicate +EOD; + $expected = array( + 'parent' => array( + 'child' => 'first', + ), + ); + $this->assertSame($expected, Yaml::parse($input)); + } + + /** + * @covers \Symfony\Component\Yaml\Inline::parseMapping + */ + public function testMappingDuplicateKeyFlow() + { + $input = <<<EOD +parent: { child: first, child: duplicate } +parent: { child: duplicate, child: duplicate } +EOD; + $expected = array( + 'parent' => array( + 'child' => 'first', + ), + ); + $this->assertSame($expected, Yaml::parse($input)); + } + public function testEmptyValue() { $input = <<<EOF @@ -608,6 +649,32 @@ public function testNestedFoldedStringBlockWithComments() </body> footer # comment3 +EOF + )); + } + + public function testReferenceResolvingInInlineStrings() + { + $this->assertEquals(array( + 'var' => 'var-value', + 'scalar' => 'var-value', + 'list' => array('var-value'), + 'list_in_list' => array(array('var-value')), + 'map_in_list' => array(array('key' => 'var-value')), + 'embedded_mapping' => array(array('key' => 'var-value')), + 'map' => array('key' => 'var-value'), + 'list_in_map' => array('key' => array('var-value')), + 'map_in_map' => array('foo' => array('bar' => 'var-value')), + ), Yaml::parse(<<<EOF +var: &var var-value +scalar: *var +list: [ *var ] +list_in_list: [[ *var ]] +map_in_list: [ { key: *var } ] +embedded_mapping: [ key: *var ] +map: { key: *var } +list_in_map: { key: [*var] } +map_in_map: { foo: { bar: *var } } EOF )); } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php index 1b8eeed57a94a6aefb037d68a43c7a71c89864f3..50b1018c404c138bdbbee739259200ad96c154c8 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php @@ -21,6 +21,7 @@ class Unescaper { // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters // must be converted to that encoding. + // @deprecated since 2.5, to be removed in 3.0 const ENCODING = 'UTF-8'; // Regex fragment that matches an escaped character in a double quoted @@ -80,13 +81,13 @@ public function unescapeCharacter($value) case 'n': return "\n"; case 'v': - return "\xb"; + return "\xB"; case 'f': - return "\xc"; + return "\xC"; case 'r': - return "\xd"; + return "\r"; case 'e': - return "\x1b"; + return "\x1B"; case ' ': return ' '; case '"': @@ -97,50 +98,44 @@ public function unescapeCharacter($value) return '\\'; case 'N': // U+0085 NEXT LINE - return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE'); + return "\xC2\x85"; case '_': // U+00A0 NO-BREAK SPACE - return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE'); + return "\xC2\xA0"; case 'L': // U+2028 LINE SEPARATOR - return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE'); + return "\xE2\x80\xA8"; case 'P': // U+2029 PARAGRAPH SEPARATOR - return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE'); + return "\xE2\x80\xA9"; case 'x': - $char = pack('n', hexdec(substr($value, 2, 2))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + return self::utf8chr(hexdec(substr($value, 2, 2))); case 'u': - $char = pack('n', hexdec(substr($value, 2, 4))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + return self::utf8chr(hexdec(substr($value, 2, 4))); case 'U': - $char = pack('N', hexdec(substr($value, 2, 8))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE'); + return self::utf8chr(hexdec(substr($value, 2, 8))); } } /** - * Convert a string from one encoding to another. + * Get the UTF-8 character for the given code point. * - * @param string $value The string to convert - * @param string $to The input encoding - * @param string $from The output encoding + * @param int $c The unicode code point * - * @return string The string with the new encoding - * - * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) + * @return string The corresponding UTF-8 character */ - private function convertEncoding($value, $to, $from) + private static function utf8chr($c) { - if (function_exists('mb_convert_encoding')) { - return mb_convert_encoding($value, $to, $from); - } elseif (function_exists('iconv')) { - return iconv($from, $to, $value); + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } - throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php index c98f6ecdd96e7f6de8c8ab37c67f1a69882d4afd..61793fb3ae473dd843cdabfe72377bfae6536e5c 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php @@ -39,8 +39,8 @@ class Yaml * 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 Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise - * @param Boolean $objectSupport True if object support is enabled, false otherwise + * @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 * * @return array The YAML converted to a PHP array * @@ -81,10 +81,10 @@ public static function parse($input, $exceptionOnInvalidType = false, $objectSup * to convert the array into friendly YAML. * * @param array $array PHP array - * @param integer $inline The level where you switch to inline YAML - * @param integer $indent The amount of spaces to use for indentation of nested nodes. - * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise - * @param Boolean $objectSupport true if object support is enabled, false otherwise + * @param int $inline The level where you switch to inline YAML + * @param int $indent The amount of spaces to use for indentation of nested nodes. + * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise + * @param bool $objectSupport true if object support is enabled, false otherwise * * @return string A YAML string representing the original PHP array * diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist b/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist index aa77e9de77ce02811de4f3291e4ca5feb97d5fb1..90e0bcc27efe8ea31b97a6d205735ee5656b0fc7 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist @@ -1,14 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="false" - backupStaticAttributes="false" +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > <testsuites>