Revert "Issue #2161397 by dawehner, Crell: Update to Symfony 2.4.1."
This caused a conflict in the language objectification patch. Postponing.
This reverts commit 9e017ada4f
.
8.0.x
parent
d179e77dff
commit
815faf7cfd
|
@ -10,15 +10,15 @@
|
|||
],
|
||||
"require": {
|
||||
"sdboyer/gliph": "0.1.*",
|
||||
"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.*",
|
||||
"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.*",
|
||||
"twig/twig": "1.12.*",
|
||||
"doctrine/common": "dev-bmaster#99b44f52a1b844f9c4c34e618b160664d5c27daf",
|
||||
"doctrine/annotations": "dev-master#463d926a8dcc49271cb7db5a08364a70ed6e3cd3",
|
||||
|
|
|
@ -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": "b3a05b2f0a069c6d34b65b604a216a92",
|
||||
"hash": "06006c1512fb829fcdb498b7e515901d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
@ -1225,17 +1225,17 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/class-loader",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/ClassLoader",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/ClassLoader.git",
|
||||
"reference": "6a2ebedbc780130f07b3a15363743d08eb46820c"
|
||||
"reference": "622d370a07321329f5259c6f96d5c636104ad46b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/6a2ebedbc780130f07b3a15363743d08eb46820c",
|
||||
"reference": "6a2ebedbc780130f07b3a15363743d08eb46820c",
|
||||
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/622d370a07321329f5259c6f96d5c636104ad46b",
|
||||
"reference": "622d370a07321329f5259c6f96d5c636104ad46b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1247,7 +1247,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1271,7 +1271,7 @@
|
|||
],
|
||||
"description": "Symfony ClassLoader Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-11-26 16:40:27"
|
||||
"time": "2013-08-13 20:18:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
|
@ -1331,17 +1331,17 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/dependency-injection",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/DependencyInjection",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/DependencyInjection.git",
|
||||
"reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c"
|
||||
"reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/7e5bde3a607dde1f8ddef5180759068ad53d259c",
|
||||
"reference": "7e5bde3a607dde1f8ddef5180759068ad53d259c",
|
||||
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/3678aa969e5bfeb8515a1f3047c63e8104723f5c",
|
||||
"reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1349,7 +1349,6 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "~2.2",
|
||||
"symfony/expression-language": "~2.4",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -1360,7 +1359,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1384,21 +1383,21 @@
|
|||
],
|
||||
"description": "Symfony DependencyInjection Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-01 09:02:49"
|
||||
"time": "2013-07-25 17:13:25"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/EventDispatcher",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||
"reference": "e3ba42f6a70554ed05749e61b829550f6ac33601"
|
||||
"reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601",
|
||||
"reference": "e3ba42f6a70554ed05749e61b829550f6ac33601",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/41c9826457c65fa3cf746f214985b7ca9cba42f8",
|
||||
"reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1414,7 +1413,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1438,21 +1437,21 @@
|
|||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-12-28 08:12:03"
|
||||
"time": "2013-07-21 12:12:18"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/HttpFoundation",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/HttpFoundation.git",
|
||||
"reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844"
|
||||
"reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844",
|
||||
"reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844",
|
||||
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/fdf130fe65457aedbc4639a22f4ef9d3be5c002c",
|
||||
"reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1461,7 +1460,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1488,21 +1487,21 @@
|
|||
],
|
||||
"description": "Symfony HttpFoundation Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-05 02:10:50"
|
||||
"time": "2013-08-26 05:49:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-kernel",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/HttpKernel",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/HttpKernel.git",
|
||||
"reference": "0605eedeb52c4d3a3144128d8336395a57be60d4"
|
||||
"reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4",
|
||||
"reference": "0605eedeb52c4d3a3144128d8336395a57be60d4",
|
||||
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/9d35da40f07bbe7a4f8dfbc41555d2b69de674bf",
|
||||
"reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1510,7 +1509,7 @@
|
|||
"psr/log": "~1.0",
|
||||
"symfony/debug": "~2.3",
|
||||
"symfony/event-dispatcher": "~2.1",
|
||||
"symfony/http-foundation": "~2.4"
|
||||
"symfony/http-foundation": "~2.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/browser-kit": "~2.2",
|
||||
|
@ -1535,7 +1534,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1559,7 +1558,7 @@
|
|||
],
|
||||
"description": "Symfony HttpKernel Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-05 02:12:11"
|
||||
"time": "2013-08-27 08:58:24"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
|
@ -1608,99 +1607,39 @@
|
|||
"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.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/Routing",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Routing.git",
|
||||
"reference": "4abfb500aab8be458c9e3a227ea56b190584f78a"
|
||||
"reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a",
|
||||
"reference": "4abfb500aab8be458c9e3a227ea56b190584f78a",
|
||||
"url": "https://api.github.com/repos/symfony/Routing/zipball/69af3f07dbf3ae93dd513dbc373f561cb2e7f143",
|
||||
"reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/annotations": "~1.0",
|
||||
"doctrine/common": "~2.2",
|
||||
"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"
|
||||
"doctrine/common": "",
|
||||
"symfony/config": "",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1724,27 +1663,21 @@
|
|||
],
|
||||
"description": "Symfony Routing Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"keywords": [
|
||||
"router",
|
||||
"routing",
|
||||
"uri",
|
||||
"url"
|
||||
],
|
||||
"time": "2014-01-05 02:10:50"
|
||||
"time": "2013-08-23 15:14:07"
|
||||
},
|
||||
{
|
||||
"name": "symfony/serializer",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/Serializer",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Serializer.git",
|
||||
"reference": "60c54346958604379392672a3a998650a169a7f4"
|
||||
"reference": "457ba76395955926a67ea692957b0872dead5278"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Serializer/zipball/60c54346958604379392672a3a998650a169a7f4",
|
||||
"reference": "60c54346958604379392672a3a998650a169a7f4",
|
||||
"url": "https://api.github.com/repos/symfony/Serializer/zipball/457ba76395955926a67ea692957b0872dead5278",
|
||||
"reference": "457ba76395955926a67ea692957b0872dead5278",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1753,7 +1686,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1777,7 +1710,7 @@
|
|||
],
|
||||
"description": "Symfony Serializer Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-01 08:14:50"
|
||||
"time": "2013-07-21 12:12:18"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
|
@ -1836,35 +1769,31 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/validator",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/Validator",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Validator.git",
|
||||
"reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730"
|
||||
"reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Validator/zipball/7ea4e53f8d68bf3ae9cca28765d49d7930618730",
|
||||
"reference": "7ea4e53f8d68bf3ae9cca28765d49d7930618730",
|
||||
"url": "https://api.github.com/repos/symfony/Validator/zipball/8f6f6be47fb8e1179cd225b1f949630e26221e42",
|
||||
"reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42",
|
||||
"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",
|
||||
"doctrine/common": "",
|
||||
"symfony/config": "",
|
||||
"symfony/http-foundation": "",
|
||||
"symfony/intl": "",
|
||||
|
@ -1873,7 +1802,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1897,21 +1826,21 @@
|
|||
],
|
||||
"description": "Symfony Validator Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-01 08:14:50"
|
||||
"time": "2013-08-24 15:26:22"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.4.1",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "4e1a237fc48145fae114b96458d799746ad89aa0"
|
||||
"reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/4e1a237fc48145fae114b96458d799746ad89aa0",
|
||||
"reference": "4e1a237fc48145fae114b96458d799746ad89aa0",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847",
|
||||
"reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1920,7 +1849,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1944,7 +1873,7 @@
|
|||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-12-28 08:12:03"
|
||||
"time": "2013-08-24 15:26:22"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
|
|
|
@ -143,7 +143,7 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa
|
|||
list( , $port) = explode(':', $normalized_base_url);
|
||||
$options['base_url'] .= ':' . $port;
|
||||
}
|
||||
elseif (($url_scheme == 'http' && $port != 80) || ($url_scheme == 'https' && $port != 443)) {
|
||||
elseif ($port != 80) {
|
||||
$options['base_url'] .= ':' . $port;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,9 +125,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
|
|||
// URLs as well.
|
||||
$index_php = strpos(url('', array('absolute' => TRUE)), 'index.php') !== FALSE;
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
$server = $request->server->all();
|
||||
$request = $this->prepareRequestForGenerator(TRUE, array('HTTP_HOST' => $server['HTTP_HOST'] . ':88'));
|
||||
$request = $this->prepareRequestForGenerator(TRUE, array('SERVER_PORT' => '88'));
|
||||
|
||||
// Create an absolute French link.
|
||||
$language = language_load('fr');
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099::getLoader();
|
||||
return ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721::getLoader();
|
||||
|
|
|
@ -15,7 +15,6 @@ 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'),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099
|
||||
class ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -19,9 +19,9 @@ class ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3a54ed71987dfc252758278dbd0c6099', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit50432d86c534be2ddddf85d27e021721', 'loadClassLoader'));
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname(dirname($vendorDir));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* deprecated the DebugClassLoader as it has been moved to the Debug component instead
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
|
|
|
@ -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(hash('sha256', implode('|', $classes)), 0, 5);
|
||||
$name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);
|
||||
}
|
||||
|
||||
$classes = array_unique($classes);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -22,8 +22,6 @@ namespace Symfony\Component\ClassLoader;
|
|||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the DebugClassLoader provided by the Debug component instead.
|
||||
*/
|
||||
class DebugClassLoader
|
||||
{
|
||||
|
@ -41,16 +39,6 @@ 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.
|
||||
*/
|
||||
|
|
|
@ -65,5 +65,5 @@ Resources
|
|||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/ClassLoader/
|
||||
$ composer.phar install
|
||||
$ composer.phar install --dev
|
||||
$ phpunit
|
||||
|
|
|
@ -189,7 +189,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testUnableToLoadClassException()
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
public function getLoadNonexistentClassTests()
|
||||
{
|
||||
return array(
|
||||
array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non existing Pearlike3_Bar class with a leading slash'),
|
||||
array('\\Pearlike3_Bar', '\\Pearlike3_Bar', '->loadClass() loads non exising Pearlike3_Bar class with a leading slash'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,10 @@ 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');
|
||||
|
||||
|
|
52
core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php
vendored
Normal file
52
core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/DebugClassLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\ClassLoader\Tests;
|
||||
|
||||
use Symfony\Component\ClassLoader\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');
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
"target-dir": "Symfony/Component/ClassLoader",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
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
|
||||
-----
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ class CheckCircularReferencesPass implements CompilerPassInterface
|
|||
{
|
||||
private $currentId;
|
||||
private $currentPath;
|
||||
private $checkedNodes;
|
||||
|
||||
/**
|
||||
* Checks the ContainerBuilder object for circular references.
|
||||
|
@ -39,7 +38,6 @@ class CheckCircularReferencesPass implements CompilerPassInterface
|
|||
{
|
||||
$graph = $container->getCompiler()->getServiceReferenceGraph();
|
||||
|
||||
$this->checkedNodes = array();
|
||||
foreach ($graph->getNodes() as $id => $node) {
|
||||
$this->currentId = $id;
|
||||
$this->currentPath = array($id);
|
||||
|
@ -60,20 +58,15 @@ class CheckCircularReferencesPass implements CompilerPassInterface
|
|||
foreach ($edges as $edge) {
|
||||
$node = $edge->getDestNode();
|
||||
$id = $node->getId();
|
||||
$searchKey = array_search($id, $this->currentPath);
|
||||
$this->currentPath[] = $id;
|
||||
|
||||
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);
|
||||
if (false !== $searchKey) {
|
||||
throw new ServiceCircularReferenceException($id, array_slice($this->currentPath, $searchKey));
|
||||
}
|
||||
|
||||
$this->checkOutEdges($node->getOutEdges());
|
||||
array_pop($this->currentPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,17 +74,6 @@ 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
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.
|
||||
|
@ -23,7 +24,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
class Compiler
|
||||
{
|
||||
private $passConfig;
|
||||
private $log = array();
|
||||
private $log;
|
||||
private $loggingFormatter;
|
||||
private $serviceReferenceGraph;
|
||||
|
||||
|
@ -35,6 +36,7 @@ class Compiler
|
|||
$this->passConfig = new PassConfig();
|
||||
$this->serviceReferenceGraph = new ServiceReferenceGraph();
|
||||
$this->loggingFormatter = new LoggingFormatter();
|
||||
$this->log = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,7 +117,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($definition->isPublic() || $definition->isLazy()) {
|
||||
if ($definition->isPublic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -125,10 +125,6 @@ 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();
|
||||
|
|
|
@ -31,9 +31,9 @@ class PassConfig
|
|||
const TYPE_REMOVE = 'removing';
|
||||
|
||||
private $mergePass;
|
||||
private $afterRemovingPasses = array();
|
||||
private $beforeOptimizationPasses = array();
|
||||
private $beforeRemovingPasses = array();
|
||||
private $afterRemovingPasses;
|
||||
private $beforeOptimizationPasses;
|
||||
private $beforeRemovingPasses;
|
||||
private $optimizationPasses;
|
||||
private $removingPasses;
|
||||
|
||||
|
@ -44,6 +44,10 @@ class PassConfig
|
|||
{
|
||||
$this->mergePass = new MergeExtensionConfigurationPass();
|
||||
|
||||
$this->afterRemovingPasses = array();
|
||||
$this->beforeOptimizationPasses = array();
|
||||
$this->beforeRemovingPasses = array();
|
||||
|
||||
$this->optimizationPasses = array(
|
||||
new ResolveDefinitionTemplatesPass(),
|
||||
new ResolveParameterPlaceHoldersPass(),
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,15 @@ class ServiceReferenceGraph
|
|||
/**
|
||||
* @var ServiceReferenceGraphNode[]
|
||||
*/
|
||||
private $nodes = array();
|
||||
private $nodes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->nodes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the graph has a specific node.
|
||||
|
|
|
@ -24,8 +24,8 @@ use Symfony\Component\DependencyInjection\Alias;
|
|||
class ServiceReferenceGraphNode
|
||||
{
|
||||
private $id;
|
||||
private $inEdges = array();
|
||||
private $outEdges = array();
|
||||
private $inEdges;
|
||||
private $outEdges;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,8 @@ class ServiceReferenceGraphNode
|
|||
{
|
||||
$this->id = $id;
|
||||
$this->value = $value;
|
||||
$this->inEdges = array();
|
||||
$this->outEdges = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,13 +67,13 @@ class Container implements IntrospectableContainerInterface
|
|||
*/
|
||||
protected $parameterBag;
|
||||
|
||||
protected $services = array();
|
||||
protected $methodMap = array();
|
||||
protected $aliases = array();
|
||||
protected $scopes = array();
|
||||
protected $scopeChildren = array();
|
||||
protected $scopedServices = array();
|
||||
protected $scopeStacks = array();
|
||||
protected $services;
|
||||
protected $methodMap;
|
||||
protected $aliases;
|
||||
protected $scopes;
|
||||
protected $scopeChildren;
|
||||
protected $scopedServices;
|
||||
protected $scopeStacks;
|
||||
protected $loading = array();
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,14 @@ class Container implements IntrospectableContainerInterface
|
|||
*/
|
||||
public function __construct(ParameterBagInterface $parameterBag = null)
|
||||
{
|
||||
$this->parameterBag = $parameterBag ?: new ParameterBag();
|
||||
$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->set('service_container', $this);
|
||||
}
|
||||
|
@ -207,7 +214,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();
|
||||
}
|
||||
|
||||
|
@ -233,10 +240,9 @@ class Container implements IntrospectableContainerInterface
|
|||
{
|
||||
$id = strtolower($id);
|
||||
|
||||
return isset($this->services[$id])
|
||||
|| array_key_exists($id, $this->services)
|
||||
|| isset($this->aliases[$id])
|
||||
|| method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_', '\\' => '_')).'Service')
|
||||
return array_key_exists($id, $this->services)
|
||||
|| array_key_exists($id, $this->aliases)
|
||||
|| method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -261,21 +267,16 @@ class Container implements IntrospectableContainerInterface
|
|||
*/
|
||||
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
|
||||
{
|
||||
// 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];
|
||||
}
|
||||
$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];
|
||||
}
|
||||
|
||||
if (isset($this->loading[$id])) {
|
||||
|
@ -284,7 +285,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) {
|
||||
|
@ -338,9 +339,7 @@ class Container implements IntrospectableContainerInterface
|
|||
*/
|
||||
public function initialized($id)
|
||||
{
|
||||
$id = strtolower($id);
|
||||
|
||||
return isset($this->services[$id]) || array_key_exists($id, $this->services);
|
||||
return array_key_exists(strtolower($id), $this->services);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -525,7 +524,7 @@ class Container implements IntrospectableContainerInterface
|
|||
*/
|
||||
public static function camelize($id)
|
||||
{
|
||||
return strtr(ucwords(strtr($id, array('_' => ' ', '.' => '_ ', '\\' => '_ '))), array(' ' => ''));
|
||||
return strtr(ucwords(strtr($id, array('_' => ' ', '.' => '_ '))), array(' ' => ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection;
|
||||
|
||||
/**
|
||||
* ContainerAware trait.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ 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.
|
||||
|
@ -79,11 +78,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
*/
|
||||
private $proxyInstantiator;
|
||||
|
||||
/**
|
||||
* @var ExpressionLanguage|null
|
||||
*/
|
||||
private $expressionLanguage;
|
||||
|
||||
/**
|
||||
* Sets the track resources flag.
|
||||
*
|
||||
|
@ -311,7 +305,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
*/
|
||||
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
|
||||
{
|
||||
$this->getCompiler()->addPass($pass, $type);
|
||||
if (null === $this->compiler) {
|
||||
$this->compiler = new Compiler();
|
||||
}
|
||||
|
||||
$this->compiler->addPass($pass, $type);
|
||||
|
||||
$this->addObjectResource($pass);
|
||||
|
||||
|
@ -327,7 +325,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
*/
|
||||
public function getCompilerPassConfig()
|
||||
{
|
||||
return $this->getCompiler()->getPassConfig();
|
||||
if (null === $this->compiler) {
|
||||
$this->compiler = new Compiler();
|
||||
}
|
||||
|
||||
return $this->compiler->getPassConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -608,17 +610,15 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
*/
|
||||
public function compile()
|
||||
{
|
||||
$compiler = $this->getCompiler();
|
||||
|
||||
if ($this->trackResources) {
|
||||
foreach ($compiler->getPassConfig()->getPasses() as $pass) {
|
||||
$this->addObjectResource($pass);
|
||||
}
|
||||
if (null === $this->compiler) {
|
||||
$this->compiler = new Compiler();
|
||||
}
|
||||
|
||||
$compiler->compile($this);
|
||||
|
||||
if ($this->trackResources) {
|
||||
foreach ($this->compiler->getPassConfig()->getPasses() as $pass) {
|
||||
$this->addObjectResource($pass);
|
||||
}
|
||||
|
||||
foreach ($this->definitions as $definition) {
|
||||
if ($definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) {
|
||||
$this->addClassResource(new \ReflectionClass($class));
|
||||
|
@ -626,6 +626,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
}
|
||||
}
|
||||
|
||||
$this->compiler->compile($this);
|
||||
|
||||
$this->extensionConfigs = array();
|
||||
|
||||
parent::compile();
|
||||
|
@ -991,12 +993,11 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Replaces service references by the real service instance and evaluates expressions.
|
||||
* Replaces service references by the real service instance.
|
||||
*
|
||||
* @param mixed $value A value
|
||||
*
|
||||
* @return mixed The same value with all service references replaced by
|
||||
* the real service instances and all expressions evaluated
|
||||
* @return mixed The same value with all service references replaced by the real service instances
|
||||
*/
|
||||
public function resolveServices($value)
|
||||
{
|
||||
|
@ -1008,8 +1009,6 @@ 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;
|
||||
|
@ -1160,16 +1159,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,24 +28,24 @@ class Definition
|
|||
private $factoryClass;
|
||||
private $factoryMethod;
|
||||
private $factoryService;
|
||||
private $scope = ContainerInterface::SCOPE_CONTAINER;
|
||||
private $properties = array();
|
||||
private $calls = array();
|
||||
private $scope;
|
||||
private $properties;
|
||||
private $calls;
|
||||
private $configurator;
|
||||
private $tags = array();
|
||||
private $public = true;
|
||||
private $synthetic = false;
|
||||
private $abstract = false;
|
||||
private $synchronized = false;
|
||||
private $lazy = false;
|
||||
private $tags;
|
||||
private $public;
|
||||
private $synthetic;
|
||||
private $abstract;
|
||||
private $synchronized;
|
||||
private $lazy;
|
||||
|
||||
protected $arguments;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|null $class The service class
|
||||
* @param array $arguments An array of arguments to pass to the service constructor
|
||||
* @param string $class The service class
|
||||
* @param array $arguments An array of arguments to pass to the service constructor
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -53,6 +53,15 @@ 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +84,7 @@ class Definition
|
|||
/**
|
||||
* Gets the factory class.
|
||||
*
|
||||
* @return string|null The factory class name
|
||||
* @return string The factory class name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -103,7 +112,7 @@ class Definition
|
|||
/**
|
||||
* Gets the factory method.
|
||||
*
|
||||
* @return string|null The factory method name
|
||||
* @return string The factory method name
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -131,7 +140,7 @@ class Definition
|
|||
/**
|
||||
* Gets the factory service id.
|
||||
*
|
||||
* @return string|null The factory service id
|
||||
* @return string The factory service id
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -159,7 +168,7 @@ class Definition
|
|||
/**
|
||||
* Gets the service class.
|
||||
*
|
||||
* @return string|null The service class
|
||||
* @return string The service class
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -499,7 +508,7 @@ class Definition
|
|||
/**
|
||||
* Gets the file to require before creating the service.
|
||||
*
|
||||
* @return string|null The full pathname to include
|
||||
* @return string The full pathname to include
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -695,7 +704,7 @@ class Definition
|
|||
/**
|
||||
* Gets the configurator to call after the service is fully initialized.
|
||||
*
|
||||
* @return callable|null The PHP callable to call
|
||||
* @return callable The PHP callable to call
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
|
|
@ -24,7 +24,7 @@ use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
|
|||
class DefinitionDecorator extends Definition
|
||||
{
|
||||
private $parent;
|
||||
private $changes = array();
|
||||
private $changes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -38,6 +38,7 @@ class DefinitionDecorator extends Definition
|
|||
parent::__construct();
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->changes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,8 +23,6 @@ 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.
|
||||
|
@ -53,7 +51,6 @@ class PhpDumper extends Dumper
|
|||
private $referenceVariables;
|
||||
private $variableCount;
|
||||
private $reservedVariables = array('instance', 'class');
|
||||
private $expressionLanguage;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
|
||||
|
@ -89,7 +86,6 @@ 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
|
||||
*
|
||||
|
@ -102,10 +98,9 @@ class PhpDumper extends Dumper
|
|||
$options = array_merge(array(
|
||||
'class' => 'ProjectServiceContainer',
|
||||
'base_class' => 'Container',
|
||||
'namespace' => '',
|
||||
), $options);
|
||||
|
||||
$code = $this->startClass($options['class'], $options['base_class'], $options['namespace']);
|
||||
$code = $this->startClass($options['class'], $options['base_class']);
|
||||
|
||||
if ($this->container->isFrozen()) {
|
||||
$code .= $this->addFrozenConstructor();
|
||||
|
@ -193,7 +188,7 @@ class PhpDumper extends Dumper
|
|||
*/
|
||||
private function addProxyClasses()
|
||||
{
|
||||
/* @var $definitions Definition[] */
|
||||
/* @var $proxyDefinitions Definition[] */
|
||||
$definitions = array_filter(
|
||||
$this->container->getDefinitions(),
|
||||
array($this->getProxyDumper(), 'isProxyCandidate')
|
||||
|
@ -446,12 +441,6 @@ 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);
|
||||
|
@ -711,24 +700,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, $namespace)
|
||||
private function startClass($class, $baseClass)
|
||||
{
|
||||
$bagClass = $this->container->isFrozen() ? 'use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;' : 'use Symfony\Component\DependencyInjection\ParameterBag\\ParameterBag;';
|
||||
$namespaceLine = $namespace ? "namespace $namespace;\n" : '';
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
$namespaceLine
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
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;
|
||||
$bagClass
|
||||
|
||||
/**
|
||||
|
@ -980,8 +969,6 @@ EOF;
|
|||
throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain service definitions. Definition for "%s" found in "%s".', $value->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);
|
||||
}
|
||||
|
@ -1118,7 +1105,7 @@ EOF;
|
|||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
private function hasReference($id, array $arguments, $deep = false, array $visited = array())
|
||||
private function hasReference($id, array $arguments, $deep = false, $visited = array())
|
||||
{
|
||||
foreach ($arguments as $argument) {
|
||||
if (is_array($argument)) {
|
||||
|
@ -1126,15 +1113,14 @@ EOF;
|
|||
return true;
|
||||
}
|
||||
} elseif ($argument instanceof Reference) {
|
||||
$argumentId = (string) $argument;
|
||||
if ($id === $argumentId) {
|
||||
if ($id === (string) $argument) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($deep && !isset($visited[$argumentId])) {
|
||||
$visited[$argumentId] = true;
|
||||
if ($deep && !isset($visited[(string) $argument])) {
|
||||
$visited[(string) $argument] = true;
|
||||
|
||||
$service = $this->container->getDefinition($argumentId);
|
||||
$service = $this->container->getDefinition((string) $argument);
|
||||
$arguments = array_merge($service->getMethodCalls(), $service->getArguments(), $service->getProperties());
|
||||
|
||||
if ($this->hasReference($id, $arguments, $deep, $visited)) {
|
||||
|
@ -1206,8 +1192,6 @@ 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)) {
|
||||
|
@ -1330,16 +1314,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ 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.
|
||||
|
@ -260,10 +259,6 @@ 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');
|
||||
|
|
|
@ -19,7 +19,6 @@ 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.
|
||||
|
@ -75,10 +74,6 @@ 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) {
|
||||
|
@ -236,8 +231,6 @@ 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.');
|
||||
}
|
||||
|
@ -274,11 +267,6 @@ class YamlDumper extends Dumper
|
|||
return sprintf('%%%s%%', $id);
|
||||
}
|
||||
|
||||
private function getExpressionCall($expression)
|
||||
{
|
||||
return sprintf('@=%s', $expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares parameters.
|
||||
*
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\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 <fabien@symfony.com>
|
||||
*/
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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 <ocramius@gmail.com>
|
||||
*/
|
||||
|
|
|
@ -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 within the file to change the container.
|
||||
* used form the file to change the container.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
|
|
|
@ -187,10 +187,6 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -237,11 +233,10 @@ 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
|
||||
$id = sprintf('%s_%d', hash('sha256', $file), ++$count);
|
||||
$node['id'] = $id;
|
||||
$node['id'] = sprintf('%s_%d', md5($file), ++$count);
|
||||
|
||||
$definitions[$id] = array($node->service, $file, false);
|
||||
$node->service['id'] = $id;
|
||||
$definitions[(string) $node['id']] = array($node->service, $file, false);
|
||||
$node->service['id'] = (string) $node['id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,11 +244,10 @@ class XmlFileLoader extends FileLoader
|
|||
if (false !== $nodes = $xml->xpath('//container:services/container:service[not(@id)]')) {
|
||||
foreach ($nodes as $node) {
|
||||
// give it a unique name
|
||||
$id = sprintf('%s_%d', hash('sha256', $file), ++$count);
|
||||
$node['id'] = $id;
|
||||
$node['id'] = sprintf('%s_%d', md5($file), ++$count);
|
||||
|
||||
$definitions[$id] = array($node, $file, true);
|
||||
$node->service['id'] = $id;
|
||||
$definitions[(string) $node['id']] = array($node, $file, true);
|
||||
$node->service['id'] = (string) $node['id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ 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.
|
||||
|
@ -225,8 +224,8 @@ class YamlFileLoader extends FileLoader
|
|||
unset($tag['name']);
|
||||
|
||||
foreach ($tag as $attribute => $value) {
|
||||
if (!is_scalar($value) && null !== $value) {
|
||||
throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s.', $id, $name, $attribute, $file));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,8 +311,6 @@ 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);
|
||||
|
|
|
@ -121,12 +121,10 @@
|
|||
|
||||
<xsd:complexType name="property" mixed="true">
|
||||
<xsd:choice minOccurs="0" maxOccurs="1">
|
||||
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="service" type="service" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="argument_type" />
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
<xsd:attribute name="key" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="on-invalid" type="xsd:string" />
|
||||
<xsd:attribute name="strict" type="boolean" />
|
||||
|
@ -166,7 +164,6 @@
|
|||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="collection" />
|
||||
<xsd:enumeration value="service" />
|
||||
<xsd:enumeration value="expression" />
|
||||
<xsd:enumeration value="string" />
|
||||
<xsd:enumeration value="constant" />
|
||||
</xsd:restriction>
|
||||
|
|
|
@ -24,8 +24,8 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
*/
|
||||
class ParameterBag implements ParameterBagInterface
|
||||
{
|
||||
protected $parameters = array();
|
||||
protected $resolved = false;
|
||||
protected $parameters;
|
||||
protected $resolved;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -36,7 +36,9 @@ class ParameterBag implements ParameterBagInterface
|
|||
*/
|
||||
public function __construct(array $parameters = array())
|
||||
{
|
||||
$this->parameters = array();
|
||||
$this->add($parameters);
|
||||
$this->resolved = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,5 +69,5 @@ Resources
|
|||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/DependencyInjection/
|
||||
$ composer.phar install
|
||||
$ composer.phar install --dev
|
||||
$ phpunit
|
||||
|
|
|
@ -47,7 +47,7 @@ class Reference
|
|||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->id;
|
||||
return (string) $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
namespace Symfony\Component\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
/**
|
||||
* SimpleXMLElement class.
|
||||
|
@ -22,7 +21,7 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
|||
class SimpleXMLElement extends \SimpleXMLElement
|
||||
{
|
||||
/**
|
||||
* Converts an attribute as a PHP type.
|
||||
* Converts an attribute as a php type.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
|
@ -34,7 +33,7 @@ class SimpleXMLElement extends \SimpleXMLElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns arguments as valid PHP types.
|
||||
* Returns arguments as valid php types.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Boolean $lowercase
|
||||
|
@ -78,9 +77,6 @@ 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;
|
||||
|
@ -99,7 +95,7 @@ class SimpleXMLElement extends \SimpleXMLElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts an xml value to a PHP type.
|
||||
* Converts an xml value to a php type.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
|
|
|
@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testProcessDetectsSyntheticNonPublicDefinitions()
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testProcessDetectsSyntheticPrototypeDefinitions()
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass()
|
||||
{
|
||||
|
@ -61,28 +61,6 @@ 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();
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
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;
|
||||
|
@ -124,41 +126,6 @@ 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()));
|
||||
|
|
|
@ -21,12 +21,10 @@ 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
|
||||
{
|
||||
|
@ -379,15 +377,6 @@ 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
|
||||
*/
|
||||
|
@ -397,7 +386,6 @@ 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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,6 +403,7 @@ 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');
|
||||
|
||||
|
@ -422,6 +411,7 @@ 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');
|
||||
|
||||
|
@ -449,7 +439,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::merge
|
||||
* @expectedException \LogicException
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testMergeLogicException()
|
||||
{
|
||||
|
@ -497,6 +487,10 @@ 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);
|
||||
|
@ -523,6 +517,10 @@ 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);
|
||||
|
@ -549,6 +547,10 @@ 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');
|
||||
|
@ -575,6 +577,10 @@ 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'));
|
||||
|
@ -649,7 +655,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
* @expectedException BadMethodCallException
|
||||
*/
|
||||
public function testThrowsExceptionWhenSetServiceOnAFrozenContainer()
|
||||
{
|
||||
|
@ -661,10 +667,14 @@ 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());
|
||||
|
@ -672,6 +682,10 @@ 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);
|
||||
|
@ -728,7 +742,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
* @expectedException BadMethodCallException
|
||||
*/
|
||||
public function testThrowsExceptionWhenSetDefinitionOnAFrozenContainer()
|
||||
{
|
||||
|
@ -759,39 +773,6 @@ 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 {}
|
||||
|
|
|
@ -51,7 +51,6 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
|||
array('.foo', '_Foo'),
|
||||
array('foo_', 'Foo'),
|
||||
array('foo.', 'Foo_'),
|
||||
array('foo\bar', 'Foo_Bar'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -188,7 +187,6 @@ 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()');
|
||||
|
@ -260,7 +258,6 @@ 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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,13 @@ 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/';
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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', 'namespace' => 'Symfony\Component\DependencyInjection\Dump')), '->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')), '->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,19 +181,4 @@ 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@ 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/');
|
||||
|
|
|
@ -6,7 +6,6 @@ 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->
|
||||
|
@ -16,7 +15,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'), 'qux' => array('%foo%' => 'foo is %foo%', 'foobar' => '%foo%')))->
|
||||
setProperties(array('foo' => 'bar', 'moo' => new Reference('foo.baz')))->
|
||||
addMethodCall('setBar', array(new Reference('bar')))->
|
||||
addMethodCall('initialize')->
|
||||
setConfigurator('sc_configure')
|
||||
|
@ -51,8 +50,7 @@ $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 Expression('service("foo").foo() ~ parameter("foo")')))
|
||||
addMethodCall('setBar', array(new Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
|
||||
;
|
||||
$container->
|
||||
register('factory_service', 'Bar')->
|
||||
|
|
|
@ -8,7 +8,6 @@ function sc_configure($instance)
|
|||
class BarClass
|
||||
{
|
||||
protected $baz;
|
||||
public $foo = 'foo';
|
||||
|
||||
public function setBaz(BazClass $baz)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -123,7 +125,6 @@ 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;
|
||||
|
@ -197,7 +198,6 @@ 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;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -131,7 +133,6 @@ 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;
|
||||
|
@ -202,7 +203,6 @@ class ProjectServiceContainer extends Container
|
|||
|
||||
$instance->setBar($this->get('foo'));
|
||||
$instance->setBar(NULL);
|
||||
$instance->setBar(($this->get("foo")->foo() . $this->getParameter("foo")));
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<services>
|
||||
<service id="foo" class="BarClass">
|
||||
<tag name="foo_tag"
|
||||
some-option="cat"
|
||||
some_option="ciz"
|
||||
other-option="lorem"
|
||||
an_other-option="ipsum"
|
||||
/>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
|
@ -27,6 +27,5 @@
|
|||
<parameter key="MixedCase" type="collection"> <!-- Should be lower cased -->
|
||||
<parameter key="MixedCaseKey">value</parameter> <!-- Should stay mixed case -->
|
||||
</parameter>
|
||||
<parameter key="constant" type="constant">PHP_EOL</parameter>
|
||||
</parameters>
|
||||
</container>
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
</service>
|
||||
<service id="method_call1" class="FooClass">
|
||||
<call method="setBar" />
|
||||
<call method="setBar">
|
||||
<argument type="expression">service("foo").foo() ~ parameter("foo")</argument>
|
||||
</call>
|
||||
</service>
|
||||
<service id="method_call2" class="FooClass">
|
||||
<call method="setBar">
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
<argument type="service" id="service_container"/>
|
||||
<property name="foo">bar</property>
|
||||
<property name="moo" type="service" id="foo.baz"/>
|
||||
<property name="qux" type="collection">
|
||||
<property key="%foo%">foo is %foo%</property>
|
||||
<property key="foobar">%foo%</property>
|
||||
</property>
|
||||
<call method="setBar">
|
||||
<argument type="service" id="bar"/>
|
||||
</call>
|
||||
|
@ -53,9 +49,6 @@
|
|||
<call method="setBar">
|
||||
<argument type="service" id="foobaz" on-invalid="ignore"/>
|
||||
</call>
|
||||
<call method="setBar">
|
||||
<argument type="expression">service("foo").foo() ~ parameter("foo")</argument>
|
||||
</call>
|
||||
</service>
|
||||
<service id="factory_service" class="Bar" factory-method="getInstance" factory-service="foo.baz"/>
|
||||
<service id="foo_with_inline" class="Foo">
|
||||
|
|
|
@ -3,4 +3,4 @@ services:
|
|||
class: FooClass
|
||||
tags:
|
||||
# tag-attribute is not a scalar
|
||||
- { name: foo, bar: { foo: foo, bar: bar } }
|
||||
- { name: foo, foo: { foo: foo, bar: bar } }
|
||||
|
|
|
@ -15,7 +15,6 @@ services:
|
|||
calls:
|
||||
- [ setBar, [] ]
|
||||
- [ setBar ]
|
||||
- [ setBar, ['@=service("foo").foo() ~ parameter("foo")'] ]
|
||||
method_call2:
|
||||
class: FooClass
|
||||
calls:
|
||||
|
|
|
@ -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', qux: { '%foo%': 'foo is %foo%', foobar: '%foo%' } }
|
||||
properties: { foo: bar, moo: '@foo.baz' }
|
||||
calls:
|
||||
- [setBar, ['@bar']]
|
||||
- [initialize, { }]
|
||||
|
@ -38,7 +38,6 @@ services:
|
|||
- [setBar, ['@?foo2']]
|
||||
- [setBar, ['@?foo3']]
|
||||
- [setBar, ['@?foobaz']]
|
||||
- [setBar, ['@=service("foo").foo() ~ parameter("foo")']]
|
||||
|
||||
factory_service:
|
||||
class: Bar
|
||||
|
@ -51,7 +50,6 @@ services:
|
|||
|
||||
inlined:
|
||||
class: Bar
|
||||
public: false
|
||||
properties: { pub: pub }
|
||||
calls:
|
||||
- [setBaz, ['@baz']]
|
||||
|
|
|
@ -16,6 +16,13 @@ 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
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,10 @@ 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'));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@ 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
|
||||
*/
|
||||
|
|
|
@ -22,12 +22,18 @@ 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/');
|
||||
|
@ -93,33 +99,17 @@ 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'),
|
||||
'constant' => PHP_EOL,
|
||||
);
|
||||
$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'));
|
||||
|
||||
$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')),
|
||||
|
@ -130,30 +120,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
$loader->load('services4.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'),
|
||||
'constant' => PHP_EOL,
|
||||
'bar' => '%foo%',
|
||||
'imported_from_ini' => true,
|
||||
'imported_from_yaml' => true
|
||||
);
|
||||
$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);
|
||||
|
||||
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');
|
||||
|
||||
|
@ -212,7 +179,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()), 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())), $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());
|
||||
|
@ -231,29 +198,6 @@ 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");
|
||||
|
|
|
@ -20,12 +20,22 @@ 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/');
|
||||
|
@ -114,7 +124,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()), array('setBar', array(new Expression('service("foo").foo() ~ parameter("foo")')))), $services['method_call1']->getMethodCalls(), '->load() parses the method_call tag');
|
||||
$this->assertEquals(array(array('setBar', array()), array('setBar', array())), $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());
|
||||
|
||||
|
@ -199,7 +209,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 "foo_service", tag "foo", attribute "bar"', $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 ', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"symfony/yaml": "~2.0",
|
||||
"symfony/config": "~2.2",
|
||||
"symfony/expression-language": "~2.4"
|
||||
"symfony/config": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/yaml": "",
|
||||
|
@ -35,7 +34,7 @@
|
|||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<services>
|
||||
<service id="foo" class="BarClass" />
|
||||
</services>
|
||||
</container>
|
|
@ -76,8 +76,6 @@ 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)
|
||||
|
@ -90,8 +88,6 @@ 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()
|
||||
|
@ -104,8 +100,6 @@ 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()
|
||||
|
@ -118,8 +112,6 @@ 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)
|
||||
|
|
|
@ -154,14 +154,14 @@ class EventDispatcher implements EventDispatcherInterface
|
|||
* This method can be overridden to add functionality that is executed
|
||||
* for each listener.
|
||||
*
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
protected function doDispatch($listeners, $eventName, Event $event)
|
||||
{
|
||||
foreach ($listeners as $listener) {
|
||||
call_user_func($listener, $event, $eventName, $this);
|
||||
call_user_func($listener, $event);
|
||||
if ($event->isPropagationStopped()) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Symfony\Component\EventDispatcher;
|
|||
class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Event subject.
|
||||
* Observer pattern subject.
|
||||
*
|
||||
* @var mixed usually object or callable
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
EventDispatcher Component
|
||||
=========================
|
||||
|
||||
The Symfony2 EventDispatcher component implements the Mediator pattern in a
|
||||
simple and effective way to make your projects truly extensible.
|
||||
EventDispatcher implements a lightweight version of the Observer design
|
||||
pattern.
|
||||
|
||||
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
|
||||
$ composer.phar install --dev
|
||||
$ phpunit
|
||||
|
|
|
@ -19,6 +19,13 @@ 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();
|
||||
|
|
|
@ -23,9 +23,6 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
const preBar = 'pre.bar';
|
||||
const postBar = 'post.bar';
|
||||
|
||||
/**
|
||||
* @var EventDispatcher
|
||||
*/
|
||||
private $dispatcher;
|
||||
|
||||
private $listener;
|
||||
|
@ -240,6 +237,7 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testEventReceivesTheDispatcherInstance()
|
||||
{
|
||||
$test = $this;
|
||||
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
|
||||
$dispatcher = $event->getDispatcher();
|
||||
});
|
||||
|
@ -247,17 +245,6 @@ 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
|
||||
*
|
||||
|
@ -270,7 +257,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'));
|
||||
}
|
||||
}
|
||||
|
@ -302,18 +289,6 @@ 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()
|
||||
|
|
|
@ -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->dispatcher = null;
|
||||
$this->eventDispatcher = null;
|
||||
}
|
||||
|
||||
public function testIsPropagationStopped()
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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,13 +54,7 @@ class BinaryFileResponse extends Response
|
|||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
|
||||
{
|
||||
|
@ -70,10 +64,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
|
||||
*
|
||||
|
@ -183,7 +177,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)) {
|
||||
|
@ -216,18 +210,14 @@ class BinaryFileResponse extends Response
|
|||
$start = (int) $start;
|
||||
}
|
||||
|
||||
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;
|
||||
$start = max($start, 0);
|
||||
$end = min($end, $fileSize - 1);
|
||||
|
||||
$this->setStatusCode(206);
|
||||
$this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize));
|
||||
$this->headers->set('Content-Length', $end - $start + 1);
|
||||
}
|
||||
}
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* added RequestStack
|
||||
* added Request::getEncodings()
|
||||
* added accessors methods to session handlers
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
|
||||
/**
|
||||
* ExpressionRequestMatcher uses an expression to match a Request.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -137,7 +137,7 @@ class File extends \SplFileInfo
|
|||
throw new FileException(sprintf('Unable to write in the "%s" directory', $directory));
|
||||
}
|
||||
|
||||
$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
|
||||
$target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
|
||||
|
||||
return new File($target, false);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ class UploadedFile extends File
|
|||
return $target;
|
||||
}
|
||||
|
||||
throw new FileException($this->getErrorMessage());
|
||||
throw new FileException($this->getErrorMessage($this->getError()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,37 +262,30 @@ class UploadedFile extends File
|
|||
*/
|
||||
public static function getMaxFilesize()
|
||||
{
|
||||
$iniMax = strtolower(ini_get('upload_max_filesize'));
|
||||
$max = strtolower(ini_get('upload_max_filesize'));
|
||||
|
||||
if ('' === $iniMax) {
|
||||
if ('' === $max) {
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
|
||||
$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);
|
||||
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]];
|
||||
}
|
||||
|
||||
switch (substr($iniMax, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
case 'g': $max *= 1024;
|
||||
case 'm': $max *= 1024;
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
return $max;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function getErrorMessage()
|
||||
private function getErrorMessage($errorCode)
|
||||
{
|
||||
static $errors = array(
|
||||
UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d kb).',
|
||||
|
@ -301,13 +294,12 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace Symfony\Component\HttpFoundation;
|
|||
*/
|
||||
class HeaderBag implements \IteratorAggregate, \Countable
|
||||
{
|
||||
protected $headers = array();
|
||||
protected $cacheControl = array();
|
||||
protected $headers;
|
||||
protected $cacheControl;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -32,6 +32,8 @@ 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);
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ class IpUtils
|
|||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets
|
||||
* Validates an IPv4 or IPv6 address.
|
||||
*
|
||||
* @param string $requestIp IP to check
|
||||
* @param string|array $ips List of IPs or subnets (can be a string if only a single one)
|
||||
* @param string $requestIp
|
||||
* @param string|array $ips
|
||||
*
|
||||
* @return boolean Whether the IP is valid
|
||||
*/
|
||||
|
@ -49,11 +49,10 @@ class IpUtils
|
|||
}
|
||||
|
||||
/**
|
||||
* Compares two IPv4 addresses.
|
||||
* In case a subnet is given, it checks if it contains the request IP.
|
||||
* Validates an IPv4 address.
|
||||
*
|
||||
* @param string $requestIp IPv4 address to check
|
||||
* @param string $ip IPv4 address or subnet in CIDR notation
|
||||
* @param string $requestIp
|
||||
* @param string $ip
|
||||
*
|
||||
* @return boolean Whether the IP is valid
|
||||
*/
|
||||
|
@ -74,14 +73,13 @@ class IpUtils
|
|||
}
|
||||
|
||||
/**
|
||||
* Compares two IPv6 addresses.
|
||||
* In case a subnet is given, it checks if it contains the request IP.
|
||||
* Validates an IPv6 address.
|
||||
*
|
||||
* @author David Soria Parra <dsp at php dot net>
|
||||
* @see https://github.com/dsp/v6tools
|
||||
*
|
||||
* @param string $requestIp IPv6 address to check
|
||||
* @param string $ip IPv6 address or subnet in CIDR notation
|
||||
* @param string $requestIp
|
||||
* @param string $ip
|
||||
*
|
||||
* @return boolean Whether the IP is valid
|
||||
*
|
||||
|
|
|
@ -55,11 +55,11 @@ class JsonResponse extends Response
|
|||
/**
|
||||
* Sets the JSONP callback.
|
||||
*
|
||||
* @param string|null $callback The JSONP callback or null to use none
|
||||
* @param string $callback
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* @throws \InvalidArgumentException When the callback name is not valid
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setCallback($callback = null)
|
||||
{
|
||||
|
@ -85,18 +85,12 @@ 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();
|
||||
}
|
||||
|
||||
|
@ -122,31 +116,4 @@ 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.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -44,5 +44,5 @@ Resources
|
|||
You can run the unit tests with the following command:
|
||||
|
||||
$ cd path/to/Symfony/Component/HttpFoundation/
|
||||
$ composer.phar install
|
||||
$ composer.phar install --dev
|
||||
$ phpunit
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -64,8 +64,6 @@ class Request
|
|||
protected static $httpMethodParameterOverride = false;
|
||||
|
||||
/**
|
||||
* Custom parameters
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
*
|
||||
* @api
|
||||
|
@ -73,8 +71,6 @@ class Request
|
|||
public $attributes;
|
||||
|
||||
/**
|
||||
* Request body parameters ($_POST)
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
*
|
||||
* @api
|
||||
|
@ -82,8 +78,6 @@ class Request
|
|||
public $request;
|
||||
|
||||
/**
|
||||
* Query string parameters ($_GET)
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
*
|
||||
* @api
|
||||
|
@ -91,8 +85,6 @@ class Request
|
|||
public $query;
|
||||
|
||||
/**
|
||||
* Server and execution environment parameters ($_SERVER)
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ServerBag
|
||||
*
|
||||
* @api
|
||||
|
@ -100,8 +92,6 @@ class Request
|
|||
public $server;
|
||||
|
||||
/**
|
||||
* Uploaded files ($_FILES)
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\FileBag
|
||||
*
|
||||
* @api
|
||||
|
@ -109,8 +99,6 @@ class Request
|
|||
public $files;
|
||||
|
||||
/**
|
||||
* Cookies ($_COOKIE)
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
*
|
||||
* @api
|
||||
|
@ -118,8 +106,6 @@ class Request
|
|||
public $cookies;
|
||||
|
||||
/**
|
||||
* Headers (taken from the $_SERVER)
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\HeaderBag
|
||||
*
|
||||
* @api
|
||||
|
@ -141,11 +127,6 @@ class Request
|
|||
*/
|
||||
protected $charsets;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $encodings;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -201,8 +182,6 @@ class Request
|
|||
*/
|
||||
protected static $formats;
|
||||
|
||||
protected static $requestFactory;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -249,7 +228,6 @@ class Request
|
|||
$this->content = $content;
|
||||
$this->languages = null;
|
||||
$this->charsets = null;
|
||||
$this->encodings = null;
|
||||
$this->acceptableContentTypes = null;
|
||||
$this->pathInfo = null;
|
||||
$this->requestUri = null;
|
||||
|
@ -268,7 +246,7 @@ class Request
|
|||
*/
|
||||
public static function createFromGlobals()
|
||||
{
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
|
||||
$request = new static($_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'))
|
||||
|
@ -368,39 +346,16 @@ class Request
|
|||
break;
|
||||
}
|
||||
|
||||
$queryString = '';
|
||||
if (isset($components['query'])) {
|
||||
parse_str(html_entity_decode($components['query']), $qs);
|
||||
|
||||
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, '', '&');
|
||||
$query = array_replace($qs, $query);
|
||||
}
|
||||
$queryString = http_build_query($query, '', '&');
|
||||
|
||||
$server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
|
||||
$server['QUERY_STRING'] = $queryString;
|
||||
|
||||
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;
|
||||
return new static($query, $request, array(), $cookies, $files, $server, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -441,7 +396,6 @@ class Request
|
|||
}
|
||||
$dup->languages = null;
|
||||
$dup->charsets = null;
|
||||
$dup->encodings = null;
|
||||
$dup->acceptableContentTypes = null;
|
||||
$dup->pathInfo = null;
|
||||
$dup->requestUri = null;
|
||||
|
@ -450,12 +404,8 @@ class Request
|
|||
$dup->method = null;
|
||||
$dup->format = null;
|
||||
|
||||
if (!$dup->get('_format') && $this->get('_format')) {
|
||||
$dup->attributes->set('_format', $this->get('_format'));
|
||||
}
|
||||
|
||||
if (!$dup->getRequestFormat(null)) {
|
||||
$dup->setRequestFormat($format = $this->getRequestFormat(null));
|
||||
if (!$dup->get('_format')) {
|
||||
$dup->setRequestFormat($this->getRequestFormat());
|
||||
}
|
||||
|
||||
return $dup;
|
||||
|
@ -517,7 +467,7 @@ class Request
|
|||
|
||||
$request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE);
|
||||
|
||||
$requestOrder = ini_get('request_order') ?: ini_get('variables_order');
|
||||
$requestOrder = ini_get('request_order') ?: ini_get('variable_order');
|
||||
$requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
|
||||
|
||||
$_REQUEST = array();
|
||||
|
@ -769,9 +719,9 @@ class Request
|
|||
/**
|
||||
* Returns the client IP addresses.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* Use this method carefully; you should use getClientIp() instead.
|
||||
*
|
||||
|
@ -792,18 +742,19 @@ class Request
|
|||
}
|
||||
|
||||
$clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP])));
|
||||
$clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from
|
||||
$clientIps[] = $ip;
|
||||
|
||||
$ip = $clientIps[0]; // Fallback to this when the client IP falls into the range of trusted proxies
|
||||
$trustedProxies = !self::$trustedProxies ? array($ip) : self::$trustedProxies;
|
||||
$ip = $clientIps[0];
|
||||
|
||||
// Eliminate all IPs from the forwarded IP chain which are trusted proxies
|
||||
foreach ($clientIps as $key => $clientIp) {
|
||||
if (IpUtils::checkIp($clientIp, self::$trustedProxies)) {
|
||||
if (IpUtils::checkIp($clientIp, $trustedProxies)) {
|
||||
unset($clientIps[$key]);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Now the IP chain contains only untrusted proxies and the client IP
|
||||
return $clientIps ? array_reverse($clientIps) : array($ip);
|
||||
}
|
||||
|
||||
|
@ -895,14 +846,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
|
||||
*/
|
||||
|
@ -954,14 +905,6 @@ 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');
|
||||
}
|
||||
|
||||
|
@ -996,7 +939,7 @@ class Request
|
|||
|
||||
$pass = $this->getPassword();
|
||||
if ('' != $pass) {
|
||||
$userinfo .= ":$pass";
|
||||
$userinfo .= ":$pass";
|
||||
}
|
||||
|
||||
return $userinfo;
|
||||
|
@ -1120,7 +1063,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(current(explode(',', $proto))), array('https', 'on', 'ssl', '1'));
|
||||
return in_array(strtolower($proto), array('https', 'on', '1'));
|
||||
}
|
||||
|
||||
return 'on' == strtolower($this->server->get('HTTPS')) || 1 == $this->server->get('HTTPS');
|
||||
|
@ -1162,7 +1105,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(sprintf('Invalid Host "%s"', $host));
|
||||
throw new \UnexpectedValueException('Invalid Host "'.$host.'"');
|
||||
}
|
||||
|
||||
if (count(self::$trustedHostPatterns) > 0) {
|
||||
|
@ -1180,7 +1123,7 @@ class Request
|
|||
}
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException(sprintf('Untrusted Host "%s"', $host));
|
||||
throw new \UnexpectedValueException('Untrusted Host "'.$host.'"');
|
||||
}
|
||||
|
||||
return $host;
|
||||
|
@ -1559,20 +1502,6 @@ 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
|
||||
*
|
||||
|
@ -1629,13 +1558,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));
|
||||
|
@ -1684,7 +1613,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?
|
||||
|
@ -1701,7 +1630,7 @@ class Request
|
|||
}
|
||||
|
||||
$truncatedRequestUri = $requestUri;
|
||||
if (false !== $pos = strpos($requestUri, '?')) {
|
||||
if (($pos = strpos($requestUri, '?')) !== false) {
|
||||
$truncatedRequestUri = substr($requestUri, 0, $pos);
|
||||
}
|
||||
|
||||
|
@ -1714,7 +1643,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));
|
||||
}
|
||||
|
||||
|
@ -1767,7 +1696,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) {
|
||||
|
@ -1836,19 +1765,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
/**
|
||||
* Request stack that controls the lifecycle of requests.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
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];
|
||||
}
|
||||
}
|
|
@ -20,67 +20,6 @@ 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
|
||||
*/
|
||||
|
@ -188,7 +127,7 @@ class Response
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $content The response content, see setContent()
|
||||
* @param string $content The response content
|
||||
* @param integer $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
*
|
||||
|
@ -215,7 +154,7 @@ class Response
|
|||
* return Response::create($body, 200)
|
||||
* ->setSharedMaxAge(300);
|
||||
*
|
||||
* @param mixed $content The response content, see setContent()
|
||||
* @param string $content The response content
|
||||
* @param integer $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
*
|
||||
|
@ -284,7 +223,7 @@ class Response
|
|||
$charset = $this->charset ?: 'UTF-8';
|
||||
if (!$headers->has('Content-Type')) {
|
||||
$headers->set('Content-Type', 'text/html; charset='.$charset);
|
||||
} elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) {
|
||||
} elseif (0 === strpos($headers->get('Content-Type'), 'text/') && false === strpos($headers->get('Content-Type'), 'charset')) {
|
||||
// add the charset
|
||||
$headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset);
|
||||
}
|
||||
|
@ -332,12 +271,12 @@ class Response
|
|||
}
|
||||
|
||||
// status
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText));
|
||||
|
||||
// headers
|
||||
foreach ($this->headers->allPreserveCase() as $name => $values) {
|
||||
foreach ($values as $value) {
|
||||
header($name.': '.$value, false, $this->statusCode);
|
||||
header($name.': '.$value, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,9 +342,9 @@ class Response
|
|||
/**
|
||||
* Sets the response content.
|
||||
*
|
||||
* Valid types are strings, numbers, null, and objects that implement a __toString() method.
|
||||
* Valid types are strings, numbers, and objects that implement a __toString() method.
|
||||
*
|
||||
* @param mixed $content Content that can be cast to string
|
||||
* @param mixed $content
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
|
@ -1242,7 +1181,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
|
||||
*/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue