diff --git a/composer.json b/composer.json index 7d460ed48638..711dd619a2a3 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,15 @@ ], "require": { "sdboyer/gliph": "0.1.*", - "symfony/class-loader": "2.3.*", - "symfony/dependency-injection": "2.3.*", - "symfony/event-dispatcher": "2.3.*", - "symfony/http-foundation": "2.3.*", - "symfony/http-kernel": "2.3.*", - "symfony/routing": "2.3.*", - "symfony/serializer": "2.3.*", - "symfony/validator": "2.3.*", - "symfony/yaml": "2.3.*", + "symfony/class-loader": "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/serializer": "2.4.*", + "symfony/validator": "2.4.*", + "symfony/yaml": "2.4.*", "twig/twig": "1.12.*", "doctrine/common": "dev-bmaster#99b44f52a1b844f9c4c34e618b160664d5c27daf", "doctrine/annotations": "dev-master#463d926a8dcc49271cb7db5a08364a70ed6e3cd3", diff --git a/composer.lock b/composer.lock index 185081677568..8879c53fda82 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "06006c1512fb829fcdb498b7e515901d", + "hash": "b3a05b2f0a069c6d34b65b604a216a92", "packages": [ { "name": "doctrine/annotations", @@ -1225,17 +1225,17 @@ }, { "name": "symfony/class-loader", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader.git", - "reference": "622d370a07321329f5259c6f96d5c636104ad46b" + "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/622d370a07321329f5259c6f96d5c636104ad46b", - "reference": "622d370a07321329f5259c6f96d5c636104ad46b", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/6a2ebedbc780130f07b3a15363743d08eb46820c", + "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c", "shasum": "" }, "require": { @@ -1247,7 +1247,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1271,7 +1271,7 @@ ], "description": "Symfony ClassLoader Component", "homepage": "http://symfony.com", - "time": "2013-08-13 20:18:00" + "time": "2013-11-26 16:40:27" }, { "name": "symfony/debug", @@ -1331,17 +1331,17 @@ }, { "name": "symfony/dependency-injection", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c" + "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/3678aa969e5bfeb8515a1f3047c63e8104723f5c", - "reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/7e5bde3a607dde1f8ddef5180759068ad53d259c", + "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c", "shasum": "" }, "require": { @@ -1349,6 +1349,7 @@ }, "require-dev": { "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", "symfony/yaml": "~2.0" }, "suggest": { @@ -1359,7 +1360,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1383,21 +1384,21 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2013-07-25 17:13:25" + "time": "2014-01-01 09:02:49" }, { "name": "symfony/event-dispatcher", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8" + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/41c9826457c65fa3cf746f214985b7ca9cba42f8", - "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", "shasum": "" }, "require": { @@ -1413,7 +1414,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1437,21 +1438,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-07-21 12:12:18" + "time": "2013-12-28 08:12:03" }, { "name": "symfony/http-foundation", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c" + "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/fdf130fe65457aedbc4639a22f4ef9d3be5c002c", - "reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", "shasum": "" }, "require": { @@ -1460,7 +1461,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1487,21 +1488,21 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-08-26 05:49:51" + "time": "2014-01-05 02:10:50" }, { "name": "symfony/http-kernel", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf" + "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/9d35da40f07bbe7a4f8dfbc41555d2b69de674bf", - "reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4", + "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4", "shasum": "" }, "require": { @@ -1509,7 +1510,7 @@ "psr/log": "~1.0", "symfony/debug": "~2.3", "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": "~2.2" + "symfony/http-foundation": "~2.4" }, "require-dev": { "symfony/browser-kit": "~2.2", @@ -1534,7 +1535,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1558,7 +1559,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2013-08-27 08:58:24" + "time": "2014-01-05 02:12:11" }, { "name": "symfony/process", @@ -1607,39 +1608,99 @@ "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", + "homepage": "http://symfony.com", + "keywords": [ + "access", + "array", + "extraction", + "index", + "injection", + "object", + "property", + "property path", + "reflection" + ], + "time": "2013-11-13 21:30:16" + }, { "name": "symfony/routing", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143" + "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/69af3f07dbf3ae93dd513dbc373f561cb2e7f143", - "reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143", + "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", + "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "doctrine/common": "~2.2", + "doctrine/annotations": "~1.0", "psr/log": "~1.0", "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", "symfony/yaml": "~2.0" }, "suggest": { - "doctrine/common": "", - "symfony/config": "", - "symfony/yaml": "" + "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" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1663,21 +1724,27 @@ ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2013-08-23 15:14:07" + "keywords": [ + "router", + "routing", + "uri", + "url" + ], + "time": "2014-01-05 02:10:50" }, { "name": "symfony/serializer", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/Serializer", "source": { "type": "git", "url": "https://github.com/symfony/Serializer.git", - "reference": "457ba76395955926a67ea692957b0872dead5278" + "reference": "60c54346958604379392672a3a998650a169a7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Serializer/zipball/457ba76395955926a67ea692957b0872dead5278", - "reference": "457ba76395955926a67ea692957b0872dead5278", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/60c54346958604379392672a3a998650a169a7f4", + "reference": "60c54346958604379392672a3a998650a169a7f4", "shasum": "" }, "require": { @@ -1686,7 +1753,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1710,7 +1777,7 @@ ], "description": "Symfony Serializer Component", "homepage": "http://symfony.com", - "time": "2013-07-21 12:12:18" + "time": "2014-01-01 08:14:50" }, { "name": "symfony/translation", @@ -1769,31 +1836,35 @@ }, { "name": "symfony/validator", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42" + "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/8f6f6be47fb8e1179cd225b1f949630e26221e42", - "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42", + "url": "https://api.github.com/repos/symfony/Validator/zipball/7ea4e53f8d68bf3ae9cca28765d49d7930618730", + "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730", "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", "symfony/config": "~2.2", "symfony/http-foundation": "~2.1", "symfony/intl": "~2.3", "symfony/yaml": "~2.0" }, "suggest": { - "doctrine/common": "", + "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": "", @@ -1802,7 +1873,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1826,21 +1897,21 @@ ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2013-08-24 15:26:22" + "time": "2014-01-01 08:14:50" }, { "name": "symfony/yaml", - "version": "v2.3.4", + "version": "v2.4.1", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" + "reference": "4e1a237fc48145fae114b96458d799746ad89aa0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", - "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4e1a237fc48145fae114b96458d799746ad89aa0", + "reference": "4e1a237fc48145fae114b96458d799746ad89aa0", "shasum": "" }, "require": { @@ -1849,7 +1920,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1873,7 +1944,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-08-24 15:26:22" + "time": "2013-12-28 08:12:03" }, { "name": "twig/twig", diff --git a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php index d212c7b2896d..589e0b635bd4 100644 --- a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php +++ b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php @@ -143,7 +143,7 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa list( , $port) = explode(':', $normalized_base_url); $options['base_url'] .= ':' . $port; } - elseif ($port != 80) { + elseif (($url_scheme == 'http' && $port != 80) || ($url_scheme == 'https' && $port != 443)) { $options['base_url'] .= ':' . $port; } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php index 07ee9a9762f3..e785bd8efbef 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php @@ -125,7 +125,9 @@ class LanguageUrlRewritingTest extends WebTestBase { // URLs as well. $index_php = strpos(url('', array('absolute' => TRUE)), 'index.php') !== FALSE; - $request = $this->prepareRequestForGenerator(TRUE, array('SERVER_PORT' => '88')); + $request = Request::createFromGlobals(); + $server = $request->server->all(); + $request = $this->prepareRequestForGenerator(TRUE, array('HTTP_HOST' => $server['HTTP_HOST'] . ':88')); // Create an absolute French link. $language = language_load('fr'); diff --git a/core/vendor/autoload.php b/core/vendor/autoload.php index aea9b1796da5..6f10559d6e60 100644 --- a/core/vendor/autoload.php +++ b/core/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721::getLoader(); +return ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099::getLoader(); diff --git a/core/vendor/composer/autoload_namespaces.php b/core/vendor/composer/autoload_namespaces.php index f6dbb7cc1c34..83fb6eda09c2 100644 --- a/core/vendor/composer/autoload_namespaces.php +++ b/core/vendor/composer/autoload_namespaces.php @@ -15,6 +15,7 @@ return array( '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/autoload_real.php b/core/vendor/composer/autoload_real.php index 035394bca571..0d236cfeb6c6 100644 --- a/core/vendor/composer/autoload_real.php +++ b/core/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721 +class ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099 { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099', 'loadClassLoader')); $vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 51c9889d1394..eb44290b16dc 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -1138,116 +1138,6 @@ "http client" ] }, - { - "name": "symfony/class-loader", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/ClassLoader", - "source": { - "type": "git", - "url": "https://github.com/symfony/ClassLoader.git", - "reference": "622d370a07321329f5259c6f96d5c636104ad46b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/622d370a07321329f5259c6f96d5c636104ad46b", - "reference": "622d370a07321329f5259c6f96d5c636104ad46b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/finder": "~2.0" - }, - "time": "2013-08-13 20:18:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\ClassLoader\\": "" - } - }, - "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 ClassLoader Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/dependency-injection", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/DependencyInjection", - "source": { - "type": "git", - "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/3678aa969e5bfeb8515a1f3047c63e8104723f5c", - "reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/config": "~2.2", - "symfony/yaml": "~2.0" - }, - "suggest": { - "symfony/config": "", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "time": "2013-07-25 17:13:25", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\DependencyInjection\\": "" - } - }, - "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 DependencyInjection Component", - "homepage": "http://symfony.com" - }, { "name": "symfony/debug", "version": "v2.3.4", @@ -1306,296 +1196,6 @@ "description": "Symfony Debug Component", "homepage": "http://symfony.com" }, - { - "name": "symfony/http-foundation", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/HttpFoundation", - "source": { - "type": "git", - "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/fdf130fe65457aedbc4639a22f4ef9d3be5c002c", - "reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "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\\HttpFoundation\\": "" - }, - "classmap": [ - "Symfony/Component/HttpFoundation/Resources/stubs" - ] - }, - "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 HttpFoundation Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/41c9826457c65fa3cf746f214985b7ca9cba42f8", - "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/dependency-injection": "~2.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "time": "2013-07-21 12:12:18", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "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 EventDispatcher Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/http-kernel", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/HttpKernel", - "source": { - "type": "git", - "url": "https://github.com/symfony/HttpKernel.git", - "reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/9d35da40f07bbe7a4f8dfbc41555d2b69de674bf", - "reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "psr/log": "~1.0", - "symfony/debug": "~2.3", - "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": "~2.2" - }, - "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": "" - }, - "time": "2013-08-27 08:58:24", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\HttpKernel\\": "" - } - }, - "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 HttpKernel Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/routing", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Routing", - "source": { - "type": "git", - "url": "https://github.com/symfony/Routing.git", - "reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/69af3f07dbf3ae93dd513dbc373f561cb2e7f143", - "reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "doctrine/common": "~2.2", - "psr/log": "~1.0", - "symfony/config": "~2.2", - "symfony/yaml": "~2.0" - }, - "suggest": { - "doctrine/common": "", - "symfony/config": "", - "symfony/yaml": "" - }, - "time": "2013-08-23 15:14:07", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Routing\\": "" - } - }, - "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 Routing Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/serializer", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Serializer", - "source": { - "type": "git", - "url": "https://github.com/symfony/Serializer.git", - "reference": "457ba76395955926a67ea692957b0872dead5278" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Serializer/zipball/457ba76395955926a67ea692957b0872dead5278", - "reference": "457ba76395955926a67ea692957b0872dead5278", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "time": "2013-07-21 12:12:18", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Serializer\\": "" - } - }, - "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 Serializer Component", - "homepage": "http://symfony.com" - }, { "name": "symfony/translation", "version": "v2.3.4", @@ -1653,118 +1253,6 @@ "description": "Symfony Translation Component", "homepage": "http://symfony.com" }, - { - "name": "symfony/validator", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Validator", - "source": { - "type": "git", - "url": "https://github.com/symfony/Validator.git", - "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/8f6f6be47fb8e1179cd225b1f949630e26221e42", - "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/translation": "~2.0" - }, - "require-dev": { - "symfony/config": "~2.2", - "symfony/http-foundation": "~2.1", - "symfony/intl": "~2.3", - "symfony/yaml": "~2.0" - }, - "suggest": { - "doctrine/common": "", - "symfony/config": "", - "symfony/http-foundation": "", - "symfony/intl": "", - "symfony/yaml": "" - }, - "time": "2013-08-24 15:26:22", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Validator\\": "" - } - }, - "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 Validator Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/yaml", - "version": "v2.3.4", - "version_normalized": "2.3.4.0", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", - "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "time": "2013-08-24 15:26:22", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "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 Yaml Component", - "homepage": "http://symfony.com" - }, { "name": "symfony/process", "version": "v2.3.4", @@ -2125,5 +1613,590 @@ "support": { "source": "https://github.com/dawehner/common/tree/bmaster" } + }, + { + "name": "symfony/class-loader", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/ClassLoader", + "source": { + "type": "git", + "url": "https://github.com/symfony/ClassLoader.git", + "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/6a2ebedbc780130f07b3a15363743d08eb46820c", + "reference": "6a2ebedbc780130f07b3a15363743d08eb46820c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/finder": "~2.0" + }, + "time": "2013-11-26 16:40:27", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\ClassLoader\\": "" + } + }, + "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 ClassLoader Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/dependency-injection", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/DependencyInjection", + "source": { + "type": "git", + "url": "https://github.com/symfony/DependencyInjection.git", + "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/7e5bde3a607dde1f8ddef5180759068ad53d259c", + "reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c", + "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", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DependencyInjection\\": "" + } + }, + "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 DependencyInjection Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/http-foundation", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation.git", + "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-01-05 02:10:50", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] + }, + "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 HttpFoundation Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~2.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "time": "2013-12-28 08:12:03", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "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 EventDispatcher Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/http-kernel", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/HttpKernel", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpKernel.git", + "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4", + "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4", + "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": "" + }, + "time": "2014-01-05 02:12:11", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpKernel\\": "" + } + }, + "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 HttpKernel Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/routing", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/Routing", + "source": { + "type": "git", + "url": "https://github.com/symfony/Routing.git", + "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", + "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "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" + }, + "time": "2014-01-05 02:10:50", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Routing\\": "" + } + }, + "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 Routing Component", + "homepage": "http://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ] + }, + { + "name": "symfony/serializer", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/Serializer", + "source": { + "type": "git", + "url": "https://github.com/symfony/Serializer.git", + "reference": "60c54346958604379392672a3a998650a169a7f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/60c54346958604379392672a3a998650a169a7f4", + "reference": "60c54346958604379392672a3a998650a169a7f4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-01-01 08:14:50", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Serializer\\": "" + } + }, + "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 Serializer Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/property-access", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "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" + }, + "time": "2013-11-13 21:30:16", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "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", + "homepage": "http://symfony.com", + "keywords": [ + "access", + "array", + "extraction", + "index", + "injection", + "object", + "property", + "property path", + "reflection" + ] + }, + { + "name": "symfony/validator", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/Validator", + "source": { + "type": "git", + "url": "https://github.com/symfony/Validator.git", + "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Validator/zipball/7ea4e53f8d68bf3ae9cca28765d49d7930618730", + "reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730", + "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", + "symfony/config": "~2.2", + "symfony/http-foundation": "~2.1", + "symfony/intl": "~2.3", + "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", + "symfony/config": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "" + }, + "time": "2014-01-01 08:14:50", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Validator\\": "" + } + }, + "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 Validator Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/yaml", + "version": "v2.4.1", + "version_normalized": "2.4.1.0", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "4e1a237fc48145fae114b96458d799746ad89aa0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4e1a237fc48145fae114b96458d799746ad89aa0", + "reference": "4e1a237fc48145fae114b96458d799746ad89aa0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2013-12-28 08:12:03", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "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 Yaml Component", + "homepage": "http://symfony.com" } ] diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md index 54ffb642e69d..b770166735bf 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.4.0 +----- + + * deprecated the DebugClassLoader as it has been moved to the Debug component instead + 2.3.0 ----- 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 be1c7e2b5563..b2be33ad88ec 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -53,7 +53,7 @@ class ClassCollectionLoader $classes = array_diff($classes, $declared); // the cache is different depending on which classes are already declared - $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5); + $name = $name.'-'.substr(hash('sha256', implode('|', $classes)), 0, 5); } $classes = array_unique($classes); 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 3b09305954f3..59c99d0f1b75 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -39,7 +39,7 @@ class ClassMapGenerator /** * Iterate over all files in the given directory searching for classes * - * @param Iterator|string $dir The directory to search in or an iterator + * @param \Iterator|string $dir The directory to search in or an iterator * * @return array A class map array */ 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 842f4744c0f6..8edd4c1999fa 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -22,6 +22,8 @@ namespace Symfony\Component\ClassLoader; * @author Christophe Coevoet * * @api + * + * @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the DebugClassLoader provided by the Debug component instead. */ class DebugClassLoader { @@ -39,6 +41,16 @@ class DebugClassLoader $this->classFinder = $classFinder; } + /** + * Gets the wrapped class loader. + * + * @return object a class loader instance + */ + public function getClassLoader() + { + return $this->classFinder; + } + /** * Replaces all autoloaders implementing a findFile method by a DebugClassLoader wrapper. */ diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md index 5ac31c64890d..fc222b1c9e39 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/README.md @@ -65,5 +65,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/ClassLoader/ - $ composer.phar install --dev + $ composer.phar install $ phpunit diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index dfa51e37fed1..7b71854da381 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -189,7 +189,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testUnableToLoadClassException() { diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php index 9dae537442f5..a870935797cd 100644 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php +++ b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php @@ -72,7 +72,7 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase public function getLoadNonexistentClassTests() { return array( - array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non exising Pearlike3_Bar class with a leading slash'), + array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'), ); } 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 18f64f75887e..b8600fc54ed7 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 @@ -120,10 +120,6 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase public function testCreateMapFinderSupport() { - if (!class_exists('Symfony\\Component\\Finder\\Finder')) { - $this->markTestSkipped('Finder component is not available'); - } - $finder = new \Symfony\Component\Finder\Finder(); $finder->files()->in(__DIR__.'/Fixtures/beta/NamespaceCollision'); diff --git a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php b/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php deleted file mode 100644 index 873515c3369f..000000000000 --- a/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * 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\ClassLoader; -use Symfony\Component\ClassLoader\DebugClassLoader; - -class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase -{ - private $loader; - - protected function setUp() - { - $this->loader = new ClassLoader(); - spl_autoload_register(array($this->loader, 'loadClass')); - } - - protected function tearDown() - { - spl_autoload_unregister(array($this->loader, 'loadClass')); - } - - public function testIdempotence() - { - DebugClassLoader::enable(); - 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('classFinder'); - $reflProp->setAccessible(true); - - $this->assertNotInstanceOf('Symfony\Component\ClassLoader\DebugClassLoader', $reflProp->getValue($function[0])); - - return; - } - } - - throw new \Exception('DebugClassLoader did not register'); - } -} 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 06a1c624b24b..b28f4f55cb26 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.3-dev" + "dev-master": "2.4-dev" } } } 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 4839bd8bee7b..9a41e8570551 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.4.0 +----- + + * added support for expressions in service definitions + * added ContainerAwareTrait to add default container aware behavior to a class + 2.2.0 ----- diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php index 03528fefa9ef..e81110dc0140 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php @@ -28,6 +28,7 @@ class CheckCircularReferencesPass implements CompilerPassInterface { private $currentId; private $currentPath; + private $checkedNodes; /** * Checks the ContainerBuilder object for circular references. @@ -38,6 +39,7 @@ class CheckCircularReferencesPass implements CompilerPassInterface { $graph = $container->getCompiler()->getServiceReferenceGraph(); + $this->checkedNodes = array(); foreach ($graph->getNodes() as $id => $node) { $this->currentId = $id; $this->currentPath = array($id); @@ -58,15 +60,20 @@ class CheckCircularReferencesPass implements CompilerPassInterface foreach ($edges as $edge) { $node = $edge->getDestNode(); $id = $node->getId(); - $searchKey = array_search($id, $this->currentPath); - $this->currentPath[] = $id; - if (false !== $searchKey) { - throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey)); + if (empty($this->checkedNodes[$id])) { + $searchKey = array_search($id, $this->currentPath); + $this->currentPath[] = $id; + + if (false !== $searchKey) { + throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey)); + } + + $this->checkOutEdges($node->getOutEdges()); + + $this->checkedNodes[$id] = true; + array_pop($this->currentPath); } - - $this->checkOutEdges($node->getOutEdges()); - array_pop($this->currentPath); } } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php index e536331c6e27..c8978f377f44 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php @@ -74,6 +74,17 @@ class CheckDefinitionValidityPass implements CompilerPassInterface $id )); } + + // tag attribute values must be scalars + foreach ($definition->getTags() as $name => $tags) { + foreach ($tags as $attributes) { + foreach ($attributes as $attribute => $value) { + if (!is_scalar($value) && null !== $value) { + throw new RuntimeException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute)); + } + } + } + } } } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/Compiler.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/Compiler.php index 01f224b82325..4dfa9cf31cb3 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/Compiler.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/Compiler.php @@ -12,7 +12,6 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; /** * This class is used to remove circular dependencies between individual passes. @@ -24,7 +23,7 @@ use Symfony\Component\DependencyInjection\Compiler\PassConfig; class Compiler { private $passConfig; - private $log; + private $log = array(); private $loggingFormatter; private $serviceReferenceGraph; @@ -36,7 +35,6 @@ class Compiler $this->passConfig = new PassConfig(); $this->serviceReferenceGraph = new ServiceReferenceGraph(); $this->loggingFormatter = new LoggingFormatter(); - $this->log = array(); } /** 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 ab8895a8c9a5..ba1688f5e867 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 @@ -117,7 +117,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface return true; } - if ($definition->isPublic()) { + if ($definition->isPublic() || $definition->isLazy()) { return false; } @@ -125,6 +125,10 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface return true; } + if ($this->currentId == $id) { + return false; + } + $ids = array(); foreach ($this->graph->getNode($id)->getInEdges() as $edge) { $ids[] = $edge->getSourceNode()->getId(); 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 e863f75640fb..ac395db22e9a 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 @@ -31,9 +31,9 @@ class PassConfig const TYPE_REMOVE = 'removing'; private $mergePass; - private $afterRemovingPasses; - private $beforeOptimizationPasses; - private $beforeRemovingPasses; + private $afterRemovingPasses = array(); + private $beforeOptimizationPasses = array(); + private $beforeRemovingPasses = array(); private $optimizationPasses; private $removingPasses; @@ -44,10 +44,6 @@ class PassConfig { $this->mergePass = new MergeExtensionConfigurationPass(); - $this->afterRemovingPasses = array(); - $this->beforeOptimizationPasses = array(); - $this->beforeRemovingPasses = array(); - $this->optimizationPasses = array( new ResolveDefinitionTemplatesPass(), new ResolveParameterPlaceHoldersPass(), 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 c5187f3b91d1..4699ac34148e 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 @@ -112,7 +112,7 @@ class ResolveDefinitionTemplatesPass implements CompilerPassInterface if (isset($changes['public'])) { $def->setPublic($definition->isPublic()); } - if (isset($changes['lazy'])){ + if (isset($changes['lazy'])) { $def->setLazy($definition->isLazy()); } 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 fbd33eeee16f..1de14fa62f96 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 @@ -26,15 +26,7 @@ class ServiceReferenceGraph /** * @var ServiceReferenceGraphNode[] */ - private $nodes; - - /** - * Constructor. - */ - public function __construct() - { - $this->nodes = array(); - } + private $nodes = array(); /** * Checks if the graph has a specific node. 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 3fd50771d54e..283f6de5ba0e 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 @@ -24,8 +24,8 @@ use Symfony\Component\DependencyInjection\Alias; class ServiceReferenceGraphNode { private $id; - private $inEdges; - private $outEdges; + private $inEdges = array(); + private $outEdges = array(); private $value; /** @@ -38,8 +38,6 @@ class ServiceReferenceGraphNode { $this->id = $id; $this->value = $value; - $this->inEdges = array(); - $this->outEdges = array(); } /** 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 ab0abf316fc9..c4d8f16f32ee 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php @@ -67,13 +67,13 @@ class Container implements IntrospectableContainerInterface */ protected $parameterBag; - protected $services; - protected $methodMap; - protected $aliases; - protected $scopes; - protected $scopeChildren; - protected $scopedServices; - protected $scopeStacks; + protected $services = array(); + protected $methodMap = array(); + protected $aliases = array(); + protected $scopes = array(); + protected $scopeChildren = array(); + protected $scopedServices = array(); + protected $scopeStacks = array(); protected $loading = array(); /** @@ -85,14 +85,7 @@ class Container implements IntrospectableContainerInterface */ public function __construct(ParameterBagInterface $parameterBag = null) { - $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag; - - $this->services = array(); - $this->aliases = array(); - $this->scopes = array(); - $this->scopeChildren = array(); - $this->scopedServices = array(); - $this->scopeStacks = array(); + $this->parameterBag = $parameterBag ?: new ParameterBag(); $this->set('service_container', $this); } @@ -214,7 +207,7 @@ class Container implements IntrospectableContainerInterface $this->services[$id] = $service; - if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_')).'Service')) { + if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')) { $this->$method(); } @@ -240,9 +233,10 @@ class Container implements IntrospectableContainerInterface { $id = strtolower($id); - return array_key_exists($id, $this->services) - || array_key_exists($id, $this->aliases) - || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service') + return isset($this->services[$id]) + || array_key_exists($id, $this->services) + || isset($this->aliases[$id]) + || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service') ; } @@ -267,16 +261,21 @@ class Container implements IntrospectableContainerInterface */ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { - $id = strtolower($id); - - // resolve aliases - if (isset($this->aliases[$id])) { - $id = $this->aliases[$id]; - } - - // re-use shared service instance if it exists - if (array_key_exists($id, $this->services)) { - return $this->services[$id]; + // Attempt to retrieve the service by checking first aliases then + // available services. Service IDs are case insensitive, however since + // this method can be called thousands of times during a request, avoid + // calling strtolower() unless necessary. + foreach (array(false, true) as $strtolower) { + if ($strtolower) { + $id = strtolower($id); + } + if (isset($this->aliases[$id])) { + $id = $this->aliases[$id]; + } + // Re-use shared service instance if it exists. + if (isset($this->services[$id]) || array_key_exists($id, $this->services)) { + return $this->services[$id]; + } } if (isset($this->loading[$id])) { @@ -285,7 +284,7 @@ class Container implements IntrospectableContainerInterface if (isset($this->methodMap[$id])) { $method = $this->methodMap[$id]; - } elseif (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { + } elseif (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')) { // $method is set to the right value, proceed } else { if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { @@ -339,7 +338,9 @@ class Container implements IntrospectableContainerInterface */ public function initialized($id) { - return array_key_exists(strtolower($id), $this->services); + $id = strtolower($id); + + return isset($this->services[$id]) || array_key_exists($id, $this->services); } /** @@ -524,7 +525,7 @@ class Container implements IntrospectableContainerInterface */ public static function camelize($id) { - return strtr(ucwords(strtr($id, array('_' => ' ', '.' => '_ '))), array(' ' => '')); + return strtr(ucwords(strtr($id, array('_' => ' ', '.' => '_ ', '\\' => '_ '))), array(' ' => '')); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerAwareTrait.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerAwareTrait.php new file mode 100644 index 000000000000..57280aad60da --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerAwareTrait.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection; + +/** + * ContainerAware trait. + * + * @author Fabien Potencier + */ +trait ContainerAwareTrait +{ + /** + * @var ContainerInterface + */ + protected $container; + + /** + * Sets the Container associated with this Controller. + * + * @param ContainerInterface $container A ContainerInterface instance + */ + public function setContainer(ContainerInterface $container = null) + { + $this->container = $container; + } +} 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 733d016d6608..0e07ec6b159b 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -24,6 +24,7 @@ use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Resource\ResourceInterface; use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface; use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator; +use Symfony\Component\ExpressionLanguage\Expression; /** * ContainerBuilder is a DI container that provides an API to easily describe services. @@ -78,6 +79,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ private $proxyInstantiator; + /** + * @var ExpressionLanguage|null + */ + private $expressionLanguage; + /** * Sets the track resources flag. * @@ -305,11 +311,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - $this->compiler->addPass($pass, $type); + $this->getCompiler()->addPass($pass, $type); $this->addObjectResource($pass); @@ -325,11 +327,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function getCompilerPassConfig() { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - return $this->compiler->getPassConfig(); + return $this->getCompiler()->getPassConfig(); } /** @@ -610,15 +608,17 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function compile() { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } + $compiler = $this->getCompiler(); if ($this->trackResources) { - foreach ($this->compiler->getPassConfig()->getPasses() as $pass) { + foreach ($compiler->getPassConfig()->getPasses() as $pass) { $this->addObjectResource($pass); } + } + $compiler->compile($this); + + if ($this->trackResources) { foreach ($this->definitions as $definition) { if ($definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) { $this->addClassResource(new \ReflectionClass($class)); @@ -626,8 +626,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } } - $this->compiler->compile($this); - $this->extensionConfigs = array(); parent::compile(); @@ -993,11 +991,12 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } /** - * Replaces service references by the real service instance. + * Replaces service references by the real service instance and evaluates expressions. * * @param mixed $value A value * - * @return mixed The same value with all service references replaced by the real service instances + * @return mixed The same value with all service references replaced by + * the real service instances and all expressions evaluated */ public function resolveServices($value) { @@ -1009,6 +1008,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface $value = $this->get((string) $value, $value->getInvalidBehavior()); } elseif ($value instanceof Definition) { $value = $this->createService($value, null); + } elseif ($value instanceof Expression) { + $value = $this->getExpressionLanguage()->evaluate($value, array('container' => $this)); } return $value; @@ -1159,4 +1160,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } } } + + private function getExpressionLanguage() + { + if (null === $this->expressionLanguage) { + if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); + } + $this->expressionLanguage = new ExpressionLanguage(); + } + + return $this->expressionLanguage; + } } 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 1168444389ef..428fee27c3a2 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Definition.php @@ -28,24 +28,24 @@ class Definition private $factoryClass; private $factoryMethod; private $factoryService; - private $scope; - private $properties; - private $calls; + private $scope = ContainerInterface::SCOPE_CONTAINER; + private $properties = array(); + private $calls = array(); private $configurator; - private $tags; - private $public; - private $synthetic; - private $abstract; - private $synchronized; - private $lazy; + private $tags = array(); + private $public = true; + private $synthetic = false; + private $abstract = false; + private $synchronized = false; + private $lazy = false; protected $arguments; /** * Constructor. * - * @param string $class The service class - * @param array $arguments An array of arguments to pass to the service constructor + * @param string|null $class The service class + * @param array $arguments An array of arguments to pass to the service constructor * * @api */ @@ -53,15 +53,6 @@ class Definition { $this->class = $class; $this->arguments = $arguments; - $this->calls = array(); - $this->scope = ContainerInterface::SCOPE_CONTAINER; - $this->tags = array(); - $this->public = true; - $this->synthetic = false; - $this->synchronized = false; - $this->lazy = false; - $this->abstract = false; - $this->properties = array(); } /** @@ -84,7 +75,7 @@ class Definition /** * Gets the factory class. * - * @return string The factory class name + * @return string|null The factory class name * * @api */ @@ -112,7 +103,7 @@ class Definition /** * Gets the factory method. * - * @return string The factory method name + * @return string|null The factory method name * * @api */ @@ -140,7 +131,7 @@ class Definition /** * Gets the factory service id. * - * @return string The factory service id + * @return string|null The factory service id * * @api */ @@ -168,7 +159,7 @@ class Definition /** * Gets the service class. * - * @return string The service class + * @return string|null The service class * * @api */ @@ -508,7 +499,7 @@ class Definition /** * Gets the file to require before creating the service. * - * @return string The full pathname to include + * @return string|null The full pathname to include * * @api */ @@ -704,7 +695,7 @@ class Definition /** * Gets the configurator to call after the service is fully initialized. * - * @return callable The PHP callable to call + * @return callable|null The PHP callable to call * * @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 1f72b8f16b2e..b7eed8c564d4 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -24,7 +24,7 @@ use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException; class DefinitionDecorator extends Definition { private $parent; - private $changes; + private $changes = array(); /** * Constructor. @@ -38,7 +38,6 @@ class DefinitionDecorator extends Definition parent::__construct(); $this->parent = $parent; - $this->changes = array(); } /** 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 8888d3f3f433..7be1fe2ece19 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 @@ -23,6 +23,8 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as ProxyDumper; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper; +use Symfony\Component\DependencyInjection\ExpressionLanguage; +use Symfony\Component\ExpressionLanguage\Expression; /** * PhpDumper dumps a service container as a PHP class. @@ -51,6 +53,7 @@ class PhpDumper extends Dumper private $referenceVariables; private $variableCount; private $reservedVariables = array('instance', 'class'); + private $expressionLanguage; /** * @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface @@ -86,6 +89,7 @@ class PhpDumper extends Dumper * * * class: The class name * * base_class: The base class name + * * namespace: The class namespace * * @param array $options An array of options * @@ -98,9 +102,10 @@ class PhpDumper extends Dumper $options = array_merge(array( 'class' => 'ProjectServiceContainer', 'base_class' => 'Container', + 'namespace' => '', ), $options); - $code = $this->startClass($options['class'], $options['base_class']); + $code = $this->startClass($options['class'], $options['base_class'], $options['namespace']); if ($this->container->isFrozen()) { $code .= $this->addFrozenConstructor(); @@ -188,7 +193,7 @@ class PhpDumper extends Dumper */ private function addProxyClasses() { - /* @var $proxyDefinitions Definition[] */ + /* @var $definitions Definition[] */ $definitions = array_filter( $this->container->getDefinitions(), array($this->getProxyDumper(), 'isProxyCandidate') @@ -441,6 +446,12 @@ class PhpDumper extends Dumper continue; } + // if the instance is simple, the return statement has already been generated + // so, the only possible way to get there is because of a circular reference + if ($this->isSimpleInstance($id, $definition)) { + throw new ServiceCircularReferenceException($id, array($id)); + } + $name = (string) $this->definitionVariables->offsetGet($iDefinition); $code .= $this->addServiceMethodCalls(null, $iDefinition, $name); $code .= $this->addServiceProperties(null, $iDefinition, $name); @@ -700,24 +711,24 @@ EOF; * * @param string $class Class name * @param string $baseClass The name of the base class + * @param string $namespace The class namespace * * @return string */ - private function startClass($class, $baseClass) + private function startClass($class, $baseClass, $namespace) { $bagClass = $this->container->isFrozen() ? 'use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;' : 'use Symfony\Component\DependencyInjection\ParameterBag\\ParameterBag;'; + $namespaceLine = $namespace ? "namespace $namespace;\n" : ''; return <<getClass(), $path.'/'.$key)); } elseif ($value instanceof Reference) { throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain references to other services (reference to service "%s" found in "%s").', $value, $path.'/'.$key)); + } elseif ($value instanceof Expression) { + throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain expressions. Expression "%s" found in "%s".', $value, $path.'/'.$key)); } else { $value = var_export($value, true); } @@ -1105,7 +1118,7 @@ EOF; * * @return Boolean */ - private function hasReference($id, array $arguments, $deep = false, $visited = array()) + private function hasReference($id, array $arguments, $deep = false, array $visited = array()) { foreach ($arguments as $argument) { if (is_array($argument)) { @@ -1113,14 +1126,15 @@ EOF; return true; } } elseif ($argument instanceof Reference) { - if ($id === (string) $argument) { + $argumentId = (string) $argument; + if ($id === $argumentId) { return true; } - if ($deep && !isset($visited[(string) $argument])) { - $visited[(string) $argument] = true; + if ($deep && !isset($visited[$argumentId])) { + $visited[$argumentId] = true; - $service = $this->container->getDefinition((string) $argument); + $service = $this->container->getDefinition($argumentId); $arguments = array_merge($service->getMethodCalls(), $service->getArguments(), $service->getProperties()); if ($this->hasReference($id, $arguments, $deep, $visited)) { @@ -1192,6 +1206,8 @@ EOF; } return $this->getServiceCall((string) $value, $value); + } elseif ($value instanceof Expression) { + return $this->getExpressionLanguage()->compile((string) $value, array('container')); } elseif ($value instanceof Parameter) { return $this->dumpParameter($value); } elseif (true === $interpolate && is_string($value)) { @@ -1314,4 +1330,16 @@ EOF; return $name; } } + + private function getExpressionLanguage() + { + if (null === $this->expressionLanguage) { + if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); + } + $this->expressionLanguage = new ExpressionLanguage(); + } + + return $this->expressionLanguage; + } } 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 a311af348e34..31bec31b2245 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 @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\ExpressionLanguage\Expression; /** * XmlDumper dumps a service container as an XML string. @@ -259,6 +260,10 @@ class XmlDumper extends Dumper } elseif ($value instanceof Definition) { $element->setAttribute('type', 'service'); $this->addService($value, null, $element); + } elseif ($value instanceof Expression) { + $element->setAttribute('type', 'expression'); + $text = $this->document->createTextNode(self::phpToXml((string) $value)); + $element->appendChild($text); } else { if (in_array($value, array('null', 'true', 'false'), true)) { $element->setAttribute('type', 'string'); 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 807e656283b5..b4748545dc2a 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 @@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\ExpressionLanguage\Expression; /** * YamlDumper dumps a service container as a YAML string. @@ -74,6 +75,10 @@ class YamlDumper extends Dumper $code .= sprintf(" class: %s\n", $definition->getClass()); } + if (!$definition->isPublic()) { + $code .= " public: false\n"; + } + $tagsCode = ''; foreach ($definition->getTags() as $name => $tags) { foreach ($tags as $attributes) { @@ -231,6 +236,8 @@ class YamlDumper extends Dumper return $this->getServiceCall((string) $value, $value); } elseif ($value instanceof Parameter) { return $this->getParameterCall((string) $value); + } elseif ($value instanceof Expression) { + return $this->getExpressionCall((string) $value); } elseif (is_object($value) || is_resource($value)) { throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); } @@ -267,6 +274,11 @@ class YamlDumper extends Dumper return sprintf('%%%s%%', $id); } + private function getExpressionCall($expression) + { + return sprintf('@=%s', $expression); + } + /** * Prepares parameters. * diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ExpressionLanguage.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ExpressionLanguage.php new file mode 100644 index 000000000000..2e7edcd32f62 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ExpressionLanguage.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection; + +use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage; + +/** + * Adds some function to the default ExpressionLanguage. + * + * To get a service, use service('request'). + * To get a parameter, use parameter('kernel.debug'). + * + * @author Fabien Potencier + */ +class ExpressionLanguage extends BaseExpressionLanguage +{ + protected function registerFunctions() + { + parent::registerFunctions(); + + $this->register('service', function ($arg) { + return sprintf('$this->get(%s)', $arg); + }, function (array $variables, $value) { + return $variables['container']->get($value); + }); + + $this->register('parameter', function ($arg) { + return sprintf('$this->getParameter(%s)', $arg); + }, function (array $variables, $value) { + return $variables['container']->getParameter($value); + }); + } +} diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php index fc015e1459b4..424f02088e31 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php @@ -28,7 +28,7 @@ interface ExtensionInterface * @param array $config An array of configuration values * @param ContainerBuilder $container A ContainerBuilder instance * - * @throws InvalidArgumentException When provided tag is not defined in this extension + * @throws \InvalidArgumentException When provided tag is not defined in this extension * * @api */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php index 475d26f3a1c6..878d965b1c39 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php @@ -14,7 +14,7 @@ namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper; use Symfony\Component\DependencyInjection\Definition; /** - * Lazy proxy dumper capable of generating the instantiation logic php code for proxied services. + * Lazy proxy dumper capable of generating the instantiation logic PHP code for proxied services. * * @author Marco Pivetta */ 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 f2bf441d25fb..e866a29f7067 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 @@ -17,7 +17,7 @@ use Symfony\Component\Config\Resource\FileResource; * PhpFileLoader loads service definitions from a PHP file. * * The PHP file is required and the $container variable can be - * used form the file to change the container. + * used within the file to change the container. * * @author Fabien Potencier */ 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 9f25ab7683cd..9b2d46d28ef2 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 @@ -187,6 +187,10 @@ class XmlFileLoader extends FileLoader continue; } + if (false !== strpos($name, '-') && false === strpos($name, '_') && !array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) { + $parameters[$normalizedName] = SimpleXMLElement::phpize($value); + } + // keep not normalized key for BC too $parameters[$name] = SimpleXMLElement::phpize($value); } @@ -233,10 +237,11 @@ class XmlFileLoader extends FileLoader if (false !== $nodes = $xml->xpath('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]')) { foreach ($nodes as $node) { // give it a unique name - $node['id'] = sprintf('%s_%d', md5($file), ++$count); + $id = sprintf('%s_%d', hash('sha256', $file), ++$count); + $node['id'] = $id; - $definitions[(string) $node['id']] = array($node->service, $file, false); - $node->service['id'] = (string) $node['id']; + $definitions[$id] = array($node->service, $file, false); + $node->service['id'] = $id; } } @@ -244,10 +249,11 @@ class XmlFileLoader extends FileLoader if (false !== $nodes = $xml->xpath('//container:services/container:service[not(@id)]')) { foreach ($nodes as $node) { // give it a unique name - $node['id'] = sprintf('%s_%d', md5($file), ++$count); + $id = sprintf('%s_%d', hash('sha256', $file), ++$count); + $node['id'] = $id; - $definitions[(string) $node['id']] = array($node, $file, true); - $node->service['id'] = (string) $node['id']; + $definitions[$id] = array($node, $file, true); + $node->service['id'] = $id; } } 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 ce135fa81f92..e081be5c2abd 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 @@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Yaml\Parser as YamlParser; +use Symfony\Component\ExpressionLanguage\Expression; /** * YamlFileLoader loads YAML files service definitions. @@ -224,8 +225,8 @@ class YamlFileLoader extends FileLoader unset($tag['name']); foreach ($tag as $attribute => $value) { - if (!is_scalar($value)) { - throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s" in %s.', $id, $name, $file)); + 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)); } } @@ -311,6 +312,8 @@ class YamlFileLoader extends FileLoader { if (is_array($value)) { $value = array_map(array($this, 'resolveServices'), $value); + } elseif (is_string($value) && 0 === strpos($value, '@=')) { + return new Expression(substr($value, 2)); } elseif (is_string($value) && 0 === strpos($value, '@')) { if (0 === strpos($value, '@@')) { $value = substr($value, 1); 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 f1c2003c6225..f7b578767bb5 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 @@ -121,10 +121,12 @@ + + @@ -164,6 +166,7 @@ + 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 494d231e9f29..dabd1c621567 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 @@ -24,8 +24,8 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; */ class ParameterBag implements ParameterBagInterface { - protected $parameters; - protected $resolved; + protected $parameters = array(); + protected $resolved = false; /** * Constructor. @@ -36,9 +36,7 @@ class ParameterBag implements ParameterBagInterface */ public function __construct(array $parameters = array()) { - $this->parameters = array(); $this->add($parameters); - $this->resolved = false; } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md index ab6759524040..29d1cd0aa0c5 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md @@ -69,5 +69,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/DependencyInjection/ - $ composer.phar install --dev + $ composer.phar install $ phpunit 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 1517da29885a..725747055c1d 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Reference.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Reference.php @@ -47,7 +47,7 @@ class Reference */ public function __toString() { - return (string) $this->id; + return $this->id; } /** 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 cc5e31198715..db855f66d1e8 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/SimpleXMLElement.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/SimpleXMLElement.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection; use Symfony\Component\Config\Util\XmlUtils; +use Symfony\Component\ExpressionLanguage\Expression; /** * SimpleXMLElement class. @@ -21,7 +22,7 @@ use Symfony\Component\Config\Util\XmlUtils; class SimpleXMLElement extends \SimpleXMLElement { /** - * Converts an attribute as a php type. + * Converts an attribute as a PHP type. * * @param string $name * @@ -33,7 +34,7 @@ class SimpleXMLElement extends \SimpleXMLElement } /** - * Returns arguments as valid php types. + * Returns arguments as valid PHP types. * * @param string $name * @param Boolean $lowercase @@ -77,6 +78,9 @@ class SimpleXMLElement extends \SimpleXMLElement $arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict); break; + case 'expression': + $arguments[$key] = new Expression((string) $arg); + break; case 'collection': $arguments[$key] = $arg->getArgumentsAsPhp($name, false); break; @@ -95,7 +99,7 @@ class SimpleXMLElement extends \SimpleXMLElement } /** - * Converts an xml value to a php type. + * Converts an xml value to a PHP type. * * @param mixed $value * diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php index 06845a2b86d3..b5e49842e7af 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException */ public function testProcessDetectsSyntheticNonPublicDefinitions() { @@ -29,7 +29,7 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException */ public function testProcessDetectsSyntheticPrototypeDefinitions() { @@ -40,7 +40,7 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \RuntimeException + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException */ public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass() { @@ -61,6 +61,28 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase $this->process($container); } + public function testValidTags() + { + $container = new ContainerBuilder(); + $container->register('a', 'class')->addTag('foo', array('bar' => 'baz')); + $container->register('b', 'class')->addTag('foo', array('bar' => null)); + $container->register('c', 'class')->addTag('foo', array('bar' => 1)); + $container->register('d', 'class')->addTag('foo', array('bar' => 1.1)); + + $this->process($container); + } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + */ + public function testInvalidTags() + { + $container = new ContainerBuilder(); + $container->register('a', 'class')->addTag('foo', array('bar' => array('baz' => 'baz'))); + + $this->process($container); + } + protected function process(ContainerBuilder $container) { $pass = new CheckDefinitionValidityPass(); diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php index f22f0da9f877..6458a335d891 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php @@ -12,10 +12,8 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use Symfony\Component\DependencyInjection\Scope; - use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; -use Symfony\Component\DependencyInjection\Compiler\Compiler; use Symfony\Component\DependencyInjection\Compiler\RepeatedPass; use Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass; use Symfony\Component\DependencyInjection\Reference; @@ -126,6 +124,41 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase $this->assertTrue($container->hasDefinition('a')); } + public function testProcessDoesNotInlineWhenServiceIsPrivateButLazy() + { + $container = new ContainerBuilder(); + $container + ->register('foo') + ->setPublic(false) + ->setLazy(true) + ; + + $container + ->register('service') + ->setArguments(array($ref = new Reference('foo'))) + ; + + $this->process($container); + + $arguments = $container->getDefinition('service')->getArguments(); + $this->assertSame($ref, $arguments[0]); + } + + public function testProcessDoesNotInlineWhenServiceReferencesItself() + { + $container = new ContainerBuilder(); + $container + ->register('foo') + ->setPublic(false) + ->addMethodCall('foo', array($ref = new Reference('foo'))) + ; + + $this->process($container); + + $calls = $container->getDefinition('foo')->getMethodCalls(); + $this->assertSame($ref, $calls[0][1][0]); + } + protected function process(ContainerBuilder $container) { $repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass())); 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 a5e7531b68af..dd08c97c114e 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,10 +21,12 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\ExpressionLanguage\Expression; class ContainerBuilderTest extends \PHPUnit_Framework_TestCase { @@ -377,6 +379,15 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $builder->get('foo'); } + 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")'))); + $this->assertEquals('foobar', $builder->get('foo')->arguments['foo']); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices */ @@ -386,6 +397,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $builder->register('foo', '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'); } /** @@ -403,7 +415,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $container->setResourceTracking(false); $config = new ContainerBuilder(new ParameterBag(array('foo' => '%bar%'))); $container->merge($config); -////// FIXME $container->compile(); $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo'), $container->getParameterBag()->all(), '->merge() evaluates the values of the parameters towards already defined ones'); @@ -411,7 +422,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $container->setResourceTracking(false); $config = new ContainerBuilder(new ParameterBag(array('foo' => '%bar%', 'baz' => '%foo%'))); $container->merge($config); -////// FIXME $container->compile(); $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), $container->getParameterBag()->all(), '->merge() evaluates the values of the parameters towards already defined ones'); @@ -439,7 +449,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::merge - * @expectedException LogicException + * @expectedException \LogicException */ public function testMergeLogicException() { @@ -487,10 +497,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase */ public function testAddObjectResource() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $container = new ContainerBuilder(); $container->setResourceTracking(false); @@ -517,10 +523,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase */ public function testAddClassResource() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $container = new ContainerBuilder(); $container->setResourceTracking(false); @@ -547,10 +549,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase */ public function testCompilesClassDefinitionsOfLazyServices() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $container = new ContainerBuilder(); $this->assertEmpty($container->getResources(), 'No resources get registered without resource tracking'); @@ -577,10 +575,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase */ public function testResources() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $container = new ContainerBuilder(); $container->addResource($a = new FileResource(__DIR__.'/Fixtures/xml/services1.xml')); $container->addResource($b = new FileResource(__DIR__.'/Fixtures/xml/services2.xml')); @@ -655,7 +649,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException BadMethodCallException + * @expectedException \BadMethodCallException */ public function testThrowsExceptionWhenSetServiceOnAFrozenContainer() { @@ -667,14 +661,10 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException BadMethodCallException + * @expectedException \BadMethodCallException */ public function testThrowsExceptionWhenAddServiceOnAFrozenContainer() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $container = new ContainerBuilder(); $container->compile(); $container->set('a', new \stdClass()); @@ -682,10 +672,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase public function testNoExceptionWhenSetSyntheticServiceOnAFrozenContainer() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $container = new ContainerBuilder(); $def = new Definition('stdClass'); $def->setSynthetic(true); @@ -742,7 +728,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException BadMethodCallException + * @expectedException \BadMethodCallException */ public function testThrowsExceptionWhenSetDefinitionOnAFrozenContainer() { @@ -773,6 +759,39 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $configs = $container->getExtensionConfig('foo'); $this->assertEquals(array($second, $first), $configs); } + + public function testLazyLoadedService() + { + $loader = new ClosureLoader($container = new ContainerBuilder()); + $loader->load(function (ContainerBuilder $container) { + $container->set('a', new \BazClass()); + $definition = new Definition('BazClass'); + $definition->setLazy(true); + $container->setDefinition('a', $definition); + } + ); + + $container->setResourceTracking(true); + + $container->compile(); + + $class = new \BazClass(); + $reflectionClass = new \ReflectionClass($class); + + $r = new \ReflectionProperty($container, 'resources'); + $r->setAccessible(true); + $resources = $r->getValue($container); + + $classInList = false; + foreach ($resources as $resource) { + if ($resource->getResource() === $reflectionClass->getFileName()) { + $classInList = true; + break; + } + } + + $this->assertEquals(true, $classInList); + } } class FooClass {} 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 6c49982bea6c..e145c7a10c1a 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 @@ -51,6 +51,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase array('.foo', '_Foo'), array('foo_', 'Foo'), array('foo.', 'Foo_'), + array('foo\bar', 'Foo_Bar'), ); } @@ -187,6 +188,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($sc->__bar, $sc->get('bar'), '->get() returns the service for the given id'); $this->assertEquals($sc->__foo_bar, $sc->get('foo_bar'), '->get() returns the service if a get*Method() is defined'); $this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined'); + $this->assertEquals($sc->__foo_baz, $sc->get('foo\\baz'), '->get() returns the service if a get*Method() is defined'); $sc->set('bar', $bar = new \stdClass()); $this->assertEquals($bar, $sc->get('bar'), '->get() prefers to return a service defined with set() than one defined with a getXXXMethod()'); @@ -258,6 +260,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined'); $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined'); $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined'); + $this->assertTrue($sc->has('foo\\baz'), '->has() returns true if a get*Method() is defined'); } /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php index 3464a6af3c66..692d73dbcdc2 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php @@ -18,13 +18,6 @@ class CrossCheckTest extends \PHPUnit_Framework_TestCase { protected static $fixturesPath; - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - public static function setUpBeforeClass() { self::$fixturesPath = __DIR__.'/Fixtures/'; diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php index 8be8b64230ef..a266e9b31a4e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php @@ -81,7 +81,7 @@ class DefinitionDecoratorTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testReplaceArgumentShouldRequireIntegerIndex() { @@ -106,7 +106,7 @@ class DefinitionDecoratorTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException OutOfBoundsException + * @expectedException \OutOfBoundsException */ public function testGetArgumentShouldCheckBounds() { 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 d41c6a8e2b2a..4ffd7c079267 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 @@ -275,7 +275,7 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException OutOfBoundsException + * @expectedException \OutOfBoundsException */ public function testGetArgumentShouldCheckBounds() { @@ -286,7 +286,7 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException OutOfBoundsException + * @expectedException \OutOfBoundsException */ public function testReplaceArgumentShouldCheckBounds() { 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 8bd31b076c39..98b05d2501ee 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 @@ -31,7 +31,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $dumper = new PhpDumper($container = new ContainerBuilder()); $this->assertStringEqualsFile(self::$fixturesPath.'/php/services1.php', $dumper->dump(), '->dump() dumps an empty container as an empty PHP class'); - $this->assertStringEqualsFile(self::$fixturesPath.'/php/services1-1.php', $dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer')), '->dump() takes a class and a base_class options'); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/services1-1.php', $dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer', 'namespace' => 'Symfony\Component\DependencyInjection\Dump')), '->dump() takes a class and a base_class options'); $container = new ContainerBuilder(); new PhpDumper($container); @@ -81,7 +81,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testExportParameters() { @@ -121,7 +121,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException * @expectedExceptionMessage Service id "bar$" cannot be converted to a valid PHP method name. */ public function testAddServiceInvalidServiceId() @@ -181,4 +181,19 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $this->assertSame($bar, $container->get('foo')->bar, '->set() overrides an already defined service'); } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + */ + public function testCircularReference() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass')->addArgument(new Reference('bar')); + $container->register('bar', 'stdClass')->setPublic(false)->addMethodCall('setA', array(new Reference('baz'))); + $container->register('baz', 'stdClass')->addMethodCall('setA', array(new Reference('foo'))); + $container->compile(); + + $dumper = new PhpDumper($container); + $dumper->dump(); + } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index ca7aec054e48..f9747a7c2fae 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -18,13 +18,6 @@ class YamlDumperTest extends \PHPUnit_Framework_TestCase { protected static $fixturesPath; - protected function setUp() - { - if (!class_exists('Symfony\Component\Yaml\Yaml')) { - $this->markTestSkipped('The "Yaml" component is not available'); - } - } - public static function setUpBeforeClass() { self::$fixturesPath = realpath(__DIR__.'/../Fixtures/'); 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 6abe5e2a917f..19882c0211c3 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 @@ -6,6 +6,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Parameter; +use Symfony\Component\ExpressionLanguage\Expression; $container = new ContainerBuilder(); $container-> @@ -15,7 +16,7 @@ $container-> setFactoryClass('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')))-> + setProperties(array('foo' => 'bar', 'moo' => new Reference('foo.baz'), 'qux' => array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%')))-> addMethodCall('setBar', array(new Reference('bar')))-> addMethodCall('initialize')-> setConfigurator('sc_configure') @@ -50,7 +51,8 @@ $container-> 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 Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))-> + addMethodCall('setBar', array(new Expression('service("foo").foo() ~ parameter("foo")'))) ; $container-> register('factory_service', 'Bar')-> diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php index 48e1c2c84e12..70c3d275b889 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php @@ -8,6 +8,7 @@ function sc_configure($instance) class BarClass { protected $baz; + public $foo = 'foo'; public function setBaz(BazClass $baz) { diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index bc093efe7b77..084e7891af90 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -6,8 +6,6 @@ use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** 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 8796df8ae539..d1f9c0d1664c 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 @@ -6,8 +6,6 @@ use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; /** diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 77712e8297d1..f922d2000c7e 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -6,8 +6,6 @@ use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** 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 9361a0e87c5a..3fafcf175735 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 @@ -6,8 +6,6 @@ use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** @@ -125,6 +123,7 @@ class ProjectServiceContainer extends Container $instance->initialize(); $instance->foo = 'bar'; $instance->moo = $a; + $instance->qux = array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')); sc_configure($instance); return $instance; @@ -198,6 +197,7 @@ class ProjectServiceContainer extends Container if ($this->has('foobaz')) { $instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)); } + $instance->setBar(($this->get("foo")->foo() . $this->getParameter("foo"))); return $instance; } 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 b60cbff8e8bb..c4b8e47586f9 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 @@ -6,8 +6,6 @@ use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Parameter; use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; /** @@ -133,6 +131,7 @@ class ProjectServiceContainer extends Container $instance->initialize(); $instance->foo = 'bar'; $instance->moo = $a; + $instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar'); sc_configure($instance); return $instance; @@ -203,6 +202,7 @@ class ProjectServiceContainer extends Container $instance->setBar($this->get('foo')); $instance->setBar(NULL); + $instance->setBar(($this->get("foo")->foo() . $this->getParameter("foo"))); return $instance; } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml new file mode 100644 index 000000000000..a4da1bf74cf7 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services10.xml @@ -0,0 +1,16 @@ + + + + + + + + + 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 6e8a6ce364dc..43cf86c54751 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 @@ -27,5 +27,6 @@ value + PHP_EOL 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 abd9fbc1529b..ffc038234fae 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 @@ -32,6 +32,9 @@ + + service("foo").foo() ~ parameter("foo") + 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 cb3a1f69ded5..e53b03ed7091 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 @@ -19,6 +19,10 @@ bar + + foo is %foo% + %foo% + @@ -49,6 +53,9 @@ + + service("foo").foo() ~ parameter("foo") + diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag3.yml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag3.yml index 8137fab63fc0..72ec4e8f0bc6 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag3.yml +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag3.yml @@ -3,4 +3,4 @@ services: class: FooClass tags: # tag-attribute is not a scalar - - { name: foo, foo: { foo: foo, bar: bar } } + - { name: foo, bar: { foo: foo, bar: bar } } 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 7ba9453bdd6d..d3c793f2e31c 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,6 +15,7 @@ services: calls: - [ setBar, [] ] - [ setBar ] + - [ setBar, ['@=service("foo").foo() ~ parameter("foo")'] ] method_call2: class: FooClass calls: 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 6a4c3d5d97a0..6de64ee46396 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 @@ -12,7 +12,7 @@ services: factory_class: FooClass factory_method: getInstance arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', foobar: '%foo%' }, true, '@service_container'] - properties: { foo: bar, moo: '@foo.baz' } + properties: { foo: bar, moo: '@foo.baz', qux: { '%foo%': 'foo is %foo%', foobar: '%foo%' } } calls: - [setBar, ['@bar']] - [initialize, { }] @@ -38,6 +38,7 @@ services: - [setBar, ['@?foo2']] - [setBar, ['@?foo3']] - [setBar, ['@?foobaz']] + - [setBar, ['@=service("foo").foo() ~ parameter("foo")']] factory_service: class: Bar @@ -50,6 +51,7 @@ services: inlined: class: Bar + public: false properties: { pub: pub } calls: - [setBaz, ['@baz']] diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php index 33594d640cf6..483e30b78b81 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/ClosureLoaderTest.php @@ -16,13 +16,6 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader; class ClosureLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - /** * @covers Symfony\Component\DependencyInjection\Loader\ClosureLoader::supports */ diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 220ad7fe4d87..b9f402b70189 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -29,10 +29,6 @@ class IniFileLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $this->container = new ContainerBuilder(); $this->loader = new IniFileLoader($this->container, new FileLocator(self::$fixturesPath.'/ini')); } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php index 3a97dc27da5e..505f710cbeb1 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php @@ -18,13 +18,6 @@ use Symfony\Component\Config\FileLocator; class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - /** * @covers Symfony\Component\DependencyInjection\Loader\PhpFileLoader::supports */ 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 d8138f947541..74db3c8eff5d 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 @@ -22,18 +22,12 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\IniFileLoader; use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\FileLocator; +use Symfony\Component\ExpressionLanguage\Expression; class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase { protected static $fixturesPath; - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - public static function setUpBeforeClass() { self::$fixturesPath = realpath(__DIR__.'/../Fixtures/'); @@ -99,17 +93,33 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $loader->load('services2.xml'); $actual = $container->getParameterBag()->all(); - $expected = array('a string', 'foo' => 'bar', 'values' => array(0, 'integer' => 4, 100 => null, 'true', true, false, 'on', 'off', 'float' => 1.3, 1000.3, 'a string', array('foo', 'bar')), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value')); + $expected = array( + 'a string', + 'foo' => 'bar', + 'values' => array( + 0, + 'integer' => 4, + 100 => null, + 'true', + true, + false, + 'on', + 'off', + 'float' => 1.3, + 1000.3, + 'a string', + array('foo', 'bar'), + ), + 'foo_bar' => new Reference('foo_bar'), + 'mixedcase' => array('MixedCaseKey' => 'value'), + 'constant' => PHP_EOL, + ); $this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones'); } public function testLoadImports() { - if (!class_exists('Symfony\Component\Yaml\Yaml')) { - $this->markTestSkipped('The "Yaml" component is not available'); - } - $container = new ContainerBuilder(); $resolver = new LoaderResolver(array( new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')), @@ -120,7 +130,30 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $loader->load('services4.xml'); $actual = $container->getParameterBag()->all(); - $expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true); + $expected = array( + 'a string', + 'foo' => 'bar', + 'values' => array( + 0, + 'integer' => 4, + 100 => null, + 'true', + true, + false, + 'on', + 'off', + 'float' => 1.3, + 1000.3, + '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 + ); $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); @@ -179,7 +212,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $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())), $services['method_call1']->getMethodCalls(), '->load() parses the method_call 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('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()); @@ -198,6 +231,29 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); } + public function testParsesTags() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('services10.xml'); + + $services = $container->findTaggedServiceIds('foo_tag'); + $this->assertCount(1, $services); + + foreach ($services as $id => $tagAttributes) { + foreach ($tagAttributes as $attributes) { + $this->assertArrayHasKey('other_option', $attributes); + $this->assertEquals('lorem', $attributes['other_option']); + $this->assertArrayHasKey('other-option', $attributes, 'unnormalized tag attributes should not be removed'); + + $this->assertEquals('ciz', $attributes['some_option'], 'no overriding should be done when normalizing'); + $this->assertEquals('cat', $attributes['some-option']); + + $this->assertArrayNotHasKey('an_other_option', $attributes, 'normalization should not be done when an underscore is already found'); + } + } + } + public function testConvertDomElementToArray() { $doc = new \DOMDocument("1.0"); 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 e452e5d221d1..c7cb0cde5f01 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 @@ -20,22 +20,12 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\IniFileLoader; use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\FileLocator; +use Symfony\Component\ExpressionLanguage\Expression; class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase { protected static $fixturesPath; - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\Loader\Loader')) { - $this->markTestSkipped('The "Config" component is not available'); - } - - if (!class_exists('Symfony\Component\Yaml\Yaml')) { - $this->markTestSkipped('The "Yaml" component is not available'); - } - } - public static function setUpBeforeClass() { self::$fixturesPath = realpath(__DIR__.'/../Fixtures/'); @@ -124,7 +114,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $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())), $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() ~ parameter("foo")')))), $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()); @@ -209,7 +199,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->fail('->load() should throw an exception when a tag-attribute is not a scalar'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); - $this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service ', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); + $this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service "foo_service", tag "foo", attribute "bar"', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); } } } 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 2631da96df2f..1a29489d2baf 100644 --- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/composer.json @@ -20,7 +20,8 @@ }, "require-dev": { "symfony/yaml": "~2.0", - "symfony/config": "~2.2" + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4" }, "suggest": { "symfony/yaml": "", @@ -34,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/services10.xml b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/services10.xml new file mode 100644 index 000000000000..824d8b5d7539 --- /dev/null +++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/services10.xml @@ -0,0 +1,9 @@ + + + + + + + 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 42f09eaa5118..e25e7f1ebae4 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php @@ -76,6 +76,8 @@ class Event * * @param EventDispatcherInterface $dispatcher * + * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. + * * @api */ public function setDispatcher(EventDispatcherInterface $dispatcher) @@ -88,6 +90,8 @@ class Event * * @return EventDispatcherInterface * + * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. + * * @api */ public function getDispatcher() @@ -100,6 +104,8 @@ class Event * * @return string * + * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. + * * @api */ public function getName() @@ -112,6 +118,8 @@ class Event * * @param string $name The event name. * + * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. + * * @api */ public function setName($name) 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 eb1fb5949efb..ad48d4311d8e 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -154,14 +154,14 @@ class EventDispatcher implements EventDispatcherInterface * This method can be overridden to add functionality that is executed * for each listener. * - * @param array[callback] $listeners The event listeners. - * @param string $eventName The name of the event to dispatch. - * @param Event $event The event object to pass to the event handlers/listeners. + * @param callable[] $listeners The event listeners. + * @param string $eventName The name of the event to dispatch. + * @param Event $event The event object to pass to the event handlers/listeners. */ protected function doDispatch($listeners, $eventName, Event $event) { foreach ($listeners as $listener) { - call_user_func($listener, $event); + call_user_func($listener, $event, $eventName, $this); if ($event->isPropagationStopped()) { break; } 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 3a5efcfecc26..c226fdf2e599 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php @@ -21,7 +21,7 @@ namespace Symfony\Component\EventDispatcher; class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate { /** - * Observer pattern subject. + * Event subject. * * @var mixed usually object or callable */ diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md index 11f6b1888e39..22bf74fdc9d6 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md @@ -1,8 +1,8 @@ EventDispatcher Component ========================= -EventDispatcher implements a lightweight version of the Observer design -pattern. +The Symfony2 EventDispatcher component implements the Mediator pattern in a +simple and effective way to make your projects truly extensible. use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; @@ -21,5 +21,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/EventDispatcher/ - $ composer.phar install --dev + $ composer.phar install $ phpunit 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 71f3ad05215e..965a0c6bcfb5 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 @@ -19,13 +19,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - } - public function testAddAListenerService() { $event = new Event(); 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 ad7e4484541b..50af44549b0c 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 @@ -23,6 +23,9 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase const preBar = 'pre.bar'; const postBar = 'post.bar'; + /** + * @var EventDispatcher + */ private $dispatcher; private $listener; @@ -237,7 +240,6 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase public function testEventReceivesTheDispatcherInstance() { - $test = $this; $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) { $dispatcher = $event->getDispatcher(); }); @@ -245,6 +247,17 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->dispatcher, $dispatcher); } + public function testEventReceivesTheDispatcherInstanceAsArgument() + { + $listener = new TestWithDispatcher(); + $this->dispatcher->addListener('test', array($listener, 'foo')); + $this->assertNull($listener->name); + $this->assertNull($listener->dispatcher); + $this->dispatcher->dispatch('test'); + $this->assertEquals('test', $listener->name); + $this->assertSame($this->dispatcher, $listener->dispatcher); + } + /** * @see https://bugs.php.net/bug.php?id=62976 * @@ -257,7 +270,7 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase { $dispatcher = new EventDispatcher(); $dispatcher->addListener('bug.62976', new CallableClass()); - $dispatcher->removeListener('bug.62976', function() {}); + $dispatcher->removeListener('bug.62976', function () {}); $this->assertTrue($dispatcher->hasListeners('bug.62976')); } } @@ -289,6 +302,18 @@ class TestEventListener } } +class TestWithDispatcher +{ + public $name; + public $dispatcher; + + public function foo(Event $e, $name, $dispatcher) + { + $this->name = $name; + $this->dispatcher = $dispatcher; + } +} + class TestEventSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() diff --git a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php index 52aa9ad68a8f..7a20fe6bf3a4 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php @@ -35,7 +35,7 @@ class EventTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->event = new Event; + $this->event = new Event(); $this->dispatcher = new EventDispatcher(); } @@ -46,7 +46,7 @@ class EventTest extends \PHPUnit_Framework_TestCase protected function tearDown() { $this->event = null; - $this->eventDispatcher = null; + $this->dispatcher = null; } public function testIsPropagationStopped() 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 8dd6f5b419ac..c1e22f445136 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 @@ -33,7 +33,7 @@ class GenericEventTest extends \PHPUnit_Framework_TestCase { parent::setUp(); - $this->subject = new \StdClass(); + $this->subject = new \stdClass(); $this->event = new GenericEvent($this->subject, array('name' => 'Event'), 'foo'); } 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 1db2ecfd6c87..e748c506c188 100644 --- a/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json +++ b/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } 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 9d4c3132d32e..0cec4eda1317 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -90,7 +90,7 @@ class AcceptHeaderItem { $string = $this->value.($this->quality < 1 ? ';q='.$this->quality : ''); if (count($this->attributes) > 0) { - $string .= ';'.implode(';', array_map(function($name, $value) { + $string .= ';'.implode(';', array_map(function ($name, $value) { return sprintf(preg_match('/[,;=]/', $value) ? '%s="%s"' : '%s=%s', $name, $value); }, array_keys($this->attributes), $this->attributes)); } 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 06d530ddf833..4d2743580727 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -34,13 +34,13 @@ class BinaryFileResponse extends Response /** * Constructor. * - * @param SplFileInfo|string $file The file to stream - * @param integer $status The response status code - * @param array $headers An array of response headers - * @param boolean $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 \SplFileInfo|string $file The file to stream + * @param integer $status The response status code + * @param array $headers An array of response headers + * @param boolean $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 */ public function __construct($file, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { @@ -54,7 +54,13 @@ class BinaryFileResponse extends Response } /** - * {@inheritdoc} + * @param \SplFileInfo|string $file The file to stream + * @param integer $status The response status code + * @param array $headers An array of response headers + * @param boolean $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 */ public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { @@ -64,10 +70,10 @@ class BinaryFileResponse extends Response /** * Sets the file to stream. * - * @param SplFileInfo|string $file The file to stream - * @param string $contentDisposition - * @param Boolean $autoEtag - * @param Boolean $autoLastModified + * @param \SplFileInfo|string $file The file to stream + * @param string $contentDisposition + * @param Boolean $autoEtag + * @param Boolean $autoLastModified * * @return BinaryFileResponse * @@ -177,7 +183,7 @@ class BinaryFileResponse extends Response $path = $this->file->getRealPath(); if (strtolower($type) == 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. - foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { + foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); if (2 == count($mapping)) { @@ -210,14 +216,18 @@ class BinaryFileResponse extends Response $start = (int) $start; } - $start = max($start, 0); - $end = min($end, $fileSize - 1); + if ($start <= $end) { + if ($start < 0 || $end > $fileSize - 1) { + $this->setStatusCode(416); + } elseif ($start !== 0 || $end !== $fileSize - 1) { + $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; + $this->offset = $start; - $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; - $this->offset = $start; - - $this->setStatusCode(206); - $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); + $this->setStatusCode(206); + $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); + $this->headers->set('Content-Length', $end - $start + 1); + } + } } } 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 41e8eb2ec32a..061d47e7eec9 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,13 @@ CHANGELOG ========= +2.4.0 +----- + + * added RequestStack + * added Request::getEncodings() + * added accessors methods to session handlers + 2.3.0 ----- diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php new file mode 100644 index 000000000000..e9c8441ce314 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation; + +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; + +/** + * ExpressionRequestMatcher uses an expression to match a Request. + * + * @author Fabien Potencier + */ +class ExpressionRequestMatcher extends RequestMatcher +{ + private $language; + private $expression; + + public function setExpression(ExpressionLanguage $language, $expression) + { + $this->language = $language; + $this->expression = $expression; + } + + public function matches(Request $request) + { + if (!$this->language) { + throw new \LogicException('Unable to match the request as the expression language is not available.'); + } + + return $this->language->evaluate($this->expression, array( + 'request' => $request, + 'method' => $request->getMethod(), + 'path' => rawurldecode($request->getPathInfo()), + 'host' => $request->getHost(), + 'ip' => $request->getClientIp(), + 'attributes' => $request->attributes->all(), + )) && parent::matches($request); + } +} 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 9002b510851a..4fabfb910692 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 @@ -137,7 +137,7 @@ class File extends \SplFileInfo throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); } - $target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); + $target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); return new File($target, false); } 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 1f23c35c6b8b..16c4cdb65eda 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 @@ -252,7 +252,7 @@ class UploadedFile extends File return $target; } - throw new FileException($this->getErrorMessage($this->getError())); + throw new FileException($this->getErrorMessage()); } /** @@ -262,30 +262,37 @@ class UploadedFile extends File */ public static function getMaxFilesize() { - $max = strtolower(ini_get('upload_max_filesize')); + $iniMax = strtolower(ini_get('upload_max_filesize')); - if ('' === $max) { + if ('' === $iniMax) { return PHP_INT_MAX; } - if (preg_match('#^\+?(0x?)?(.*?)([kmg]?)$#', $max, $match)) { - $shifts = array('' => 0, 'k' => 10, 'm' => 20, 'g' => 30); - $bases = array('' => 10, '0' => 8, '0x' => 16); - - return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]]; + $max = ltrim($iniMax, '+'); + if (0 === strpos($max, '0x')) { + $max = intval($max, 16); + } elseif (0 === strpos($max, '0')) { + $max = intval($max, 8); + } else { + $max = intval($max); } - return 0; + switch (substr($iniMax, -1)) { + case 't': $max *= 1024; + case 'g': $max *= 1024; + case 'm': $max *= 1024; + case 'k': $max *= 1024; + } + + return $max; } /** * Returns an informative upload error message. * - * @param int $code The error code returned by an upload attempt - * * @return string The error message regarding the specified error code */ - private function getErrorMessage($errorCode) + public function getErrorMessage() { static $errors = array( UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d kb).', @@ -294,12 +301,13 @@ class UploadedFile extends File UPLOAD_ERR_NO_FILE => 'No file was uploaded.', UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.', UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.', - UPLOAD_ERR_EXTENSION => 'File upload was stopped by a php extension.', + UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.', ); + $errorCode = $this->error; $maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0; $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; - return sprintf($message, $this->getClientOriginalName(), $maxFilesize); + return sprintf($message, $this->getClientOriginalName(), $maxFilesize); } } 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 b579eb991a14..2b9ef0e443e1 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php @@ -20,8 +20,8 @@ namespace Symfony\Component\HttpFoundation; */ class HeaderBag implements \IteratorAggregate, \Countable { - protected $headers; - protected $cacheControl; + protected $headers = array(); + protected $cacheControl = array(); /** * Constructor. @@ -32,8 +32,6 @@ class HeaderBag implements \IteratorAggregate, \Countable */ public function __construct(array $headers = array()) { - $this->cacheControl = array(); - $this->headers = array(); foreach ($headers as $key => $values) { $this->set($key, $values); } 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 7c3742e768f9..98b848108cb5 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php @@ -24,10 +24,10 @@ class IpUtils private function __construct() {} /** - * Validates an IPv4 or IPv6 address. + * Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets * - * @param string $requestIp - * @param string|array $ips + * @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 */ @@ -49,10 +49,11 @@ class IpUtils } /** - * Validates an IPv4 address. + * Compares two IPv4 addresses. + * In case a subnet is given, it checks if it contains the request IP. * - * @param string $requestIp - * @param string $ip + * @param string $requestIp IPv4 address to check + * @param string $ip IPv4 address or subnet in CIDR notation * * @return boolean Whether the IP is valid */ @@ -73,13 +74,14 @@ class IpUtils } /** - * Validates an IPv6 address. + * Compares two IPv6 addresses. + * In case a subnet is given, it checks if it contains the request IP. * * @author David Soria Parra * @see https://github.com/dsp/v6tools * - * @param string $requestIp - * @param string $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 * 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 eafccaa844dc..6dfa75cd2ddc 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php @@ -55,11 +55,11 @@ class JsonResponse extends Response /** * Sets the JSONP callback. * - * @param string $callback + * @param string|null $callback The JSONP callback or null to use none * * @return JsonResponse * - * @throws \InvalidArgumentException + * @throws \InvalidArgumentException When the callback name is not valid */ public function setCallback($callback = null) { @@ -85,12 +85,18 @@ class JsonResponse extends Response * @param mixed $data * * @return JsonResponse + * + * @throws \InvalidArgumentException */ 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); + if (JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException($this->transformJsonError()); + } + return $this->update(); } @@ -116,4 +122,31 @@ class JsonResponse extends Response return $this->setContent($this->data); } + + private function transformJsonError() + { + if (function_exists('json_last_error_msg')) { + return json_last_error_msg(); + } + + switch (json_last_error()) { + case JSON_ERROR_DEPTH: + return 'Maximum stack depth exceeded.'; + + case JSON_ERROR_STATE_MISMATCH: + return 'Underflow or the modes mismatch.'; + + case JSON_ERROR_CTRL_CHAR: + return 'Unexpected control character found.'; + + case JSON_ERROR_SYNTAX: + return 'Syntax error, malformed JSON.'; + + case JSON_ERROR_UTF8: + return 'Malformed UTF-8 characters, possibly incorrectly encoded.'; + + default: + return 'Unknown error.'; + } + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php index c8720cdc12e2..a4ac98cffebf 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php @@ -266,7 +266,7 @@ class ParameterBag implements \IteratorAggregate, \Countable * * @return mixed */ - public function filter($key, $default = null, $deep = false, $filter=FILTER_DEFAULT, $options=array()) + public function filter($key, $default = null, $deep = false, $filter = FILTER_DEFAULT, $options = array()) { $value = $this->get($key, $default, $deep); diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md index ed49b4e15e41..ea6a790a641a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md @@ -44,5 +44,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/HttpFoundation/ - $ composer.phar install --dev + $ composer.phar install $ phpunit 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 54f57216b03a..fbf377bae02b 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -27,7 +27,7 @@ class RedirectResponse extends Response * * @param string $url The URL to redirect to * @param integer $status The status code (302 by default) - * @param array $headers The headers (Location is always set to the given url) + * @param array $headers The headers (Location is always set to the given URL) * * @throws \InvalidArgumentException * 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 4641eadab132..88a61b642dd8 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php @@ -64,6 +64,8 @@ class Request protected static $httpMethodParameterOverride = false; /** + * Custom parameters + * * @var \Symfony\Component\HttpFoundation\ParameterBag * * @api @@ -71,6 +73,8 @@ class Request public $attributes; /** + * Request body parameters ($_POST) + * * @var \Symfony\Component\HttpFoundation\ParameterBag * * @api @@ -78,6 +82,8 @@ class Request public $request; /** + * Query string parameters ($_GET) + * * @var \Symfony\Component\HttpFoundation\ParameterBag * * @api @@ -85,6 +91,8 @@ class Request public $query; /** + * Server and execution environment parameters ($_SERVER) + * * @var \Symfony\Component\HttpFoundation\ServerBag * * @api @@ -92,6 +100,8 @@ class Request public $server; /** + * Uploaded files ($_FILES) + * * @var \Symfony\Component\HttpFoundation\FileBag * * @api @@ -99,6 +109,8 @@ class Request public $files; /** + * Cookies ($_COOKIE) + * * @var \Symfony\Component\HttpFoundation\ParameterBag * * @api @@ -106,6 +118,8 @@ class Request public $cookies; /** + * Headers (taken from the $_SERVER) + * * @var \Symfony\Component\HttpFoundation\HeaderBag * * @api @@ -127,6 +141,11 @@ class Request */ protected $charsets; + /** + * @var array + */ + protected $encodings; + /** * @var array */ @@ -182,6 +201,8 @@ class Request */ protected static $formats; + protected static $requestFactory; + /** * Constructor. * @@ -228,6 +249,7 @@ class Request $this->content = $content; $this->languages = null; $this->charsets = null; + $this->encodings = null; $this->acceptableContentTypes = null; $this->pathInfo = null; $this->requestUri = null; @@ -246,7 +268,7 @@ class Request */ public static function createFromGlobals() { - $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER); + $request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER); if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH')) @@ -346,16 +368,39 @@ class Request break; } + $queryString = ''; if (isset($components['query'])) { parse_str(html_entity_decode($components['query']), $qs); - $query = array_replace($qs, $query); + + if ($query) { + $query = array_replace($qs, $query); + $queryString = http_build_query($query, '', '&'); + } else { + $query = $qs; + $queryString = $components['query']; + } + } elseif ($query) { + $queryString = http_build_query($query, '', '&'); } - $queryString = http_build_query($query, '', '&'); $server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : ''); $server['QUERY_STRING'] = $queryString; - return new static($query, $request, array(), $cookies, $files, $server, $content); + return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content); + } + + /** + * Sets a callable able to create a Request instance. + * + * This is mainly useful when you need to override the Request class + * to keep BC with an existing system. It should not be used for any + * other purpose. + * + * @param callable|null $callable A PHP callable + */ + public static function setFactory($callable) + { + self::$requestFactory = $callable; } /** @@ -396,6 +441,7 @@ class Request } $dup->languages = null; $dup->charsets = null; + $dup->encodings = null; $dup->acceptableContentTypes = null; $dup->pathInfo = null; $dup->requestUri = null; @@ -404,8 +450,12 @@ class Request $dup->method = null; $dup->format = null; - if (!$dup->get('_format')) { - $dup->setRequestFormat($this->getRequestFormat()); + if (!$dup->get('_format') && $this->get('_format')) { + $dup->attributes->set('_format', $this->get('_format')); + } + + if (!$dup->getRequestFormat(null)) { + $dup->setRequestFormat($format = $this->getRequestFormat(null)); } return $dup; @@ -467,7 +517,7 @@ class Request $request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE); - $requestOrder = ini_get('request_order') ?: ini_get('variable_order'); + $requestOrder = ini_get('request_order') ?: ini_get('variables_order'); $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp'; $_REQUEST = array(); @@ -719,9 +769,9 @@ class Request /** * Returns the client IP addresses. * - * The most trusted IP address is first, and the less trusted one last. - * The "real" client IP address is the last one, but this is also the - * less trusted one. + * In the returned array the most trusted IP address is first, and the + * least trusted one last. The "real" client IP address is the last one, + * but this is also the least trusted one. Trusted proxies are stripped. * * Use this method carefully; you should use getClientIp() instead. * @@ -742,19 +792,18 @@ class Request } $clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP]))); - $clientIps[] = $ip; + $clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from - $trustedProxies = !self::$trustedProxies ? array($ip) : self::$trustedProxies; - $ip = $clientIps[0]; + $ip = $clientIps[0]; // Fallback to this when the client IP falls into the range of trusted proxies + // Eliminate all IPs from the forwarded IP chain which are trusted proxies foreach ($clientIps as $key => $clientIp) { - if (IpUtils::checkIp($clientIp, $trustedProxies)) { + if (IpUtils::checkIp($clientIp, self::$trustedProxies)) { unset($clientIps[$key]); - - continue; } } + // Now the IP chain contains only untrusted proxies and the client IP return $clientIps ? array_reverse($clientIps) : array($ip); } @@ -846,14 +895,14 @@ class Request } /** - * Returns the root url from which this request is executed. + * Returns the root URL from which this request is executed. * * The base URL never ends with a /. * * This is similar to getBasePath(), except that it also includes the * script filename (e.g. index.php) if one exists. * - * @return string The raw url (i.e. not urldecoded) + * @return string The raw URL (i.e. not urldecoded) * * @api */ @@ -905,6 +954,14 @@ class Request } } + if ($host = $this->headers->get('HOST')) { + if (false !== $pos = strrpos($host, ':')) { + return intval(substr($host, $pos + 1)); + } + + return 'https' === $this->getScheme() ? 443 : 80; + } + return $this->server->get('SERVER_PORT'); } @@ -939,7 +996,7 @@ class Request $pass = $this->getPassword(); if ('' != $pass) { - $userinfo .= ":$pass"; + $userinfo .= ":$pass"; } return $userinfo; @@ -1063,7 +1120,7 @@ class Request public function isSecure() { if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) { - return in_array(strtolower($proto), array('https', 'on', '1')); + return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1')); } return 'on' == strtolower($this->server->get('HTTPS')) || 1 == $this->server->get('HTTPS'); @@ -1105,7 +1162,7 @@ class Request // 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)) { - throw new \UnexpectedValueException('Invalid Host "'.$host.'"'); + throw new \UnexpectedValueException(sprintf('Invalid Host "%s"', $host)); } if (count(self::$trustedHostPatterns) > 0) { @@ -1123,7 +1180,7 @@ class Request } } - throw new \UnexpectedValueException('Untrusted Host "'.$host.'"'); + throw new \UnexpectedValueException(sprintf('Untrusted Host "%s"', $host)); } return $host; @@ -1502,6 +1559,20 @@ class Request return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all()); } + /** + * Gets a list of encodings acceptable by the client browser. + * + * @return array List of encodings in preferable order + */ + public function getEncodings() + { + if (null !== $this->encodings) { + return $this->encodings; + } + + return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all()); + } + /** * Gets a list of content types acceptable by the client browser * @@ -1558,13 +1629,13 @@ class Request $requestUri = $this->headers->get('X_REWRITE_URL'); $this->headers->remove('X_REWRITE_URL'); } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') { - // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) + // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem) $requestUri = $this->server->get('UNENCODED_URL'); $this->server->remove('UNENCODED_URL'); $this->server->remove('IIS_WasUrlRewritten'); } elseif ($this->server->has('REQUEST_URI')) { $requestUri = $this->server->get('REQUEST_URI'); - // HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path + // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path $schemeAndHttpHost = $this->getSchemeAndHttpHost(); if (strpos($requestUri, $schemeAndHttpHost) === 0) { $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); @@ -1613,7 +1684,7 @@ class Request $seg = $segs[$index]; $baseUrl = '/'.$seg.$baseUrl; ++$index; - } while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos)); + } while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos); } // Does the baseUrl have anything in common with the request_uri? @@ -1630,7 +1701,7 @@ class Request } $truncatedRequestUri = $requestUri; - if (($pos = strpos($requestUri, '?')) !== false) { + if (false !== $pos = strpos($requestUri, '?')) { $truncatedRequestUri = substr($requestUri, 0, $pos); } @@ -1643,7 +1714,7 @@ class Request // If using mod_rewrite or ISAPI_Rewrite strip the script filename // out of baseUrl. $pos !== 0 makes sure it is not matching a value // from PATH_INFO or QUERY_STRING - if ((strlen($requestUri) >= strlen($baseUrl)) && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0))) { + if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && $pos !== 0) { $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); } @@ -1696,7 +1767,7 @@ class Request $requestUri = substr($requestUri, 0, $pos); } - if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) { + if (null !== $baseUrl && false === $pathInfo = substr($requestUri, strlen($baseUrl))) { // If substr() returns false then PATH_INFO is set to an empty string return '/'; } elseif (null === $baseUrl) { @@ -1765,4 +1836,19 @@ class Request return false; } + + private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) + { + if (self::$requestFactory) { + $request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content); + + if (!$request instanceof Request) { + throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.'); + } + + return $request; + } + + return new static($query, $request, $attributes, $cookies, $files, $server, $content); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php new file mode 100644 index 000000000000..4b0ef28deefd --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation; + +/** + * Request stack that controls the lifecycle of requests. + * + * @author Benjamin Eberlei + */ +class RequestStack +{ + /** + * @var Request[] + */ + private $requests = array(); + + /** + * Pushes a Request on the stack. + * + * This method should generally not be called directly as the stack + * management should be taken care of by the application itself. + */ + public function push(Request $request) + { + $this->requests[] = $request; + } + + /** + * Pops the current request from the stack. + * + * This operation lets the current request go out of scope. + * + * This method should generally not be called directly as the stack + * management should be taken care of by the application itself. + * + * @return Request|null + */ + public function pop() + { + if (!$this->requests) { + return null; + } + + return array_pop($this->requests); + } + + /** + * @return Request|null + */ + public function getCurrentRequest() + { + return end($this->requests) ?: null; + } + + /** + * Gets the master Request. + * + * Be warned that making your code aware of the master request + * might make it un-compatible with other features of your framework + * like ESI support. + * + * @return Request|null + */ + public function getMasterRequest() + { + if (!$this->requests) { + return null; + } + + return $this->requests[0]; + } + + /** + * Returns the parent request of the current. + * + * Be warned that making your code aware of the parent request + * might make it un-compatible with other features of your framework + * like ESI support. + * + * If current Request is the master request, it returns null. + * + * @return Request|null + */ + public function getParentRequest() + { + $pos = count($this->requests) - 2; + + if (!isset($this->requests[$pos])) { + return null; + } + + return $this->requests[$pos]; + } +} 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 25c49c9419d8..bc9a193c7dc2 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php @@ -20,6 +20,67 @@ namespace Symfony\Component\HttpFoundation; */ class Response { + const HTTP_CONTINUE = 100; + const HTTP_SWITCHING_PROTOCOLS = 101; + const HTTP_PROCESSING = 102; // RFC2518 + const HTTP_OK = 200; + const HTTP_CREATED = 201; + const HTTP_ACCEPTED = 202; + const HTTP_NON_AUTHORITATIVE_INFORMATION = 203; + const HTTP_NO_CONTENT = 204; + const HTTP_RESET_CONTENT = 205; + const HTTP_PARTIAL_CONTENT = 206; + const HTTP_MULTI_STATUS = 207; // RFC4918 + const HTTP_ALREADY_REPORTED = 208; // RFC5842 + const HTTP_IM_USED = 226; // RFC3229 + const HTTP_MULTIPLE_CHOICES = 300; + const HTTP_MOVED_PERMANENTLY = 301; + const HTTP_FOUND = 302; + const HTTP_SEE_OTHER = 303; + const HTTP_NOT_MODIFIED = 304; + 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_BAD_REQUEST = 400; + const HTTP_UNAUTHORIZED = 401; + const HTTP_PAYMENT_REQUIRED = 402; + const HTTP_FORBIDDEN = 403; + const HTTP_NOT_FOUND = 404; + const HTTP_METHOD_NOT_ALLOWED = 405; + const HTTP_NOT_ACCEPTABLE = 406; + const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; + const HTTP_REQUEST_TIMEOUT = 408; + const HTTP_CONFLICT = 409; + const HTTP_GONE = 410; + const HTTP_LENGTH_REQUIRED = 411; + const HTTP_PRECONDITION_FAILED = 412; + const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; + const HTTP_REQUEST_URI_TOO_LONG = 414; + const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; + const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; + const HTTP_EXPECTATION_FAILED = 417; + const HTTP_I_AM_A_TEAPOT = 418; // RFC2324 + const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918 + const HTTP_LOCKED = 423; // RFC4918 + const HTTP_FAILED_DEPENDENCY = 424; // RFC4918 + const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817 + const HTTP_UPGRADE_REQUIRED = 426; // RFC2817 + const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 + const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 + const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 + const HTTP_INTERNAL_SERVER_ERROR = 500; + const HTTP_NOT_IMPLEMENTED = 501; + const HTTP_BAD_GATEWAY = 502; + const HTTP_SERVICE_UNAVAILABLE = 503; + const HTTP_GATEWAY_TIMEOUT = 504; + const HTTP_VERSION_NOT_SUPPORTED = 505; + const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295 + const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918 + const HTTP_LOOP_DETECTED = 508; // RFC5842 + const HTTP_NOT_EXTENDED = 510; // RFC2774 + const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585 + /** * @var \Symfony\Component\HttpFoundation\ResponseHeaderBag */ @@ -127,7 +188,7 @@ class Response /** * Constructor. * - * @param string $content The response content + * @param mixed $content The response content, see setContent() * @param integer $status The response status code * @param array $headers An array of response headers * @@ -154,7 +215,7 @@ class Response * return Response::create($body, 200) * ->setSharedMaxAge(300); * - * @param string $content The response content + * @param mixed $content The response content, see setContent() * @param integer $status The response status code * @param array $headers An array of response headers * @@ -223,7 +284,7 @@ class Response $charset = $this->charset ?: 'UTF-8'; if (!$headers->has('Content-Type')) { $headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === strpos($headers->get('Content-Type'), 'text/') && false === strpos($headers->get('Content-Type'), '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); } @@ -271,12 +332,12 @@ class Response } // status - header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)); + header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode); // headers foreach ($this->headers->allPreserveCase() as $name => $values) { foreach ($values as $value) { - header($name.': '.$value, false); + header($name.': '.$value, false, $this->statusCode); } } @@ -342,9 +403,9 @@ class Response /** * Sets the response content. * - * Valid types are strings, numbers, and objects that implement a __toString() method. + * Valid types are strings, numbers, null, and objects that implement a __toString() method. * - * @param mixed $content + * @param mixed $content Content that can be cast to string * * @return Response * @@ -1181,7 +1242,7 @@ class Response } /** - * Check if we need to remove Cache-Control for ssl encrypted downloads when using IE < 9 + * Check 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 d7aadc6bb65f..de6dbc9fb533 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php @@ -64,11 +64,17 @@ class ServerBag extends ParameterBag $authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION']; } - // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic - if ((null !== $authorizationHeader) && (0 === stripos($authorizationHeader, 'basic'))) { - $exploded = explode(':', base64_decode(substr($authorizationHeader, 6))); - if (count($exploded) == 2) { - list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; + if (null !== $authorizationHeader) { + 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))); + 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'))) { + // In some circumstances PHP_AUTH_DIGEST needs to be set + $headers['PHP_AUTH_DIGEST'] = $authorizationHeader; + $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader; } } } @@ -76,6 +82,8 @@ class ServerBag extends ParameterBag // PHP_AUTH_USER/PHP_AUTH_PW if (isset($headers['PHP_AUTH_USER'])) { $headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']); + } elseif (isset($headers['PHP_AUTH_DIGEST'])) { + $headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST']; } return $headers; 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 e9d0257152ec..af416d6d3a4c 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 @@ -31,7 +31,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta /** * Constructor. * - * @param string $storageKey The key used to store attributes in the session. + * @param string $storageKey The key used to store attributes in the session */ public function __construct($storageKey = '_sf2_attributes') { @@ -148,7 +148,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta /** * Returns the number of attributes. * - * @return int The number of attributes + * @return integer 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 5f1f37be25c3..6356056eddde 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 @@ -33,7 +33,7 @@ interface AttributeBagInterface extends SessionBagInterface * Returns an attribute. * * @param string $name The attribute name - * @param mixed $default The default value if not found. + * @param mixed $default The default value if not found * * @return mixed */ @@ -66,7 +66,7 @@ interface AttributeBagInterface extends SessionBagInterface * * @param string $name * - * @return mixed The removed value + * @return mixed The removed value or null when it does not exist */ public function remove($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 c0dd358e8511..7cafb2241c83 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 @@ -149,8 +149,8 @@ class NamespacedAttributeBag extends AttributeBag */ protected function resolveKey($name) { - if (strpos($name, $this->namespaceCharacter) !== false) { - $name = substr($name, strrpos($name, $this->namespaceCharacter)+1, strlen($name)); + if (false !== $pos = strrpos($name, $this->namespaceCharacter)) { + $name = substr($name, $pos+1); } return $name; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php index c6e41de62e28..25a62604d260 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php @@ -25,7 +25,7 @@ class AutoExpireFlashBag implements FlashBagInterface * * @var array */ - private $flashes = array(); + private $flashes = array('display' => array(), 'new' => array()); /** * The storage key for flashes in the session @@ -42,7 +42,6 @@ class AutoExpireFlashBag implements FlashBagInterface public function __construct($storageKey = '_sf2_flashes') { $this->storageKey = $storageKey; - $this->flashes = array('display' => array(), 'new' => array()); } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index d62e3835abe0..2bd7786d7a91 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -14,6 +14,8 @@ namespace Symfony\Component\HttpFoundation\Session\Flash; /** * FlashBag flash message container. * + * \IteratorAggregate implementation is deprecated and will be removed in 3.0. + * * @author Drak */ class FlashBag implements FlashBagInterface, \IteratorAggregate @@ -76,7 +78,7 @@ class FlashBag implements FlashBagInterface, \IteratorAggregate /** * {@inheritdoc} */ - public function peek($type, array $default =array()) + public function peek($type, array $default = array()) { return $this->has($type) ? $this->flashes[$type] : $default; } @@ -167,6 +169,8 @@ class FlashBag implements FlashBagInterface, \IteratorAggregate /** * Returns an iterator for flashes. * + * @deprecated Will be removed in 3.0. + * * @return \ArrayIterator An \ArrayIterator instance */ public function getIterator() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php index 15df09770994..ac626fd58998 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php @@ -16,7 +16,6 @@ use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; /** 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 a94fad00d6f0..dc2f7bc4f339 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 @@ -163,7 +163,7 @@ interface SessionInterface * * @param string $name * - * @return mixed The removed value + * @return mixed The removed value or null when it does not exist * * @api */ 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 4a5e63989a46..b2384505ae60 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 @@ -106,4 +106,14 @@ class MemcacheSessionHandler implements \SessionHandlerInterface // not required here because memcache will auto expire the records anyhow. return true; } + + /** + * Return a Memcache instance + * + * @return \Memcache + */ + protected function getMemcache() + { + return $this->memcache; + } } 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 b3ca0bd3cdcf..ed7d6edf4b82 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 @@ -112,4 +112,14 @@ class MemcachedSessionHandler implements \SessionHandlerInterface // not required here because memcached will auto expire the records anyhow. return true; } + + /** + * Return a Memcached instance + * + * @return \Memcached + */ + protected function getMemcached() + { + return $this->memcached; + } } 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 69ebae9542cc..4d819fe3f8cc 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 @@ -160,4 +160,14 @@ class MongoDbSessionHandler implements \SessionHandlerInterface return $this->collection; } + + /** + * Return a Mongo instance + * + * @return \Mongo + */ + protected function getMongo() + { + return $this->mongo; + } } 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 347cbee706a0..baf8eea8f610 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 @@ -240,4 +240,14 @@ class PdoSessionHandler implements \SessionHandlerInterface return true; } + + /** + * Return a PDO instance + * + * @return \PDO + */ + protected function getConnection() + { + return $this->pdo; + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php new file mode 100644 index 000000000000..c43c9d05feb0 --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; + +/** + * Wraps another SessionHandlerInterface to only write the session when it has been modified. + * + * @author Adrien Brault + */ +class WriteCheckSessionHandler implements \SessionHandlerInterface +{ + /** + * @var \SessionHandlerInterface + */ + private $wrappedSessionHandler; + + /** + * @var array sessionId => session + */ + private $readSessions; + + public function __construct(\SessionHandlerInterface $wrappedSessionHandler) + { + $this->wrappedSessionHandler = $wrappedSessionHandler; + } + + /** + * {@inheritdoc} + */ + public function close() + { + return $this->wrappedSessionHandler->close(); + } + + /** + * {@inheritdoc} + */ + public function destroy($sessionId) + { + return $this->wrappedSessionHandler->destroy($sessionId); + } + + /** + * {@inheritdoc} + */ + public function gc($maxLifetime) + { + return $this->wrappedSessionHandler->gc($maxLifetime); + } + + /** + * {@inheritdoc} + */ + public function open($savePath, $sessionId) + { + return $this->wrappedSessionHandler->open($savePath, $sessionId); + } + + /** + * {@inheritdoc} + */ + public function read($sessionId) + { + $session = $this->wrappedSessionHandler->read($sessionId); + + $this->readSessions[$sessionId] = $session; + + return $session; + } + + /** + * {@inheritdoc} + */ + public function write($sessionId, $sessionData) + { + if (isset($this->readSessions[$sessionId]) && $sessionData === $this->readSessions[$sessionId]) { + return true; + } + + return $this->wrappedSessionHandler->write($sessionId, $sessionData); + } +} 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 892d004b5d61..44212979c307 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 @@ -39,7 +39,7 @@ class MetadataBag implements SessionBagInterface /** * @var array */ - protected $meta = array(); + protected $meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0); /** * Unix timestamp. @@ -48,15 +48,21 @@ class MetadataBag implements SessionBagInterface */ private $lastUsed; + /** + * @var integer + */ + private $updateThreshold; + /** * Constructor. * - * @param string $storageKey The key used to store bag in the session. + * @param string $storageKey The key used to store bag in the session. + * @param integer $updateThreshold The time to wait between two UPDATED updates */ - public function __construct($storageKey = '_sf2_meta') + public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0) { $this->storageKey = $storageKey; - $this->meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0); + $this->updateThreshold = $updateThreshold; } /** @@ -68,7 +74,11 @@ class MetadataBag implements SessionBagInterface if (isset($array[self::CREATED])) { $this->lastUsed = $this->meta[self::UPDATED]; - $this->meta[self::UPDATED] = time(); + + $timeStamp = time(); + if ($timeStamp - $array[self::UPDATED] >= $this->updateThreshold) { + $this->meta[self::UPDATED] = $timeStamp; + } } else { $this->stampCreated(); } 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 a1fcf539f8fd..8b1c2137f6a8 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 @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpFoundation\Session\Storage; use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; /** * MockArraySessionStorage mocks the session for unit tests. @@ -164,6 +163,7 @@ class MockArraySessionStorage implements SessionStorageInterface } // nothing to do since we don't persist the session data $this->closed = false; + $this->started = false; } /** @@ -249,7 +249,7 @@ class MockArraySessionStorage implements SessionStorageInterface */ protected function generateId() { - return sha1(uniqid(mt_rand())); + return hash('sha256', uniqid(mt_rand())); } protected function loadSession() 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 d86ff33d1db0..083df9de40f9 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 @@ -13,7 +13,6 @@ namespace Symfony\Component\HttpFoundation\Session\Storage; use Symfony\Component\HttpFoundation\Session\SessionBagInterface; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; @@ -163,7 +162,7 @@ class NativeSessionStorage implements SessionStorageInterface */ public function getId() { - if (!$this->started) { + if (!$this->started && !$this->closed) { return ''; // returning empty is consistent with session_id() behaviour } @@ -219,6 +218,8 @@ class NativeSessionStorage implements SessionStorageInterface } else { session_start(); } + + $this->loadSession(); } return $ret; @@ -237,6 +238,7 @@ class NativeSessionStorage implements SessionStorageInterface } $this->closed = true; + $this->started = false; } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php index 0f0020397ad5..f70b5e6227af 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpFoundation\Session\Storage; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; 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 711eaa29a312..74f19c5216dc 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 @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpFoundation\Session\Storage; use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; /** * StorageInterface. 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 ae579beaa954..d9fece658f49 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -34,9 +34,9 @@ class StreamedResponse extends Response /** * Constructor. * - * @param mixed $callback A valid PHP callback - * @param integer $status The response status code - * @param array $headers An array of response headers + * @param callable|null $callback A valid PHP callback or null to set it later + * @param integer $status The response status code + * @param array $headers An array of response headers * * @api */ @@ -51,7 +51,13 @@ class StreamedResponse extends Response } /** - * {@inheritDoc} + * 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 array $headers An array of response headers + * + * @return StreamedResponse */ public static function create($callback = null, $status = 200, $headers = array()) { @@ -61,7 +67,7 @@ class StreamedResponse extends Response /** * Sets the PHP callback associated with this Response. * - * @param mixed $callback A valid PHP callback + * @param callable $callback A valid PHP callback * * @throws \LogicException */ 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 c3d324fa9f07..75863168d1db 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 @@ -84,12 +84,73 @@ class BinaryFileResponseTest extends ResponseTestCase return array( array('bytes=1-4', 1, 4, 'bytes 1-4/35'), array('bytes=-5', 30, 5, 'bytes 30-34/35'), - array('bytes=-35', 0, 35, 'bytes 0-34/35'), - array('bytes=-40', 0, 35, 'bytes 0-34/35'), array('bytes=30-', 30, 5, 'bytes 30-34/35'), array('bytes=30-30', 30, 1, 'bytes 30-30/35'), array('bytes=30-34', 30, 5, 'bytes 30-34/35'), - array('bytes=30-40', 30, 5, 'bytes 30-34/35') + ); + } + + /** + * @dataProvider provideFullFileRanges + */ + public function testFullFileRequests($requestRange) + { + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('Range', $requestRange); + + $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); + $data = fread($file, 35); + fclose($file); + + $this->expectOutputString($data); + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('binary', $response->headers->get('Content-Transfer-Encoding')); + } + + public function provideFullFileRanges() + { + return array( + array('bytes=0-'), + array('bytes=0-34'), + array('bytes=-35'), + // Syntactical invalid range-request should also return the full resource + array('bytes=20-10'), + array('bytes=50-40'), + ); + } + + /** + * @dataProvider provideInvalidRanges + */ + public function testInvalidRequests($requestRange) + { + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('Range', $requestRange); + + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals(416, $response->getStatusCode()); + $this->assertEquals('binary', $response->headers->get('Content-Transfer-Encoding')); + #$this->assertEquals('', $response->headers->get('Content-Range')); + } + + public function provideInvalidRanges() + { + return array( + array('bytes=-40'), + array('bytes=30-40') ); } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php index f4c9ec157450..def1c7a378f2 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -38,7 +38,7 @@ class CookieTest extends \PHPUnit_Framework_TestCase /** * @dataProvider invalidNames - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException * @covers Symfony\Component\HttpFoundation\Cookie::__construct */ public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters($name) @@ -47,11 +47,11 @@ class CookieTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testInvalidExpiration() { - $cookie = new Cookie('MyCookie', 'foo','bar'); + $cookie = new Cookie('MyCookie', 'foo', 'bar'); } /** diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php index 7bf10a297e19..1078fc2d414a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Tests\File; +namespace Symfony\Component\HttpFoundation\Tests\File\MimeType; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index f6ea340091ba..5b48970d5e15 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -224,7 +224,7 @@ class UploadedFileTest extends \PHPUnit_Framework_TestCase null, filesize(__DIR__.'/Fixtures/test.gif'), UPLOAD_ERR_OK, - true + true ); $this->assertTrue($file->isValid()); 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 8f1383fba9b8..ef392ca59dbe 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 @@ -159,18 +159,27 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase $this->assertEquals('text/javascript', $response->headers->get('Content-Type')); } - public function testSetCallbackInvalidIdentifier() - { - $response = new JsonResponse('foo'); - - $this->setExpectedException('InvalidArgumentException'); - $response->setCallback('+invalid'); - } - public function testJsonEncodeFlags() { $response = new JsonResponse('<>\'&"'); $this->assertEquals('"\u003C\u003E\u0027\u0026\u0022"', $response->getContent()); } + + /** + * @expectedException \InvalidArgumentException + */ + public function testSetCallbackInvalidIdentifier() + { + $response = new JsonResponse('foo'); + $response->setCallback('+invalid'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testSetContent() + { + JsonResponse::create("\xB1\x31"); + } } 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 6cd42bf91dd0..7f4f243b481b 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 @@ -205,10 +205,10 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase $this->assertEquals('example@example.com', $bag->filter('email', '', false, FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email'); - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as url with a path'); + $this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as URL with a path'); // This test is repeated for code-coverage - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as url with a path'); + $this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path'); $this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FLAG_ALLOW_HEX, diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php index 330d9fee51fb..2a097d6fd422 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php @@ -11,7 +11,7 @@ namespace Symfony\Component\HttpFoundation\Tests; -use \Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\RedirectResponse; class RedirectResponseTest extends \PHPUnit_Framework_TestCase { 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 ba95c4aea965..db331f283d05 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 @@ -211,6 +211,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals('testnopass', $request->getUser()); $this->assertNull($request->getPassword()); $this->assertFalse($request->isSecure()); + + $request = Request::create('http://test.com/?foo'); + $this->assertEquals('/?foo', $request->getRequestUri()); + $this->assertEquals(array('foo' => ''), $request->query->all()); } /** @@ -250,9 +254,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals('foo=bar', $request->getQueryString()); } - /** - * @covers Symfony\Component\HttpFoundation\Request::duplicate - */ public function testDuplicate() { $request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar')); @@ -271,6 +272,21 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided'); } + public function testDuplicateWithFormat() + { + $request = new Request(array(), array(), array('_format' => 'json')); + $dup = $request->duplicate(); + + $this->assertEquals('json', $dup->getRequestFormat()); + $this->assertEquals('json', $dup->attributes->get('_format')); + + $request = new Request(); + $request->setRequestFormat('xml'); + $dup = $request->duplicate(); + + $this->assertEquals('xml', $dup->getRequestFormat()); + } + /** * @covers Symfony\Component\HttpFoundation\Request::getFormat * @covers Symfony\Component\HttpFoundation\Request::setFormat @@ -653,18 +669,18 @@ class RequestTest extends \PHPUnit_Framework_TestCase $request->initialize(array('foo' => 'bar')); $this->assertEquals('', $request->getHost(), '->getHost() return empty string if not initialized'); - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from Host Header'); + $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.example.com')); + $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from Host Header'); // Host header with port number - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.exemple.com:8080')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from Host Header with port number'); + $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.example.com:8080')); + $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from Host Header with port number'); // Server values - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com')); - $this->assertEquals('www.exemple.com', $request->getHost(), '->getHost() from server name'); + $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.example.com')); + $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from server name'); - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_HOST' => 'www.host.com')); + $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.example.com', 'HTTP_HOST' => 'www.host.com')); $this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME '); } @@ -699,12 +715,31 @@ class RequestTest extends \PHPUnit_Framework_TestCase )); $port = $request->getPort(); - $this->assertEquals(80, $port, 'If X_FORWARDED_PROTO is set to http return 80.'); + $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' + )); + $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' + )); + $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' + )); + $port = $request->getPort(); + $this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.'); + Request::setTrustedProxies(array()); } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testGetHostWithFakeHttpHostValue() { @@ -846,14 +881,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase public function testGetContentWorksTwiceInDefaultMode() { - $req = new Request; + $req = new Request(); $this->assertEquals('', $req->getContent()); $this->assertEquals('', $req->getContent()); } public function testGetContentReturnsResource() { - $req = new Request; + $req = new Request(); $retval = $req->getContent(true); $this->assertInternalType('resource', $retval); $this->assertEquals("", fread($retval, 1)); @@ -861,12 +896,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException LogicException + * @expectedException \LogicException * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider */ public function testGetContentCantBeCalledTwiceWithResources($first, $second) { - $req = new Request; + $req = new Request(); $req->getContent($first); $req->getContent($second); } @@ -966,6 +1001,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertArrayHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); + $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); + // restore initial $_SERVER array $_SERVER = $server; } @@ -1122,6 +1163,22 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('ISO-8859-1', 'utf-8', '*'), $request->getCharsets()); } + public function testGetEncodings() + { + $request = new Request(); + $this->assertEquals(array(), $request->getEncodings()); + $request->headers->set('Accept-Encoding', 'gzip,deflate,sdch'); + $this->assertEquals(array(), $request->getEncodings()); // testing caching + + $request = new Request(); + $request->headers->set('Accept-Encoding', 'gzip,deflate,sdch'); + $this->assertEquals(array('gzip', 'deflate', 'sdch'), $request->getEncodings()); + + $request = new Request(); + $request->headers->set('Accept-Encoding', 'gzip;q=0.4,deflate;q=0.9,compress;q=0.7'); + $this->assertEquals(array('deflate', 'compress', 'gzip'), $request->getEncodings()); + } + public function testGetAcceptableContentTypes() { $request = new Request(); @@ -1304,7 +1361,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase */ public function testUrlencodedStringPrefix($string, $prefix, $expect) { - $request = new Request; + $request = new Request(); $me = new \ReflectionMethod($request, 'getUrlencodedPrefix'); $me->setAccessible(true); @@ -1385,6 +1442,13 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals(443, $request->getPort()); $this->assertTrue($request->isSecure()); + // check various X_FORWARDED_PROTO header values + $request->headers->set('X_FORWARDED_PROTO', 'ssl'); + $this->assertTrue($request->isSecure()); + + $request->headers->set('X_FORWARDED_PROTO', 'https, http'); + $this->assertTrue($request->isSecure()); + // custom header names Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_MY_FOR'); Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X_MY_HOST'); @@ -1413,6 +1477,24 @@ class RequestTest extends \PHPUnit_Framework_TestCase Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_FORWARDED_PROTO'); } + /** + * @expectedException \InvalidArgumentException + */ + public function testSetTrustedProxiesInvalidHeaderName() + { + Request::create('http://example.com/'); + Request::setTrustedHeaderName('bogus name', 'X_MY_FOR'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testGetTrustedProxiesInvalidHeaderName() + { + Request::create('http://example.com/'); + Request::getTrustedHeaderName('bogus name'); + } + /** * @dataProvider iisRequestUriProvider */ @@ -1425,7 +1507,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct'); $subRequestUri = '/bar/foo'; - $subRequest = $request::create($subRequestUri, 'get', array(), array(), array(), $request->server->all()); + $subRequest = Request::create($subRequestUri, 'get', array(), array(), array(), $request->server->all()); $this->assertEquals($subRequestUri, $subRequest->getRequestUri(), '->getRequestUri() is correct in sub request'); } @@ -1526,12 +1608,35 @@ class RequestTest extends \PHPUnit_Framework_TestCase // trusted hosts $request->headers->set('host', 'trusted.com'); $this->assertEquals('trusted.com', $request->getHost()); + $this->assertEquals(80, $request->getPort()); + + $request->server->set('HTTPS', true); + $request->headers->set('host', 'trusted.com'); + $this->assertEquals('trusted.com', $request->getHost()); + $this->assertEquals(443, $request->getPort()); + $request->server->set('HTTPS', false); + + $request->headers->set('host', 'trusted.com:8000'); + $this->assertEquals('trusted.com', $request->getHost()); + $this->assertEquals(8000, $request->getPort()); + $request->headers->set('host', 'subdomain.trusted.com'); $this->assertEquals('subdomain.trusted.com', $request->getHost()); // reset request for following tests Request::setTrustedHosts(array()); } + + public function testFactory() + { + Request::setFactory(function (array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) { + return new NewRequest(); + }); + + $this->assertEquals('foo', Request::create('/')->getFoo()); + + Request::setFactory(null); + } } class RequestContentProxy extends Request @@ -1541,3 +1646,11 @@ class RequestContentProxy extends Request return http_build_query(array('_method' => 'PUT', 'content' => 'mycontent')); } } + +class NewRequest extends Request +{ + public function getFoo() + { + return 'foo'; + } +} 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 3a084954c443..11eb38c72372 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 @@ -79,6 +79,19 @@ class ResponseTest extends ResponseTestCase $this->assertFalse($response->isCacheable()); } + public function testIsCacheableWithErrorCode() + { + $response = new Response('', 500); + $this->assertFalse($response->isCacheable()); + } + + public function testIsCacheableWithNoStoreDirective() + { + $response = new Response(); + $response->headers->set('cache-control', 'private'); + $this->assertFalse($response->isCacheable()); + } + public function testIsCacheableWithSetTtl() { $response = new Response(); @@ -118,6 +131,50 @@ class ResponseTest extends ResponseTestCase $this->assertFalse($modified); } + public function testIsNotModifiedNotSafe() + { + $request = Request::create('/homepage', 'POST'); + + $response = new Response(); + $this->assertFalse($response->isNotModified($request)); + } + + public function testIsNotModifiedLastModified() + { + $modified = 'Sun, 25 Aug 2013 18: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', ''); + $this->assertFalse($response->isNotModified($request)); + } + + public function testIsNotModifiedEtag() + { + $etagOne = 'randomly_generated_etag'; + $etagTwo = 'randomly_generated_etag_2'; + + $request = new Request(); + $request->headers->set('if_none_match', sprintf('%s, %s, %s', $etagOne, $etagTwo, 'etagThree')); + + $response = new Response(); + + $response->headers->set('ETag', $etagOne); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('ETag', $etagTwo); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('ETag', ''); + $this->assertFalse($response->isNotModified($request)); + } + public function testIsValidateable() { $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); @@ -361,9 +418,42 @@ class ResponseTest extends ResponseTestCase $response = new Response('foo'); $request = Request::create('/', 'HEAD'); + $length = 12345; + $response->headers->set('Content-Length', $length); $response->prepare($request); $this->assertEquals('', $response->getContent()); + $this->assertEquals($length, $response->headers->get('Content-Length'), 'Content-Length should be as if it was GET; see RFC2616 14.13'); + } + + public function testPrepareRemovesContentForInformationalResponse() + { + $response = new Response('foo'); + $request = Request::create('/'); + + $response->setContent('content'); + $response->setStatusCode(101); + $response->prepare($request); + $this->assertEquals('', $response->getContent()); + + $response->setContent('content'); + $response->setStatusCode(304); + $response->prepare($request); + $this->assertEquals('', $response->getContent()); + } + + public function testPrepareRemovesContentLength() + { + $response = new Response('foo'); + $request = Request::create('/'); + + $response->headers->set('Content-Length', 12345); + $response->prepare($request); + $this->assertEquals(12345, $response->headers->get('Content-Length')); + + $response->headers->set('Transfer-Encoding', 'chunked'); + $response->prepare($request); + $this->assertFalse($response->headers->has('Content-Length')); } public function testPrepareSetsPragmaOnHttp10Only() @@ -634,7 +724,7 @@ class ResponseTest extends ResponseTestCase } /** - * @expectedException UnexpectedValueException + * @expectedException \UnexpectedValueException * @dataProvider invalidContentProvider */ public function testSetContentInvalid($content) @@ -668,7 +758,7 @@ class ResponseTest extends ResponseTestCase public function validContentProvider() { return array( - 'obj' => array(new StringableObject), + 'obj' => array(new StringableObject()), 'string' => array('Foo'), 'int' => array(2), ); 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 f8e487d7f874..89920f1fbc54 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 @@ -89,6 +89,28 @@ class ServerBagTest extends \PHPUnit_Framework_TestCase ), $bag->getHeaders()); } + public function testHttpDigestAuthWithPhpCgi() + { + $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; + $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); + + $this->assertEquals(array( + 'AUTHORIZATION' => $digest, + 'PHP_AUTH_DIGEST' => $digest, + ), $bag->getHeaders()); + } + + public function testHttpDigestAuthWithPhpCgiRedirect() + { + $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; + $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => $digest)); + + $this->assertEquals(array( + 'AUTHORIZATION' => $digest, + 'PHP_AUTH_DIGEST' => $digest, + ), $bag->getHeaders()); + } + public function testOAuthBearerAuth() { $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index da0440d4289e..8d38ab3de991 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -121,4 +121,12 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase array(array('expiretime' => 100, 'foo' => 'bar'), false), ); } + + public function testGetConnection() + { + $method = new \ReflectionMethod($this->storage, 'getMemcache'); + $method->setAccessible(true); + + $this->assertInstanceOf('\Memcache', $method->invoke($this->storage)); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index 985fae488877..72be3272526f 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -116,4 +116,12 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase array(array('expiretime' => 100, 'foo' => 'bar'), false), ); } + + public function testGetConnection() + { + $method = new \ReflectionMethod($this->storage, 'getMemcached'); + $method->setAccessible(true); + + $this->assertInstanceOf('\Memcached', $method->invoke($this->storage)); + } } 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 1cfd1175cbe1..d907ce4a9031 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 @@ -31,7 +31,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('MongoDbSessionHandler requires the PHP "mongo" extension.'); } - $mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? 'Mongo' : 'MongoClient'; + $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; $this->mongo = $this->getMockBuilder($mongoClass) ->disableOriginalConstructor() @@ -49,7 +49,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testConstructorShouldThrowExceptionForInvalidMongo() { @@ -57,7 +57,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testConstructorShouldThrowExceptionForMissingOptions() { @@ -90,7 +90,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $collection->expects($this->once()) ->method('update') - ->will($this->returnCallback(function($criteria, $updateData, $options) use ($that, &$data) { + ->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) { $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria); $that->assertEquals(array('upsert' => true, 'multiple' => false), $options); @@ -118,7 +118,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $collection->expects($this->exactly(2)) ->method('update') - ->will($this->returnCallback(function($criteria, $updateData, $options) use (&$data) { + ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { $data = $updateData; })); @@ -161,11 +161,21 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $collection->expects($this->once()) ->method('remove') - ->will($this->returnCallback(function($criteria) use ($that) { + ->will($this->returnCallback(function ($criteria) use ($that) { $that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']); $that->assertGreaterThanOrEqual(time() - -1, $criteria[$that->options['time_field']]['$lt']->sec); })); $this->assertTrue($this->storage->gc(-1)); } + + public function testGetConnection() + { + $method = new \ReflectionMethod($this->storage, 'getMongo'); + $method->setAccessible(true); + + $mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? '\Mongo' : '\MongoClient'; + + $this->assertInstanceOf($mongoClass, $method->invoke($this->storage)); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php index 45a47ce8fa56..371ab6f3fa06 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php @@ -22,7 +22,7 @@ use Symfony\Component\HttpFoundation\Session\Session; * * @runTestsInSeparateProcesses */ -class NullSessionStorageTest extends \PHPUnit_Framework_TestCase +class NullSessionHandlerTest extends \PHPUnit_Framework_TestCase { public function testSaveHandlers() { 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 1abf3844c6fd..06da0096f3c4 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 @@ -98,4 +98,14 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase $storage->gc(-1); $this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); } + + public function testGetConnection() + { + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); + + $method = new \ReflectionMethod($storage, 'getConnection'); + $method->setAccessible(true); + + $this->assertInstanceOf('\PDO', $method->invoke($storage)); + } } 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 new file mode 100644 index 000000000000..dcfd94bd1ecf --- /dev/null +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; + +use Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler; + +/** + * @author Adrien Brault + */ +class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase +{ + public function test() + { + $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); + + $wrappedSessionHandlerMock + ->expects($this->once()) + ->method('close') + ->with() + ->will($this->returnValue(true)) + ; + + $this->assertEquals(true, $writeCheckSessionHandler->close()); + } + + public function testWrite() + { + $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); + + $wrappedSessionHandlerMock + ->expects($this->once()) + ->method('write') + ->with('foo', 'bar') + ->will($this->returnValue(true)) + ; + + $this->assertEquals(true, $writeCheckSessionHandler->write('foo', 'bar')); + } + + public function testSkippedWrite() + { + $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); + + $wrappedSessionHandlerMock + ->expects($this->once()) + ->method('read') + ->with('foo') + ->will($this->returnValue('bar')) + ; + + $wrappedSessionHandlerMock + ->expects($this->never()) + ->method('write') + ; + + $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); + $this->assertEquals(true, $writeCheckSessionHandler->write('foo', 'bar')); + } + + public function testNonSkippedWrite() + { + $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); + $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); + + $wrappedSessionHandlerMock + ->expects($this->once()) + ->method('read') + ->with('foo') + ->will($this->returnValue('bar')) + ; + + $wrappedSessionHandlerMock + ->expects($this->once()) + ->method('write') + ->with('foo', 'baZZZ') + ->will($this->returnValue(true)) + ; + + $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); + $this->assertEquals(true, $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 ef70281ce08d..c502c38ae613 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 @@ -43,27 +43,23 @@ class MetadataBagTest extends \PHPUnit_Framework_TestCase public function testInitialize() { - $p = new \ReflectionProperty('Symfony\Component\HttpFoundation\Session\Storage\MetadataBag', 'meta'); - $p->setAccessible(true); + $sessionMetadata = array(); $bag1 = new MetadataBag(); - $array = array(); - $bag1->initialize($array); + $bag1->initialize($sessionMetadata); $this->assertGreaterThanOrEqual(time(), $bag1->getCreated()); $this->assertEquals($bag1->getCreated(), $bag1->getLastUsed()); sleep(1); $bag2 = new MetadataBag(); - $array2 = $p->getValue($bag1); - $bag2->initialize($array2); + $bag2->initialize($sessionMetadata); $this->assertEquals($bag1->getCreated(), $bag2->getCreated()); $this->assertEquals($bag1->getLastUsed(), $bag2->getLastUsed()); $this->assertEquals($bag2->getCreated(), $bag2->getLastUsed()); sleep(1); $bag3 = new MetadataBag(); - $array3 = $p->getValue($bag2); - $bag3->initialize($array3); + $bag3->initialize($sessionMetadata); $this->assertEquals($bag1->getCreated(), $bag3->getCreated()); $this->assertGreaterThan($bag2->getLastUsed(), $bag3->getLastUsed()); $this->assertNotEquals($bag3->getCreated(), $bag3->getLastUsed()); @@ -104,4 +100,36 @@ class MetadataBagTest extends \PHPUnit_Framework_TestCase { $this->bag->clear(); } + + public function testSkipLastUsedUpdate() + { + $bag = new MetadataBag('', 30); + $timeStamp = time(); + + $created = $timeStamp - 15; + $sessionMetadata = array( + MetadataBag::CREATED => $created, + MetadataBag::UPDATED => $created, + MetadataBag::LIFETIME => 1000 + ); + $bag->initialize($sessionMetadata); + + $this->assertEquals($created, $sessionMetadata[MetadataBag::UPDATED]); + } + + public function testDoesNotSkipLastUsedUpdate() + { + $bag = new MetadataBag('', 30); + $timeStamp = time(); + + $created = $timeStamp - 45; + $sessionMetadata = array( + MetadataBag::CREATED => $created, + MetadataBag::UPDATED => $created, + MetadataBag::LIFETIME => 1000 + ); + $bag->initialize($sessionMetadata); + + $this->assertEquals($timeStamp, $sessionMetadata[MetadataBag::UPDATED]); + } } diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php index 2a6f6bb7e8fe..c56ea4a60071 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php @@ -97,7 +97,7 @@ class MockArraySessionStorageTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testUnstartedSave() { diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php index d42c62a25ca0..329c090d8d91 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php @@ -107,7 +107,7 @@ class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testSaveWithoutStart() { 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 14ae52f97be3..691ee1459347 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 @@ -59,7 +59,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase protected function getStorage(array $options = array()) { $storage = new NativeSessionStorage($options); - $storage->registerBag(new AttributeBag); + $storage->registerBag(new AttributeBag()); return $storage; } @@ -85,8 +85,12 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase { $storage = $this->getStorage(); $this->assertEquals('', $storage->getId()); + $storage->start(); $this->assertNotEquals('', $storage->getId()); + + $storage->save(); + $this->assertNotEquals('', $storage->getId()); } public function testRegenerate() @@ -154,7 +158,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase public function testSetSaveHandlerException() { $storage = $this->getStorage(); - $storage->setSaveHandler(new \StdClass); + $storage->setSaveHandler(new \stdClass); } public function testSetSaveHandler53() diff --git a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index d5a66d61efc5..0510f3fe9a5a 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; * * @runTestsInSeparateProcesses */ -class PhpSessionStorageTest extends \PHPUnit_Framework_TestCase +class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase { private $savePath; @@ -53,7 +53,7 @@ class PhpSessionStorageTest extends \PHPUnit_Framework_TestCase protected function getStorage() { $storage = new PhpBridgeSessionStorage(); - $storage->registerBag(new AttributeBag); + $storage->registerBag(new AttributeBag()); return $storage; } 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 6b8bba0d5b0d..58b632aeb0e5 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 @@ -22,7 +22,7 @@ class ConcreteProxy extends AbstractProxy class ConcreteSessionHandlerInterfaceProxy extends AbstractProxy implements \SessionHandlerInterface { - public function open($savePath, $sessionName) + public function open($savePath, $sessionName) { } 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 f77e08ebd6ac..09f5b24aa0ae 100644 --- a/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json +++ b/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } 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 215d1e1862d9..2fdbe1ccd0fa 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 @@ -29,8 +29,8 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; abstract class Bundle extends ContainerAware implements BundleInterface { protected $name; - protected $reflected; protected $extension; + protected $path; /** * Boots the Bundle. @@ -109,11 +109,9 @@ abstract class Bundle extends ContainerAware implements BundleInterface */ public function getNamespace() { - if (null === $this->reflected) { - $this->reflected = new \ReflectionObject($this); - } + $class = get_class($this); - return $this->reflected->getNamespaceName(); + return substr($class, 0, strrpos($class, '\\')); } /** @@ -125,11 +123,12 @@ abstract class Bundle extends ContainerAware implements BundleInterface */ public function getPath() { - if (null === $this->reflected) { - $this->reflected = new \ReflectionObject($this); + if (null === $this->path) { + $reflected = new \ReflectionObject($this); + $this->path = dirname($reflected->getFileName()); } - return dirname($this->reflected->getFileName()); + return $this->path; } /** @@ -160,7 +159,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface $name = get_class($this); $pos = strrpos($name, '\\'); - return $this->name = false === $pos ? $name : substr($name, $pos + 1); + return $this->name = false === $pos ? $name : substr($name, $pos + 1); } /** @@ -188,7 +187,14 @@ abstract class Bundle extends ContainerAware implements BundleInterface if ($relativePath = $file->getRelativePath()) { $ns .= '\\'.strtr($relativePath, '/', '\\'); } - $r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php')); + $class = $ns.'\\'.$file->getBasename('.php'); + if ($this->container) { + $alias = 'console.command.'.strtolower(str_replace('\\', '_', $class)); + if ($this->container->has($alias)) { + continue; + } + } + $r = new \ReflectionClass($class); if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { $application->add($r->newInstance()); } 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 c06dd3fa57e0..66219ae11637 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,12 @@ CHANGELOG ========= +2.4.0 +----- + + * added event listeners for the session + * added the KernelEvents::FINISH_REQUEST event + 2.3.0 ----- 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 eb26ac59e62d..bd96057ded64 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 @@ -18,13 +18,14 @@ namespace Symfony\Component\HttpKernel\CacheWarmer; */ class CacheWarmerAggregate implements CacheWarmerInterface { - protected $warmers; - protected $optionalsEnabled; + protected $warmers = array(); + protected $optionalsEnabled = false; public function __construct(array $warmers = array()) { - $this->setWarmers($warmers); - $this->optionalsEnabled = false; + foreach ($warmers as $warmer) { + $this->add($warmer); + } } public function enableOptionalWarmers() 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 bb427b35af22..b40d7006d696 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php @@ -11,16 +11,15 @@ namespace Symfony\Component\HttpKernel; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\BrowserKit\Client as BaseClient; use Symfony\Component\BrowserKit\Request as DomRequest; use Symfony\Component\BrowserKit\Response as DomResponse; use Symfony\Component\BrowserKit\Cookie as DomCookie; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\HttpKernel\TerminableInterface; +use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; /** * Client simulates a browser and makes requests to a Kernel object. @@ -43,11 +42,11 @@ class Client extends BaseClient */ public function __construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) { + // These class properties must be set before calling the parent constructor, as it may depend on it. $this->kernel = $kernel; + $this->followRedirects = false; parent::__construct($server, $history, $cookieJar); - - $this->followRedirects = false; } /** @@ -104,7 +103,7 @@ class Client extends BaseClient $requirePath = str_replace("'", "\\'", $r->getFileName()); $symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..')); - return <<register(); \$kernel = unserialize('$kernel'); -echo serialize(\$kernel->handle(unserialize('$request'))); +\$request = unserialize('$request'); +EOF; + + return $code.$this->getHandleScript(); + } + + protected function getHandleScript() + { + return <<<'EOF' +$response = $kernel->handle($request); + +if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) { + $kernel->terminate($request, $response); +} + +echo serialize($response); EOF; } 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 047ade1062ca..46484498474c 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 @@ -40,18 +40,11 @@ class ControllerResolver implements ControllerResolverInterface } /** - * Returns the Controller instance associated with a Request. + * {@inheritdoc} * * This method looks for a '_controller' request attribute that represents * the controller name (a string like ClassName::MethodName). * - * @param Request $request A Request instance - * - * @return mixed|Boolean A PHP callable representing the Controller, - * or false if this resolver is not able to determine the controller - * - * @throws \InvalidArgumentException|\LogicException If the controller can't be found - * * @api */ public function getController(Request $request) @@ -86,14 +79,7 @@ class ControllerResolver implements ControllerResolverInterface } /** - * Returns the arguments to pass to the controller. - * - * @param Request $request A Request instance - * @param mixed $controller A PHP callable - * - * @return array - * - * @throws \RuntimeException When value for argument given is not provided + * {@inheritdoc} * * @api */ diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php index f58f50db5329..6f805ed2dab7 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php @@ -38,10 +38,10 @@ interface ControllerResolverInterface * * @param Request $request A Request instance * - * @return mixed|Boolean A PHP callable representing the Controller, - * or false if this resolver is not able to determine the controller + * @return callable|false A PHP callable representing the Controller, + * or false if this resolver is not able to determine the controller * - * @throws \InvalidArgumentException|\LogicException If the controller can't be found + * @throws \LogicException If the controller can't be found * * @api */ @@ -50,8 +50,8 @@ interface ControllerResolverInterface /** * Returns the arguments to pass to the controller. * - * @param Request $request A Request instance - * @param mixed $controller A PHP callable + * @param Request $request A Request instance + * @param callable $controller A PHP callable * * @return array An array of arguments to pass to the controller * 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 47529fd19048..51b6d7ae01a4 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 @@ -13,7 +13,6 @@ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php index 7d9c28943b72..1835938a0726 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php @@ -11,17 +11,25 @@ namespace Symfony\Component\HttpKernel\DataCollector; +use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; + /** * DataCollector. * * Children of this class must store the collected data in the data property. * * @author Fabien Potencier + * @author Bernhard Schussek */ abstract class DataCollector implements DataCollectorInterface, \Serializable { protected $data; + /** + * @var ValueExporter + */ + private $valueExporter; + public function serialize() { return serialize($this->data); @@ -41,35 +49,10 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable */ protected function varToString($var) { - if (is_object($var)) { - return sprintf('Object(%s)', get_class($var)); + if (null === $this->valueExporter) { + $this->valueExporter = new ValueExporter(); } - if (is_array($var)) { - $a = array(); - foreach ($var as $k => $v) { - $a[] = sprintf('%s => %s', $k, $this->varToString($v)); - } - - return sprintf("Array(%s)", implode(', ', $a)); - } - - if (is_resource($var)) { - return sprintf('Resource(%s)', get_resource_type($var)); - } - - if (null === $var) { - return 'null'; - } - - if (false === $var) { - return 'false'; - } - - if (true === $var) { - return 'true'; - } - - return (string) $var; + return $this->valueExporter->exportValue($var); } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php index cd7f7870177c..418ed686c64d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php @@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; /** @@ -20,8 +21,15 @@ use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; * * @author Fabien Potencier */ -class EventDataCollector extends DataCollector +class EventDataCollector extends DataCollector implements LateDataCollectorInterface { + protected $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher = null) + { + $this->dispatcher = $dispatcher; + } + /** * {@inheritdoc} */ @@ -33,6 +41,14 @@ class EventDataCollector extends DataCollector ); } + public function lateCollect() + { + if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { + $this->setCalledListeners($this->dispatcher->getCalledListeners()); + $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners()); + } + } + /** * Sets the called listeners. * diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php new file mode 100644 index 000000000000..012332de479f --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\DataCollector; + +/** + * LateDataCollectorInterface. + * + * @author Fabien Potencier + */ +interface LateDataCollectorInterface +{ + /** + * Collects data as late as possible. + */ + public function lateCollect(); +} 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 f08720e8073b..ba2ea44c5ed3 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 @@ -21,7 +21,7 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; * * @author Fabien Potencier */ -class LoggerDataCollector extends DataCollector +class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface { private $logger; @@ -36,6 +36,14 @@ class LoggerDataCollector extends DataCollector * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) + { + // everything is done as late as possible + } + + /** + * {@inheritdoc} + */ + public function lateCollect() { if (null !== $this->logger) { $this->data = array( 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 5540a1b27ac9..e36f1f457e7b 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 @@ -19,13 +19,13 @@ use Symfony\Component\HttpFoundation\Response; * * @author Fabien Potencier */ -class MemoryDataCollector extends DataCollector +class MemoryDataCollector extends DataCollector implements LateDataCollectorInterface { public function __construct() { $this->data = array( 'memory' => 0, - 'memory_limit' => $this->convertToBytes(strtolower(ini_get('memory_limit'))), + 'memory_limit' => $this->convertToBytes(ini_get('memory_limit')), ); } @@ -37,6 +37,14 @@ class MemoryDataCollector extends DataCollector $this->updateMemoryUsage(); } + /** + * {@inheritdoc} + */ + public function lateCollect() + { + $this->updateMemoryUsage(); + } + /** * Gets the memory. * @@ -79,13 +87,23 @@ class MemoryDataCollector extends DataCollector return -1; } - if (preg_match('#^\+?(0x?)?(.*?)([kmg]?)$#', $memoryLimit, $match)) { - $shifts = array('' => 0, 'k' => 10, 'm' => 20, 'g' => 30); - $bases = array('' => 10, '0' => 8, '0x' => 16); - - return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]]; + $memoryLimit = strtolower($memoryLimit); + $max = strtolower(ltrim($memoryLimit, '+')); + if (0 === strpos($max, '0x')) { + $max = intval($max, 16); + } elseif (0 === strpos($max, '0')) { + $max = intval($max, 8); + } else { + $max = intval($max); } - return 0; + switch (substr($memoryLimit, -1)) { + case 't': $max *= 1024; + case 'g': $max *= 1024; + case 'm': $max *= 1024; + case 'k': $max *= 1024; + } + + return $max; } } 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 934c8477a528..4473605e843f 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 @@ -50,11 +50,15 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter $attributes = array(); foreach ($request->attributes->all() as $key => $value) { - if ('_route' == $key && is_object($value)) { - $value = $value->getPath(); + if ('_route' === $key && is_object($value)) { + $attributes['_route'] = $this->varToString($value->getPath()); + } elseif ('_route_params' === $key) { + foreach ($value as $key => $v) { + $attributes['_route_params'][$key] = $this->varToString($v); + } + } else { + $attributes[$key] = $this->varToString($value); } - - $attributes[$key] = $this->varToString($value); } $content = null; 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 80e250ad0f68..8757412c63c5 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 @@ -14,7 +14,6 @@ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; /** @@ -50,6 +49,8 @@ class RouterDataCollector extends DataCollector $this->data['route'] = $this->guessRoute($request, $this->controllers[$request]); } } + + unset($this->controllers[$request]); } protected function guessRoute(Request $request, $controller) 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 74d7616bf9cf..4b5b00f0bf36 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 @@ -11,23 +11,24 @@ namespace Symfony\Component\HttpKernel\DataCollector; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; -use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\KernelInterface; /** * TimeDataCollector. * * @author Fabien Potencier */ -class TimeDataCollector extends DataCollector +class TimeDataCollector extends DataCollector implements LateDataCollectorInterface { protected $kernel; + protected $stopwatch; - public function __construct(KernelInterface $kernel = null) + public function __construct(KernelInterface $kernel = null, $stopwatch = null) { $this->kernel = $kernel; + $this->stopwatch = $stopwatch; } /** @@ -42,11 +43,23 @@ class TimeDataCollector extends DataCollector } $this->data = array( + 'token' => $response->headers->get('X-Debug-Token'), 'start_time' => $startTime * 1000, 'events' => array(), ); } + /** + * {@inheritdoc} + */ + public function lateCollect() + { + if (null !== $this->stopwatch && isset($this->data['token'])) { + $this->setEvents($this->stopwatch->getSectionEvents($this->data['token'])); + } + unset($this->data['token']); + } + /** * Sets the request events. * 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 new file mode 100644 index 000000000000..f3aeb80cb227 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\DataCollector\Util; + +/** + * @author Bernhard Schussek + */ +class ValueExporter +{ + /** + * Converts a PHP value to a string. + * + * @param mixed $value The PHP value + * + * @return string The string representation of the given value + */ + public function exportValue($value) + { + if (is_object($value)) { + return sprintf('Object(%s)', get_class($value)); + } + + if (is_array($value)) { + $a = array(); + foreach ($value as $k => $v) { + $a[] = sprintf('%s => %s', $k, $this->exportValue($v)); + } + + return sprintf("Array(%s)", implode(', ', $a)); + } + + if (is_resource($value)) { + return sprintf('Resource(%s)', get_resource_type($value)); + } + + if (null === $value) { + return 'null'; + } + + if (false === $value) { + return 'false'; + } + + if (true === $value) { + return 'true'; + } + + return (string) $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 6bfd7a01dd38..c8905fe304a7 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 @@ -13,10 +13,8 @@ namespace Symfony\Component\HttpKernel\Debug; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\HttpKernel\KernelEvents; -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -32,13 +30,13 @@ use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEventDispatcherInterface { private $logger; - private $called; + private $called = array(); private $stopwatch; - private $profiler; private $dispatcher; - private $wrappedListeners; - private $firstCalledEvent; + private $wrappedListeners = array(); + private $firstCalledEvent = array(); private $id; + private $lastEventId = 0; /** * Constructor. @@ -52,19 +50,21 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve $this->dispatcher = $dispatcher; $this->stopwatch = $stopwatch; $this->logger = $logger; - $this->called = array(); - $this->wrappedListeners = array(); - $this->firstCalledEvent = array(); } /** * Sets the profiler. * + * The traceable event dispatcher does not use the profiler anymore. + * The job is now done directly by the Profiler listener and the + * data collectors themselves. + * * @param Profiler|null $profiler A Profiler instance + * + * @deprecated Deprecated since version 2.4, to be removed in 3.0. */ public function setProfiler(Profiler $profiler = null) { - $this->profiler = $profiler; } /** @@ -124,7 +124,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve $event = new Event(); } - $this->id = spl_object_hash($event); + $this->id = $eventId = ++$this->lastEventId; $this->preDispatch($eventName, $event); @@ -139,11 +139,13 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve $this->dispatcher->dispatch($eventName, $event); // reset the id as another event might have been dispatched during the dispatching of this event - $this->id = spl_object_hash($event); + $this->id = $eventId; unset($this->firstCalledEvent[$eventName]); - $e->stop(); + if ($e->isStarted()) { + $e->stop(); + } $this->postDispatch($eventName, $event); @@ -257,7 +259,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve * @param object $listener The listener * @param string $eventName The event name * - * @return array Informations about the listener + * @return array Information about the listener */ private function getListenerInfo($listener, $eventName) { @@ -313,57 +315,6 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve return $info; } - /** - * Updates the stopwatch data in the profile hierarchy. - * - * @param string $token Profile token - * @param Boolean $updateChildren Whether to update the children altogether - */ - private function updateProfiles($token, $updateChildren) - { - if (!$this->profiler || !$profile = $this->profiler->loadProfile($token)) { - return; - } - - $this->saveInfoInProfile($profile, $updateChildren); - } - - /** - * Update the profiles with the timing and events information and saves them. - * - * @param Profile $profile The root profile - * @param Boolean $updateChildren Whether to update the children altogether - */ - private function saveInfoInProfile(Profile $profile, $updateChildren) - { - try { - $collector = $profile->getCollector('memory'); - $collector->updateMemoryUsage(); - } catch (\InvalidArgumentException $e) { - } - - try { - $collector = $profile->getCollector('time'); - $collector->setEvents($this->stopwatch->getSectionEvents($profile->getToken())); - } catch (\InvalidArgumentException $e) { - } - - try { - $collector = $profile->getCollector('events'); - $collector->setCalledListeners($this->getCalledListeners()); - $collector->setNotCalledListeners($this->getNotCalledListeners()); - } catch (\InvalidArgumentException $e) { - } - - $this->profiler->saveProfile($profile); - - if ($updateChildren) { - foreach ($profile->getChildren() as $child) { - $this->saveInfoInProfile($child, true); - } - } - } - private function preDispatch($eventName, Event $event) { // wrap all listeners before they are called @@ -412,23 +363,14 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve case KernelEvents::RESPONSE: $token = $event->getResponse()->headers->get('X-Debug-Token'); $this->stopwatch->stopSection($token); - if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { - // The profiles can only be updated once they have been created - // that is after the 'kernel.response' event of the main request - $this->updateProfiles($token, true); - } break; case KernelEvents::TERMINATE: - $token = $event->getResponse()->headers->get('X-Debug-Token'); // In the special case described in the `preDispatch` method above, the `$token` section // does not exist, then closing it throws an exception which must be caught. + $token = $event->getResponse()->headers->get('X-Debug-Token'); try { $this->stopwatch->stopSection($token); } catch (\LogicException $e) {} - // The children profiles have been updated by the previous 'kernel.response' - // event. Only the root profile need to be updated with the 'kernel.terminate' - // timing informations. - $this->updateProfiles($token, false); break; } @@ -447,9 +389,11 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve return function (Event $event) use ($self, $eventName, $listener) { $e = $self->preListenerCall($eventName, $listener); - call_user_func($listener, $event); + call_user_func($listener, $event, $eventName, $self); - $e->stop(); + if ($e->isStarted()) { + $e->stop(); + } if ($event->isPropagationStopped()) { $self->logSkippedListeners($eventName, $event, $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 7e694eba7a0a..b1f34158109e 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 @@ -13,7 +13,6 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\Kernel; /** diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php index c9b8a211d429..69e7937d18c1 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; @@ -35,10 +36,11 @@ class ContainerAwareHttpKernel extends HttpKernel * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance * @param ContainerInterface $container A ContainerInterface instance * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance + * @param RequestStack $requestStack A stack for master/sub requests */ - public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver) + public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null) { - parent::__construct($dispatcher, $controllerResolver); + parent::__construct($dispatcher, $controllerResolver, $requestStack); $this->container = $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 ee00fbb6656b..e48c409d8d00 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 @@ -50,18 +50,27 @@ class RegisterListenersPass implements CompilerPassInterface public function process(ContainerBuilder $container) { - if (!$container->hasDefinition($this->dispatcherService)) { + if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { return; } - $definition = $container->getDefinition($this->dispatcherService); + $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 "kernel.event_listener" tags.', $id)); + throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag)); } if (!isset($event['method'])) { @@ -77,8 +86,13 @@ class RegisterListenersPass implements CompilerPassInterface } 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 = $container->getDefinition($id)->getClass(); + $class = $def->getClass(); $refClass = new \ReflectionClass($class); $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php new file mode 100644 index 000000000000..ee724843cd84 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Event; + +/** + * Triggered whenever a request is fully processed. + * + * @author Benjamin Eberlei + */ +class FinishRequestEvent extends KernelEvent +{ +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php index 1bc0f98fd0a1..fcb38daaa8c7 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php @@ -56,7 +56,7 @@ class GetResponseForControllerResultEvent extends GetResponseEvent /** * Assigns the return value of the controller. * - * @param mixed The controller return value + * @param mixed $controllerResult The controller return value * * @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 e57eed4d16f2..98763253dadd 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 @@ -86,4 +86,16 @@ class KernelEvent extends Event { return $this->requestType; } + + /** + * Checks if this is a master request. + * + * @return Boolean True if the request is a master request + * + * @api + */ + public function isMasterRequest() + { + return HttpKernelInterface::MASTER_REQUEST === $this->requestType; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php index b90562b5d386..686778afc4ad 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpKernel\EventListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\HttpCache\Esi; @@ -43,7 +42,7 @@ class EsiListener implements EventSubscriberInterface */ public function onKernelResponse(FilterResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType() || null === $this->esi) { + if (!$event->isMasterRequest() || null === $this->esi) { return; } 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 55950b29edac..33ce993b079c 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 @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -51,18 +52,7 @@ class ExceptionListener implements EventSubscriberInterface $this->logException($exception, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); - $attributes = array( - '_controller' => $this->controller, - 'exception' => FlattenException::create($exception), - 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, - // keep for BC -- as $format can be an argument of the controller callable - // see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php - // @deprecated in 2.4, to be removed in 3.0 - 'format' => $request->getRequestFormat(), - ); - - $request = $request->duplicate(null, null, $attributes); - $request->setMethod('GET'); + $request = $this->duplicateRequest($exception, $request); try { $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, true); @@ -109,4 +99,29 @@ class ExceptionListener implements EventSubscriberInterface error_log($message); } } + + /** + * Clones the request for the exception. + * + * @param \Exception $exception The thrown exception. + * @param Request $request The original request. + * + * @return Request $request The cloned request. + */ + protected function duplicateRequest(\Exception $exception, Request $request) + { + $attributes = array( + '_controller' => $this->controller, + 'exception' => FlattenException::create($exception), + 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, + // keep for BC -- as $format can be an argument of the controller callable + // see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php + // @deprecated in 2.4, to be removed in 3.0 + 'format' => $request->getRequestFormat(), + ); + $request = $request->duplicate(null, null, $attributes); + $request->setMethod('GET'); + + return $request; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php index 0b864c02f2bc..bdcf4c7644a7 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php @@ -12,7 +12,9 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RequestContextAwareInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -20,32 +22,48 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Initializes the locale based on the current request. * + * This listener works in 2 modes: + * + * * 2.3 compatibility mode where you must call setRequest whenever the Request changes. + * * 2.4+ mode where you must pass a RequestStack instance in the constructor. + * * @author Fabien Potencier */ class LocaleListener implements EventSubscriberInterface { private $router; private $defaultLocale; + private $requestStack; - public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null) + /** + * RequestStack will become required in 3.0. + */ + public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null, RequestStack $requestStack = null) { $this->defaultLocale = $defaultLocale; + $this->requestStack = $requestStack; $this->router = $router; } + /** + * Sets the current Request. + * + * This method was used to synchronize the Request, but as the HttpKernel + * is doing that automatically now, you should never call it directly. + * It is kept public for BC with the 2.3 version. + * + * @param Request|null $request A Request instance + * + * @deprecated Deprecated since version 2.4, to be removed in 3.0. + */ public function setRequest(Request $request = null) { if (null === $request) { return; } - if ($locale = $request->attributes->get('_locale')) { - $request->setLocale($locale); - } - - if (null !== $this->router) { - $this->router->getContext()->setParameter('_locale', $request->getLocale()); - } + $this->setLocale($request); + $this->setRouterContext($request); } public function onKernelRequest(GetResponseEvent $event) @@ -53,7 +71,33 @@ class LocaleListener implements EventSubscriberInterface $request = $event->getRequest(); $request->setDefaultLocale($this->defaultLocale); - $this->setRequest($request); + $this->setLocale($request); + $this->setRouterContext($request); + } + + public function onKernelFinishRequest(FinishRequestEvent $event) + { + if (null === $this->requestStack) { + return; // removed when requestStack is required + } + + if (null !== $parentRequest = $this->requestStack->getParentRequest()) { + $this->setRouterContext($parentRequest); + } + } + + private function setLocale(Request $request) + { + if ($locale = $request->attributes->get('_locale')) { + $request->setLocale($locale); + } + } + + private function setRouterContext(Request $request) + { + if (null !== $this->router) { + $this->router->getContext()->setParameter('_locale', $request->getLocale()); + } } public static function getSubscribedEvents() @@ -61,6 +105,7 @@ class LocaleListener implements EventSubscriberInterface return array( // must be registered after the Router to have access to the _locale KernelEvents::REQUEST => array(array('onKernelRequest', 16)), + KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), ); } } 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 5b2228ba1a58..995c998b6ff1 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 @@ -11,14 +11,14 @@ namespace Symfony\Component\HttpKernel\EventListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\HttpFoundation\RequestMatcherInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -33,9 +33,10 @@ class ProfilerListener implements EventSubscriberInterface protected $onlyException; protected $onlyMasterRequests; protected $exception; - protected $children; - protected $requests; + protected $requests = array(); protected $profiles; + protected $requestStack; + protected $parents; /** * Constructor. @@ -45,14 +46,15 @@ class ProfilerListener implements EventSubscriberInterface * @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 */ - public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false) + 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->children = new \SplObjectStorage(); - $this->profiles = array(); + $this->profiles = new \SplObjectStorage(); + $this->parents = new \SplObjectStorage(); + $this->requestStack = $requestStack; } /** @@ -62,16 +64,21 @@ class ProfilerListener implements EventSubscriberInterface */ public function onKernelException(GetResponseForExceptionEvent $event) { - if ($this->onlyMasterRequests && HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if ($this->onlyMasterRequests && !$event->isMasterRequest()) { return; } $this->exception = $event->getException(); } + /** + * @deprecated Deprecated since version 2.4, to be removed in 3.0. + */ public function onKernelRequest(GetResponseEvent $event) { - $this->requests[] = $event->getRequest(); + if (null === $this->requestStack) { + $this->requests[] = $event->getRequest(); + } } /** @@ -81,7 +88,7 @@ class ProfilerListener implements EventSubscriberInterface */ public function onKernelResponse(FilterResponseEvent $event) { - $master = HttpKernelInterface::MASTER_REQUEST === $event->getRequestType(); + $master = $event->isMasterRequest(); if ($this->onlyMasterRequests && !$master) { return; } @@ -102,40 +109,36 @@ class ProfilerListener implements EventSubscriberInterface return; } - $this->profiles[] = $profile; + $this->profiles[$request] = $profile; - if (null !== $exception) { - foreach ($this->profiles as $profile) { - $this->profiler->saveProfile($profile); - } - - return; - } - - // keep the profile as the child of its parent - if (!$master) { + if (null !== $this->requestStack) { + $this->parents[$request] = $this->requestStack->getParentRequest(); + } elseif (!$master) { + // to be removed when requestStack is required array_pop($this->requests); - $parent = end($this->requests); + $this->parents[$request] = end($this->requests); + } + } - // when simulating requests, we might not have the parent - if ($parent) { - $profiles = isset($this->children[$parent]) ? $this->children[$parent] : array(); - $profiles[] = $profile; - $this->children[$parent] = $profiles; + public function onKernelTerminate(PostResponseEvent $event) + { + // attach children to parents + 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->children[$request])) { - foreach ($this->children[$request] as $child) { - $profile->addChild($child); - } - $this->children[$request] = array(); + // save profiles + foreach ($this->profiles as $request) { + $this->profiler->saveProfile($this->profiles[$request]); } - if ($master) { - $this->saveProfiles($profile); - } + $this->profiles = new \SplObjectStorage(); + $this->parents = new \SplObjectStorage(); + $this->requests = array(); } public static function getSubscribedEvents() @@ -146,19 +149,7 @@ class ProfilerListener implements EventSubscriberInterface KernelEvents::REQUEST => array('onKernelRequest', 1024), KernelEvents::RESPONSE => array('onKernelResponse', -100), KernelEvents::EXCEPTION => 'onKernelException', + KernelEvents::TERMINATE => array('onKernelTerminate', -1024), ); } - - /** - * Saves the profile hierarchy. - * - * @param Profile $profile The root profile - */ - private function saveProfiles(Profile $profile) - { - $this->profiler->saveProfile($profile); - foreach ($profile->getChildren() as $profile) { - $this->saveProfiles($profile); - } - } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php index 669980cf2b61..eeb2b0fcb235 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -37,7 +36,7 @@ class ResponseListener implements EventSubscriberInterface */ public function onKernelResponse(FilterResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { return; } 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 f68716c144f8..27ac632b6fae 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 @@ -13,9 +13,11 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; @@ -28,6 +30,11 @@ use Symfony\Component\HttpFoundation\Request; /** * Initializes the context from the request and sets request attributes based on a matching route. * + * This listener works in 2 modes: + * + * * 2.3 compatibility mode where you must call setRequest whenever the Request changes. + * * 2.4+ mode where you must pass a RequestStack instance in the constructor. + * * @author Fabien Potencier */ class RouterListener implements EventSubscriberInterface @@ -36,17 +43,20 @@ class RouterListener implements EventSubscriberInterface private $context; private $logger; private $request; + private $requestStack; /** * Constructor. * + * 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 * * @throws \InvalidArgumentException */ - public function __construct($matcher, RequestContext $context = null, LoggerInterface $logger = null) + public function __construct($matcher, RequestContext $context = null, LoggerInterface $logger = null, RequestStack $requestStack = null) { if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) { throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); @@ -58,18 +68,20 @@ class RouterListener implements EventSubscriberInterface $this->matcher = $matcher; $this->context = $context ?: $matcher->getContext(); + $this->requestStack = $requestStack; $this->logger = $logger; } /** * Sets the current Request. * - * The application should call this method whenever the Request - * object changes (entering a Request scope for instance, but - * also when leaving a Request scope -- especially when they are - * nested). + * This method was used to synchronize the Request, but as the HttpKernel + * is doing that automatically now, you should never call it directly. + * It is kept public for BC with the 2.3 version. * * @param Request|null $request A Request instance + * + * @deprecated Deprecated since version 2.4, to be moved to a private function in 3.0. */ public function setRequest(Request $request = null) { @@ -79,6 +91,15 @@ class RouterListener implements EventSubscriberInterface $this->request = $request; } + public function onKernelFinishRequest(FinishRequestEvent $event) + { + if (null === $this->requestStack) { + return; // removed when requestStack is required + } + + $this->setRequest($this->requestStack->getParentRequest()); + } + public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); @@ -86,7 +107,10 @@ class RouterListener implements EventSubscriberInterface // initialize the context that is also used by the generator (assuming matcher and generator share the same context instance) // we call setRequest even if most of the time, it has already been done to keep compatibility // with frameworks which do not use the Symfony service container - $this->setRequest($request); + // when we have a RequestStack, no need to do it + if (null !== $this->requestStack) { + $this->setRequest($request); + } if ($request->attributes->has('_controller')) { // routing is already done @@ -113,9 +137,13 @@ class RouterListener implements EventSubscriberInterface } catch (ResourceNotFoundException $e) { $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo()); + if ($referer = $request->headers->get('referer')) { + $message .= sprintf(' (from "%s")', $referer); + } + throw new NotFoundHttpException($message, $e); } catch (MethodNotAllowedException $e) { - $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), strtoupper(implode(', ', $e->getAllowedMethods()))); + $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); } @@ -135,6 +163,7 @@ class RouterListener implements EventSubscriberInterface { return array( KernelEvents::REQUEST => array(array('onKernelRequest', 32)), + KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), ); } } 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 new file mode 100644 index 000000000000..d1023b297c0f --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php @@ -0,0 +1,54 @@ + + * + * 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\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * Sets the session in the request. + * + * @author Johannes M. Schmitt + */ +abstract class SessionListener implements EventSubscriberInterface +{ + public function onKernelRequest(GetResponseEvent $event) + { + if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + return; + } + + $request = $event->getRequest(); + $session = $this->getSession(); + if (null === $session || $request->hasSession()) { + return; + } + + $request->setSession($session); + } + + public static function getSubscribedEvents() + { + return array( + KernelEvents::REQUEST => array('onKernelRequest', 128), + ); + } + + /** + * Gets the session object. + * + * @return SessionInterface|null A SessionInterface instance of null if no session is available + */ + abstract protected function getSession(); +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php index 88505fac6e7a..571cd74e343d 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php @@ -13,7 +13,6 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -32,7 +31,7 @@ class StreamedResponseListener implements EventSubscriberInterface */ public function onKernelResponse(FilterResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { return; } 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 new file mode 100644 index 000000000000..ee047a6accbd --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php @@ -0,0 +1,84 @@ + + * + * 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\HttpFoundation\Cookie; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * TestSessionListener. + * + * Saves session in test environment. + * + * @author Bulat Shakirzyanov + * @author Fabien Potencier + */ +abstract class TestSessionListener implements EventSubscriberInterface +{ + public function onKernelRequest(GetResponseEvent $event) + { + if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + return; + } + + // bootstrap the session + $session = $this->getSession(); + if (!$session) { + return; + } + + $cookies = $event->getRequest()->cookies; + + if ($cookies->has($session->getName())) { + $session->setId($cookies->get($session->getName())); + } + } + + /** + * Checks if session was initialized and saves if current request is master + * Runs on 'kernel.response' in test environment + * + * @param FilterResponseEvent $event + */ + public function onKernelResponse(FilterResponseEvent $event) + { + if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + return; + } + + $session = $event->getRequest()->getSession(); + if ($session && $session->isStarted()) { + $session->save(); + $params = session_get_cookie_params(); + $event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'])); + } + } + + public static function getSubscribedEvents() + { + return array( + KernelEvents::REQUEST => array('onKernelRequest', 192), + KernelEvents::RESPONSE => array('onKernelResponse', -128), + ); + } + + /** + * Gets the session object. + * + * @return SessionInterface|null A SessionInterface instance of null if no session is available + */ + abstract protected function getSession(); +} 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 68b1a87da65c..a491a85ade22 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 @@ -35,7 +35,7 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer * @param Esi $esi An Esi instance * @param InlineFragmentRenderer $inlineStrategy The inline strategy to use when ESI is not supported */ - public function __construct(Esi $esi, InlineFragmentRenderer $inlineStrategy) + public function __construct(Esi $esi = null, InlineFragmentRenderer $inlineStrategy) { $this->esi = $esi; $this->inlineStrategy = $inlineStrategy; @@ -56,7 +56,7 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer */ public function render($uri, Request $request, array $options = array()) { - if (!$this->esi->hasSurrogateEsiCapability($request)) { + if (!$this->esi || !$this->esi->hasSurrogateEsiCapability($request)) { return $this->inlineStrategy->render($uri, $request, $options); } 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 af9b9ba98b74..029730484439 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 @@ -14,6 +14,7 @@ namespace Symfony\Component\HttpKernel\Fragment; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Controller\ControllerReference; /** @@ -22,6 +23,11 @@ use Symfony\Component\HttpKernel\Controller\ControllerReference; * This class handles the rendering of resource fragments that are included into * a main resource. The handling of the rendering is managed by specialized renderers. * + * This listener works in 2 modes: + * + * * 2.3 compatibility mode where you must call setRequest whenever the Request changes. + * * 2.4+ mode where you must pass a RequestStack instance in the constructor. + * * @author Fabien Potencier * * @see FragmentRendererInterface @@ -29,18 +35,22 @@ use Symfony\Component\HttpKernel\Controller\ControllerReference; class FragmentHandler { private $debug; - private $renderers; + private $renderers = array(); private $request; + private $requestStack; /** * Constructor. * - * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances - * @param Boolean $debug Whether the debug mode is enabled or not + * 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 RequestStack|null $requestStack The Request stack that controls the lifecycle of requests */ - public function __construct(array $renderers = array(), $debug = false) + public function __construct(array $renderers = array(), $debug = false, RequestStack $requestStack = null) { - $this->renderers = array(); + $this->requestStack = $requestStack; foreach ($renderers as $renderer) { $this->addRenderer($renderer); } @@ -60,7 +70,13 @@ class FragmentHandler /** * Sets the current Request. * - * @param Request $request The current Request + * This method was used to synchronize the Request, but as the HttpKernel + * is doing that automatically now, you should never call it directly. + * It is kept public for BC with the 2.3 version. + * + * @param Request|null $request A Request instance + * + * @deprecated Deprecated since version 2.4, to be removed in 3.0. */ public function setRequest(Request $request = null) { @@ -81,7 +97,7 @@ class FragmentHandler * @return string|null The Response content or null when the Response is streamed * * @throws \InvalidArgumentException when the renderer does not exist - * @throws \RuntimeException when the Response is not successful + * @throws \LogicException when the Request is not successful */ public function render($uri, $renderer = 'inline', array $options = array()) { @@ -93,11 +109,11 @@ class FragmentHandler throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer)); } - if (null === $this->request) { - throw new \LogicException('Rendering a fragment can only be done when handling a master Request.'); + if (!$request = $this->getRequest()) { + throw new \LogicException('Rendering a fragment can only be done when handling a Request.'); } - return $this->deliver($this->renderers[$renderer]->render($uri, $this->request, $options)); + return $this->deliver($this->renderers[$renderer]->render($uri, $request, $options)); } /** @@ -115,7 +131,7 @@ class FragmentHandler protected function deliver(Response $response) { if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->request->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->getRequest()->getUri(), $response->getStatusCode())); } if (!$response instanceof StreamedResponse) { @@ -124,4 +140,9 @@ class FragmentHandler $response->sendContent(); } + + private function getRequest() + { + return $this->requestStack ? $this->requestStack->getCurrentRequest() : $this->request; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php index a758d2c58200..ae172df80da3 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php @@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Fragment; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; +use Symfony\Component\HttpFoundation\Response; /** * Interface implemented by all rendering strategies. 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 882bc2b0f28a..8fc45724e76b 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 @@ -91,7 +91,8 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.'); } - $uri = $this->signer->sign($this->generateFragmentUri($uri, $request)); + // we need to sign the absolute URI, but want to return the path only. + $uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), strlen($request->getSchemeAndHttpHost())); } // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content. 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 a3f37c359ae7..c6ca3d475e88 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 @@ -32,7 +32,8 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer /** * Constructor. * - * @param HttpKernelInterface $kernel A HttpKernelInterface instance + * @param HttpKernelInterface $kernel A HttpKernelInterface instance + * @param EventDispatcherInterface $dispatcher A EventDispatcherInterface instance */ public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null) { @@ -60,14 +61,15 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer $attributes = $reference->attributes; $reference->attributes = array(); - // The request format and locale might have been overriden by the user + // The request format and locale might have been overridden by the user foreach (array('_format', '_locale') as $key) { if (isset($attributes[$key])) { $reference->attributes[$key] = $attributes[$key]; } } - $uri = $this->generateFragmentUri($uri, $request); + $uri = $this->generateFragmentUri($uri, $request, false, false); + $reference->attributes = array_merge($attributes, $reference->attributes); } @@ -130,7 +132,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer $server['REMOTE_ADDR'] = '127.0.0.1'; - $subRequest = $request::create($uri, 'get', array(), $cookies, array(), $server); + $subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server); if ($request->headers->has('Surrogate-Capability')) { $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability')); } 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 1f3b84f61904..bdf710b27a56 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 @@ -40,12 +40,18 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface * Generates a fragment URI for a given controller. * * @param ControllerReference $reference A ControllerReference instance - * @param Request $request A Request 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 * * @return string A fragment URI */ - protected function generateFragmentUri(ControllerReference $reference, Request $request) + protected function generateFragmentUri(ControllerReference $reference, Request $request, $absolute = false, $strict = true) { + if ($strict) { + $this->checkNonScalar($reference->attributes); + } + // We need to forward the current _format and _locale values as we don't have // a proper routing pattern to do the job for us. // This makes things inconsistent if you switch from rendering a controller @@ -62,6 +68,23 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface $reference->query['_path'] = http_build_query($reference->attributes, '', '&'); - return $request->getUriForPath($this->fragmentPath.'?'.http_build_query($reference->query, '', '&')); + $path = $this->fragmentPath.'?'.http_build_query($reference->query, '', '&'); + + if ($absolute) { + return $request->getUriForPath($path); + } + + return $request->getBaseUrl().$path; + } + + 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)); + } + } } } 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 63cde7e5b222..f80d6f03e73c 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 @@ -19,7 +19,6 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\TerminableInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\Esi; /** * Cache provides HTTP caching. @@ -35,7 +34,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface private $request; private $esi; private $esiCacheStrategy; - private $traces; + private $options = array(); + private $traces = array(); /** * Constructor. @@ -81,6 +81,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface { $this->store = $store; $this->kernel = $kernel; + $this->esi = $esi; // needed in case there is a fatal error because the backend is too slow to respond register_shutdown_function(array($this->store, 'cleanup')); @@ -94,8 +95,6 @@ class HttpCache implements HttpKernelInterface, TerminableInterface 'stale_while_revalidate' => 2, 'stale_if_error' => 60, ), $options); - $this->esi = $esi; - $this->traces = array(); } /** @@ -268,7 +267,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface // As per the RFC, invalidate Location and Content-Location URLs if present foreach (array('Location', 'Content-Location') as $header) { if ($uri = $response->headers->get($header)) { - $subRequest = $request::create($uri, 'get', array(), array(), array(), $request->server->all()); + $subRequest = Request::create($uri, 'get', array(), array(), array(), $request->server->all()); $this->store->invalidate($subRequest); } 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 a1cda1fd2709..1d55ab4118f2 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 @@ -50,7 +50,9 @@ class Store implements StoreInterface { // unlock everything foreach ($this->locks as $lock) { - @unlink($lock); + if (file_exists($lock)) { + @unlink($lock); + } } $error = error_get_last(); @@ -214,7 +216,7 @@ class Store implements StoreInterface */ protected function generateContentDigest(Response $response) { - return 'en'.sha1($response->getContent()); + return 'en'.hash('sha256', $response->getContent()); } /** @@ -364,6 +366,25 @@ class Store implements StoreInterface return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6); } + /** + * Generates a cache key for the given Request. + * + * This method should return a key that must only depend on a + * normalized version of the request URI. + * + * If the same URI can have more than one representation, based on some + * headers, use a Vary header to indicate them, and each representation will + * be stored independently under the same cache key. + * + * @param Request $request A Request instance + * + * @return string A key for the given Request + */ + protected function generateCacheKey(Request $request) + { + return 'md'.hash('sha256', $request->getUri()); + } + /** * Returns a cache key for the given Request. * @@ -377,7 +398,7 @@ class Store implements StoreInterface return $this->keyCache[$request]; } - return $this->keyCache[$request] = 'md'.sha1($request->getUri()); + return $this->keyCache[$request] = $this->generateCacheKey($request); } /** 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 837a16ff370e..0be8e1b4dbb7 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php @@ -16,11 +16,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -35,19 +37,22 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface { protected $dispatcher; protected $resolver; + protected $requestStack; /** * Constructor * - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance + * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance + * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance + * @param RequestStack $requestStack A stack for master/sub requests * * @api */ - public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver) + public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null) { $this->dispatcher = $dispatcher; $this->resolver = $resolver; + $this->requestStack = $requestStack ?: new RequestStack(); } /** @@ -61,6 +66,8 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface return $this->handleRaw($request, $type); } catch (\Exception $e) { if (false === $catch) { + $this->finishRequest($request, $type); + throw $e; } @@ -93,6 +100,8 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface */ private function handleRaw(Request $request, $type = self::MASTER_REQUEST) { + $this->requestStack->push($request); + // request $event = new GetResponseEvent($this, $request, $type); $this->dispatcher->dispatch(KernelEvents::REQUEST, $event); @@ -156,9 +165,27 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); + $this->finishRequest($request, $type); + return $event->getResponse(); } + /** + * Publishes the finish request event, then pop the request from the stack. + * + * Note that the order of the operations is important here, otherwise + * operations such as {@link RequestStack::getParentRequest()} can lead to + * weird results. + * + * @param Request $request + * @param int $type + */ + private function finishRequest(Request $request, $type) + { + $this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this, $request, $type)); + $this->requestStack->pop(); + } + /** * Handles an exception by trying to convert it to a Response. * @@ -179,6 +206,8 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface $e = $event->getException(); if (!$event->hasResponse()) { + $this->finishRequest($request, $type); + throw $e; } 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 96a746ee8007..94353c042211 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php @@ -24,7 +24,6 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; @@ -48,24 +47,23 @@ abstract class Kernel implements KernelInterface, TerminableInterface /** * @var BundleInterface[] */ - protected $bundles; + protected $bundles = array(); protected $bundleMap; protected $container; protected $rootDir; protected $environment; protected $debug; - protected $booted; + protected $booted = false; protected $name; protected $startTime; protected $loadClassCache; - protected $errorReportingLevel; - const VERSION = '2.3.4'; - const VERSION_ID = '20304'; + const VERSION = '2.4.1'; + const VERSION_ID = '20401'; const MAJOR_VERSION = '2'; - const MINOR_VERSION = '3'; - const RELEASE_VERSION = '4'; + const MINOR_VERSION = '4'; + const RELEASE_VERSION = '1'; const EXTRA_VERSION = ''; /** @@ -80,10 +78,8 @@ abstract class Kernel implements KernelInterface, TerminableInterface { $this->environment = $environment; $this->debug = (Boolean) $debug; - $this->booted = false; $this->rootDir = $this->getRootDir(); $this->name = $this->getName(); - $this->bundles = array(); if ($this->debug) { $this->startTime = microtime(true); @@ -190,7 +186,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface } /** - * Gets a http kernel from the container + * Gets a HTTP kernel from the container * * @return HttpKernel */ @@ -498,7 +494,9 @@ abstract class Kernel implements KernelInterface, TerminableInterface } // look for orphans - if (count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) { + if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) { + $diff = array_keys($diff); + throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0])); } @@ -713,7 +711,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass)); if (!$this->debug) { - $content = self::stripComments($content); + $content = static::stripComments($content); } $cache->write($content, $container->getResources()); 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 fce48ac3a6ed..5e6ebcb8d992 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php @@ -102,4 +102,14 @@ final class KernelEvents * @var string */ const TERMINATE = 'kernel.terminate'; + + /** + * The REQUEST_FINISHED 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. + * + * @var string + */ + const FINISH_REQUEST = 'kernel.finish_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 dd37b60e0325..6905a1279c3c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\Config\Loader\LoaderInterface; 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 69ff9730540e..fd6bd96e2d85 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 @@ -89,7 +89,7 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface --$limit; } - usort($result, function($a, $b) { + usort($result, function ($a, $b) { if ($a['time'] === $b['time']) { return 0; } 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 9265fc13f5c5..e225b0dd2eeb 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 @@ -70,7 +70,7 @@ class FileProfilerStorage implements ProfilerStorageInterface } if (!empty($start) && $csvTime < $start) { - continue; + continue; } if (!empty($end) && $csvTime > $end) { 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 a78cec0c8a32..2034a19db1e6 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 @@ -42,7 +42,7 @@ class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage $host = $matches[1] ?: $matches[2]; $port = $matches[3]; - $memcache = new Memcache; + $memcache = new Memcache(); $memcache->addServer($host, $port); $this->memcache = $memcache; 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 f7f68423589a..31f313639085 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 @@ -42,7 +42,7 @@ class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage $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); 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 49f3137e1525..b545b4acd510 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 @@ -13,8 +13,8 @@ namespace Symfony\Component\HttpKernel\Profiler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface; use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; +use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Psr\Log\LoggerInterface; /** @@ -109,6 +109,13 @@ class Profiler */ public function saveProfile(Profile $profile) { + // late collect + foreach ($profile->getCollectors() as $collector) { + if ($collector instanceof LateDataCollectorInterface) { + $collector->lateCollect(); + } + } + if (!($ret = $this->storage->write($profile)) && null !== $this->logger) { $this->logger->warning('Unable to store the profiler information.'); } @@ -204,7 +211,7 @@ class Profiler return; } - $profile = new Profile(substr(sha1(uniqid(mt_rand(), true)), 0, 6)); + $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6)); $profile->setTime(time()); $profile->setUrl($request->getUri()); $profile->setIp($request->getClientIp()); @@ -215,8 +222,8 @@ class Profiler foreach ($this->collectors as $collector) { $collector->collect($request, $response, $exception); - // forces collectors to become "read/only" (they loose their object dependencies) - $profile->addCollector(unserialize(serialize($collector))); + // we need to clone for sub-requests + $profile->addCollector(clone $collector); } return $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 d62d6c7996d0..de2decfbf59e 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 @@ -11,8 +11,6 @@ namespace Symfony\Component\HttpKernel\Profiler; -use Redis; - /** * RedisProfilerStorage stores profiling information in Redis. * @@ -32,7 +30,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface protected $lifetime; /** - * @var Redis + * @var \Redis */ private $redis; @@ -199,7 +197,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface /** * Internal convenience method that returns the instance of Redis. * - * @return Redis + * @return \Redis * * @throws \RuntimeException */ @@ -216,7 +214,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface 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'])) { @@ -238,7 +236,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface /** * Set instance of the Redis * - * @param Redis $redis + * @param \Redis $redis */ public function setRedis($redis) { diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md index e0f3c987c477..7aa0656b3afb 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md @@ -85,5 +85,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/HttpKernel/ - $ composer.phar install --dev + $ composer.phar install $ phpunit 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 8affb5f300bf..a451b7aba021 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,28 +11,18 @@ 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\ExtensionPresentBundle\ExtensionPresentBundle; 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; class BundleTest extends \PHPUnit_Framework_TestCase { public function testRegisterCommands() { - if (!class_exists('Symfony\Component\Console\Application')) { - $this->markTestSkipped('The "Console" component is not available'); - } - - if (!interface_exists('Symfony\Component\DependencyInjection\ContainerAwareInterface')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - - if (!class_exists('Symfony\Component\Finder\Finder')) { - $this->markTestSkipped('The "Finder" component is not available'); - } - $cmd = new FooCommand(); $app = $this->getMock('Symfony\Component\Console\Application'); $app->expects($this->once())->method('add')->with($this->equalTo($cmd)); @@ -43,6 +33,25 @@ class BundleTest extends \PHPUnit_Framework_TestCase $bundle2 = new ExtensionAbsentBundle(); $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 755d7f614c97..c58c9588d5d4 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 @@ -22,13 +22,6 @@ use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient; class ClientTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\BrowserKit\Client')) { - $this->markTestSkipped('The "BrowserKit" component is not available'); - } - } - public function testDoRequest() { $client = new Client(new TestHttpKernel()); @@ -50,14 +43,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase public function testGetScript() { - if (!class_exists('Symfony\Component\Process\Process')) { - $this->markTestSkipped('The "Process" component is not available'); - } - - if (!class_exists('Symfony\Component\ClassLoader\ClassLoader')) { - $this->markTestSkipped('The "ClassLoader" component is not available'); - } - $client = new TestClient(new TestHttpKernel()); $client->insulate(); $client->request('GET', '/'); 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 aa401f44d6f4..dd14186dd267 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 @@ -9,20 +9,14 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests; +namespace Symfony\Component\HttpKernel\Tests\Controller; use Symfony\Component\HttpKernel\Controller\ControllerResolver; +use Symfony\Component\HttpKernel\Tests\Logger; use Symfony\Component\HttpFoundation\Request; class ControllerResolverTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testGetController() { $logger = new Logger(); @@ -32,9 +26,9 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $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\ControllerResolverTest::testGetController'); + $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::testGetController'); $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable'); + $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable'); $request->attributes->set('_controller', $lambda = function () {}); $controller = $resolver->getController($request); @@ -44,21 +38,21 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $controller = $resolver->getController($request); $this->assertSame($this, $controller); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\ControllerResolverTest'); + $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest'); $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\ControllerResolverTest', $controller); + $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller); $request->attributes->set('_controller', array($this, 'controllerMethod1')); $controller = $resolver->getController($request); $this->assertSame(array($this, 'controllerMethod1'), $controller); - $request->attributes->set('_controller', array('Symfony\Component\HttpKernel\Tests\ControllerResolverTest', 'controllerMethod4')); + $request->attributes->set('_controller', array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4')); $controller = $resolver->getController($request); - $this->assertSame(array('Symfony\Component\HttpKernel\Tests\ControllerResolverTest', 'controllerMethod4'), $controller); + $this->assertSame(array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4'), $controller); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\some_controller_function'); + $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'); $controller = $resolver->getController($request); - $this->assertSame('Symfony\Component\HttpKernel\Tests\some_controller_function', $controller); + $this->assertSame('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function', $controller); $request->attributes->set('_controller', 'foo'); try { @@ -76,7 +70,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('\InvalidArgumentException', $e, '->getController() throws an \InvalidArgumentException if the _controller attribute contains a non-existent class'); } - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\ControllerResolverTest::bar'); + $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'); @@ -126,7 +120,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('foobar', 'foobar'); - $controller = 'Symfony\Component\HttpKernel\Tests\some_controller_function'; + $controller = 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'; $this->assertEquals(array('foo', 'foobar'), $resolver->getArguments($request, $controller)); $request = Request::create('/'); @@ -153,7 +147,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase public function testCreateControllerCanReturnAnyCallable() { $mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController')); - $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\some_controller_function')); + $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); $request = Request::create('/'); $request->attributes->set('_controller', 'foobar'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 192c8083e027..0c7396158631 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -19,13 +19,6 @@ use Symfony\Component\HttpFoundation\Response; class ConfigDataCollectorTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testCollect() { $kernel = new KernelForTest('test', true); 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 54a8aabe671b..ebea3ea6e1fc 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 @@ -18,13 +18,6 @@ use Symfony\Component\HttpFoundation\Response; class ExceptionDataCollectorTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testCollect() { $e = new \Exception('foo',500); 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 ea82d9d31573..7cd4d06c7ad6 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 @@ -13,18 +13,9 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector; use Symfony\Component\HttpKernel\Debug\ErrorHandler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - /** * @dataProvider getCollectTestData */ @@ -35,7 +26,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); $c = new LoggerDataCollector($logger); - $c->collect(new Request(), new Response()); + $c->lateCollect(); $this->assertSame('logger', $c->getName()); $this->assertSame($nb, $c->countErrors()); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php index 607a580aefc9..340b42881688 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php @@ -17,13 +17,6 @@ use Symfony\Component\HttpFoundation\Response; class MemoryDataCollectorTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testCollect() { $collector = new MemoryDataCollector(); @@ -56,6 +49,7 @@ class MemoryDataCollectorTest extends \PHPUnit_Framework_TestCase array('010', 8), array('+0x10 k', 16 * 1024), array('1g', 1024 * 1024 * 1024), + array('1G', 1024 * 1024 * 1024), array('-1', -1), array('0', 0), array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' 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 8c14604b28cd..bb80781ebeb5 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,13 +22,6 @@ use Symfony\Component\EventDispatcher\EventDispatcher; class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - /** * @dataProvider provider */ @@ -38,21 +31,23 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase $c->collect($request, $response); - $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',$c->getRequestRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag',$c->getRequestQuery()); - $this->assertEquals('html',$c->getFormat()); - $this->assertEquals(array(),$c->getSessionAttributes()); - $this->assertEquals('en',$c->getLocale()); + $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', $c->getRequestRequest()); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); + $this->assertSame('html', $c->getFormat()); + $this->assertSame('foobar', $c->getRoute()); + $this->assertSame(array('name' => 'foo'), $c->getRouteParams()); + $this->assertSame(array(), $c->getSessionAttributes()); + $this->assertSame('en', $c->getLocale()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag',$c->getResponseHeaders()); - $this->assertEquals('OK',$c->getStatusText()); - $this->assertEquals(200,$c->getStatusCode()); - $this->assertEquals('application/json',$c->getContentType()); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getResponseHeaders()); + $this->assertSame('OK', $c->getStatusText()); + $this->assertSame(200, $c->getStatusCode()); + $this->assertSame('application/json', $c->getContentType()); } /** @@ -80,7 +75,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase array( 'Closure', - function() { return 'foo'; }, + function () { return 'foo'; }, array( 'class' => __NAMESPACE__.'\{closure}', 'method' => null, @@ -145,7 +140,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase foreach ($controllerTests as $controllerTest) { $this->injectController($c, $controllerTest[1], $request); $c->collect($request, $response); - $this->assertEquals($controllerTest[2], $c->getController(), sprintf('Testing: %s', $controllerTest[0])); + $this->assertSame($controllerTest[2], $c->getController(), sprintf('Testing: %s', $controllerTest[0])); } } @@ -157,6 +152,8 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase $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')); $response = new Response(); $response->setStatusCode(200); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index 13abb6769694..b5d64bffe350 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -17,16 +17,9 @@ use Symfony\Component\HttpFoundation\Response; class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testCollect() { - $c = new TimeDataCollector; + $c = new TimeDataCollector(); $request = new Request(); $request->server->set('REQUEST_TIME', 1); @@ -42,7 +35,7 @@ class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase $this->assertEquals(2000, $c->getStartTime()); $request = new Request(); - $c->collect($request, new Response); + $c->collect($request, new Response()); $this->assertEquals(0, $c->getStartTime()); $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); 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 a5f507cd4eea..d30837d2c685 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 @@ -22,17 +22,6 @@ use Symfony\Component\Stopwatch\Stopwatch; class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testAddRemoveListener() { $dispatcher = new EventDispatcher(); @@ -159,6 +148,22 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase $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()); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php index 61372cd3a0c8..83182e63eae5 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php @@ -13,27 +13,13 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventDispatcher; class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - /** * @dataProvider getProviderTypes */ @@ -41,61 +27,51 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase { $request = new Request(); $expected = new Response(); - - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container - ->expects($this->once()) - ->method('enterScope') - ->with($this->equalTo('request')) - ; - $container - ->expects($this->once()) - ->method('leaveScope') - ->with($this->equalTo('request')) - ; - $container - ->expects($this->at(0)) - ->method('hasScope') - ->with($this->equalTo('request')) - ->will($this->returnValue(false)); - $container - ->expects($this->at(1)) - ->method('addScope') - ->with($this->isInstanceOf('Symfony\Component\DependencyInjection\Scope')); - // enterScope() - $container - ->expects($this->at(3)) - ->method('set') - ->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request')) - ; - $container - ->expects($this->at(4)) - ->method('set') - ->with($this->equalTo('request'), $this->equalTo(null), $this->equalTo('request')) - ; - - $dispatcher = new EventDispatcher(); - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver); - - $controller = function() use ($expected) { + $controller = function () use ($expected) { return $expected; }; - $resolver->expects($this->once()) - ->method('getController') - ->with($request) - ->will($this->returnValue($controller)); - $resolver->expects($this->once()) - ->method('getArguments') - ->with($request, $controller) - ->will($this->returnValue(array())); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $this + ->expectsEnterScopeOnce($container) + ->expectsLeaveScopeOnce($container) + ->expectsSetRequestWithAt($container, $request, 3) + ->expectsSetRequestWithAt($container, null, 4) + ; + + $dispatcher = new EventDispatcher(); + $resolver = $this->getResolverMockFor($controller, $request); + $stack = new RequestStack(); + $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); $actual = $kernel->handle($request, $type); $this->assertSame($expected, $actual, '->handle() returns the response'); } + /** + * @dataProvider getProviderTypes + */ + public function testVerifyRequestStackPushPopDuringHandle($type) + { + $request = new Request(); + $expected = new Response(); + $controller = function () use ($expected) { + return $expected; + }; + + $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop')); + $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); + $stack->expects($this->at(1))->method('pop'); + + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $dispatcher = new EventDispatcher(); + $resolver = $this->getResolverMockFor($controller, $request); + $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); + + $kernel->handle($request, $type); + } + /** * @dataProvider getProviderTypes */ @@ -103,51 +79,23 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase { $request = new Request(); $expected = new \Exception(); + $controller = function () use ($expected) { + throw $expected; + }; $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container - ->expects($this->once()) - ->method('enterScope') - ->with($this->equalTo('request')) - ; - $container - ->expects($this->once()) - ->method('leaveScope') - ->with($this->equalTo('request')) - ; - $container - ->expects($this->at(0)) - ->method('hasScope') - ->with($this->equalTo('request')) - ->will($this->returnValue(true)); - // enterScope() - $container - ->expects($this->at(2)) - ->method('set') - ->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request')) - ; - $container - ->expects($this->at(3)) - ->method('set') - ->with($this->equalTo('request'), $this->equalTo(null), $this->equalTo('request')) + $this + ->expectsEnterScopeOnce($container) + ->expectsLeaveScopeOnce($container) + ->expectsSetRequestWithAt($container, $request, 3) + ->expectsSetRequestWithAt($container, null, 4) ; $dispatcher = new EventDispatcher(); $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver); - - $controller = function() use ($expected) { - throw $expected; - }; - - $resolver->expects($this->once()) - ->method('getController') - ->with($request) - ->will($this->returnValue($controller)); - $resolver->expects($this->once()) - ->method('getArguments') - ->with($request, $controller) - ->will($this->returnValue(array())); + $resolver = $this->getResolverMockFor($controller, $request); + $stack = new RequestStack(); + $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); try { $kernel->handle($request, $type); @@ -166,4 +114,52 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase array(HttpKernelInterface::SUB_REQUEST), ); } + + private function getResolverMockFor($controller, $request) + { + $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); + $resolver->expects($this->once()) + ->method('getController') + ->with($request) + ->will($this->returnValue($controller)); + $resolver->expects($this->once()) + ->method('getArguments') + ->with($request, $controller) + ->will($this->returnValue(array())); + + return $resolver; + } + + private function expectsSetRequestWithAt($container, $with, $at) + { + $container + ->expects($this->at($at)) + ->method('set') + ->with($this->equalTo('request'), $this->equalTo($with), $this->equalTo('request')) + ; + + return $this; + } + + private function expectsEnterScopeOnce($container) + { + $container + ->expects($this->once()) + ->method('enterScope') + ->with($this->equalTo('request')) + ; + + return $this; + } + + private function expectsLeaveScopeOnce($container) + { + $container + ->expects($this->once()) + ->method('leaveScope') + ->with($this->equalTo('request')) + ; + + return $this; + } } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php index 0800758b1d87..0df6a454b660 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php @@ -9,23 +9,12 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests; +namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - - if (!class_exists('Symfony\Component\Config\FileLocator')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - public function testAutoloadMainExtension() { $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php index d1e825a8241b..b82053ece6f0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase @@ -31,6 +30,9 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase ); $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition->expects($this->atLeastOnce()) + ->method('isPublic') + ->will($this->returnValue(true)); $definition->expects($this->atLeastOnce()) ->method('getClass') ->will($this->returnValue('stdClass')); @@ -60,6 +62,9 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase ); $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $definition->expects($this->atLeastOnce()) + ->method('isPublic') + ->will($this->returnValue(true)); $definition->expects($this->atLeastOnce()) ->method('getClass') ->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\SubscriberService')); @@ -78,9 +83,55 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase ->method('getDefinition') ->will($this->returnValue($definition)); + $builder->expects($this->atLeastOnce()) + ->method('findDefinition') + ->will($this->returnValue($definition)); + $registerListenersPass = new RegisterListenersPass(); $registerListenersPass->process($builder); } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The service "foo" must be public as event listeners are lazy-loaded. + */ + public function testPrivateEventListener() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_listener', array()); + $container->register('event_dispatcher', 'stdClass'); + + $registerListenersPass = new RegisterListenersPass(); + $registerListenersPass->process($container); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The service "foo" must be public as event subscribers are lazy-loaded. + */ + public function testPrivateEventSubscriber() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_subscriber', array()); + $container->register('event_dispatcher', 'stdClass'); + + $registerListenersPass = new RegisterListenersPass(); + $registerListenersPass->process($container); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded. + */ + public function testAbstractEventListener() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array()); + $container->register('event_dispatcher', 'stdClass'); + + $registerListenersPass = new RegisterListenersPass(); + $registerListenersPass->process($container); + } } class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/EsiListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/EsiListenerTest.php index 2eddc572a46d..56f68535f1e2 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/EsiListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/EsiListenerTest.php @@ -22,13 +22,6 @@ use Symfony\Component\EventDispatcher\EventDispatcher; class EsiListenerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - } - public function testFilterDoesNothingForSubRequests() { $dispatcher = new EventDispatcher(); 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 c6a01281a7d5..30e8c74ecd29 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 @@ -26,17 +26,6 @@ use Symfony\Component\HttpKernel\Tests\Logger; */ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testConstruct() { $logger = new TestLogger(); 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 153d8a44ff9c..ec9360a431eb 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 @@ -19,13 +19,6 @@ use Symfony\Component\HttpKernel\UriSigner; class FragmentListenerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - } - public function testOnlyTriggeredOnFragmentRoute() { $request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo'); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index e5e4e3a286df..d128753ffab0 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -11,23 +11,24 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; -use Symfony\Component\HttpKernel\EventListener\LocaleListener; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\EventListener\LocaleListener; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; class LocaleListenerTest extends \PHPUnit_Framework_TestCase { + private $requestStack; + protected function setUp() { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } + $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false); } public function testDefaultLocaleWithoutSession() { - $listener = new LocaleListener('fr'); + $listener = new LocaleListener('fr', null, $this->requestStack); $event = $this->getEvent($request = Request::create('/')); $listener->onKernelRequest($event); @@ -41,7 +42,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase $request->cookies->set('foo', 'value'); $request->attributes->set('_locale', 'es'); - $listener = new LocaleListener('fr'); + $listener = new LocaleListener('fr', null, $this->requestStack); $event = $this->getEvent($request); $listener->onKernelRequest($event); @@ -49,6 +50,22 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase } public function testLocaleSetForRoutingContext() + { + // the request context is updated + $context = $this->getMock('Symfony\Component\Routing\RequestContext'); + $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); + + $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false); + $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); + + $request = Request::create('/'); + + $request->attributes->set('_locale', 'es'); + $listener = new LocaleListener('fr', $router, $this->requestStack); + $listener->onKernelRequest($this->getEvent($request)); + } + + public function testRouterResetWithParentRequestOnKernelFinishRequest() { if (!class_exists('Symfony\Component\Routing\Router')) { $this->markTestSkipped('The "Routing" component is not available'); @@ -61,18 +78,22 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); - $request = Request::create('/'); + $parentRequest = Request::create('/'); + $parentRequest->setLocale('es'); - $request->attributes->set('_locale', 'es'); - $listener = new LocaleListener('fr', $router); - $listener->onKernelRequest($this->getEvent($request)); + $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); + + $event = $this->getMock('Symfony\Component\HttpKernel\Event\FinishRequestEvent', array(), array(), '', false); + + $listener = new LocaleListener('fr', $router, $this->requestStack); + $listener->onKernelFinishRequest($event); } public function testRequestLocaleIsNotOverridden() { $request = Request::create('/'); $request->setLocale('de'); - $listener = new LocaleListener('fr'); + $listener = new LocaleListener('fr', null, $this->requestStack); $event = $this->getEvent($request); $listener->onKernelRequest($event); 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 new file mode 100644 index 000000000000..772dfd0a4c11 --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -0,0 +1,55 @@ + + * + * 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\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\PostResponseEvent; +use Symfony\Component\HttpKernel\EventListener\ProfilerListener; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Kernel; + +class ProfilerListenerTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test to ensure BC without RequestStack + * + * @deprecated Deprecated since version 2.4, to be removed in 3.0. + */ + public function testEventsWithoutRequestStack() + { + $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'); + + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + ->disableOriginalConstructor() + ->getMock(); + + $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') + ->disableOriginalConstructor() + ->getMock(); + + $listener = new ProfilerListener($profiler); + $listener->onKernelRequest(new GetResponseEvent($kernel, $request, Kernel::MASTER_REQUEST)); + $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, Kernel::MASTER_REQUEST, $response)); + $listener->onKernelTerminate(new PostResponseEvent($kernel, $request, $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 3f8e85210445..2698f8e7625f 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 @@ -27,10 +27,6 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - $this->dispatcher = new EventDispatcher(); $listener = new ResponseListener('UTF-8'); $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 3ba56a8da78b..ac742b35e08c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -11,23 +11,20 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; -use Symfony\Component\HttpKernel\EventListener\RouterListener; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\EventListener\RouterListener; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Routing\RequestContext; class RouterListenerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } + private $requestStack; - if (!class_exists('Symfony\Component\Routing\Router')) { - $this->markTestSkipped('The "Routing" component is not available'); - } + public function setUp() + { + $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false); } /** @@ -45,7 +42,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase ->method('getContext') ->will($this->returnValue($context)); - $listener = new RouterListener($urlMatcher); + $listener = new RouterListener($urlMatcher, null, null, $this->requestStack); $event = $this->createGetResponseEventForUri($uri); $listener->onKernelRequest($event); @@ -83,7 +80,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase */ public function testInvalidMatcher() { - new RouterListener(new \stdClass()); + new RouterListener(new \stdClass(), null, null, $this->requestStack); } public function testRequestMatcher() @@ -98,7 +95,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) ->will($this->returnValue(array())); - $listener = new RouterListener($requestMatcher, new RequestContext()); + $listener = new RouterListener($requestMatcher, new RequestContext(), null, $this->requestStack); $listener->onKernelRequest($event); } @@ -119,7 +116,7 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase ->method('getContext') ->will($this->returnValue($context)); - $listener = new RouterListener($requestMatcher, new RequestContext()); + $listener = new RouterListener($requestMatcher, new RequestContext(), null, $this->requestStack); $listener->onKernelRequest($event); // sub-request with another HTTP method diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php new file mode 100644 index 000000000000..907c20375fee --- /dev/null +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -0,0 +1,132 @@ + + * + * 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\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpFoundation\Session\SessionInterface; + +/** + * SessionListenerTest. + * + * Tests SessionListener. + * + * @author Bulat Shakirzyanov + */ +class TestSessionListenerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var TestSessionListener + */ + private $listener; + + /** + * @var SessionInterface + */ + private $session; + + protected function setUp() + { + $this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\TestSessionListener'); + $this->session = $this->getSession(); + } + + public function testShouldSaveMasterRequestSession() + { + $this->sessionHasBeenStarted(); + $this->sessionMustBeSaved(); + + $this->filterResponse(new Request()); + } + + public function testShouldNotSaveSubRequestSession() + { + $this->sessionMustNotBeSaved(); + + $this->filterResponse(new Request(), HttpKernelInterface::SUB_REQUEST); + } + + public function testDoesNotDeleteCookieIfUsingSessionLifetime() + { + $this->sessionHasBeenStarted(); + + $params = session_get_cookie_params(); + session_set_cookie_params(0, $params['path'], $params['domain'], $params['secure'], $params['httponly']); + + $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); + $cookies = $response->headers->getCookies(); + + $this->assertEquals(0, reset($cookies)->getExpiresTime()); + } + + public function testUnstartedSessionIsNotSave() + { + $this->sessionHasNotBeenStarted(); + $this->sessionMustNotBeSaved(); + + $this->filterResponse(new Request()); + } + + private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST) + { + $request->setSession($this->session); + $response = new Response(); + $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $event = new FilterResponseEvent($kernel, $request, $type, $response); + + $this->listener->onKernelResponse($event); + + $this->assertSame($response, $event->getResponse()); + + return $response; + } + + private function sessionMustNotBeSaved() + { + $this->session->expects($this->never()) + ->method('save'); + } + + private function sessionMustBeSaved() + { + $this->session->expects($this->once()) + ->method('save'); + } + + private function sessionHasBeenStarted() + { + $this->session->expects($this->once()) + ->method('isStarted') + ->will($this->returnValue(true)); + } + + private function sessionHasNotBeenStarted() + { + $this->session->expects($this->once()) + ->method('isStarted') + ->will($this->returnValue(false)); + } + + private function getSession() + { + $mock = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session') + ->disableOriginalConstructor() + ->getMock(); + + // set return value for getName() + $mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID')); + + return $mock; + } +} diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php index e24daef2b353..5fd61bbc7e7c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php @@ -23,32 +23,15 @@ class KernelForTest extends Kernel public function registerBundles() { - } - - public function init() - { - } - - public function registerBundleDirs() - { + return array(); } public function registerContainerConfiguration(LoaderInterface $loader) { } - public function initializeBundles() - { - parent::initializeBundles(); - } - public function isBooted() { return $this->booted; } - - public function setIsBooted($value) - { - $this->booted = (Boolean) $value; - } } 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 5bbfdace9bde..8acf45d96f6d 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 @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Tests\Fragment\FragmentRenderer; +namespace Symfony\Component\HttpKernel\Tests\Fragment; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; @@ -18,13 +18,6 @@ use Symfony\Component\HttpFoundation\Request; class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testRenderFallbackToInlineStrategyIfNoRequest() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true)); @@ -48,7 +41,7 @@ class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase $this->assertEquals('', $strategy->render('/', $request)->getContent()); $this->assertEquals("\n", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); $this->assertEquals('', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent()); + $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent()); } private function getInlineStrategy($called = false) diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index cec8ae98403a..1893d85b80ac 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php @@ -17,17 +17,32 @@ use Symfony\Component\HttpFoundation\Response; class FragmentHandlerTest extends \PHPUnit_Framework_TestCase { + private $requestStack; + + public function setUp() + { + $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') + ->disableOriginalConstructor() + ->getMock() + ; + $this->requestStack + ->expects($this->any()) + ->method('getCurrentRequest') + ->will($this->returnValue(Request::create('/'))) + ; + } + /** * @expectedException \InvalidArgumentException */ public function testRenderWhenRendererDoesNotExist() { - $handler = new FragmentHandler(); + $handler = new FragmentHandler(array(), null, $this->requestStack); $handler->render('/', 'foo'); } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testRenderWithUnknownRenderer() { @@ -37,7 +52,7 @@ class FragmentHandlerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException * @expectedExceptionMessage Error when rendering "http://localhost/" (Status code is 404). */ public function testDeliverWithUnsuccessfulResponse() @@ -72,9 +87,8 @@ class FragmentHandlerTest extends \PHPUnit_Framework_TestCase call_user_func_array(array($e, 'with'), $arguments); } - $handler = new FragmentHandler(); + $handler = new FragmentHandler(array(), null, $this->requestStack); $handler->addRenderer($renderer); - $handler->setRequest(Request::create('/')); return $handler; } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index 20840f35e0e7..2f266dba77cd 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Fragment\Tests\FragmentRenderer; +namespace Symfony\Component\HttpKernel\Tests\Fragment; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; @@ -18,13 +18,6 @@ use Symfony\Component\HttpFoundation\Request; class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - /** * @expectedException \LogicException */ @@ -38,7 +31,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase { $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); + $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); } public function testRenderWithUri() 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 ffc0c0aab09c..c7252c9cba55 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 @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Fragment\Tests\FragmentRenderer; +namespace Symfony\Component\HttpKernel\Tests\Fragment; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\HttpKernel; @@ -21,17 +21,6 @@ use Symfony\Component\EventDispatcher\EventDispatcher; class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testRender() { $strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo')))); @@ -67,6 +56,24 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/')); } + public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController() + { + $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver', array('getController')); + $resolver + ->expects($this->once()) + ->method('getController') + ->will($this->returnValue(function (\stdClass $object, Bar $object1) { + return new Response($object1->getBar()); + })) + ; + + $kernel = new HttpKernel(new EventDispatcher(), $resolver); + $renderer = new InlineFragmentRenderer($kernel); + + $response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/')); + $this->assertEquals('bar', $response->getContent()); + } + public function testRenderWithTrustedHeaderDisabled() { $trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP); @@ -83,7 +90,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase $strategy = new InlineFragmentRenderer($kernel); $strategy->render('/', Request::create('/')); - + Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName); } @@ -197,3 +204,13 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName); } } + +class Bar +{ + public $bar = 'bar'; + + public function getBar() + { + return $this->bar; + } +} 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 69385dccbd2f..4af3601b4109 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 @@ -9,11 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpKernel\Fragment\Tests\FragmentRenderer; +namespace Symfony\Component\HttpKernel\Tests\Fragment; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer; class RoutableFragmentRendererTest extends \PHPUnit_Framework_TestCase { @@ -22,17 +21,26 @@ class RoutableFragmentRendererTest extends \PHPUnit_Framework_TestCase */ public function testGenerateFragmentUri($uri, $controller) { - $this->assertEquals($uri, $this->getRenderer()->doGenerateFragmentUri($controller, Request::create('/'))); + $this->assertEquals($uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'))); + } + + /** + * @dataProvider getGenerateFragmentUriData + */ + public function testGenerateAbsoluteFragmentUri($uri, $controller) + { + $this->assertEquals('http://localhost'.$uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'), true)); } public function getGenerateFragmentUriData() { return array( - array('http://localhost/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())), - array('http://localhost/_fragment?_path=_format%3Dxml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())), - array('http://localhost/_fragment?_path=foo%3Dfoo%26_format%3Djson%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())), - array('http://localhost/_fragment?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))), - array('http://localhost/_fragment?foo=foo&_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))), + array('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())), + array('/_fragment?_path=_format%3Dxml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())), + array('/_fragment?_path=foo%3Dfoo%26_format%3Djson%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())), + array('/_fragment?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))), + array('/_fragment?foo=foo&_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))), + array('/_fragment?_path=foo%255B0%255D%3Dfoo%26foo%255B1%255D%3Dbar%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => array('foo', 'bar')), array())), ); } @@ -43,22 +51,48 @@ class RoutableFragmentRendererTest extends \PHPUnit_Framework_TestCase $request->setLocale('fr'); $controller = new ControllerReference('controller', array(), array()); - $this->assertEquals('http://localhost/_fragment?_path=_format%3Djson%26_locale%3Dfr%26_controller%3Dcontroller', $this->getRenderer()->doGenerateFragmentUri($controller, $request)); + $this->assertEquals('/_fragment?_path=_format%3Djson%26_locale%3Dfr%26_controller%3Dcontroller', $this->callGenerateFragmentUriMethod($controller, $request)); } - private function getRenderer() + /** + * @expectedException LogicException + * @dataProvider getGenerateFragmentUriDataWithNonScalar + */ + public function testGenerateFragmentUriWithNonScalar($controller) { - return new Renderer(); + $this->callGenerateFragmentUriMethod($controller, Request::create('/')); + } + + public function getGenerateFragmentUriDataWithNonScalar() + { + return array( + array(new ControllerReference('controller', array('foo' => new Foo(), 'bar' => 'bar'), array())), + array(new ControllerReference('controller', array('foo' => array('foo' => 'foo'), 'bar' => array('bar' => new Foo())), array())), + ); + } + + private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) + { + $renderer = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer'); + $r = new \ReflectionObject($renderer); + $m = $r->getMethod('generateFragmentUri'); + $m->setAccessible(true); + + return $m->invoke($renderer, $reference, $request, $absolute); } } -class Renderer extends RoutableFragmentRenderer +class Foo { - public function render($uri, Request $request, array $options = array()) {} - public function getName() {} + public $foo; - public function doGenerateFragmentUri(ControllerReference $reference, Request $request) + public function getFoo() { - return parent::generateFragmentUri($reference, $request); + 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 7180da1ff3b7..c50970638901 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 @@ -17,13 +17,6 @@ use Symfony\Component\HttpFoundation\Response; class EsiTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testHasSurrogateEsiCapability() { $esi = new Esi(); @@ -133,7 +126,7 @@ class EsiTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testProcessWhenNoSrcInAnEsi() { @@ -173,7 +166,7 @@ class EsiTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testHandleWhenResponseIsNot200() { 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 a8064b832b7f..a2b38bd807c0 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 @@ -19,19 +19,8 @@ use Symfony\Component\HttpFoundation\Response; class HttpCacheTest extends HttpCacheTestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - $storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface') ->disableOriginalConstructor() ->getMock(); @@ -634,7 +623,7 @@ class HttpCacheTest extends HttpCacheTestCase $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); - $m->invoke($this->store, 'md'.sha1('http://localhost/'), serialize($tmp)); + $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); // build subsequent request; should be found but miss due to freshness $this->request('GET', '/'); 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 4377f61fbeac..9a1c7d767fda 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 @@ -31,10 +31,6 @@ class HttpCacheTestCase extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $this->kernel = null; $this->cache = null; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php index 6a3e5653a781..d8cf75ff7a9a 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php @@ -23,10 +23,6 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $this->request = Request::create('/'); $this->response = new Response('hello world', 200, array()); @@ -93,7 +89,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $entries = $this->getStoreMetadata($cacheKey); list ($req, $res) = $entries[0]; - $this->assertEquals('ena94a8fe5ccb19ba61c4c0873d391e987982fbbd3', $res['x-content-digest'][0]); + $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); } public function testFindsAStoredEntryWithLookup() @@ -143,7 +139,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase { $this->storeSimpleEntry(); $response = $this->store->lookup($this->request); - $this->assertEquals($this->getStorePath('en'.sha1('test')), $response->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test')), $response->getContent()); } public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate() @@ -186,9 +182,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); $this->store->write($req3, $res3); - $this->assertEquals($this->getStorePath('en'.sha1('test 3')), $this->store->lookup($req3)->getContent()); - $this->assertEquals($this->getStorePath('en'.sha1('test 2')), $this->store->lookup($req2)->getContent()); - $this->assertEquals($this->getStorePath('en'.sha1('test 1')), $this->store->lookup($req1)->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); $this->assertCount(3, $this->getStoreMetadata($key)); } @@ -198,17 +194,17 @@ class StoreTest extends \PHPUnit_Framework_TestCase $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); $key = $this->store->write($req1, $res1); - $this->assertEquals($this->getStorePath('en'.sha1('test 1')), $this->store->lookup($req1)->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); $this->store->write($req2, $res2); - $this->assertEquals($this->getStorePath('en'.sha1('test 2')), $this->store->lookup($req2)->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); $key = $this->store->write($req3, $res3); - $this->assertEquals($this->getStorePath('en'.sha1('test 3')), $this->store->lookup($req3)->getContent()); + $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); $this->assertCount(2, $this->getStoreMetadata($key)); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php index cf23d7bf8abf..da8c34c17768 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php @@ -23,9 +23,9 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface protected $body; protected $status; protected $headers; - protected $called; + protected $called = false; protected $customizer; - protected $catch; + protected $catch = false; protected $backendRequest; public function __construct($body, $status, $headers, \Closure $customizer = null) @@ -34,8 +34,6 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface $this->status = $status; $this->headers = $headers; $this->customizer = $customizer; - $this->called = false; - $this->catch = false; parent::__construct(new EventDispatcher(), $this); } diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php index 6dd3d9e499d6..89ef406bbb15 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php @@ -20,20 +20,14 @@ use Symfony\Component\EventDispatcher\EventDispatcher; class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface { - protected $bodies; - protected $statuses; - protected $headers; - protected $catch; - protected $call; + protected $bodies = array(); + protected $statuses = array(); + protected $headers = array(); + protected $call = false; protected $backendRequest; public function __construct($responses) { - $this->bodies = array(); - $this->statuses = array(); - $this->headers = array(); - $this->call = false; - foreach ($responses as $response) { $this->bodies[] = $response['body']; $this->statuses[] = $response['status']; diff --git a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 367e3e2d41d6..700b111228be 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -23,19 +23,8 @@ use Symfony\Component\EventDispatcher\EventDispatcher; class HttpKernelTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue() { @@ -45,7 +34,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException RuntimeException + * @expectedException \RuntimeException */ public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered() { @@ -147,7 +136,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException LogicException + * @expectedException \LogicException */ public function testHandleWhenTheControllerIsNotACallable() { @@ -199,7 +188,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException LogicException + * @expectedException \LogicException */ public function testHandleWhenTheControllerDoesNotReturnAResponse() { @@ -249,10 +238,24 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase $this->assertEquals($response, $capturedResponse); } + public function testVerifyRequestStackPushPopDuringHandle() + { + $request = new Request(); + + $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop')); + $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); + $stack->expects($this->at(1))->method('pop'); + + $dispatcher = new EventDispatcher(); + $kernel = new HttpKernel($dispatcher, $this->getResolver(), $stack); + + $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST); + } + protected function getResolver($controller = null) { if (null === $controller) { - $controller = function() { return new Response('Hello'); }; + $controller = function () { return new Response('Hello'); }; } $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); 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 b36f9093f1b6..f4aba74c721d 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 @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Tests; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -22,13 +21,6 @@ use Symfony\Component\HttpKernel\Tests\Fixtures\FooBarBundle; class KernelTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\DependencyInjection\Container')) { - $this->markTestSkipped('The "DependencyInjection" component is not available'); - } - } - public function testConstructor() { $env = 'test_env'; @@ -59,33 +51,22 @@ class KernelTest extends \PHPUnit_Framework_TestCase public function testBootInitializesBundlesAndContainer() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel->expects($this->once()) ->method('initializeBundles'); $kernel->expects($this->once()) ->method('initializeContainer'); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->boot(); } public function testBootSetsTheContainerToTheBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once()) ->method('setContainer'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'getBundles')); $kernel->expects($this->once()) ->method('getBundles') ->will($this->returnValue(array($bundle))); @@ -95,13 +76,11 @@ class KernelTest extends \PHPUnit_Framework_TestCase public function testBootSetsTheBootedFlagToTrue() { + // use test kernel to access isBooted() $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) + ->setConstructorArgs(array('test', false)) + ->setMethods(array('initializeBundles', 'initializeContainer')) ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->boot(); @@ -110,14 +89,8 @@ class KernelTest extends \PHPUnit_Framework_TestCase public function testClassCacheIsLoaded() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); $kernel->loadClassCache('name', '.extension'); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->expects($this->once()) ->method('doLoadClassCache') ->with('name', '.extension'); @@ -127,13 +100,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase public function testClassCacheIsNotLoadedByDefault() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) - ->getMock(); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array())); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel->expects($this->never()) ->method('doLoadClassCache'); @@ -142,27 +109,17 @@ class KernelTest extends \PHPUnit_Framework_TestCase public function testClassCacheIsNotLoadedWhenKernelIsNotBooted() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); $kernel->loadClassCache(); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->expects($this->never()) ->method('doLoadClassCache'); } public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); + ->method('initializeBundles'); $kernel->boot(); $kernel->boot(); @@ -170,40 +127,29 @@ class KernelTest extends \PHPUnit_Framework_TestCase public function testShutdownCallsShutdownOnAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once()) ->method('shutdown'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); + $kernel = $this->getKernel(array(), array($bundle)); + $kernel->boot(); $kernel->shutdown(); } public function testShutdownGivesNullContainerToAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); - $bundle->expects($this->once()) + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle->expects($this->at(3)) ->method('setContainer') ->with(null); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) + $kernel = $this->getKernel(array('getBundles')); + $kernel->expects($this->any()) ->method('getBundles') ->will($this->returnValue(array($bundle))); + $kernel->boot(); $kernel->shutdown(); } @@ -221,11 +167,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase ->method('handle') ->with($request, $type, $catch); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -243,11 +185,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel', 'boot')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel', 'boot')); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -255,10 +193,6 @@ class KernelTest extends \PHPUnit_Framework_TestCase $kernel->expects($this->once()) ->method('boot'); - // required as this value is initialized - // in the kernel constructor, which we don't call - $kernel->setIsBooted(false); - $kernel->handle($request, $type, $catch); } @@ -334,8 +268,8 @@ EOF; $output = Kernel::stripComments($source); - // Heredocs are preserved, making the output mixing unix and windows line - // endings, switching to "\n" everywhere on windows to avoid failure. + // Heredocs are preserved, making the output mixing Unix and Windows line + // endings, switching to "\n" everywhere on Windows to avoid failure. if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $expected = str_replace("\r\n", "\n", $expected); $output = str_replace("\r\n", "\n", $output); @@ -369,10 +303,7 @@ EOF; { $bundle = new FooBarBundle(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('getBundles')); $kernel->expects($this->once()) ->method('getBundles') ->will($this->returnValue(array($bundle))); @@ -416,7 +347,7 @@ EOF; */ public function testLocateResourceThrowsExceptionWhenNameIsNotValid() { - $this->getKernelForInvalidLocateResource()->locateResource('Foo'); + $this->getKernel()->locateResource('Foo'); } /** @@ -424,7 +355,7 @@ EOF; */ public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() { - $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/../bar'); + $this->getKernel()->locateResource('@FooBundle/../bar'); } /** @@ -432,7 +363,7 @@ EOF; */ public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() { - $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/config/routing.xml'); + $this->getKernel()->locateResource('@FooBundle/config/routing.xml'); } /** @@ -440,7 +371,7 @@ EOF; */ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -452,7 +383,7 @@ EOF; public function testLocateResourceReturnsTheFirstThatMatches() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -467,7 +398,7 @@ EOF; $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(2)) ->method('getBundle') @@ -483,7 +414,7 @@ EOF; $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -498,7 +429,7 @@ EOF; public function testLocateResourceReturnsAllMatchesBis() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -516,7 +447,7 @@ EOF; public function testLocateResourceIgnoresDirOnNonResource() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -531,7 +462,7 @@ EOF; public function testLocateResourceReturnsTheDirOneForResources() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -546,7 +477,7 @@ EOF; public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -565,7 +496,7 @@ EOF; $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle'); $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle'); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(4)) ->method('getBundle') @@ -600,7 +531,7 @@ EOF; public function testLocateResourceOnDirectories() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(2)) ->method('getBundle') @@ -616,7 +547,7 @@ EOF; $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources') ); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(2)) ->method('getBundle') @@ -638,13 +569,19 @@ EOF; $parent = $this->getBundle(null, null, 'ParentABundle'); $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); - $kernel = $this->getKernel(); + // 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 ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($parent, $child))) ; - $kernel->initializeBundles(); + $kernel->boot(); $map = $kernel->getBundleMap(); $this->assertEquals(array($child, $parent), $map['ParentABundle']); @@ -656,14 +593,20 @@ EOF; $parent = $this->getBundle(null, 'GrandParentBBundle', 'ParentBBundle'); $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); - $kernel = $this->getKernel(); + // 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 ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($grandparent, $parent, $child))) ; - $kernel->initializeBundles(); + $kernel->boot(); $map = $kernel->getBundleMap(); $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']); @@ -673,43 +616,45 @@ EOF; /** * @expectedException \LogicException + * @expectedExceptionMessage Bundle "ChildCBundle" extends bundle "FooBar", which is not registered. */ public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists() { $child = $this->getBundle(null, 'FooBar', 'ChildCBundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($child))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($child)); + $kernel->boot(); } public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() { - $grandparent = $this->getBundle(null, null, 'GrandParentCCundle'); - $parent = $this->getBundle(null, 'GrandParentCCundle', 'ParentCCundle'); - $child = $this->getBundle(null, 'ParentCCundle', 'ChildCCundle'); + $grandparent = $this->getBundle(null, null, 'GrandParentCBundle'); + $parent = $this->getBundle(null, 'GrandParentCBundle', 'ParentCBundle'); + $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle'); - $kernel = $this->getKernel(); + // 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 ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($parent, $grandparent, $child))) ; - $kernel->initializeBundles(); + $kernel->boot(); $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCCundle']); - $this->assertEquals(array($child, $parent), $map['ParentCCundle']); - $this->assertEquals(array($child), $map['ChildCCundle']); + $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCBundle']); + $this->assertEquals(array($child, $parent), $map['ParentCBundle']); + $this->assertEquals(array($child), $map['ChildCBundle']); } /** * @expectedException \LogicException + * @expectedExceptionMessage Bundle "ParentCBundle" is directly extended by two bundles "ChildC2Bundle" and "ChildC1Bundle". */ public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtendedByTwoBundles() { @@ -717,59 +662,41 @@ EOF; $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle'); $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle'); - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $child1, $child2))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($parent, $child1, $child2)); + $kernel->boot(); } /** * @expectedException \LogicException + * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName" */ public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() { $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($fooBundle, $barBundle))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($fooBundle, $barBundle)); + $kernel->boot(); } /** * @expectedException \LogicException + * @expectedExceptionMessage Bundle "CircularRefBundle" can not extend itself. */ public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself() { $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle'); - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($circularRef))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($circularRef)); + $kernel->boot(); } public function testTerminateReturnsSilentlyIfKernelIsNotBooted() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->never()) ->method('getHttpKernel'); - $kernel->setIsBooted(false); $kernel->terminate(Request::create('/'), new Response()); } @@ -784,16 +711,12 @@ EOF; ->expects($this->never()) ->method('terminate'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); - $kernel->setIsBooted(true); + $kernel->boot(); $kernel->terminate(Request::create('/'), new Response()); // implements TerminableInterface @@ -806,19 +729,20 @@ EOF; ->expects($this->once()) ->method('terminate'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->exactly(2)) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); - $kernel->setIsBooted(true); + $kernel->boot(); $kernel->terminate(Request::create('/'), new Response()); } + /** + * Returns a mock for the BundleInterface + * + * @return BundleInterface + */ protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) { $bundle = $this @@ -854,22 +778,28 @@ EOF; return $bundle; } - protected function getKernel() + /** + * Returns a mock for the abstract kernel. + * + * @param array $methods Additional methods to mock (besides the abstract ones) + * @param array $bundles Bundles to register + * + * @return Kernel + */ + protected function getKernel(array $methods = array(), array $bundles = array()) { - return $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setMethods(array('getBundle', 'registerBundles')) - ->disableOriginalConstructor() - ->getMock() - ; - } - - protected function getKernelForInvalidLocateResource() - { - return $this + $kernel = $this ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') - ->disableOriginalConstructor() + ->setMethods($methods) + ->setConstructorArgs(array('test', false)) ->getMockForAbstractClass() ; + + $kernel->expects($this->any()) + ->method('registerBundles') + ->will($this->returnValue($bundles)) + ; + + return $kernel; } } 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 014f5492fc8e..9ff962c5b75e 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 @@ -18,14 +18,8 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler\Mock; */ class MemcacheMock { - private $connected; - private $storage; - - public function __construct() - { - $this->connected = false; - $this->storage = array(); - } + private $connected = false; + private $storage = array(); /** * Open memcached server connection 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 2b17d70d2832..d28d54211d11 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 @@ -18,14 +18,8 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler\Mock; */ class MemcachedMock { - private $connected; - private $storage; - - public function __construct() - { - $this->connected = false; - $this->storage = array(); - } + private $connected = false; + private $storage = array(); /** * Set a Memcached option 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 ca2980edde46..4a89e2db8872 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 @@ -18,15 +18,8 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler\Mock; */ class RedisMock { - - private $connected; - private $storage; - - public function __construct() - { - $this->connected = false; - $this->storage = array(); - } + private $connected = false; + private $storage = array(); /** * Add a server to connection pool 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 2a41531ecb18..ede7c3f14b0d 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,13 +19,6 @@ use Symfony\Component\HttpFoundation\Response; class ProfilerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - } - public function testCollect() { if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { 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 665e99e2efb2..7ede0c32f76e 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php @@ -67,6 +67,6 @@ class UriSigner private function computeHash($uri) { - return urlencode(base64_encode(hash_hmac('sha1', $uri, $this->secret, true))); + return urlencode(base64_encode(hash_hmac('sha256', $uri, $this->secret, true))); } } 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 af659da90409..a09b0013271c 100644 --- a/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json +++ b/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.3.3", "symfony/event-dispatcher": "~2.1", - "symfony/http-foundation": "~2.2", + "symfony/http-foundation": "~2.4", "symfony/debug": "~2.3", "psr/log": "~1.0" }, @@ -49,7 +49,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitattributes b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitattributes new file mode 100644 index 000000000000..80481513cff2 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitattributes @@ -0,0 +1,2 @@ +/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 new file mode 100644 index 000000000000..071ef3b5201b --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/CHANGELOG.md @@ -0,0 +1,14 @@ +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/AccessException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/AccessException.php new file mode 100644 index 000000000000..b3a854646efc --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/AccessException.php @@ -0,0 +1,21 @@ + + * + * 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 property path is not available. + * + * @author Stéphane Escandell + */ +class AccessException extends RuntimeException +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php new file mode 100644 index 000000000000..d1fcdac94253 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyAccess\Exception; + +/** + * Marker interface for the PropertyAccess component. + * + * @author Bernhard Schussek + */ +interface ExceptionInterface +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/InvalidPropertyPathException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/InvalidPropertyPathException.php new file mode 100644 index 000000000000..69de31cee497 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/InvalidPropertyPathException.php @@ -0,0 +1,21 @@ + + * + * 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 property path is malformed. + * + * @author Bernhard Schussek + */ +class InvalidPropertyPathException extends RuntimeException +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchIndexException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchIndexException.php new file mode 100644 index 000000000000..597b9904a22a --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchIndexException.php @@ -0,0 +1,21 @@ + + * + * 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 an index cannot be found. + * + * @author Stéphane Escandell + */ +class NoSuchIndexException extends AccessException +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchPropertyException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchPropertyException.php new file mode 100644 index 000000000000..1c7eda5f8383 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/NoSuchPropertyException.php @@ -0,0 +1,21 @@ + + * + * 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 property cannot be found. + * + * @author Bernhard Schussek + */ +class NoSuchPropertyException extends AccessException +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/OutOfBoundsException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/OutOfBoundsException.php new file mode 100644 index 000000000000..a3c45597dabc --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/OutOfBoundsException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyAccess\Exception; + +/** + * Base OutOfBoundsException for the PropertyAccess component. + * + * @author Bernhard Schussek + */ +class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface +{ +} diff --git a/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/RuntimeException.php b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/RuntimeException.php new file mode 100644 index 000000000000..9fe843e309d8 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/RuntimeException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyAccess\Exception; + +/** + * Base RuntimeException for the PropertyAccess component. + * + * @author Bernhard Schussek + */ +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ +} 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 new file mode 100644 index 000000000000..029d48c22a9e --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php @@ -0,0 +1,25 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..88a57f8d8da4 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/LICENSE @@ -0,0 +1,19 @@ +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 new file mode 100644 index 000000000000..3b234df9d275 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccess.php @@ -0,0 +1,60 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..d48891ef275d --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -0,0 +1,457 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..50b872f3a35c --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php @@ -0,0 +1,104 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..1eed7c7b074c --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php @@ -0,0 +1,81 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..840fc7157233 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPath.php @@ -0,0 +1,225 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..f4eb0fb93ff5 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -0,0 +1,306 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..95f34ffae6da --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathInterface.php @@ -0,0 +1,86 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..d6cd49caa077 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIterator.php @@ -0,0 +1,55 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..cb43f8d7ea59 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyPathIteratorInterface.php @@ -0,0 +1,34 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..79b6ebca5aa7 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/README.md @@ -0,0 +1,14 @@ +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 new file mode 100644 index 000000000000..509bce4b92d8 --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/StringUtil.php @@ -0,0 +1,201 @@ + + * + * 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 + */ +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 new file mode 100644 index 000000000000..d79eba11fdca --- /dev/null +++ b/core/vendor/symfony/property-access/Symfony/Component/PropertyAccess/composer.json @@ -0,0 +1,31 @@ +{ + "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 abdbea27c699..ebda0971c5fd 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php @@ -22,12 +22,13 @@ class Route { private $path; private $name; - private $requirements; - private $options; - private $defaults; + private $requirements = array(); + private $options = array(); + private $defaults = array(); private $host; - private $methods; - private $schemes; + private $methods = array(); + private $schemes = array(); + private $condition; /** * Constructor. @@ -38,12 +39,6 @@ class Route */ public function __construct(array $data) { - $this->requirements = array(); - $this->options = array(); - $this->defaults = array(); - $this->methods = array(); - $this->schemes = array(); - if (isset($data['value'])) { $data['path'] = $data['value']; unset($data['value']); @@ -153,4 +148,14 @@ class Route { return $this->methods; } + + public function setCondition($condition) + { + $this->condition = $condition; + } + + public function getCondition() + { + return $this->condition; + } } 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 5925838c3fa4..8c25f34b120a 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php @@ -25,7 +25,7 @@ namespace Symfony\Component\Routing\Generator; * params because they come from third party libs but don't want to have a 404 in * production environment. It should log the mismatch so one can review it. * - setStrictRequirements(null): Return the URL with the given parameters without - * checking the requirements at all. When generating an URL you should either trust + * checking the requirements at all. When generating a URL you should either trust * your params or you validated them beforehand because otherwise it would break your * link anyway. So in production environment you should know that params always pass * the requirements. Thus this option allows to disable the check on URL generation for 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 42cd9108939d..4d19d2a2ec8d 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 @@ -92,6 +92,7 @@ EOF; $properties[] = $route->getRequirements(); $properties[] = $compiledRoute->getTokens(); $properties[] = $compiledRoute->getHostTokens(); + $properties[] = $route->getSchemes(); $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); } @@ -114,9 +115,9 @@ EOF; throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', \$name)); } - list(\$variables, \$defaults, \$requirements, \$tokens, \$hostTokens) = self::\$declaredRoutes[\$name]; + list(\$variables, \$defaults, \$requirements, \$tokens, \$hostTokens, \$requiredSchemes) = self::\$declaredRoutes[\$name]; - return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostTokens); + return \$this->doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostTokens, \$requiredSchemes); } EOF; } 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 f224cb3f6d9f..468708479bbe 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -137,7 +137,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt // the Route has a cache of its own and is not recompiled as long as it does not get modified $compiledRoute = $route->compile(); - return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens()); + return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes()); } /** @@ -145,7 +145,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens) + protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array()) { $variables = array_flip($variables); $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); @@ -188,7 +188,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt $url = '/'; } - // the contexts base url is already encoded (see Symfony\Component\HttpFoundation\Request) + // the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request) $url = strtr(rawurlencode($url), $this->decodedChars); // the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3 @@ -204,7 +204,24 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt $schemeAuthority = ''; if ($host = $this->context->getHost()) { $scheme = $this->context->getScheme(); - if (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) { + + if ($requiredSchemes) { + $schemeMatched = false; + foreach ($requiredSchemes as $requiredScheme) { + if ($scheme === $requiredScheme) { + $schemeMatched = true; + + break; + } + } + + if (!$schemeMatched) { + $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; $scheme = $req; } 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 9831d85a0967..af70a888b867 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -116,6 +116,7 @@ abstract class AnnotationClassLoader implements LoaderInterface 'schemes' => array(), 'methods' => array(), 'host' => '', + 'condition' => '', ); $class = new \ReflectionClass($class); @@ -154,6 +155,10 @@ abstract class AnnotationClassLoader implements LoaderInterface if (null !== $annot->getHost()) { $globals['host'] = $annot->getHost(); } + + if (null !== $annot->getCondition()) { + $globals['condition'] = $annot->getCondition(); + } } $collection = new RouteCollection(); @@ -180,7 +185,7 @@ abstract class AnnotationClassLoader implements LoaderInterface $defaults = array_replace($globals['defaults'], $annot->getDefaults()); foreach ($method->getParameters() as $param) { - if ($param->isOptional()) { + if (!isset($defaults[$param->getName()]) && $param->isOptional()) { $defaults[$param->getName()] = $param->getDefaultValue(); } } @@ -194,7 +199,12 @@ abstract class AnnotationClassLoader implements LoaderInterface $host = $globals['host']; } - $route = new Route($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods); + $condition = $annot->getCondition(); + if (null === $condition) { + $condition = $globals['condition']; + } + + $route = new Route($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods, $condition); $this->configureRoute($route, $class, $method, $annot); 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 da7b33d856ff..e854202f7092 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -129,9 +129,9 @@ class XmlFileLoader extends FileLoader $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY); $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY); - list($defaults, $requirements, $options) = $this->parseConfigs($node, $path); + list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); - $route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods); + $route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods, $condition); $collection->add($id, $route); } @@ -157,7 +157,7 @@ class XmlFileLoader extends FileLoader $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null; $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null; - list($defaults, $requirements, $options) = $this->parseConfigs($node, $path); + list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); $this->setCurrentDir(dirname($path)); @@ -211,6 +211,7 @@ class XmlFileLoader extends FileLoader $defaults = array(); $requirements = array(); $options = array(); + $condition = null; foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { switch ($n->localName) { @@ -228,11 +229,14 @@ class XmlFileLoader extends FileLoader case 'option': $options[$n->getAttribute('key')] = trim($n->textContent); break; + case 'condition': + $condition = trim($n->textContent); + break; default: throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement" or "option".', $n->localName, $path)); } } - return array($defaults, $requirements, $options); + return array($defaults, $requirements, $options, $condition); } } 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 9deea7fe4f55..d3eaea42e604 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 @@ use Symfony\Component\Config\Loader\FileLoader; class YamlFileLoader extends FileLoader { private static $availableKeys = array( - 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', + 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition' ); private $yamlParser; @@ -123,8 +123,9 @@ class YamlFileLoader extends FileLoader $host = isset($config['host']) ? $config['host'] : ''; $schemes = isset($config['schemes']) ? $config['schemes'] : array(); $methods = isset($config['methods']) ? $config['methods'] : array(); + $condition = isset($config['condition']) ? $config['condition'] : null; - $route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods); + $route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods, $condition); $collection->add($name, $route); } 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 daea8143865c..9ab969a41d8a 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,6 +29,7 @@ + @@ -61,4 +62,9 @@ + + + + + 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 01d8c0358947..5b32684876b9 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 @@ -50,6 +50,9 @@ class ApacheMatcherDumper extends MatcherDumper $prevHostRegex = ''; foreach ($this->getRoutes()->all() as $name => $route) { + if ($route->getCondition()) { + throw new \LogicException(sprintf('Unable to dump the routes for Apache as route "%s" has a condition.', $name)); + } $compiledRoute = $route->compile(); $hostRegex = $compiledRoute->getHostRegex(); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php index f85e4ceff0a7..5e7c134b9f39 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Routing\Matcher\Dumper; +use Symfony\Component\Routing\RouteCollection; + /** * MatcherDumperInterface is the interface that all matcher dumper classes must implement. * 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 dc17ffbe984a..784f3099daf5 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 @@ -13,6 +13,7 @@ namespace Symfony\Component\Routing\Matcher\Dumper; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; /** * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. @@ -23,6 +24,8 @@ use Symfony\Component\Routing\RouteCollection; */ class PhpMatcherDumper extends MatcherDumper { + private $expressionLanguage; + /** * Dumps a set of routes to a PHP class. * @@ -91,6 +94,8 @@ EOF; { \$allow = array(); \$pathinfo = rawurldecode(\$pathinfo); + \$context = \$this->context; + \$request = \$this->request; $code @@ -237,6 +242,10 @@ EOF; $hostMatches = true; } + if ($route->getCondition()) { + $conditions[] = $this->getExpressionLanguage()->compile($route->getCondition(), array('context', 'request')); + } + $conditions = implode(' && ', $conditions); $code .= <<context->getMethod() != '$methods[0]') { @@ -280,14 +288,15 @@ EOF; EOF; } - if ($scheme = $route->getRequirement('_scheme')) { + if ($schemes = $route->getSchemes()) { if (!$supportsRedirections) { - throw new \LogicException('The "_scheme" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); + throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); } - + $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); $code .= <<context->getScheme() !== '$scheme') { - return \$this->redirect(\$pathinfo, '$name', '$scheme'); + \$requiredSchemes = $schemes; + if (!isset(\$requiredSchemes[\$this->context->getScheme()])) { + return \$this->redirect(\$pathinfo, '$name', key(\$requiredSchemes)); } @@ -305,8 +314,11 @@ EOF; } $vars[] = "array('_route' => '$name')"; - $code .= sprintf(" return \$this->mergeDefaults(array_replace(%s), %s);\n" - , implode(', ', $vars), str_replace("\n", '', var_export($route->getDefaults(), true))); + $code .= sprintf( + " return \$this->mergeDefaults(array_replace(%s), %s);\n", + 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))); @@ -375,4 +387,16 @@ EOF; return $tree; } + + private function getExpressionLanguage() + { + if (null === $this->expressionLanguage) { + if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); + } + $this->expressionLanguage = new ExpressionLanguage(); + } + + return $this->expressionLanguage; + } } 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 51e80057cd53..3d13181f467d 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -50,10 +50,16 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable */ protected function handleRouteRequirements($pathinfo, $name, Route $route) { + // expression condition + if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) { + return array(self::REQUIREMENT_MISMATCH, null); + } + // check HTTP scheme requirement - $scheme = $route->getRequirement('_scheme'); - if ($scheme && $this->context->getScheme() !== $scheme) { - return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, $scheme)); + $scheme = $this->context->getScheme(); + $schemes = $route->getSchemes(); + if ($schemes && !$route->hasScheme($scheme)) { + return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, current($schemes))); } return array(self::REQUIREMENT_MATCH, null); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php index c09f83e86a22..22af699d4a7c 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Routing\Matcher; use Symfony\Component\Routing\Exception\ExceptionInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Matcher\UrlMatcher; /** * TraceableUrlMatcher helps debug path info matching by tracing the match. @@ -75,7 +74,7 @@ class TraceableUrlMatcher extends UrlMatcher if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { $this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), self::ROUTE_ALMOST_MATCHES, $name, $route); - return true; + continue; } // check HTTP method requirement @@ -94,10 +93,21 @@ class TraceableUrlMatcher extends UrlMatcher } } + // check condition + if ($condition = $route->getCondition()) { + if (!$this->getExpressionLanguage()->evaluate($condition, array('context' => $this->context, 'request' => $this->request))) { + $this->addTrace(sprintf('Condition "%s" does not evaluate to "true"', $condition), self::ROUTE_ALMOST_MATCHES, $name, $route); + + continue; + } + } + // check HTTP scheme requirement - if ($scheme = $route->getRequirement('_scheme')) { - if ($this->context->getScheme() !== $scheme) { - $this->addTrace(sprintf('Scheme "%s" does not match the requirement ("%s"); the user will be redirected', $this->context->getScheme(), $scheme), self::ROUTE_ALMOST_MATCHES, $name, $route); + if ($requiredSchemes = $route->getSchemes()) { + $scheme = $this->context->getScheme(); + + if (!$route->hasScheme($scheme)) { + $this->addTrace(sprintf('Scheme "%s" does not match any of the required schemes ("%s"); the user will be redirected to first required scheme', $scheme, implode(', ', $requiredSchemes)), self::ROUTE_ALMOST_MATCHES, $name, $route); return true; } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php index db18ec4e7b25..8d081a8629de 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -16,6 +16,8 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\Route; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\ExpressionLanguage\ExpressionLanguage; /** * UrlMatcher matches URL based on a set of routes. @@ -24,7 +26,7 @@ use Symfony\Component\Routing\Route; * * @api */ -class UrlMatcher implements UrlMatcherInterface +class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface { const REQUIREMENT_MATCH = 0; const REQUIREMENT_MISMATCH = 1; @@ -45,6 +47,9 @@ class UrlMatcher implements UrlMatcherInterface */ protected $routes; + protected $request; + protected $expressionLanguage; + /** * Constructor. * @@ -91,6 +96,20 @@ class UrlMatcher implements UrlMatcherInterface : new ResourceNotFoundException(); } + /** + * {@inheritdoc} + */ + public function matchRequest(Request $request) + { + $this->request = $request; + + $ret = $this->match($request->getPathInfo()); + + $this->request = null; + + return $ret; + } + /** * Tries to match a URL with a set of routes. * @@ -180,9 +199,14 @@ class UrlMatcher implements UrlMatcherInterface */ protected function handleRouteRequirements($pathinfo, $name, Route $route) { + // expression condition + if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) { + return array(self::REQUIREMENT_MISMATCH, null); + } + // check HTTP scheme requirement - $scheme = $route->getRequirement('_scheme'); - $status = $scheme && $scheme !== $this->context->getScheme() ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; + $scheme = $this->context->getScheme(); + $status = $route->getSchemes() && !$route->hasScheme($scheme) ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; return array($status, null); } @@ -205,4 +229,16 @@ class UrlMatcher implements UrlMatcherInterface return $defaults; } + + protected function getExpressionLanguage() + { + if (null === $this->expressionLanguage) { + if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); + } + $this->expressionLanguage = new ExpressionLanguage(); + } + + return $this->expressionLanguage; + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/README.md b/core/vendor/symfony/routing/Symfony/Component/Routing/README.md index 663844a67429..83febc79bbda 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/README.md +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/README.md @@ -30,5 +30,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/Routing/ - $ composer.phar install --dev + $ composer.phar install $ phpunit diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php index 5bc535c683ed..08005541461e 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Route.php @@ -61,6 +61,8 @@ class Route implements \Serializable */ private $compiled; + private $condition; + /** * Constructor. * @@ -75,10 +77,11 @@ class Route implements \Serializable * @param string $host The host pattern to match * @param string|array $schemes A required URI scheme or an array of restricted schemes * @param string|array $methods A required HTTP method or an array of restricted methods + * @param string $condition A condition that should evaluate to true for the route to match * * @api */ - public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array()) + public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = null) { $this->setPath($path); $this->setDefaults($defaults); @@ -93,6 +96,7 @@ class Route implements \Serializable if ($methods) { $this->setMethods($methods); } + $this->setCondition($condition); } public function serialize() @@ -105,6 +109,7 @@ class Route implements \Serializable 'options' => $this->options, 'schemes' => $this->schemes, 'methods' => $this->methods, + 'condition' => $this->condition, )); } @@ -118,6 +123,7 @@ class Route implements \Serializable $this->options = $data['options']; $this->schemes = $data['schemes']; $this->methods = $data['methods']; + $this->condition = $data['condition']; } /** @@ -241,6 +247,25 @@ class Route implements \Serializable return $this; } + /** + * Checks if a scheme requirement has been set. + * + * @param string $scheme + * + * @return Boolean true if the scheme requirement exists, otherwise false + */ + public function hasScheme($scheme) + { + $scheme = strtolower($scheme); + foreach ($this->schemes as $requiredScheme) { + if ($scheme === $requiredScheme) { + return true; + } + } + + return false; + } + /** * Returns the uppercased HTTP methods this route is restricted to. * So an empty array means that any method is allowed. @@ -543,6 +568,33 @@ class Route implements \Serializable return $this; } + /** + * Returns the condition. + * + * @return string The condition + */ + public function getCondition() + { + return $this->condition; + } + + /** + * Sets the condition. + * + * This method implements a fluent interface. + * + * @param string $condition The condition + * + * @return Route The current Route instance + */ + public function setCondition($condition) + { + $this->condition = (string) $condition; + $this->compiled = null; + + return $this; + } + /** * Compiles the route. * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php index 499fe0f04f83..f02832424236 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php @@ -177,6 +177,20 @@ class RouteCollection implements \IteratorAggregate, \Countable } } + /** + * Sets a condition on all routes. + * + * Existing conditions will be overridden. + * + * @param string $condition The condition + */ + public function setCondition($condition) + { + foreach ($this->routes as $route) { + $route->setCondition($condition); + } + } + /** * Adds defaults to all routes. * diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php index d1e289795c18..62abec387245 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php @@ -16,7 +16,11 @@ use Symfony\Component\Config\ConfigCache; use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\Generator\Dumper\GeneratorDumperInterface; +use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; +use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface; +use Symfony\Component\HttpFoundation\Request; /** * The Router class is an example of the integration of all pieces of the @@ -24,7 +28,7 @@ use Symfony\Component\Routing\Matcher\UrlMatcherInterface; * * @author Fabien Potencier */ -class Router implements RouterInterface +class Router implements RouterInterface, RequestMatcherInterface { /** * @var UrlMatcherInterface|null @@ -80,7 +84,7 @@ class Router implements RouterInterface $this->loader = $loader; $this->resource = $resource; $this->logger = $logger; - $this->context = null === $context ? new RequestContext() : $context; + $this->context = $context ?: new RequestContext(); $this->setOptions($options); } @@ -215,6 +219,20 @@ class Router implements RouterInterface return $this->getMatcher()->match($pathinfo); } + /** + * {@inheritdoc} + */ + public function matchRequest(Request $request) + { + $matcher = $this->getMatcher(); + if (!$matcher instanceof RequestMatcherInterface) { + // fallback to the default UrlMatcherInterface + return $matcher->match($request->getPathInfo()); + } + + return $matcher->matchRequest($request); + } + /** * Gets the UrlMatcher instance associated with this Router. * @@ -232,8 +250,8 @@ class Router implements RouterInterface $class = $this->options['matcher_cache_class']; $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']); - if (!$cache->isFresh($class)) { - $dumper = new $this->options['matcher_dumper_class']($this->getRouteCollection()); + if (!$cache->isFresh()) { + $dumper = $this->getMatcherDumperInstance(); $options = array( 'class' => $class, @@ -264,8 +282,8 @@ class Router implements RouterInterface } else { $class = $this->options['generator_cache_class']; $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']); - if (!$cache->isFresh($class)) { - $dumper = new $this->options['generator_dumper_class']($this->getRouteCollection()); + if (!$cache->isFresh()) { + $dumper = $this->getGeneratorDumperInstance(); $options = array( 'class' => $class, @@ -286,4 +304,20 @@ class Router implements RouterInterface return $this->generator; } + + /** + * @return GeneratorDumperInterface + */ + protected function getGeneratorDumperInstance() + { + return new $this->options['generator_dumper_class']($this->getRouteCollection()); + } + + /** + * @return MatcherDumperInterface + */ + protected function getMatcherDumperInstance() + { + return new $this->options['matcher_dumper_class']($this->getRouteCollection()); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index b58869f7afc6..bd0167089e05 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -35,15 +35,16 @@ class RouteTest extends \PHPUnit_Framework_TestCase public function getValidParameters() { return array( - array('value', '/Blog', 'getPattern'), - array('value', '/Blog', 'getPath'), - array('requirements', array('_method' => 'GET'), 'getRequirements'), - array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'), - array('name', 'blog_index', 'getName'), - array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'), - array('schemes', array('https'), 'getSchemes'), - array('methods', array('GET', 'POST'), 'getMethods'), - array('host', array('{locale}.example.com'), 'getHost') + array('value', '/Blog', 'getPattern'), + array('value', '/Blog', 'getPath'), + array('requirements', array('_method' => 'GET'), 'getRequirements'), + array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'), + array('name', 'blog_index', 'getName'), + array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'), + array('schemes', array('https'), 'getSchemes'), + array('methods', array('GET', 'POST'), 'getMethods'), + array('host', array('{locale}.example.com'), 'getHost'), + array('condition', array('context.getMethod() == "GET"'), 'getCondition'), ); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php index 12a5bedb4fc9..2e9b028de860 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php @@ -21,6 +21,6 @@ class CustomXmlFileLoader extends XmlFileLoader { protected function loadFile($file) { - return XmlUtils::loadFile($file, function() { return true; }); + return XmlUtils::loadFile($file, function () { return true; }); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index e5f7665c81bc..248a4f153fc3 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -24,6 +24,8 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher { $allow = array(); $pathinfo = rawurldecode($pathinfo); + $context = $this->context; + $request = $this->request; // foo if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index ad157909b8c0..acf1163c5b39 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -24,6 +24,8 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec { $allow = array(); $pathinfo = rawurldecode($pathinfo); + $context = $this->context; + $request = $this->request; // foo if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { @@ -319,8 +321,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec // secure if ($pathinfo === '/secure') { - if ($this->context->getScheme() !== 'https') { - return $this->redirect($pathinfo, 'secure', 'https'); + $requiredSchemes = array ( 'https' => 0,); + if (!isset($requiredSchemes[$this->context->getScheme()])) { + return $this->redirect($pathinfo, 'secure', key($requiredSchemes)); } return array('_route' => 'secure'); @@ -328,8 +331,9 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec // nonsecure if ($pathinfo === '/nonsecure') { - if ($this->context->getScheme() !== 'http') { - return $this->redirect($pathinfo, 'nonsecure', 'http'); + $requiredSchemes = array ( 'http' => 0,); + if (!isset($requiredSchemes[$this->context->getScheme()])) { + return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes)); } return array('_route' => 'nonsecure'); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index f2f642eb8669..c3463fa77208 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -24,6 +24,8 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher { $allow = array(); $pathinfo = rawurldecode($pathinfo); + $context = $this->context; + $request = $this->request; if (0 === strpos($pathinfo, '/rootprefix')) { // static @@ -38,6 +40,11 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } + // with-condition + if ($pathinfo === '/with-condition' && ($context->getMethod() == "GET")) { + return array('_route' => 'with-condition'); + } + throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); } } 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 b8bbbb5f8f01..b652d9465659 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 @@ -10,14 +10,18 @@ $collection->add('blog_show', new Route( array('compiler_class' => 'RouteCompiler'), '{locale}.example.com', array('https'), - array('GET','POST','put','OpTiOnS') + array('GET','POST','put','OpTiOnS'), + 'context.getMethod() == "GET"' )); $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('compiler_class' => 'RouteCompiler'), - '{locale}.example.com' + '{locale}.example.com', + array(), + array(), + 'context.getMethod() == "GET"' )); return $collection; 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 b9f22347b40c..cfee9d688283 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 @@ -8,6 +8,7 @@ MyBundle:Blog:show \w+ + context.getMethod() == "GET" @@ -17,5 +18,6 @@ hTTps \w+ + context.getMethod() == "GET" 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 4ada8832197b..48cf7f8817cc 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 @@ -5,6 +5,7 @@ blog_show: requirements: { 'locale': '\w+' } methods: ['GET','POST','put','OpTiOnS'] schemes: ['https'] + condition: 'context.getMethod() == "GET"' options: compiler_class: RouteCompiler @@ -13,5 +14,6 @@ blog_show_legacy: defaults: { _controller: "MyBundle:Blog:show" } host: "{locale}.example.com" requirements: { '_method': 'GET|POST|put|OpTiOnS', _scheme: https, 'locale': '\w+' } + condition: 'context.getMethod() == "GET"' options: compiler_class: RouteCompiler 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 ab5f4cdae0aa..78e3907fd56b 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 @@ -114,4 +114,37 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase $this->assertEquals($url, '/testing'); } + + public function testDumpWithSchemeRequirement() + { + $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https'))); + $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); + + $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php')); + + $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true); + $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true); + $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false); + $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false); + + $this->assertEquals($absoluteUrl, 'ftp://localhost/app.php/testing'); + $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc'); + $this->assertEquals($relativeUrl, 'ftp://localhost/app.php/testing'); + $this->assertEquals($relativeUrlBC, 'https://localhost/app.php/testing_bc'); + + $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https')); + + $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true); + $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true); + $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false); + $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false); + + $this->assertEquals($absoluteUrl, 'https://localhost/app.php/testing'); + $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc'); + $this->assertEquals($relativeUrl, '/app.php/testing'); + $this->assertEquals($relativeUrlBC, '/app.php/testing_bc'); + } } 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 5f8ef491276c..143e3448a29c 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 @@ -207,10 +207,6 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger() { - if (!interface_exists('Psr\Log\LoggerInterface')) { - $this->markTestSkipped('The "psr/log" package is not available'); - } - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); $logger = $this->getMock('Psr\Log\LoggerInterface'); $logger->expects($this->once()) @@ -248,20 +244,38 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase public function testSchemeRequirementDoesNothingIfSameCurrentScheme() { - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); // BC $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); // BC + $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); + $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); } public function testSchemeRequirementForcesAbsoluteUrl() { - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); // BC $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); + $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); // BC $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); + $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); + + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); + $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); + } + + public function testSchemeRequirementCreatesUrlForFirstRequiredScheme() + { + $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('Ftp', 'https'))); + $this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->generate('test')); } public function testPathWithTwoStartingSlashes() @@ -447,7 +461,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertNull($generator->generate('test', array('foo' => 'baz'), false)); } - public function testGenerateNetworkPath() + public function testGenerateNetworkPathBC() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com')); @@ -465,13 +479,32 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase ); } + 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' + ); + $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' + ); + $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' + ); + $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' + ); + } + public function testGenerateRelativePath() { $routes = new RouteCollection(); $routes->add('article', new Route('/{author}/{article}/')); $routes->add('comments', new Route('/{author}/{article}/comments')); $routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com')); - $routes->add('scheme', new Route('/{author}', array(), array('_scheme' => 'https'))); + $routes->add('schemeBC', new Route('/{author}', array(), array('_scheme' => 'https'))); // BC + $routes->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array('https'))); $routes->add('unrelated', new Route('/about')); $generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/')); @@ -491,9 +524,12 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host', array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) ); - $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('scheme', + $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('schemeBC', array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) ); + $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme', + array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) + ); $this->assertSame('../../about', $generator->generate('unrelated', array(), UrlGeneratorInterface::RELATIVE_PATH) ); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php index c927ae4a85fe..288bf64ffaf7 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php @@ -13,13 +13,6 @@ namespace Symfony\Component\Routing\Tests\Loader; abstract class AbstractAnnotationLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Doctrine\\Common\\Version')) { - $this->markTestSkipped('Doctrine is not available.'); - } - } - public function getReader() { return $this->getMockBuilder('Doctrine\Common\Annotations\Reader') 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 31c43f58c69b..c60997902e0e 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 @@ -11,6 +11,8 @@ namespace Symfony\Component\Routing\Tests\Loader; +use Symfony\Component\Routing\Annotation\Route; + class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest { protected $loader; @@ -71,12 +73,22 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest return array( array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('name'=>'route1'), + array('name' => 'route1'), + 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( + 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', + array('name' => 'route1', 'defaults' => array('arg2' => 'foobar')), array('arg2' => 'defaultValue2', 'arg3' =>'defaultValue3') ), array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('name'=>'route1', 'defaults' => array('arg2' => 'foo')), + array('name' => 'route1', 'defaults' => array('arg2' => 'foo'), 'condition' => 'context.getMethod() == "GET"'), array('arg2' => 'defaultValue2', 'arg3' =>'defaultValue3') ), ); @@ -95,6 +107,7 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest 'defaults' => array(), 'schemes' => array(), 'methods' => array(), + 'condition' => null, ), $routeDatas); $this->reader @@ -108,12 +121,12 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest $this->assertSame($routeDatas['path'], $route->getPath(), '->load preserves path annotation'); $this->assertSame($routeDatas['requirements'],$route->getRequirements(), '->load preserves requirements annotation'); $this->assertCount(0, array_intersect($route->getOptions(), $routeDatas['options']), '->load preserves options annotation'); - $this->assertSame(array_replace($routeDatas['defaults'], $methodArgs), $route->getDefaults(), '->load preserves defaults annotation'); + $this->assertSame(array_replace($methodArgs, $routeDatas['defaults']), $route->getDefaults(), '->load preserves defaults annotation'); + $this->assertEquals($routeDatas['condition'], $route->getCondition(), '->load preserves condition annotation'); } private function getAnnotatedRoute($datas) { - return new \Symfony\Component\Routing\Annotation\Route($datas); + return new Route($datas); } - } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php index 64d1b086ef69..d34fa87ec533 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php @@ -17,13 +17,6 @@ use Symfony\Component\Routing\RouteCollection; class ClosureLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\FileLocator')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - public function testSupports() { $loader = new ClosureLoader(); diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index 18b166fc558c..bf76d3465b9a 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -16,13 +16,6 @@ use Symfony\Component\Routing\Loader\PhpFileLoader; class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\FileLocator')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - public function testSupports() { $loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); 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 9f038c1611a7..c38adbd93838 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 @@ -17,13 +17,6 @@ use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader; class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\FileLocator')) { - $this->markTestSkipped('The "Config" component is not available'); - } - } - public function testSupports() { $loader = new XmlFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); @@ -52,6 +45,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); $this->assertEquals(array('https'), $route->getSchemes()); + $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); } } 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 a3e934cef02b..f0301062055e 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 @@ -17,17 +17,6 @@ use Symfony\Component\Config\Resource\FileResource; class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Config\FileLocator')) { - $this->markTestSkipped('The "Config" component is not available'); - } - - if (!class_exists('Symfony\Component\Yaml\Yaml')) { - $this->markTestSkipped('The "Yaml" component is not available'); - } - } - public function testSupports() { $loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); @@ -90,6 +79,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); $this->assertEquals(array('https'), $route->getSchemes()); + $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php index 54b377272d25..7b6001c1f6d9 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Routing\Test\Matcher\Dumper; +namespace Symfony\Component\Routing\Tests\Matcher\Dumper; use Symfony\Component\Routing\Matcher\Dumper\DumperCollection; diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php index 7b4565c40375..de01a75d0b1b 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php @@ -20,7 +20,7 @@ class DumperPrefixCollectionTest extends \PHPUnit_Framework_TestCase { public function testAddPrefixRoute() { - $coll = new DumperPrefixCollection; + $coll = new DumperPrefixCollection(); $coll->setPrefix(''); $route = new DumperRoute('bar', new Route('/foo/bar')); @@ -66,7 +66,7 @@ EOF; public function testMergeSlashNodes() { - $coll = new DumperPrefixCollection; + $coll = new DumperPrefixCollection(); $coll->setPrefix(''); $route = new DumperRoute('bar', new Route('/foo/bar')); 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 542ede85c001..473af6aa5cea 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 @@ -251,6 +251,9 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $rootprefixCollection->add('static', new Route('/test')); $rootprefixCollection->add('dynamic', new Route('/{var}')); $rootprefixCollection->addPrefix('rootprefix'); + $route = new Route('/with-condition'); + $route->setCondition('context.getMethod() == "GET"'); + $rootprefixCollection->add('with-condition', $route); return array( array($collection, 'url_matcher1.php', array()), diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php index 2ad4fc8725a8..5cbb60547911 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php @@ -41,7 +41,7 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase $matcher->match('/foo'); } - public function testSchemeRedirect() + public function testSchemeRedirectBC() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); @@ -55,4 +55,32 @@ class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase ; $matcher->match('/foo'); } + + public function testSchemeRedirectRedirectsToFirstScheme() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('FTP', 'HTTPS'))); + + $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); + $matcher + ->expects($this->once()) + ->method('redirect') + ->with('/foo', 'foo', 'ftp') + ->will($this->returnValue(array('_route' => 'foo'))) + ; + $matcher->match('/foo'); + } + + public function testNoSchemaRedirectIfOnOfMultipleSchemesMatches() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https', 'http'))); + + $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); + $matcher + ->expects($this->never()) + ->method('redirect') + ; + $matcher->match('/foo'); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php index 86d8d954c008..969ab0a2f0d0 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php @@ -26,13 +26,14 @@ class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase $coll->add('bar1', new Route('/bar/{name}', array(), array('id' => '\w+', '_method' => 'POST'))); $coll->add('bar2', new Route('/foo', array(), array(), array(), 'baz')); $coll->add('bar3', new Route('/foo1', array(), array(), array(), 'baz')); + $coll->add('bar4', new Route('/foo2', array(), array(), array(), 'baz', array(), array(), 'context.getMethod() == "GET"')); $context = new RequestContext(); $context->setHost('baz'); $matcher = new TraceableUrlMatcher($coll, $context); $traces = $matcher->getTraces('/babar'); - $this->assertEquals(array(0, 0, 0, 0, 0), $this->getLevels($traces)); + $this->assertEquals(array(0, 0, 0, 0, 0, 0), $this->getLevels($traces)); $traces = $matcher->getTraces('/foo'); $this->assertEquals(array(1, 0, 0, 2), $this->getLevels($traces)); @@ -41,7 +42,7 @@ class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array(0, 2), $this->getLevels($traces)); $traces = $matcher->getTraces('/bar/dd'); - $this->assertEquals(array(0, 1, 1, 0, 0), $this->getLevels($traces)); + $this->assertEquals(array(0, 1, 1, 0, 0, 0), $this->getLevels($traces)); $traces = $matcher->getTraces('/foo1'); $this->assertEquals(array(0, 0, 0, 0, 2), $this->getLevels($traces)); @@ -52,6 +53,40 @@ class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase $traces = $matcher->getTraces('/bar/dd'); $this->assertEquals(array(0, 1, 2), $this->getLevels($traces)); + + $traces = $matcher->getTraces('/foo2'); + $this->assertEquals(array(0, 0, 0, 0, 0, 1), $this->getLevels($traces)); + } + + public function testMatchRouteOnMultipleHosts() + { + $routes = new RouteCollection(); + $routes->add('first', new Route( + '/mypath/', + array('_controller' => 'MainBundle:Info:first'), + array(), + array(), + 'some.example.com' + )); + + $routes->add('second', new Route( + '/mypath/', + array('_controller' => 'MainBundle:Info:second'), + array(), + array(), + 'another.example.com' + )); + + $context = new RequestContext(); + $context->setHost('baz'); + + $matcher = new TraceableUrlMatcher($routes, $context); + + $traces = $matcher->getTraces('/mypath/'); + $this->assertEquals( + array(TraceableUrlMatcher::ROUTE_ALMOST_MATCHES, TraceableUrlMatcher::ROUTE_ALMOST_MATCHES), + $this->getLevels($traces) + ); } public function getLevels($traces) 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 8a1428f17085..b03b0c3aa077 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 @@ -313,13 +313,36 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException */ - public function testSchemeRequirement() + public function testSchemeRequirementBC() { $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); $matcher = new UrlMatcher($coll, new RequestContext()); $matcher->match('/foo'); } + /** + * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testSchemeRequirement() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); + $matcher = new UrlMatcher($coll, new RequestContext()); + $matcher->match('/foo'); + } + + /** + * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException + */ + public function testCondition() + { + $coll = new RouteCollection(); + $route = new Route('/foo'); + $route->setCondition('context.getMethod() == "POST"'); + $coll->add('foo', $route); + $matcher = new UrlMatcher($coll, new RequestContext()); + $matcher->match('/foo'); + } public function testDecodeOnce() { diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php new file mode 100644 index 000000000000..21a299956f8e --- /dev/null +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Tests; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\RequestContext; + +class RequestContextTest extends \PHPUnit_Framework_TestCase +{ + public function testConstruct() + { + $requestContext = new RequestContext( + 'foo', + 'post', + 'foo.bar', + 'HTTPS', + 8080, + 444, + '/baz', + 'bar=foobar' + ); + + $this->assertEquals('foo', $requestContext->getBaseUrl()); + $this->assertEquals('POST', $requestContext->getMethod()); + $this->assertEquals('foo.bar', $requestContext->getHost()); + $this->assertEquals('https', $requestContext->getScheme()); + $this->assertSame(8080, $requestContext->getHttpPort()); + $this->assertSame(444, $requestContext->getHttpsPort()); + $this->assertEquals('/baz', $requestContext->getPathInfo()); + $this->assertEquals('bar=foobar', $requestContext->getQueryString()); + } + + public function testFromRequest() + { + $request = Request::create('https://test.com:444/foo?bar=baz'); + $requestContext = new RequestContext(); + $requestContext->setHttpPort(123); + $requestContext->fromRequest($request); + + $this->assertEquals('', $requestContext->getBaseUrl()); + $this->assertEquals('GET', $requestContext->getMethod()); + $this->assertEquals('test.com', $requestContext->getHost()); + $this->assertEquals('https', $requestContext->getScheme()); + $this->assertEquals('/foo', $requestContext->getPathInfo()); + $this->assertEquals('bar=baz', $requestContext->getQueryString()); + $this->assertSame(123, $requestContext->getHttpPort()); + $this->assertSame(444, $requestContext->getHttpsPort()); + + $request = Request::create('http://test.com:8080/foo?bar=baz'); + $requestContext = new RequestContext(); + $requestContext->setHttpsPort(567); + $requestContext->fromRequest($request); + + $this->assertSame(8080, $requestContext->getHttpPort()); + $this->assertSame(567, $requestContext->getHttpsPort()); + } + + public function testGetParameters() + { + $requestContext = new RequestContext(); + $this->assertEquals(array(), $requestContext->getParameters()); + + $requestContext->setParameters(array('foo' => 'bar')); + $this->assertEquals(array('foo' => 'bar'), $requestContext->getParameters()); + } + + public function testHasParameter() + { + $requestContext = new RequestContext(); + $requestContext->setParameters(array('foo' => 'bar')); + + $this->assertTrue($requestContext->hasParameter('foo')); + $this->assertFalse($requestContext->hasParameter('baz')); + } + + public function testGetParameter() + { + $requestContext = new RequestContext(); + $requestContext->setParameters(array('foo' => 'bar')); + + $this->assertEquals('bar', $requestContext->getParameter('foo')); + $this->assertNull($requestContext->getParameter('baz')); + } + + public function testSetParameter() + { + $requestContext = new RequestContext(); + $requestContext->setParameter('foo', 'bar'); + + $this->assertEquals('bar', $requestContext->getParameter('foo')); + } +} diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 3d78adf9232b..4c12ed56df3e 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -103,10 +103,6 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase public function testAddCollectionWithResources() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $collection = new RouteCollection(); $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); $collection1 = new RouteCollection(); @@ -178,10 +174,6 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase public function testResource() { - if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { - $this->markTestSkipped('The "Config" component is not available'); - } - $collection = new RouteCollection(); $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); $collection->addResource($bar = new FileResource(__DIR__.'/Fixtures/bar.xml')); @@ -252,4 +244,61 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $this->assertEquals('{locale}.example.com', $routea->getHost()); $this->assertEquals('{locale}.example.com', $routeb->getHost()); } + + public function testSetCondition() + { + $collection = new RouteCollection(); + $routea = new Route('/a'); + $routeb = new Route('/b', array(), array(), array(), '{locale}.example.net', array(), array(), 'context.getMethod() == "GET"'); + $collection->add('a', $routea); + $collection->add('b', $routeb); + + $collection->setCondition('context.getMethod() == "POST"'); + + $this->assertEquals('context.getMethod() == "POST"', $routea->getCondition()); + $this->assertEquals('context.getMethod() == "POST"', $routeb->getCondition()); + } + + public function testClone() + { + $collection = new RouteCollection(); + $collection->add('a', new Route('/a')); + $collection->add('b', new Route('/b', array('placeholder' => 'default'), array('placeholder' => '.+'))); + + $clonedCollection = clone $collection; + + $this->assertCount(2, $clonedCollection); + $this->assertEquals($collection->get('a'), $clonedCollection->get('a')); + $this->assertNotSame($collection->get('a'), $clonedCollection->get('a')); + $this->assertEquals($collection->get('b'), $clonedCollection->get('b')); + $this->assertNotSame($collection->get('b'), $clonedCollection->get('b')); + } + + public function testSetSchemes() + { + $collection = new RouteCollection(); + $routea = new Route('/a', array(), array(), array(), '', 'http'); + $routeb = new Route('/b'); + $collection->add('a', $routea); + $collection->add('b', $routeb); + + $collection->setSchemes(array('http', 'https')); + + $this->assertEquals(array('http', 'https'), $routea->getSchemes()); + $this->assertEquals(array('http', 'https'), $routeb->getSchemes()); + } + + public function testSetMethods() + { + $collection = new RouteCollection(); + $routea = new Route('/a', array(), array(), array(), '', array(), array('GET', 'POST')); + $routeb = new Route('/b'); + $collection->add('a', $routea); + $collection->add('b', $routeb); + + $collection->setMethods('PUT'); + + $this->assertEquals(array('PUT'), $routea->getMethods()); + $this->assertEquals(array('PUT'), $routeb->getMethods()); + } } 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 31f1066feda1..cbd5ccb43b3f 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php @@ -24,9 +24,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase $this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument'); $this->assertEquals('{locale}.example.com', $route->getHost(), '__construct() takes a host pattern as its fifth argument'); - $route = new Route('/', array(), array(), array(), '', array('Https'), array('POST', 'put')); + $route = new Route('/', array(), array(), array(), '', array('Https'), array('POST', 'put'), 'context.getMethod() == "GET"'); $this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes schemes as its sixth argument and lowercases it'); $this->assertEquals(array('POST', 'PUT'), $route->getMethods(), '__construct() takes methods as its seventh argument and uppercases it'); + $this->assertEquals('context.getMethod() == "GET"', $route->getCondition(), '__construct() takes a condition as its eight argument'); $route = new Route('/', array(), array(), array(), '', 'Https', 'Post'); $this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes a single scheme as its sixth argument'); @@ -44,7 +45,7 @@ class RouteTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/bar', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed'); $this->assertEquals($route, $route->setPath(''), '->setPath() implements a fluent interface'); $route->setPath('//path'); - $this->assertEquals('/path', $route->getPath(), '->setPath() does not allow two slahes "//" at the beginning of the path as it would be confused with a network path when generating the path from the route'); + $this->assertEquals('/path', $route->getPath(), '->setPath() does not allow two slashes "//" at the beginning of the path as it would be confused with a network path when generating the path from the route'); } public function testOptions() @@ -62,6 +63,15 @@ class RouteTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('foo' => 'foo', 'bar' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), $route->getOptions(), '->addDefaults() keep previous defaults'); } + public function testOption() + { + $route = new Route('/{foo}'); + $this->assertFalse($route->hasOption('foo'), '->hasOption() return false if option is not set'); + $this->assertEquals($route, $route->setOption('foo', 'bar'), '->setOption() implements a fluent interface'); + $this->assertEquals('bar', $route->getOption('foo'), '->setOption() sets the option'); + $this->assertTrue($route->hasOption('foo'), '->hasOption() return true if option is set'); + } + public function testDefaults() { $route = new Route('/{foo}'); @@ -74,7 +84,7 @@ class RouteTest extends \PHPUnit_Framework_TestCase $route->setDefault('foo2', 'bar2'); $this->assertEquals('bar2', $route->getDefault('foo2'), '->getDefault() return the default value'); - $this->assertNull($route->getDefault('not_defined'), '->getDefault() return null if default value is not setted'); + $this->assertNull($route->getDefault('not_defined'), '->getDefault() return null if default value is not set'); $route->setDefault('_controller', $closure = function () { return 'Hello'; }); $this->assertEquals($closure, $route->getDefault('_controller'), '->setDefault() sets a default value'); @@ -105,8 +115,10 @@ class RouteTest extends \PHPUnit_Framework_TestCase public function testRequirement() { $route = new Route('/{foo}'); + $this->assertFalse($route->hasRequirement('foo'), '->hasRequirement() return false if requirement is not set'); $route->setRequirement('foo', '^\d+$'); $this->assertEquals('\d+', $route->getRequirement('foo'), '->setRequirement() removes ^ and $ from the path'); + $this->assertTrue($route->hasRequirement('foo'), '->hasRequirement() return true if requirement is set'); } /** @@ -141,10 +153,15 @@ class RouteTest extends \PHPUnit_Framework_TestCase { $route = new Route('/'); $this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()'); + $this->assertFalse($route->hasScheme('http')); $route->setSchemes('hTTp'); $this->assertEquals(array('http'), $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it'); + $this->assertTrue($route->hasScheme('htTp')); + $this->assertFalse($route->hasScheme('httpS')); $route->setSchemes(array('HttpS', 'hTTp')); $this->assertEquals(array('https', 'http'), $route->getSchemes(), '->setSchemes() accepts an array of schemes and lowercases them'); + $this->assertTrue($route->hasScheme('htTp')); + $this->assertTrue($route->hasScheme('httpS')); } public function testSchemeIsBC() @@ -153,6 +170,9 @@ class RouteTest extends \PHPUnit_Framework_TestCase $route->setRequirement('_scheme', 'http|https'); $this->assertEquals('http|https', $route->getRequirement('_scheme')); $this->assertEquals(array('http', 'https'), $route->getSchemes()); + $this->assertTrue($route->hasScheme('https')); + $this->assertTrue($route->hasScheme('http')); + $this->assertFalse($route->hasScheme('ftp')); $route->setSchemes(array('hTTp')); $this->assertEquals('http', $route->getRequirement('_scheme')); $route->setSchemes(array()); @@ -181,6 +201,14 @@ class RouteTest extends \PHPUnit_Framework_TestCase $this->assertNull($route->getRequirement('_method')); } + public function testCondition() + { + $route = new Route('/'); + $this->assertEquals(null, $route->getCondition()); + $route->setCondition('context.getMethod() == "GET"'); + $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); + } + public function testCompile() { $route = new Route('/{foo}'); @@ -189,4 +217,24 @@ class RouteTest extends \PHPUnit_Framework_TestCase $route->setRequirement('foo', '.*'); $this->assertNotSame($compiled, $route->compile(), '->compile() recompiles if the route was modified'); } + + public function testPattern() + { + $route = new Route('/{foo}'); + $this->assertEquals('/{foo}', $route->getPattern()); + + $route->setPattern('/bar'); + $this->assertEquals('/bar', $route->getPattern()); + } + + public function testSerialize() + { + $route = new Route('/{foo}', array('foo' => 'default'), array('foo' => '\d+')); + + $serialized = serialize($route); + $unserialized = unserialize($serialized); + + $this->assertEquals($route, $unserialized); + $this->assertNotSame($route, $unserialized); + } } 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 a3c336e5b775..42a344c74a73 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Routing\Tests; use Symfony\Component\Routing\Router; +use Symfony\Component\HttpFoundation\Request; class RouterTest extends \PHPUnit_Framework_TestCase { @@ -135,4 +136,28 @@ class RouterTest extends \PHPUnit_Framework_TestCase array('generator_cache_class') ); } + + public function testMatchRequestWithUrlMatcherInterface() + { + $matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $matcher->expects($this->once())->method('match'); + + $p = new \ReflectionProperty($this->router, 'matcher'); + $p->setAccessible(true); + $p->setValue($this->router, $matcher); + + $this->router->matchRequest(Request::create('/')); + } + + public function testMatchRequestWithRequestMatcherInterface() + { + $matcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $matcher->expects($this->once())->method('matchRequest'); + + $p = new \ReflectionProperty($this->router, 'matcher'); + $p->setAccessible(true); + $p->setValue($this->router, $matcher); + + $this->router->matchRequest(Request::create('/')); + } } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json index 9a737c6b0287..3517b2362404 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/composer.json @@ -2,7 +2,7 @@ "name": "symfony/routing", "type": "library", "description": "Symfony Routing Component", - "keywords": [], + "keywords": ["routing", "router", "URL", "URI"], "homepage": "http://symfony.com", "license": "MIT", "authors": [ @@ -21,13 +21,15 @@ "require-dev": { "symfony/config": "~2.2", "symfony/yaml": "~2.0", - "doctrine/common": "~2.2", + "symfony/expression-language": "~2.4", + "doctrine/annotations": "~1.0", "psr/log": "~1.0" }, "suggest": { - "symfony/config": "", - "symfony/yaml": "", - "doctrine/common": "" + "symfony/config": "For using the all-in-one router or any loader", + "symfony/yaml": "For using the YAML loader", + "symfony/expression-language": "For using expression matching", + "doctrine/annotations": "For using the annotation loader" }, "autoload": { "psr-0": { "Symfony\\Component\\Routing\\": "" } @@ -36,7 +38,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md b/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md index 5a332da390bb..5b859623fef0 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.4.0 +----- + + * added `$context` support for XMLEncoder. + 2.3.0 ----- diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainDecoder.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainDecoder.php index 6ece3b2205b9..5321a234057e 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainDecoder.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainDecoder.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Serializer\Encoder; -use Symfony\Component\Serializer\Encoder\DecoderInterface; use Symfony\Component\Serializer\Exception\RuntimeException; /** diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php index bd10a2ad412a..088420b11820 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Serializer\Encoder; -use Symfony\Component\Serializer\Encoder\EncoderInterface; -use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface; use Symfony\Component\Serializer\Exception\RuntimeException; /** 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 d616286aef40..f8dfab35a889 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -70,7 +70,7 @@ class JsonDecode implements DecoderInterface * * json_decode_associative: boolean * If true, returns the object as associative array. - * If false, returns the object as nested StdClass + * If false, returns the object as nested stdClass * If not specified, this method will use the default set in JsonDecode::__construct * * json_decode_recursion_depth: integer diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncoder.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncoder.php index 02b179bc91a6..95dae7c8c667 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncoder.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/JsonEncoder.php @@ -32,8 +32,8 @@ class JsonEncoder implements EncoderInterface, DecoderInterface public function __construct(JsonEncode $encodingImpl = null, JsonDecode $decodingImpl = null) { - $this->encodingImpl = null === $encodingImpl ? new JsonEncode() : $encodingImpl; - $this->decodingImpl = null === $decodingImpl ? new JsonDecode(true) : $decodingImpl; + $this->encodingImpl = $encodingImpl ?: new JsonEncode(); + $this->decodingImpl = $decodingImpl ?: new JsonDecode(true); } /** diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 137f2fc3272d..9cd2417b468b 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -24,6 +24,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec { private $dom; private $format; + private $context; private $rootNodeName = 'response'; /** @@ -47,8 +48,9 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec $xmlRootNodeName = $this->resolveXmlRootName($context); - $this->dom = new \DOMDocument(); + $this->dom = $this->createDomDocument($context); $this->format = $format; + $this->context = $context; if (null !== $data && !is_scalar($data)) { $root = $this->dom->createElement($xmlRootNodeName); @@ -76,6 +78,10 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec libxml_use_internal_errors($internalErrors); libxml_disable_entity_loader($disableEntities); + if ($error = libxml_get_last_error()) { + throw new UnexpectedValueException($error->message); + } + foreach ($dom->childNodes as $child) { if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { throw new UnexpectedValueException('Document types are not allowed.'); @@ -105,24 +111,16 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } /** - * Checks whether the serializer can encode to given format - * - * @param string $format format name - * - * @return Boolean - */ + * {@inheritdoc} + */ public function supportsEncoding($format) { return 'xml' === $format; } /** - * Checks whether the serializer can decode from given format - * - * @param string $format format name - * - * @return Boolean - */ + * {@inheritdoc} + */ public function supportsDecoding($format) { return 'xml' === $format; @@ -148,12 +146,12 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } /** - * @param DOMNode $node - * @param string $val + * @param \DOMNode $node + * @param string $val * * @return Boolean */ - final protected function appendXMLString($node, $val) + final protected function appendXMLString(\DOMNode $node, $val) { if (strlen($val) > 0) { $frag = $this->dom->createDocumentFragment(); @@ -167,12 +165,12 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } /** - * @param DOMNode $node - * @param string $val + * @param \DOMNode $node + * @param string $val * * @return Boolean */ - final protected function appendText($node, $val) + final protected function appendText(\DOMNode $node, $val) { $nodeText = $this->dom->createTextNode($val); $node->appendChild($nodeText); @@ -181,12 +179,12 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } /** - * @param DOMNode $node - * @param string $val + * @param \DOMNode $node + * @param string $val * * @return Boolean */ - final protected function appendCData($node, $val) + final protected function appendCData(\DOMNode $node, $val) { $nodeText = $this->dom->createCDATASection($val); $node->appendChild($nodeText); @@ -195,12 +193,12 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } /** - * @param DOMNode $node - * @param DOMDocumentFragment $fragment + * @param \DOMNode $node + * @param \DOMDocumentFragment $fragment * * @return Boolean */ - final protected function appendDocumentFragment($node, $fragment) + final protected function appendDocumentFragment(\DOMNode $node, $fragment) { if ($fragment instanceof \DOMDocumentFragment) { $node->appendChild($fragment); @@ -228,11 +226,11 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec /** * Parse the input SimpleXmlElement into an array. * - * @param SimpleXmlElement $node xml to parse + * @param \SimpleXmlElement $node xml to parse * * @return array */ - private function parseXml($node) + private function parseXml(\SimpleXmlElement $node) { $data = array(); if ($node->attributes()) { @@ -256,9 +254,9 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec if ($key === 'item') { if (isset($value['@key'])) { if (isset($value['#'])) { - $data[(string) $value['@key']] = $value['#']; + $data[$value['@key']] = $value['#']; } else { - $data[(string) $value['@key']] = $value; + $data[$value['@key']] = $value; } } else { $data['item'][] = $value; @@ -279,15 +277,15 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec /** * Parse the data and convert it to DOMElements * - * @param DOMNode $parentNode - * @param array|object $data data - * @param string $xmlRootNodeName + * @param \DOMNode $parentNode + * @param array|object $data + * @param string|null $xmlRootNodeName * * @return Boolean * * @throws UnexpectedValueException */ - private function buildXml($parentNode, $data, $xmlRootNodeName = null) + private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null) { $append = true; @@ -325,7 +323,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } if (is_object($data)) { - $data = $this->serializer->normalize($data, $this->format); + $data = $this->serializer->normalize($data, $this->format, $this->context); if (null !== $data && !is_scalar($data)) { return $this->buildXml($parentNode, $data, $xmlRootNodeName); } @@ -347,14 +345,14 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec /** * Selects the type of node to create and appends it to the parent. * - * @param DOMNode $parentNode + * @param \DOMNode $parentNode * @param array|object $data * @param string $nodeName * @param string $key * * @return Boolean */ - private function appendNode($parentNode, $data, $nodeName, $key = null) + private function appendNode(\DOMNode $parentNode, $data, $nodeName, $key = null) { $node = $this->dom->createElement($nodeName); if (null !== $key) { @@ -384,12 +382,12 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec /** * Tests the value being passed and decide what sort of element to create * - * @param DOMNode $node - * @param mixed $val + * @param \DOMNode $node + * @param mixed $val * * @return Boolean */ - private function selectNodeType($node, $val) + private function selectNodeType(\DOMNode $node, $val) { if (is_array($val)) { return $this->buildXml($node, $val); @@ -399,7 +397,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec } elseif ($val instanceof \Traversable) { $this->buildXml($node, $val); } elseif (is_object($val)) { - return $this->buildXml($node, $this->serializer->normalize($val, $this->format)); + return $this->buildXml($node, $this->serializer->normalize($val, $this->format, $this->context)); } elseif (is_numeric($val)) { return $this->appendText($node, (string) $val); } elseif (is_string($val) && $this->needsCdataWrapping($val)) { @@ -426,4 +424,32 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec : $this->rootNodeName; } + /** + * Create a DOM document, taking serializer options into account. + * + * @param array $context options that the encoder has access to. + * + * @return \DOMDocument + */ + private function createDomDocument(array $context) + { + $document = new \DOMDocument(); + + // Set an attribute on the DOM document specifying, as part of the XML declaration, + $xmlOptions = array( + // the version number of the document + 'xml_version' => 'xmlVersion', + // the encoding of the document + 'xml_encoding' => 'encoding', + // whether the document is standalone + 'xml_standalone' => 'xmlStandalone', + ); + foreach ($xmlOptions as $xmlOption => $documentProperty) { + if (isset($context[$xmlOption])) { + $document->$documentProperty = $context[$xmlOption]; + } + } + + return $document; + } } 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 54854c6cf499..1b1a5f568874 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -41,9 +41,9 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal protected $camelizedAttributes = array(); /** - * Set normalization callbacks + * Set normalization callbacks. * - * @param array $callbacks help normalize the result + * @param callable[] $callbacks help normalize the result * * @throws InvalidArgumentException if a non-callable callback is set */ diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md b/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md index 3e808059db4d..5a1606ca09c1 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/README.md @@ -11,5 +11,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/Serializer/ - $ composer.phar install --dev + $ composer.phar install $ phpunit diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerAwareInterface.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerAwareInterface.php index dd0bb60d1aa8..ad0b768ccc8a 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerAwareInterface.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/SerializerAwareInterface.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Serializer; -use Symfony\Component\Serializer\SerializerInterface; - /** * Defines the interface of encoders * diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php index b5ec1a235223..00714f23ba2a 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php @@ -19,7 +19,7 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - $this->encoder = new JsonEncoder; + $this->encoder = new JsonEncoder(); $this->serializer = new Serializer(array(new CustomNormalizer()), array('json' => new JsonEncoder())); } 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 b23d4c793909..6ad2a6c2e256 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 @@ -20,16 +20,18 @@ use Symfony\Component\Serializer\Normalizer\CustomNormalizer; class XmlEncoderTest extends \PHPUnit_Framework_TestCase { + private $encoder; + protected function setUp() { - $this->encoder = new XmlEncoder; + $this->encoder = new XmlEncoder(); $serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder())); $this->encoder->setSerializer($serializer); } public function testEncodeScalar() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = "foo"; $expected = ''."\n". @@ -40,7 +42,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase public function testSetRootNodeName() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = "foo"; $this->encoder->setRootNodeName('test'); @@ -51,7 +53,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException UnexpectedValueException + * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException * @expectedExceptionMessage Document types are not allowed. */ public function testDocTypeIsNotAllowed() @@ -61,7 +63,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase public function testAttributes() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = array( 'foo-bar' => array( '@id' => 1, @@ -90,7 +92,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase public function testElementNameValid() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = array( 'foo-bar' => 'a', 'foo_bar' => 'a', @@ -118,6 +120,23 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $this->encoder->encode($array, 'xml')); } + public function testEncodeXmlAttributes() + { + $xml = simplexml_load_string('Peter'); + $array = array('person' => $xml); + + $expected = ''."\n". + 'Peter'."\n"; + + $context = array( + 'xml_version' => '1.1', + 'xml_encoding' => 'utf-8', + 'xml_standalone' => true, + ); + + $this->assertSame($expected, $this->encoder->encode($array, 'xml', $context)); + } + public function testEncodeScalarRootAttributes() { $array = array( @@ -187,7 +206,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase public function testEncodeSerializerXmlRootNodeNameOption() { $options = array('xml_root_node_name' => 'test'); - $this->encoder = new XmlEncoder; + $this->encoder = new XmlEncoder(); $serializer = new Serializer(array(), array('xml' => new XmlEncoder())); $this->encoder->setSerializer($serializer); @@ -270,7 +289,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase public function testDecodeWithoutItemHash() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = array( 'foo-bar' => array( '@key' => "value", @@ -301,6 +320,14 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $this->encoder->decode($xml, 'xml')); } + /** + * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException + */ + public function testDecodeInvalidXml() + { + $this->encoder->decode('', 'xml'); + } + public function testPreventsComplexExternalEntities() { $oldCwd = getcwd(); @@ -335,7 +362,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase protected function getObject() { - $obj = new Dummy; + $obj = new Dummy(); $obj->foo = 'foo'; $obj->bar = array('a', 'b'); $obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1))); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php index 7b4b4ae28d85..eef163442eda 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php @@ -19,13 +19,13 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - $this->normalizer = new CustomNormalizer; - $this->normalizer->setSerializer(new Serializer); + $this->normalizer = new CustomNormalizer(); + $this->normalizer->setSerializer(new Serializer()); } public function testSerialize() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->foo = 'foo'; $obj->xmlFoo = 'xml'; $this->assertEquals('foo', $this->normalizer->normalize($obj, 'json')); @@ -34,18 +34,18 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase public function testDeserialize() { - $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy), 'xml'); + $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy()), 'xml'); $this->assertEquals('foo', $obj->xmlFoo); $this->assertNull($obj->foo); - $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy), 'json'); + $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy()), 'json'); $this->assertEquals('foo', $obj->foo); $this->assertNull($obj->xmlFoo); } public function testSupportsNormalization() { - $this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy)); + $this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy())); $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass)); } 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 42846166e453..f3bf9694d206 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,13 +17,13 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - $this->normalizer = new GetSetMethodNormalizer; + $this->normalizer = new GetSetMethodNormalizer(); $this->normalizer->setSerializer($this->getMock('Symfony\Component\Serializer\Serializer')); } public function testNormalize() { - $obj = new GetSetDummy; + $obj = new GetSetDummy(); $obj->setFoo('foo'); $obj->setBar('bar'); $obj->setCamelCase('camelcase'); @@ -118,7 +118,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase { $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase')); - $obj = new GetSetDummy; + $obj = new GetSetDummy(); $obj->setFoo('foo'); $obj->setBar('bar'); diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php index 3c189461f28f..106bcff7adb5 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -34,14 +34,14 @@ class SerializerTest extends \PHPUnit_Framework_TestCase public function testNormalizeTraversable() { $this->serializer = new Serializer(array(), array('json' => new JsonEncoder())); - $result = $this->serializer->serialize(new TraversableDummy, 'json'); + $result = $this->serializer->serialize(new TraversableDummy(), 'json'); $this->assertEquals('{"foo":"foo","bar":"bar"}', $result); } public function testNormalizeGivesPriorityToInterfaceOverTraversable() { - $this->serializer = new Serializer(array(new CustomNormalizer), array('json' => new JsonEncoder())); - $result = $this->serializer->serialize(new NormalizableTraversableDummy, 'json'); + $this->serializer = new Serializer(array(new CustomNormalizer()), array('json' => new JsonEncoder())); + $result = $this->serializer->serialize(new NormalizableTraversableDummy(), 'json'); $this->assertEquals('{"foo":"normalizedFoo","bar":"normalizedBar"}', $result); } diff --git a/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json b/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json index ab537b295527..704356623c83 100644 --- a/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json +++ b/core/vendor/symfony/serializer/Symfony/Component/Serializer/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md b/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md index 7ab8051c1a92..f5ae1ee39092 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +2.4.0 +----- + + * added a constraint the uses the expression language + * added `minRatio`, `maxRatio`, `allowSquare`, `allowLandscape`, and `allowPortrait` to Image validator + 2.3.0 ----- diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php index 6c568aacd4a7..2f3cbdda5ad0 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraint.php @@ -87,8 +87,9 @@ abstract class Constraint $invalidOptions = array(); $missingOptions = array_flip((array) $this->getRequiredOptions()); - if (is_array($options) && count($options) == 1 && isset($options['value'])) { - $options = $options['value']; + if (is_array($options) && count($options) >= 1 && isset($options['value']) && !property_exists($this, 'value')) { + $options[$this->getDefaultOption()] = $options['value']; + unset($options['value']); } if (is_array($options) && count($options) > 0 && is_string(key($options))) { diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php index 88b5cefdc2c7..5cf36eccffc3 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php @@ -11,20 +11,33 @@ namespace Symfony\Component\Validator; -use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; -use Symfony\Component\Validator\Constraint; +use Symfony\Component\PropertyAccess\PropertyAccess; +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; +use Symfony\Component\Validator\Constraints\ExpressionValidator; /** * Default implementation of the ConstraintValidatorFactoryInterface. * * This enforces the convention that the validatedBy() method on any - * Constrain will return the class name of the ConstraintValidator that + * Constraint will return the class name of the ConstraintValidator that * should validate the Constraint. + * + * @author Bernhard Schussek */ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface { protected $validators = array(); + /** + * @var PropertyAccessorInterface + */ + private $propertyAccessor; + + public function __construct(PropertyAccessorInterface $propertyAccessor = null) + { + $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); + } + /** * {@inheritDoc} */ @@ -32,8 +45,19 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface { $className = $constraint->validatedBy(); - if (!isset($this->validators[$className]) || $className === 'Symfony\Component\Validator\Constraints\CollectionValidator') { - $this->validators[$className] = new $className(); + // 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) { + $this->validators[$className] = 'validator.expression' === $className + ? new ExpressionValidator($this->propertyAccessor) + : new $className(); } return $this->validators[$className]; diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactoryInterface.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactoryInterface.php index 584f980367c6..5e216275b493 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactoryInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactoryInterface.php @@ -11,11 +11,9 @@ namespace Symfony\Component\Validator; -use Symfony\Component\Validator\Constraint; - /** * Specifies an object able to return the correct ConstraintValidatorInterface - * instance given a Constrain object. + * instance given a Constraint object. */ interface ConstraintValidatorFactoryInterface { 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 6b76fc80b2a2..f6b919331fae 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -60,6 +60,10 @@ abstract class AbstractComparisonValidator extends ConstraintValidator */ 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'); } 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 e93efa4b9914..01aeb6ddb798 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Callback.php @@ -22,26 +22,52 @@ use Symfony\Component\Validator\Constraint; */ class Callback extends Constraint { + /** + * @var string|callable + * + * @since 2.4 + */ + public $callback; + + /** + * @var array + * + * @deprecated Deprecated since version 2.4, to be removed in Symfony 3.0. + */ public $methods; /** - * {@inheritDoc} + * {@inheritdoc} */ - public function getRequiredOptions() + public function __construct($options = null) { - return array('methods'); + // Invocation through annotations with an array parameter only + if (is_array($options) && 1 === count($options) && isset($options['value'])) { + $options = $options['value']; + } + + if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups'])) { + if (is_callable($options)) { + $options = array('callback' => $options); + } else { + // BC with Symfony < 2.4 + $options = array('methods' => $options); + } + } + + parent::__construct($options); } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getDefaultOption() { - return 'methods'; + return 'callback'; } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getTargets() { 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 ab3c56f98e2c..28b34250af6f 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -34,13 +34,20 @@ class CallbackValidator extends ConstraintValidator return; } + if (null !== $constraint->callback && null !== $constraint->methods) { + throw new ConstraintDefinitionException( + 'The Callback constraint supports either the option "callback" ' . + 'or "methods", but not both at the same time.' + ); + } + // has to be an array so that we can differentiate between callables // and method names - if (!is_array($constraint->methods)) { + if (null !== $constraint->methods && !is_array($constraint->methods)) { throw new UnexpectedTypeException($constraint->methods, 'array'); } - $methods = $constraint->methods; + $methods = $constraint->methods ?: array($constraint->callback); foreach ($methods as $method) { if (is_array($method) || $method instanceof \Closure) { @@ -54,7 +61,13 @@ class CallbackValidator extends ConstraintValidator throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method)); } - $object->$method($this->context); + $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/Collection.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php index d60f0c273d13..78fa5aee9dd5 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Collection.php @@ -12,8 +12,6 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\Required; -use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; /** @@ -25,7 +23,7 @@ use Symfony\Component\Validator\Exception\ConstraintDefinitionException; */ class Collection extends Constraint { - public $fields; + public $fields = array(); public $allowExtraFields = false; public $allowMissingFields = false; public $extraFieldsMessage = 'This field was not expected.'; 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 f59afe79ee5f..f273ac40b95e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Validator\Constraints\Optional; /** * @author Bernhard Schussek 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 abe45a87d06f..e0593102bc59 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -41,11 +41,6 @@ class EmailValidator extends ConstraintValidator if ($valid) { $host = substr($value, strpos($value, '@') + 1); - if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false) { - // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3 - $valid = false; - } - // Check for host DNS resource records if ($valid && $constraint->checkMX) { $valid = $this->checkMX($host); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php new file mode 100644 index 000000000000..b845a32392b2 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Expression.php @@ -0,0 +1,58 @@ + + * + * 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 Fabien Potencier + * @author Bernhard Schussek + */ +class Expression extends Constraint +{ + public $message = 'This value is not valid.'; + public $expression; + + /** + * {@inheritDoc} + */ + public function getDefaultOption() + { + return 'expression'; + } + + /** + * {@inheritDoc} + */ + public function getRequiredOptions() + { + return array('expression'); + } + + /** + * {@inheritDoc} + */ + public function getTargets() + { + return array(self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT); + } + + /** + * {@inheritDoc} + */ + public function validatedBy() + { + return 'validator.expression'; + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php new file mode 100644 index 000000000000..e27859b08c19 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -0,0 +1,82 @@ + + * + * 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\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\Exception\RuntimeException; + +/** + * @author Fabien Potencier + * @author Bernhard Schussek + */ +class ExpressionValidator extends ConstraintValidator +{ + /** + * @var PropertyAccessorInterface + */ + private $propertyAccessor; + + /** + * @var ExpressionLanguage + */ + private $expressionLanguage; + + public function __construct(PropertyAccessorInterface $propertyAccessor) + { + $this->propertyAccessor = $propertyAccessor; + } + + /** + * {@inheritDoc} + */ + public function validate($value, Constraint $constraint) + { + if (null === $value || '' === $value) { + return; + } + + $variables = array(); + + if (null === $this->context->getPropertyName()) { + $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 (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) { + $this->context->addViolation($constraint->message); + } + } + + private function getExpressionLanguage() + { + if (null === $this->expressionLanguage) { + if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); + } + $this->expressionLanguage = new ExpressionLanguage(); + } + + return $this->expressionLanguage; + } +} 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 1afc8f01b711..3ec4c6ea7a79 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -30,6 +30,13 @@ class IbanValidator extends ConstraintValidator 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)); + + return; + } + $teststring = preg_replace('/\s+/', '', $value); if (strlen($teststring) < 4) { 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 a23106489f35..9fa8725c6da1 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Image.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Image.php @@ -23,6 +23,11 @@ class Image extends File public $maxWidth = null; public $maxHeight = null; public $minHeight = null; + public $maxRatio = null; + public $minRatio = null; + public $allowSquare = true; + public $allowLandscape = true; + public $allowPortrait = true; public $mimeTypesMessage = 'This file is not a valid image.'; public $sizeNotDetectedMessage = 'The size of the image could not be detected.'; @@ -30,4 +35,9 @@ class Image extends File public $minWidthMessage = 'The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px.'; public $maxHeightMessage = 'The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px.'; public $minHeightMessage = 'The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px.'; + public $maxRatioMessage = 'The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.'; + public $minRatioMessage = 'The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.'; + public $allowSquareMessage = 'The image is square ({{ width }}x{{ height }}px). Square images are not allowed.'; + public $allowLandscapeMessage = 'The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.'; + public $allowPortraitMessage = 'The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.'; } 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 79e6bdcddbbb..76ce8767fcea 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ImageValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/ImageValidator.php @@ -38,7 +38,9 @@ class ImageValidator extends FileValidator } if (null === $constraint->minWidth && null === $constraint->maxWidth - && null === $constraint->minHeight && null === $constraint->maxHeight) { + && null === $constraint->minHeight && null === $constraint->maxHeight + && null === $constraint->minRatio && null === $constraint->maxRatio + && $constraint->allowSquare && $constraint->allowLandscape && $constraint->allowPortrait) { return; } @@ -109,5 +111,55 @@ class ImageValidator extends FileValidator )); } } + + $ratio = $width / $height; + + if (null !== $constraint->minRatio) { + if (!is_numeric((string) $constraint->minRatio)) { + throw new ConstraintDefinitionException(sprintf('"%s" is not a valid minimum ratio', $constraint->minRatio)); + } + + if ($ratio < $constraint->minRatio) { + $this->context->addViolation($constraint->minRatioMessage, array( + '{{ ratio }}' => $ratio, + '{{ min_ratio }}' => $constraint->minRatio + )); + } + } + + if (null !== $constraint->maxRatio) { + if (!is_numeric((string) $constraint->maxRatio)) { + throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum ratio', $constraint->maxRatio)); + } + + if ($ratio > $constraint->maxRatio) { + $this->context->addViolation($constraint->maxRatioMessage, array( + '{{ ratio }}' => $ratio, + '{{ max_ratio }}' => $constraint->maxRatio + )); + } + } + + if (!$constraint->allowSquare && $width == $height) { + $this->context->addViolation($constraint->allowSquareMessage, array( + '{{ width }}' => $width, + '{{ height }}' => $height + )); + } + + if (!$constraint->allowLandscape && $width > $height) { + $this->context->addViolation($constraint->allowLandscapeMessage, array( + '{{ width }}' => $width, + '{{ height }}' => $height + )); + } + + if (!$constraint->allowPortrait && $width < $height) { + $this->context->addViolation($constraint->allowPortraitMessage, array( + '{{ width }}' => $width, + '{{ height }}' => $height + )); + } + } } 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 0b60eee159c9..d3802fe99ae1 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LuhnValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/LuhnValidator.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Validates a PAN using the LUHN Algorithm @@ -38,6 +39,13 @@ class LuhnValidator extends ConstraintValidator return; } + /** + * need to work with strings only because long numbers are treated as floats and don't work with strlen + */ + if (!is_string($value)) { + throw new UnexpectedTypeException($value, 'string'); + } + if (!is_numeric($value)) { $this->context->addViolation($constraint->message); 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 8d3efae0d584..dd3dbdd8498a 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NotBlankValidator.php @@ -15,8 +15,6 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; /** - * @author Bernhard Schussek - * * @author Bernhard Schussek * * @api 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 e8fa24ed7495..9753f43315f3 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/NullValidator.php @@ -27,6 +27,12 @@ class NullValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if (null !== $value) { + if (is_object($value)) { + $value = get_class($value); + } elseif (is_array($value)) { + $value = 'Array'; + } + $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/RuntimeException.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/RuntimeException.php new file mode 100644 index 000000000000..df4a50c47433 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/RuntimeException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Exception; + +/** + * Base RuntimeException for the Validator component. + * + * @author Bernhard Schussek + */ +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnexpectedTypeException.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnexpectedTypeException.php index 573fecd2e898..49d8cc208223 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnexpectedTypeException.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Exception/UnexpectedTypeException.php @@ -15,6 +15,6 @@ class UnexpectedTypeException extends ValidatorException { public function __construct($value, $expectedType) { - parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, gettype($value))); + 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/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php index 4cd1175b0cc4..90dd282e0871 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php @@ -11,15 +11,28 @@ namespace Symfony\Component\Validator\Mapping; +use Symfony\Component\Validator\MetadataFactoryInterface; + /** - * Simple implementation of ClassMetadataFactoryInterface that can be used when using ValidatorInterface::validateValue(). + * Simple implementation of MetadataFactoryInterface that can be used when using ValidatorInterface::validateValue(). * * @author Fabien Potencier */ -class BlackholeMetadataFactory implements ClassMetadataFactoryInterface +class BlackholeMetadataFactory implements MetadataFactoryInterface { - public function getClassMetadata($class) + /** + * @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/Loader/AbstractLoader.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index 54c0dbe47479..8deea4eba8c5 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 @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Mapping\Loader; use Symfony\Component\Validator\Exception\MappingException; +use Symfony\Component\Validator\Constraint; abstract class AbstractLoader implements LoaderInterface { @@ -19,7 +20,7 @@ abstract class AbstractLoader implements LoaderInterface * Contains all known namespaces indexed by their prefix * @var array */ - protected $namespaces; + protected $namespaces = array(); /** * Adds a namespace alias. 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 0e7e89b548c7..10745c72e7ff 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,6 +12,7 @@ namespace Symfony\Component\Validator\Mapping\Loader; use Doctrine\Common\Annotations\Reader; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Exception\MappingException; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\GroupSequence; @@ -63,7 +64,12 @@ class AnnotationLoader implements LoaderInterface foreach ($reflClass->getMethods() as $method) { if ($method->getDeclaringClass()->name == $className) { foreach ($this->reader->getMethodAnnotations($method) as $constraint) { - if ($constraint instanceof Constraint) { + if ($constraint instanceof Callback) { + $constraint->callback = $method->getName(); + $constraint->methods = null; + + $metadata->addConstraint($constraint); + } elseif ($constraint instanceof Constraint) { if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) { $metadata->addGetterConstraint(lcfirst($matches[2]), $constraint); } else { 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 a9ae39677775..cad247e883dd 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 @@ -183,7 +183,7 @@ class XmlFileLoader extends FileLoader * * @param string $file Path of file * - * @return SimpleXMLElement + * @return \SimpleXMLElement * * @throws MappingException */ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/README.md b/core/vendor/symfony/validator/Symfony/Component/Validator/README.md index 70dd99981a71..e1601cfe47eb 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.3/book/validation.html +http://symfony.com/doc/2.4/book/validation.html JSR-303 Specification: @@ -116,5 +116,5 @@ http://jcp.org/en/jsr/detail?id=303 You can run the unit tests with the following command: $ cd path/to/Symfony/Component/Validator/ - $ composer.phar install --dev + $ composer.phar install $ phpunit 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 007bb1e3a23e..015a6dab665e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ConstraintTest.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; use Symfony\Component\Validator\Tests\Fixtures\ConstraintC; +use Symfony\Component\Validator\Tests\Fixtures\ConstraintWithValue; +use Symfony\Component\Validator\Tests\Fixtures\ConstraintWithValueAsDefault; class ConstraintTest extends \PHPUnit_Framework_TestCase { @@ -71,6 +73,30 @@ class ConstraintTest extends \PHPUnit_Framework_TestCase $this->assertEquals('foo', $constraint->property2); } + public function testSetDefaultPropertyDoctrineStylePlusOtherProperty() + { + $constraint = new ConstraintA(array('value' => 'foo', 'property1' => 'bar')); + + $this->assertEquals('foo', $constraint->property2); + $this->assertEquals('bar', $constraint->property1); + } + + public function testSetDefaultPropertyDoctrineStyleWhenDefaultPropertyIsNamedValue() + { + $constraint = new ConstraintWithValueAsDefault(array('value' => 'foo')); + + $this->assertEquals('foo', $constraint->value); + $this->assertNull($constraint->property); + } + + public function testDontSetDefaultPropertyIfValuePropertyExists() + { + $constraint = new ConstraintWithValue(array('value' => 'foo')); + + $this->assertEquals('foo', $constraint->value); + $this->assertNull($constraint->property); + } + public function testSetUndefinedDefaultProperty() { $this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); @@ -117,14 +143,14 @@ class ConstraintTest extends \PHPUnit_Framework_TestCase public function testGetTargetsCanBeString() { - $constraint = new ClassConstraint; + $constraint = new ClassConstraint(); $this->assertEquals('class', $constraint->getTargets()); } public function testGetTargetsCanBeArray() { - $constraint = new ConstraintA; + $constraint = new ConstraintA(); $this->assertEquals(array('property', 'class'), $constraint->getTargets()); } 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 d72eaf23fabd..36405e3de88e 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 @@ -14,6 +14,21 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; +class ComparisonTest_Class +{ + protected $value; + + public function __construct($value) + { + $this->value = $value; + } + + public function __toString() + { + return (string) $this->value; + } +} + /** * @author Daniel Holmes */ 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 4d248c13c840..cdcd49bb58ed 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 @@ -17,9 +17,9 @@ use Symfony\Component\Validator\Constraints\CallbackValidator; class CallbackValidatorTest_Class { - public static function validateStatic($object, ExecutionContext $context) + public static function validateCallback($object, ExecutionContext $context) { - $context->addViolation('Static message', array('{{ value }}' => 'foobar'), 'invalidValue'); + $context->addViolation('Callback message', array('{{ value }}' => 'foobar'), 'invalidValue'); return false; } @@ -27,16 +27,16 @@ class CallbackValidatorTest_Class class CallbackValidatorTest_Object { - public function validateOne(ExecutionContext $context) + public function validate(ExecutionContext $context) { $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); return false; } - public function validateTwo(ExecutionContext $context) + public static function validateStatic($object, ExecutionContext $context) { - $context->addViolation('Other message', array('{{ value }}' => 'baz'), 'otherInvalidValue'); + $context->addViolation('Static message', array('{{ value }}' => 'baz'), 'otherInvalidValue'); return false; } @@ -68,10 +68,10 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase $this->validator->validate(null, new Callback(array('foo'))); } - public function testCallbackSingleMethod() + public function testSingleMethod() { $object = new CallbackValidatorTest_Object(); - $constraint = new Callback(array('validateOne')); + $constraint = new Callback('validate'); $this->context->expects($this->once()) ->method('addViolation') @@ -82,24 +82,137 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase $this->validator->validate($object, $constraint); } - public function testCallbackSingleStaticMethod() + 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); + } + + 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); + } + + public function testClosure() + { + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(function ($object, ExecutionContext $context) { + $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); + + return false; + }); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('My message', array( '{{ value }}' => 'foobar', )); - $this->validator->validate($object, new Callback(array( - array(__CLASS__.'_Class', 'validateStatic') - ))); + $this->validator->validate($object, $constraint); } - public function testCallbackMultipleMethods() + public function testClosureExplicitName() { $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + 'callback' => function ($object, ExecutionContext $context) { + $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); + + return false; + }, + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('My message', array( + '{{ value }}' => 'foobar', + )); + + $this->validator->validate($object, $constraint); + } + + 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); + } + + public function testArrayCallableExplicitName() + { + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + 'callback' => array(__CLASS__.'_Class', 'validateCallback'), + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('Callback message', array( + '{{ value }}' => 'foobar', + )); + + $this->validator->validate($object, $constraint); + } + + // BC with Symfony < 2.4 + 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); + } + + // BC with Symfony < 2.4 + 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); + } + + // BC with Symfony < 2.4 + public function testMultipleMethodsBc() + { + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array('validate', 'validateStatic')); $this->context->expects($this->at(0)) ->method('addViolation') @@ -108,23 +221,67 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase )); $this->context->expects($this->at(1)) ->method('addViolation') - ->with('Other message', array( + ->with('Static message', array( '{{ value }}' => 'baz', )); - $this->validator->validate($object, new Callback(array( - 'validateOne', 'validateTwo' - ))); + $this->validator->validate($object, $constraint); } - /** - * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException - */ - public function testExpectCallbackArray() + // BC with Symfony < 2.4 + public function testMultipleMethodsBcExplicitName() { $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + 'methods' => array('validate', 'validateStatic'), + )); - $this->validator->validate($object, new Callback('foobar')); + $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); + } + + // BC with Symfony < 2.4 + public function testSingleStaticMethodBc() + { + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + array(__CLASS__.'_Class', 'validateCallback') + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('Callback message', array( + '{{ value }}' => 'foobar', + )); + + $this->validator->validate($object, $constraint); + } + + // BC with Symfony < 2.4 + public function testSingleStaticMethodBcExplicitName() + { + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + 'methods' => array(array(__CLASS__.'_Class', 'validateCallback')), + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('Callback message', array( + '{{ value }}' => 'foobar', + )); + + $this->validator->validate($object, $constraint); } /** @@ -147,10 +304,43 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase $this->validator->validate($object, new Callback(array(array('foo', 'bar')))); } + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + */ + public function testExpectEitherCallbackOrMethods() + { + $object = new CallbackValidatorTest_Object(); + + $this->validator->validate($object, new Callback(array( + 'callback' => 'validate', + 'methods' => array('validateStatic'), + ))); + } + public function testConstraintGetTargets() { $constraint = new Callback(array('foo')); $this->assertEquals('class', $constraint->getTargets()); } + + // Should succeed. Needed when defining constraints as annotations. + public function testNoConstructorArguments() + { + new Callback(); + } + + public function testAnnotationInvocationSingleValued() + { + $constraint = new Callback(array('value' => 'validateStatic')); + + $this->assertEquals(new Callback('validateStatic'), $constraint); + } + + public function testAnnotationInvocationMultiValued() + { + $constraint = new Callback(array('value' => array(__CLASS__.'_Class', 'validateCallback'))); + + $this->assertEquals(new Callback(array(__CLASS__.'_Class', 'validateCallback')), $constraint); + } } 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 c1618b6771c1..9267fdb87269 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 @@ -105,7 +105,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase public function testValidChoiceCallbackClosure() { - $constraint = new Choice(array('callback' => function() { + $constraint = new Choice(array('callback' => function () { return array('foo', 'bar'); })); 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 3eedaa32643f..95851e8097ad 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 @@ -104,4 +104,14 @@ class CountryValidatorTest extends \PHPUnit_Framework_TestCase array('EN'), ); } + + public function testValidateUsingCountrySpecificLocale() + { + \Locale::setDefault('en_GB'); + $existingCountry = 'GB'; + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($existingCountry, new Country()); + } } 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 d2e233ca3798..ea6c2eb43ac0 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 @@ -70,6 +70,18 @@ class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase $this->validator->validate($currency, new Currency()); } + /** + * @dataProvider getValidCurrencies + **/ + public function testValidCurrenciesWithCountrySpecificLocale($currency) + { + \Locale::setDefault('en_GB'); + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($currency, new Currency()); + } + public function getValidCurrencies() { return array( 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 b47d9e6750be..6f8abc101250 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,7 +13,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\EqualTo; use Symfony\Component\Validator\Constraints\EqualToValidator; -use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; /** * @author Daniel Holmes @@ -40,6 +39,7 @@ class EqualToValidatorTest extends AbstractComparisonValidatorTestCase array(3, '3'), array('a', 'a'), array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')), + array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)), array(null, 1), ); } @@ -52,7 +52,8 @@ class EqualToValidatorTest extends AbstractComparisonValidatorTestCase 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 \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'), ); } } 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 new file mode 100644 index 000000000000..b71138e5f6bb --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -0,0 +1,197 @@ + + * + * 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\PropertyAccess\PropertyAccess; +use Symfony\Component\Validator\Constraints\Expression; +use Symfony\Component\Validator\Constraints\ExpressionValidator; + +class ExpressionValidatorTest extends \PHPUnit_Framework_TestCase +{ + protected $context; + protected $validator; + + protected function setUp() + { + $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__)); + } + + protected function tearDown() + { + $this->context = null; + $this->validator = null; + } + + public function testNullIsValid() + { + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate(null, new Expression('value == 1')); + } + + public function testEmptyStringIsValid() + { + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate('', new Expression('value == 1')); + } + + public function testSucceedingExpressionAtObjectLevel() + { + $constraint = new Expression('this.property == 1'); + + $object = (object) array('property' => '1'); + + $this->context->expects($this->any()) + ->method('getPropertyName') + ->will($this->returnValue(null)); + + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate($object, $constraint); + } + + public function testFailingExpressionAtObjectLevel() + { + $constraint = new Expression(array( + 'expression' => 'this.property == 1', + 'message' => 'myMessage', + )); + + $object = (object) array('property' => '2'); + + $this->context->expects($this->any()) + ->method('getPropertyName') + ->will($this->returnValue(null)); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage'); + + $this->validator->validate($object, $constraint); + } + + public function testSucceedingExpressionAtPropertyLevel() + { + $constraint = new Expression('value == this.expected'); + + $object = (object) array('expected' => '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->validator->validate('1', $constraint); + } + + public function testFailingExpressionAtPropertyLevel() + { + $constraint = new Expression(array( + 'expression' => 'value == this.expected', + 'message' => 'myMessage', + )); + + $object = (object) array('expected' => '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->once()) + ->method('addViolation') + ->with('myMessage'); + + $this->validator->validate('2', $constraint); + } + + public function testSucceedingExpressionAtNestedPropertyLevel() + { + $constraint = new Expression('value == this.expected'); + + $object = (object) array('expected' => '1'); + $root = (object) array('nested' => $object); + + $this->context->expects($this->any()) + ->method('getPropertyName') + ->will($this->returnValue('property')); + + $this->context->expects($this->any()) + ->method('getPropertyPath') + ->will($this->returnValue('nested.property')); + + $this->context->expects($this->any()) + ->method('getRoot') + ->will($this->returnValue($root)); + + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->validate('1', $constraint); + } + + public function testFailingExpressionAtNestedPropertyLevel() + { + $constraint = new Expression(array( + 'expression' => 'value == this.expected', + 'message' => 'myMessage', + )); + + $object = (object) array('expected' => '1'); + $root = (object) array('nested' => $object); + + $this->context->expects($this->any()) + ->method('getPropertyName') + ->will($this->returnValue('property')); + + $this->context->expects($this->any()) + ->method('getPropertyPath') + ->will($this->returnValue('nested.property')); + + $this->context->expects($this->any()) + ->method('getRoot') + ->will($this->returnValue($root)); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage'); + + $this->validator->validate('2', $constraint); + } +} 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 0ca98067d324..0927aedacdd5 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 @@ -24,10 +24,6 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (!class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new FileValidator(); $this->validator->initialize($this->context); diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_landscape.gif b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_landscape.gif new file mode 100644 index 000000000000..870123532c3b Binary files /dev/null and b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_landscape.gif differ diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_portrait.gif b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_portrait.gif new file mode 100644 index 000000000000..cc480ca88ed7 Binary files /dev/null and b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_portrait.gif differ 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 72087fab83e3..1fc5311cf533 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 @@ -37,6 +37,7 @@ class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase return array( array(2, 1), array(new \DateTime('2005/01/01'), new \DateTime('2001/01/01')), + array(new ComparisonTest_Class(5), new ComparisonTest_Class(4)), array('333', '22'), array(null, 1), ); @@ -52,6 +53,8 @@ class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase 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') ); 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 cfd9f2cd8f43..fa3b0203b2e4 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 @@ -53,7 +53,6 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase public function getValidIbans() { return array( - array('CH93 0076 2011 6238 5295 7'), //Switzerland array('CH9300762011623852957'), // Switzerland without spaces //Country list @@ -182,6 +181,7 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase array('CY170020 128 0000 0012 0052 7600'), array('foo'), array('123'), + array('0750447346') ); } } 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 a1f6a69f4ac1..39234239c095 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,7 +13,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\IdenticalTo; use Symfony\Component\Validator\Constraints\IdenticalToValidator; -use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; /** * @author Daniel Holmes @@ -36,11 +35,13 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase public function provideValidComparisons() { $date = new \DateTime('2000-01-01'); + $object = new ComparisonTest_Class(2); return array( array(3, 3), array('a', 'a'), array($date, $date), + array($object, $object), array(null, 1), ); } @@ -55,7 +56,8 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase 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 \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'), ); } } 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 88545016243d..114c2d2f0499 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 @@ -20,6 +20,8 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase protected $validator; protected $path; protected $image; + protected $imageLandscape; + protected $imagePortrait; protected function setUp() { @@ -27,6 +29,8 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase $this->validator = new ImageValidator(); $this->validator->initialize($this->context); $this->image = __DIR__.'/Fixtures/test.gif'; + $this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif'; + $this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif'; } public function testNullIsValid() @@ -47,10 +51,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase public function testValidImage() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $this->context->expects($this->never()) ->method('addViolation'); @@ -59,10 +59,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase public function testValidSize() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $this->context->expects($this->never()) ->method('addViolation'); @@ -78,10 +74,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase public function testWidthTooSmall() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minWidth' => 3, 'minWidthMessage' => 'myMessage', @@ -99,10 +91,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase public function testWidthTooBig() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxWidth' => 1, 'maxWidthMessage' => 'myMessage', @@ -120,10 +108,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase public function testHeightTooSmall() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minHeight' => 3, 'minHeightMessage' => 'myMessage', @@ -141,10 +125,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase public function testHeightTooBig() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxHeight' => 1, 'maxHeightMessage' => 'myMessage', @@ -165,10 +145,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase */ public function testInvalidMinWidth() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minWidth' => '1abc', )); @@ -181,10 +157,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase */ public function testInvalidMaxWidth() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxWidth' => '1abc', )); @@ -197,10 +169,6 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase */ public function testInvalidMinHeight() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minHeight' => '1abc', )); @@ -213,14 +181,119 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase */ public function testInvalidMaxHeight() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxHeight' => '1abc', )); $this->validator->validate($this->image, $constraint); } + + public function testRatioTooSmall() + { + $constraint = new Image(array( + 'minRatio' => 2, + 'minRatioMessage' => 'myMessage', + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ ratio }}' => 1, + '{{ min_ratio }}' => 2, + )); + + $this->validator->validate($this->image, $constraint); + } + + public function testRatioTooBig() + { + $constraint = new Image(array( + 'maxRatio' => 0.5, + 'maxRatioMessage' => 'myMessage', + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ ratio }}' => 1, + '{{ max_ratio }}' => 0.5, + )); + + $this->validator->validate($this->image, $constraint); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + */ + public function testInvalidMinRatio() + { + $constraint = new Image(array( + 'minRatio' => '1abc', + )); + + $this->validator->validate($this->image, $constraint); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + */ + public function testInvalidMaxRatio() + { + $constraint = new Image(array( + 'maxRatio' => '1abc', + )); + + $this->validator->validate($this->image, $constraint); + } + + public function testSquareNotAllowed() + { + $constraint = new Image(array( + 'allowSquare' => false, + 'allowSquareMessage' => 'myMessage', + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ width }}' => 2, + '{{ height }}' => 2, + )); + + $this->validator->validate($this->image, $constraint); + } + + public function testLandscapeNotAllowed() + { + $constraint = new Image(array( + 'allowLandscape' => false, + 'allowLandscapeMessage' => 'myMessage', + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ width }}' => 2, + '{{ height }}' => 1, + )); + + $this->validator->validate($this->imageLandscape, $constraint); + } + + public function testPortraitNotAllowed() + { + $constraint = new Image(array( + 'allowPortrait' => false, + 'allowPortraitMessage' => 'myMessage', + )); + + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ width }}' => 1, + '{{ height }}' => 2, + )); + + $this->validator->validate($this->imagePortrait, $constraint); + } } 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 1230e3f322af..3588887d7499 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 @@ -104,4 +104,16 @@ class LanguageValidatorTest extends \PHPUnit_Framework_TestCase array('foobar'), ); } + + 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' + ))); + } } 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 406e222119e2..24ad0faf75b0 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 @@ -39,6 +39,8 @@ class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase array(1, 1), array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01')), array(new \DateTime('2000-01-01'), new \DateTime('2020-01-01')), + array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)), + array(new ComparisonTest_Class(5), new ComparisonTest_Class(5)), array('a', 'a'), array('a', 'z'), array(null, 1), @@ -53,6 +55,7 @@ class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase 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') ); } 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 f26269b3c23b..da7070e762e9 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 @@ -37,6 +37,7 @@ class LessThanValidatorTest extends AbstractComparisonValidatorTestCase return array( array(1, 2), array(new \DateTime('2000-01-01'), new \DateTime('2010-01-01')), + array(new ComparisonTest_Class(4), new ComparisonTest_Class(5)), array('22', '333'), array(null, 1), ); @@ -52,6 +53,8 @@ class LessThanValidatorTest extends AbstractComparisonValidatorTestCase 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') ); } 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 963710860b17..11c6a7cad529 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 @@ -103,7 +103,28 @@ class LuhnValidatorTest extends \PHPUnit_Framework_TestCase array('1234567812345678'), array('4222222222222222'), array('0000000000000000'), + ); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException + * @dataProvider getInvalidTypes + */ + public function testInvalidTypes($number) + { + $constraint = new Luhn(); + + $this->validator->validate($number, $constraint); + } + + public function getInvalidTypes() + { + return array( array(0), + array(123), + array(42424242424242424242), + array(378282246310005), + array(371449635398431), ); } } 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 0122643a7e86..dcf46a668d81 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,7 +13,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\NotEqualTo; use Symfony\Component\Validator\Constraints\NotEqualToValidator; -use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; /** * @author Daniel Holmes @@ -39,6 +38,7 @@ class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase array(1, 2), array('22', '333'), array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01')), + array(new ComparisonTest_Class(6), new ComparisonTest_Class(5)), array(null, 1), ); } @@ -52,7 +52,8 @@ class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase 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 \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'), ); } } 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 462202dd5a41..28026c08745c 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,7 +13,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\NotIdenticalTo; use Symfony\Component\Validator\Constraints\NotIdenticalToValidator; -use Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase; /** * @author Daniel Holmes @@ -51,11 +50,13 @@ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons() { $date = new \DateTime('2000-01-01'); + $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($date, $date, '2000-01-01 00:00:00', 'DateTime'), + array($object, $object, '2', __NAMESPACE__.'\ComparisonTest_Class'), ); } } 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 4466aa17c9df..d343c869fdf8 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 @@ -43,7 +43,7 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getInvalidValues */ - public function testInvalidValues($value) + public function testInvalidValues($value, $readableValue) { $constraint = new Null(array( 'message' => 'myMessage' @@ -52,7 +52,7 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $value, + '{{ value }}' => $readableValue, )); $this->validator->validate($value, $constraint); @@ -61,10 +61,13 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase public function getInvalidValues() { return array( - array(0), - array(false), - array(true), - array(''), + array(0, 0), + array(false, false), + array(true, true), + array('', ''), + array('foo bar', 'foo bar'), + array(new \DateTime(), 'DateTime'), + array(array(), 'Array'), ); } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php new file mode 100644 index 000000000000..0f6a2f4ae3d9 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php @@ -0,0 +1,24 @@ + + * + * 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\ExecutionContextInterface; + +/** + * @author Bernhard Schussek + */ +class CallbackClass +{ + public static function callback($object, ExecutionContextInterface $context) + { + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php new file mode 100644 index 000000000000..4ebd981eef92 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValue.php @@ -0,0 +1,31 @@ + + * + * 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\Constraint; + +/** @Annotation */ +class ConstraintWithValue extends Constraint +{ + public $property; + public $value; + + public function getDefaultOption() + { + return 'property'; + } + + public function getTargets() + { + return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); + } +} diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php new file mode 100644 index 000000000000..a975e0787fc9 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/ConstraintWithValueAsDefault.php @@ -0,0 +1,31 @@ + + * + * 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\Constraint; + +/** @Annotation */ +class ConstraintWithValueAsDefault extends Constraint +{ + public $property; + public $value; + + public function getDefaultOption() + { + return 'value'; + } + + public function getTargets() + { + return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); + } +} 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 e1cb3e04902c..70bdc5aec699 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 @@ -12,10 +12,12 @@ namespace Symfony\Component\Validator\Tests\Fixtures; use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\ExecutionContextInterface; /** * @Symfony\Component\Validator\Tests\Fixtures\ConstraintA * @Assert\GroupSequence({"Foo", "Entity"}) + * @Assert\Callback({"Symfony\Component\Validator\Tests\Fixtures\CallbackClass", "callback"}) */ class Entity extends EntityParent implements EntityInterface { @@ -58,4 +60,18 @@ class Entity extends EntityParent implements EntityInterface { return 'Overridden data'; } + + /** + * @Assert\Callback + */ + public function validateMe(ExecutionContextInterface $context) + { + } + + /** + * @Assert\Callback + */ + public static function validateMeStatic($object, ExecutionContextInterface $context) + { + } } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/BlackholeMetadataFactoryTest.php b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/BlackholeMetadataFactoryTest.php new file mode 100644 index 000000000000..74bcc69d7fb3 --- /dev/null +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/BlackholeMetadataFactoryTest.php @@ -0,0 +1,33 @@ + + * + * 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; + +use Symfony\Component\Validator\Mapping\BlackholeMetadataFactory; + +class BlackholeMetadataFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException \LogicException + */ + public function testGetMetadataForThrowsALogicException() + { + $metadataFactory = new BlackholeMetadataFactory(); + $metadataFactory->getMetadataFor('foo'); + } + + public function testHasMetadataForReturnsFalse() + { + $metadataFactory = new BlackholeMetadataFactory(); + + $this->assertFalse($metadataFactory->hasMetadataFor('foo')); + } +} 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 6f842cd6d1e7..bee4025d0d27 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 @@ -77,7 +77,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)); $cache->expects($this->once()) ->method('write') - ->will($this->returnCallback(function($metadata) use ($tester, $constraints) { + ->will($this->returnCallback(function ($metadata) use ($tester, $constraints) { $tester->assertEquals($constraints, $metadata->getConstraints()); })); 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/AbstractMethodStaticLoader.php index 3a1416cfc56e..7c6f362abb53 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/AbstractMethodStaticLoader.php @@ -7,4 +7,4 @@ use Symfony\Component\Validator\Mapping\ClassMetadata; abstract class AbstractMethodStaticLoader { abstract public static function loadMetadata(ClassMetadata $metadata); -} \ No newline at end of file +} 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 22a39c582e78..0d255b8fcad0 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 @@ -13,6 +13,7 @@ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use Doctrine\Common\Annotations\AnnotationReader; use Symfony\Component\Validator\Constraints\All; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; @@ -23,13 +24,6 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { - $this->markTestSkipped('The "Doctrine Common" library is not available'); - } - } - public function testLoadClassMetadataReturnsTrueIfSuccessful() { $reader = new AnnotationReader(); @@ -57,6 +51,9 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase $expected = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity'); $expected->setGroupSequence(array('Foo', 'Entity')); $expected->addConstraint(new ConstraintA()); + $expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback'))); + $expected->addConstraint(new Callback('validateMe')); + $expected->addConstraint(new Callback('validateMeStatic')); $expected->addPropertyConstraint('firstName', new NotNull()); $expected->addPropertyConstraint('firstName', new Range(array('min' => 3))); $expected->addPropertyConstraint('firstName', new All(array(new NotNull(), new Range(array('min' => 3))))); @@ -121,6 +118,9 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase $expected->setGroupSequence(array('Foo', 'Entity')); $expected->addConstraint(new ConstraintA()); + $expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback'))); + $expected->addConstraint(new Callback('validateMe')); + $expected->addConstraint(new Callback('validateMeStatic')); $expected->addPropertyConstraint('firstName', new NotNull()); $expected->addPropertyConstraint('firstName', new Range(array('min' => 3))); $expected->addPropertyConstraint('firstName', new All(array(new NotNull(), new Range(array('min' => 3))))); 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 7c6e355bd171..82195405e661 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 @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use Symfony\Component\Validator\Constraints\All; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; @@ -51,6 +52,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $expected->setGroupSequence(array('Foo', 'Entity')); $expected->addConstraint(new ConstraintA()); $expected->addConstraint(new ConstraintB()); + $expected->addConstraint(new Callback('validateMe')); + $expected->addConstraint(new Callback('validateMeStatic')); + $expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback'))); $expected->addPropertyConstraint('firstName', new NotNull()); $expected->addPropertyConstraint('firstName', new Range(array('min' => 3))); $expected->addPropertyConstraint('firstName', new Choice(array('A', 'B'))); 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 9e31cbb37d22..0d9a0b62c312 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 @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use Symfony\Component\Validator\Constraints\All; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; @@ -23,13 +24,6 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - if (!class_exists('Symfony\Component\Yaml\Yaml')) { - $this->markTestSkipped('The "Yaml" component is not available'); - } - } - public function testLoadClassMetadataReturnsFalseIfEmpty() { $loader = new YamlFileLoader(__DIR__.'/empty-mapping.yml'); @@ -75,6 +69,9 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $expected->setGroupSequence(array('Foo', 'Entity')); $expected->addConstraint(new ConstraintA()); $expected->addConstraint(new ConstraintB()); + $expected->addConstraint(new Callback('validateMe')); + $expected->addConstraint(new Callback('validateMeStatic')); + $expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback'))); $expected->addPropertyConstraint('firstName', new NotNull()); $expected->addPropertyConstraint('firstName', new Range(array('min' => 3))); $expected->addPropertyConstraint('firstName', new Choice(array('A', 'B'))); 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 dfac70d9cf6e..1eee1cb18036 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 @@ -21,6 +21,16 @@ + + validateMe + + validateMeStatic + + + Symfony\Component\Validator\Tests\Fixtures\CallbackClass + callback + + 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 38188dc5d976..e52d3f04b2ce 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 @@ -11,6 +11,10 @@ Symfony\Component\Validator\Tests\Fixtures\Entity: - Symfony\Component\Validator\Tests\Fixtures\ConstraintA: ~ # Custom constraint with namespaces prefix - "custom:ConstraintB": ~ + # Callbacks + - Callback: validateMe + - Callback: validateMeStatic + - Callback: [Symfony\Component\Validator\Tests\Fixtures\CallbackClass, callback] properties: firstName: 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 d48d6b1fe429..900243f31ad6 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -75,10 +75,6 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase public function testEnableAnnotationMapping() { - if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { - $this->markTestSkipped('Annotations is required for this test'); - } - $this->assertSame($this->builder, $this->builder->enableAnnotationMapping()); } diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php index a5bfc1fdf63c..e24a7071662e 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator; +use Symfony\Component\PropertyAccess\PropertyAccess; +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Validator\Mapping\ClassMetadataFactory; use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Mapping\Loader\LoaderChain; @@ -84,6 +86,11 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ private $translationDomain; + /** + * @var PropertyAccessorInterface + */ + private $propertyAccessor; + /** * {@inheritdoc} */ @@ -198,8 +205,8 @@ class ValidatorBuilder implements ValidatorBuilderInterface } if (null === $annotationReader) { - if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { - throw new \RuntimeException('Requested a ValidatorFactory with an AnnotationLoader, but the AnnotationReader was not found. You should add Doctrine Common to your project.'); + if (!class_exists('Doctrine\Common\Annotations\AnnotationReader') || !class_exists('Doctrine\Common\Cache\ArrayCache')) { + throw new \RuntimeException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and doctrine/cache to be installed.'); } $annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache()); @@ -253,6 +260,10 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory) { + if (null !== $this->propertyAccessor) { + throw new ValidatorException('You cannot set a validator factory after setting a custom property accessor. Remove the call to setPropertyAccessor() if you want to call setConstraintValidatorFactory().'); + } + $this->validatorFactory = $validatorFactory; return $this; @@ -278,6 +289,20 @@ class ValidatorBuilder implements ValidatorBuilderInterface return $this; } + /** + * {@inheritdoc} + */ + public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) + { + if (null !== $this->validatorFactory) { + throw new ValidatorException('You cannot set a property accessor after setting a custom validator factory. Configure your validator factory instead.'); + } + + $this->propertyAccessor = $propertyAccessor; + + return $this; + } + /** * {@inheritdoc} */ @@ -319,7 +344,8 @@ class ValidatorBuilder implements ValidatorBuilderInterface $metadataFactory = new ClassMetadataFactory($loader, $this->metadataCache); } - $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory(); + $propertyAccessor = $this->propertyAccessor ?: PropertyAccess::createPropertyAccessor(); + $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($propertyAccessor); $translator = $this->translator ?: new DefaultTranslator(); return new Validator($metadataFactory, $validatorFactory, $translator, $this->translationDomain, $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 99f367b6aa1a..92aaca756a3b 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator; +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; use Symfony\Component\Translation\TranslatorInterface; use Doctrine\Common\Annotations\Reader; @@ -159,6 +160,15 @@ interface ValidatorBuilderInterface */ public function setTranslationDomain($translationDomain); + /** + * Sets the property accessor for resolving property paths. + * + * @param PropertyAccessorInterface $propertyAccessor The property accessor. + * + * @return ValidatorBuilderInterface The builder object. + */ + public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor); + /** * 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 b56c5801f290..98e02d90cf4d 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorInterface.php +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/ValidatorInterface.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator; -use Symfony\Component\Validator\Constraint; - /** * Validates values and graphs of objects and arrays. * diff --git a/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json b/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json index 951ef01526e9..1b4b6a690782 100644 --- a/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json +++ b/core/vendor/symfony/validator/Symfony/Component/Validator/composer.json @@ -17,16 +17,20 @@ ], "require": { "php": ">=5.3.3", - "symfony/translation": "~2.0" + "symfony/translation": "~2.0", + "symfony/property-access": "~2.2" }, "require-dev": { "symfony/http-foundation": "~2.1", "symfony/intl": "~2.3", "symfony/yaml": "~2.0", - "symfony/config": "~2.2" + "symfony/config": "~2.2", + "doctrine/annotations": "~1.0", + "doctrine/cache": "~1.0" }, "suggest": { - "doctrine/common": "", + "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", + "doctrine/cache": "For using the default cached annotation reader", "symfony/http-foundation": "", "symfony/intl": "", "symfony/yaml": "", @@ -39,7 +43,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php index f77545db9563..3576e9ae6faa 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php @@ -2,6 +2,7 @@ /* * This file is part of the Symfony package. + * * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -71,7 +72,7 @@ class Escaper */ public static function requiresSingleQuoting($value) { - return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value); + return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $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 a27a005e6f55..938097b8b3e5 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php @@ -11,6 +11,11 @@ namespace Symfony\Component\Yaml\Exception; +if (!defined('JSON_UNESCAPED_UNICODE')) { + define('JSON_UNESCAPED_SLASHES', 64); + define('JSON_UNESCAPED_UNICODE', 256); +} + /** * Exception class thrown when an error occurs during parsing. * @@ -32,9 +37,9 @@ class ParseException extends RuntimeException * @param integer $parsedLine The line where the error occurred * @param integer $snippet The snippet of code near the problem * @param string $parsedFile The file name where the error occurred - * @param Exception $previous The previous exception + * @param \Exception $previous The previous exception */ - public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, Exception $previous = null) + public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null) { $this->parsedFile = $parsedFile; $this->parsedLine = $parsedLine; @@ -125,7 +130,7 @@ class ParseException extends RuntimeException } if (null !== $this->parsedFile) { - $this->message .= sprintf(' in %s', json_encode($this->parsedFile)); + $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } if ($this->parsedLine >= 0) { diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php index 45978a12554a..45efced3c89a 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php @@ -2,6 +2,7 @@ /* * This file is part of the Symfony package. + * * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php index d852cbf9bcf1..e8fe91848ebb 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php @@ -2,6 +2,7 @@ /* * This file is part of the Symfony package. + * * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md b/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md index 0864e49dca05..941a3460e317 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/README.md @@ -15,5 +15,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/Yaml/ - $ composer.phar install --dev + $ composer.phar install $ phpunit 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 5542b0dc6326..ac0efa88d1a1 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 @@ -56,7 +56,7 @@ test: Simple Mapping brief: | You can add a keyed list (also known as a dictionary or hash) to your document by placing each member of the - list on a new line, with a colon seperating the key + list on a new line, with a colon separating the key from its value. In YAML, this type of list is called a mapping. yaml: | diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml index 6f99f7545306..1e59f3bf9888 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml @@ -222,7 +222,7 @@ yaml: | # Following node labeled SS - &SS Sammy Sosa rbi: - - *SS # Subsequent occurance + - *SS # Subsequent occurrence - Ken Griffey php: | array( diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml index 9972c1f0d9d5..aac4e68077f6 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml @@ -226,11 +226,11 @@ brief: > time zone. yaml: | iso8601: 2001-12-14t21:59:43.10-05:00 - space seperated: 2001-12-14 21:59:43.10 -05:00 + space separated: 2001-12-14 21:59:43.10 -05:00 php: | array( 'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ), - 'space seperated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ) + 'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ) ) --- test: Date 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 a93b91612dca..dc497ca21c7c 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Yaml\Tests; -use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Inline; class InlineTest extends \PHPUnit_Framework_TestCase @@ -31,11 +30,11 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); } - foreach ($this->getTestsForParse() as $yaml => $value) { + foreach ($this->getTestsForParse() as $value) { $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } - foreach ($testsForDump as $yaml => $value) { + foreach ($testsForDump as $value) { $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } } @@ -197,7 +196,6 @@ class InlineTest extends \PHPUnit_Framework_TestCase '.Inf' => -log(0), '-.Inf' => log(0), "'686e444'" => '686e444', - '.Inf' => 646e444, '"foo\r\nbar"' => "foo\r\nbar", "'foo#bar'" => 'foo#bar', "'foo # bar'" => 'foo # bar', @@ -205,6 +203,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'', + "'-dash'" => '-dash', + "'-'" => '-', + // sequences '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12), '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'), diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php new file mode 100644 index 000000000000..289965e8d967 --- /dev/null +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Tests; + +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; + +class ParseExceptionTest extends \PHPUnit_Framework_TestCase +{ + public function testGetMessage() + { + $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml'); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; + } else { + $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")'; + } + + $this->assertEquals($message, $exception->getMessage()); + } +} diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php index 708f2a18f285..1b8eeed57a94 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php @@ -2,6 +2,7 @@ /* * This file is part of the Symfony package. + * * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE @@ -48,7 +49,7 @@ class Unescaper public function unescapeDoubleQuotedString($value) { $self = $this; - $callback = function($match) use ($self) { + $callback = function ($match) use ($self) { return $self->unescapeCharacter($match[0]); }; @@ -130,7 +131,7 @@ class Unescaper * * @return string The string with the new encoding * - * @throws RuntimeException if no suitable encoding function is found (iconv or mbstring) + * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) */ private function convertEncoding($value, $to, $from) { @@ -140,6 +141,6 @@ class Unescaper return iconv($from, $to, $value); } - throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); } } diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json b/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json index 1a009c16d6a2..33c298535449 100644 --- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } } }