Issue #2377281 by hussainweb: Upgrade to Symfony 2.6 stable
parent
596978a71d
commit
93c75faa37
|
@ -6,17 +6,17 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.5",
|
"php": ">=5.4.5",
|
||||||
"sdboyer/gliph": "0.1.*",
|
"sdboyer/gliph": "0.1.*",
|
||||||
"symfony/class-loader": "2.6.0-beta1",
|
"symfony/class-loader": "2.6.*",
|
||||||
"symfony/css-selector": "2.6.0-beta1",
|
"symfony/css-selector": "2.6.*",
|
||||||
"symfony/debug": "2.6.0-beta1",
|
"symfony/debug": "2.6.*",
|
||||||
"symfony/dependency-injection": "2.6.0-beta1",
|
"symfony/dependency-injection": "2.6.*",
|
||||||
"symfony/event-dispatcher": "2.6.0-beta1",
|
"symfony/event-dispatcher": "2.6.*",
|
||||||
"symfony/http-foundation": "2.6.0-beta1",
|
"symfony/http-foundation": "2.6.*",
|
||||||
"symfony/http-kernel": "2.6.0-beta1",
|
"symfony/http-kernel": "2.6.*",
|
||||||
"symfony/routing": "2.6.0-beta1",
|
"symfony/routing": "2.6.*",
|
||||||
"symfony/serializer": "2.6.0-beta1",
|
"symfony/serializer": "2.6.*",
|
||||||
"symfony/validator": "2.6.0-beta1",
|
"symfony/validator": "2.6.*",
|
||||||
"symfony/yaml": "2.6.0-beta1",
|
"symfony/yaml": "2.6.*",
|
||||||
"twig/twig": "1.16.*",
|
"twig/twig": "1.16.*",
|
||||||
"doctrine/common": "dev-master#a45d110f71c323e29f41eb0696fa230e3fa1b1b5",
|
"doctrine/common": "dev-master#a45d110f71c323e29f41eb0696fa230e3fa1b1b5",
|
||||||
"doctrine/annotations": "1.2.*",
|
"doctrine/annotations": "1.2.*",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "34a4f5a56891e51217c305b97e8cc675",
|
"hash": "fce47406c708047e654d8274620405e8",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/annotations",
|
"name": "doctrine/annotations",
|
||||||
|
@ -1643,17 +1643,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/class-loader",
|
"name": "symfony/class-loader",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/ClassLoader",
|
"target-dir": "Symfony/Component/ClassLoader",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/ClassLoader.git",
|
"url": "https://github.com/symfony/ClassLoader.git",
|
||||||
"reference": "d1a16139ea522ec3cc20801b7e19cd3cafd12d8c"
|
"reference": "b403af3d4fa3a2c3c926121c05042107e3a5b916"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/d1a16139ea522ec3cc20801b7e19cd3cafd12d8c",
|
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/b403af3d4fa3a2c3c926121c05042107e3a5b916",
|
||||||
"reference": "d1a16139ea522ec3cc20801b7e19cd3cafd12d8c",
|
"reference": "b403af3d4fa3a2c3c926121c05042107e3a5b916",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1689,11 +1689,11 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony ClassLoader Component",
|
"description": "Symfony ClassLoader Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-20 13:24:23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/css-selector",
|
"name": "symfony/css-selector",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/CssSelector",
|
"target-dir": "Symfony/Component/CssSelector",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -1744,17 +1744,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/debug",
|
"name": "symfony/debug",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/Debug",
|
"target-dir": "Symfony/Component/Debug",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Debug.git",
|
"url": "https://github.com/symfony/Debug.git",
|
||||||
"reference": "3548595c26175fdaca19cbec204668c22cda41f0"
|
"reference": "e1e27710efabc3f67a2d1f6710641b3bdca289d3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Debug/zipball/3548595c26175fdaca19cbec204668c22cda41f0",
|
"url": "https://api.github.com/repos/symfony/Debug/zipball/e1e27710efabc3f67a2d1f6710641b3bdca289d3",
|
||||||
"reference": "3548595c26175fdaca19cbec204668c22cda41f0",
|
"reference": "e1e27710efabc3f67a2d1f6710641b3bdca289d3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1796,21 +1796,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Debug Component",
|
"description": "Symfony Debug Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-10-28 10:06:58"
|
"time": "2014-11-28 10:00:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/dependency-injection",
|
"name": "symfony/dependency-injection",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/DependencyInjection",
|
"target-dir": "Symfony/Component/DependencyInjection",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/DependencyInjection.git",
|
"url": "https://github.com/symfony/DependencyInjection.git",
|
||||||
"reference": "926500fe0b8a6562c4e8b8166a1cb664733804aa"
|
"reference": "20bc8737876e4a2222101749b5547fd5acc24e30"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/926500fe0b8a6562c4e8b8166a1cb664733804aa",
|
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/20bc8737876e4a2222101749b5547fd5acc24e30",
|
||||||
"reference": "926500fe0b8a6562c4e8b8166a1cb664733804aa",
|
"reference": "20bc8737876e4a2222101749b5547fd5acc24e30",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1853,21 +1853,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony DependencyInjection Component",
|
"description": "Symfony DependencyInjection Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-28 10:00:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/event-dispatcher",
|
"name": "symfony/event-dispatcher",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/EventDispatcher",
|
"target-dir": "Symfony/Component/EventDispatcher",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||||
"reference": "dcf345d5ed96bc6c3b4521c1989670d2c9e5014e"
|
"reference": "697331d4ac78668cf6d21a2bb009b3faae92814f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/dcf345d5ed96bc6c3b4521c1989670d2c9e5014e",
|
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/697331d4ac78668cf6d21a2bb009b3faae92814f",
|
||||||
"reference": "dcf345d5ed96bc6c3b4521c1989670d2c9e5014e",
|
"reference": "697331d4ac78668cf6d21a2bb009b3faae92814f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1911,21 +1911,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony EventDispatcher Component",
|
"description": "Symfony EventDispatcher Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-28 10:00:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/http-foundation",
|
"name": "symfony/http-foundation",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/HttpFoundation",
|
"target-dir": "Symfony/Component/HttpFoundation",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/HttpFoundation.git",
|
"url": "https://github.com/symfony/HttpFoundation.git",
|
||||||
"reference": "4cd6c807598e560db7b3da50c4330fdb4808cfa1"
|
"reference": "bb46e43145184ce8c3069a8ea2c299fb53d432f9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/4cd6c807598e560db7b3da50c4330fdb4808cfa1",
|
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/bb46e43145184ce8c3069a8ea2c299fb53d432f9",
|
||||||
"reference": "4cd6c807598e560db7b3da50c4330fdb4808cfa1",
|
"reference": "bb46e43145184ce8c3069a8ea2c299fb53d432f9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1964,21 +1964,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony HttpFoundation Component",
|
"description": "Symfony HttpFoundation Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-28 10:00:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/http-kernel",
|
"name": "symfony/http-kernel",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/HttpKernel",
|
"target-dir": "Symfony/Component/HttpKernel",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/HttpKernel.git",
|
"url": "https://github.com/symfony/HttpKernel.git",
|
||||||
"reference": "7fa0bd9220cd529ee78d8565bbf8d5a854bd72d2"
|
"reference": "0e3cad4d574e84b01d2a0df706bb31f024a93bdc"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/7fa0bd9220cd529ee78d8565bbf8d5a854bd72d2",
|
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0e3cad4d574e84b01d2a0df706bb31f024a93bdc",
|
||||||
"reference": "7fa0bd9220cd529ee78d8565bbf8d5a854bd72d2",
|
"reference": "0e3cad4d574e84b01d2a0df706bb31f024a93bdc",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2039,21 +2039,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony HttpKernel Component",
|
"description": "Symfony HttpKernel Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 20:15:26"
|
"time": "2014-11-28 15:59:01"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/routing",
|
"name": "symfony/routing",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/Routing",
|
"target-dir": "Symfony/Component/Routing",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Routing.git",
|
"url": "https://github.com/symfony/Routing.git",
|
||||||
"reference": "f0bb6f818f9a7ece41c7dfe14e08b13c2de55b0c"
|
"reference": "5e2c6aba6cbb00a6b7e3760db99f72c85c52b6e5"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Routing/zipball/f0bb6f818f9a7ece41c7dfe14e08b13c2de55b0c",
|
"url": "https://api.github.com/repos/symfony/Routing/zipball/5e2c6aba6cbb00a6b7e3760db99f72c85c52b6e5",
|
||||||
"reference": "f0bb6f818f9a7ece41c7dfe14e08b13c2de55b0c",
|
"reference": "5e2c6aba6cbb00a6b7e3760db99f72c85c52b6e5",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2106,21 +2106,21 @@
|
||||||
"uri",
|
"uri",
|
||||||
"url"
|
"url"
|
||||||
],
|
],
|
||||||
"time": "2014-11-03 19:16:49"
|
"time": "2014-11-16 17:28:09"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/serializer",
|
"name": "symfony/serializer",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/Serializer",
|
"target-dir": "Symfony/Component/Serializer",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Serializer.git",
|
"url": "https://github.com/symfony/Serializer.git",
|
||||||
"reference": "e96b7ac54b3d75a458f76eab11b7cd2d757f09f1"
|
"reference": "16e548902fab42d26ceb1de5ca06ab676d1a81a7"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Serializer/zipball/e96b7ac54b3d75a458f76eab11b7cd2d757f09f1",
|
"url": "https://api.github.com/repos/symfony/Serializer/zipball/16e548902fab42d26ceb1de5ca06ab676d1a81a7",
|
||||||
"reference": "e96b7ac54b3d75a458f76eab11b7cd2d757f09f1",
|
"reference": "16e548902fab42d26ceb1de5ca06ab676d1a81a7",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2153,39 +2153,41 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Serializer Component",
|
"description": "Symfony Serializer Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-20 13:24:23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/translation",
|
"name": "symfony/translation",
|
||||||
"version": "v2.5.6",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/Translation",
|
"target-dir": "Symfony/Component/Translation",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Translation.git",
|
"url": "https://github.com/symfony/Translation.git",
|
||||||
"reference": "362fe4da2cfe587f72d57aaa2f89e6b61c05dedf"
|
"reference": "0a3711860976f15ee46642b4dd354e9ef9fc9a15"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/362fe4da2cfe587f72d57aaa2f89e6b61c05dedf",
|
"url": "https://api.github.com/repos/symfony/Translation/zipball/0a3711860976f15ee46642b4dd354e9ef9fc9a15",
|
||||||
"reference": "362fe4da2cfe587f72d57aaa2f89e6b61c05dedf",
|
"reference": "0a3711860976f15ee46642b4dd354e9ef9fc9a15",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.3"
|
"php": ">=5.3.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"psr/log": "~1.0",
|
||||||
"symfony/config": "~2.0",
|
"symfony/config": "~2.0",
|
||||||
"symfony/intl": "~2.3",
|
"symfony/intl": "~2.3",
|
||||||
"symfony/yaml": "~2.2"
|
"symfony/yaml": "~2.2"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
"psr/log": "To use logging capability in translator",
|
||||||
"symfony/config": "",
|
"symfony/config": "",
|
||||||
"symfony/yaml": ""
|
"symfony/yaml": ""
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.5-dev"
|
"dev-master": "2.6-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -2209,21 +2211,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Translation Component",
|
"description": "Symfony Translation Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-10-01 05:50:18"
|
"time": "2014-11-28 10:00:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/validator",
|
"name": "symfony/validator",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/Validator",
|
"target-dir": "Symfony/Component/Validator",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Validator.git",
|
"url": "https://github.com/symfony/Validator.git",
|
||||||
"reference": "6e521cdbc963cef7daf9931a7bde48b56d67d10a"
|
"reference": "cbf6575c4c9c83621df01483e215599f5377fc0b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Validator/zipball/6e521cdbc963cef7daf9931a7bde48b56d67d10a",
|
"url": "https://api.github.com/repos/symfony/Validator/zipball/cbf6575c4c9c83621df01483e215599f5377fc0b",
|
||||||
"reference": "6e521cdbc963cef7daf9931a7bde48b56d67d10a",
|
"reference": "cbf6575c4c9c83621df01483e215599f5377fc0b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2279,21 +2281,21 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Validator Component",
|
"description": "Symfony Validator Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-28 10:00:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/yaml",
|
"name": "symfony/yaml",
|
||||||
"version": "v2.6.0-BETA1",
|
"version": "v2.6.0",
|
||||||
"target-dir": "Symfony/Component/Yaml",
|
"target-dir": "Symfony/Component/Yaml",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Yaml.git",
|
"url": "https://github.com/symfony/Yaml.git",
|
||||||
"reference": "9da3813f36985a4089f7e83c601a1034d125ff69"
|
"reference": "51c845cf3e4bfc182d1d5c05ed1c7338361d86f8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/9da3813f36985a4089f7e83c601a1034d125ff69",
|
"url": "https://api.github.com/repos/symfony/Yaml/zipball/51c845cf3e4bfc182d1d5c05ed1c7338361d86f8",
|
||||||
"reference": "9da3813f36985a4089f7e83c601a1034d125ff69",
|
"reference": "51c845cf3e4bfc182d1d5c05ed1c7338361d86f8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2326,7 +2328,7 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Yaml Component",
|
"description": "Symfony Yaml Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2014-11-03 03:55:50"
|
"time": "2014-11-20 13:24:23"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
|
@ -2522,17 +2524,6 @@
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {
|
"stability-flags": {
|
||||||
"symfony/class-loader": 10,
|
|
||||||
"symfony/css-selector": 10,
|
|
||||||
"symfony/debug": 10,
|
|
||||||
"symfony/dependency-injection": 10,
|
|
||||||
"symfony/event-dispatcher": 10,
|
|
||||||
"symfony/http-foundation": 10,
|
|
||||||
"symfony/http-kernel": 10,
|
|
||||||
"symfony/routing": 10,
|
|
||||||
"symfony/serializer": 10,
|
|
||||||
"symfony/validator": 10,
|
|
||||||
"symfony/yaml": 10,
|
|
||||||
"doctrine/common": 20,
|
"doctrine/common": 20,
|
||||||
"phpunit/phpunit-mock-objects": 20
|
"phpunit/phpunit-mock-objects": 20
|
||||||
},
|
},
|
||||||
|
|
|
@ -56,7 +56,10 @@ class ClassLoader
|
||||||
|
|
||||||
public function getPrefixes()
|
public function getPrefixes()
|
||||||
{
|
{
|
||||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
if (!empty($this->prefixesPsr0)) {
|
||||||
|
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||||
|
}
|
||||||
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrefixesPsr4()
|
public function getPrefixesPsr4()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,8 +11,10 @@
|
||||||
|
|
||||||
namespace Symfony\Component\ClassLoader;
|
namespace Symfony\Component\ClassLoader;
|
||||||
|
|
||||||
if (!defined('T_TRAIT')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
define('T_TRAIT', 0);
|
define('SYMFONY_TRAIT', T_TRAIT);
|
||||||
|
} else {
|
||||||
|
define('SYMFONY_TRAIT', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +115,7 @@ class ClassMapGenerator
|
||||||
break;
|
break;
|
||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
case T_INTERFACE:
|
case T_INTERFACE:
|
||||||
case T_TRAIT:
|
case SYMFONY_TRAIT:
|
||||||
// Find the classname
|
// Find the classname
|
||||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||||
if (T_STRING === $t[0]) {
|
if (T_STRING === $t[0]) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testTraitDependencies()
|
public function testTraitDependencies()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Requires PHP > 5.4');
|
$this->markTestSkipped('Requires PHP > 5.4');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -100,7 +100,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testClassWithTraitsReordering(array $classes)
|
public function testClassWithTraitsReordering(array $classes)
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Requires PHP > 5.4');
|
$this->markTestSkipped('Requires PHP > 5.4');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -104,7 +104,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.4', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
|
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
|
||||||
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
|
|
|
@ -487,7 +487,6 @@ class ErrorHandler
|
||||||
public static function handleFatalError(array $error = null)
|
public static function handleFatalError(array $error = null)
|
||||||
{
|
{
|
||||||
self::$reservedMemory = '';
|
self::$reservedMemory = '';
|
||||||
gc_collect_cycles();
|
|
||||||
$handler = set_error_handler('var_dump', 0);
|
$handler = set_error_handler('var_dump', 0);
|
||||||
$handler = is_array($handler) ? $handler[0] : null;
|
$handler = is_array($handler) ? $handler[0] : null;
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
|
|
|
@ -15,10 +15,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Debug\Exception\FlattenException;
|
use Symfony\Component\Debug\Exception\FlattenException;
|
||||||
use Symfony\Component\Debug\Exception\OutOfMemoryException;
|
use Symfony\Component\Debug\Exception\OutOfMemoryException;
|
||||||
|
|
||||||
if (!defined('ENT_SUBSTITUTE')) {
|
|
||||||
define('ENT_SUBSTITUTE', 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExceptionHandler converts an exception to a Response object.
|
* ExceptionHandler converts an exception to a Response object.
|
||||||
*
|
*
|
||||||
|
@ -253,7 +249,7 @@ EOF
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// something nasty happened and we cannot throw an exception anymore
|
// something nasty happened and we cannot throw an exception anymore
|
||||||
if ($this->debug) {
|
if ($this->debug) {
|
||||||
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage());
|
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
|
||||||
} else {
|
} else {
|
||||||
$title = 'Whoops, looks like something went wrong.';
|
$title = 'Whoops, looks like something went wrong.';
|
||||||
}
|
}
|
||||||
|
@ -428,7 +424,7 @@ EOF;
|
||||||
$str = iconv($charset, 'UTF-8', $str);
|
$str = iconv($charset, 'UTF-8', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -162,21 +162,21 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
$handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL));
|
$handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL));
|
||||||
|
|
||||||
$loggers = array(
|
$loggers = array(
|
||||||
E_DEPRECATED => array(null, LogLevel::INFO),
|
E_DEPRECATED => array(null, LogLevel::INFO),
|
||||||
E_USER_DEPRECATED => array(null, LogLevel::INFO),
|
E_USER_DEPRECATED => array(null, LogLevel::INFO),
|
||||||
E_NOTICE => array($logger, LogLevel::NOTICE),
|
E_NOTICE => array($logger, LogLevel::NOTICE),
|
||||||
E_USER_NOTICE => array($logger, LogLevel::CRITICAL),
|
E_USER_NOTICE => array($logger, LogLevel::CRITICAL),
|
||||||
E_STRICT => array(null, LogLevel::NOTICE),
|
E_STRICT => array(null, LogLevel::NOTICE),
|
||||||
E_WARNING => array(null, LogLevel::WARNING),
|
E_WARNING => array(null, LogLevel::WARNING),
|
||||||
E_USER_WARNING => array(null, LogLevel::WARNING),
|
E_USER_WARNING => array(null, LogLevel::WARNING),
|
||||||
E_COMPILE_WARNING => array(null, LogLevel::WARNING),
|
E_COMPILE_WARNING => array(null, LogLevel::WARNING),
|
||||||
E_CORE_WARNING => array(null, LogLevel::WARNING),
|
E_CORE_WARNING => array(null, LogLevel::WARNING),
|
||||||
E_USER_ERROR => array(null, LogLevel::ERROR),
|
E_USER_ERROR => array(null, LogLevel::ERROR),
|
||||||
E_RECOVERABLE_ERROR => array(null, LogLevel::ERROR),
|
E_RECOVERABLE_ERROR => array(null, LogLevel::ERROR),
|
||||||
E_COMPILE_ERROR => array(null, LogLevel::EMERGENCY),
|
E_COMPILE_ERROR => array(null, LogLevel::EMERGENCY),
|
||||||
E_PARSE => array(null, LogLevel::EMERGENCY),
|
E_PARSE => array(null, LogLevel::EMERGENCY),
|
||||||
E_ERROR => array(null, LogLevel::EMERGENCY),
|
E_ERROR => array(null, LogLevel::EMERGENCY),
|
||||||
E_CORE_ERROR => array(null, LogLevel::EMERGENCY),
|
E_CORE_ERROR => array(null, LogLevel::EMERGENCY),
|
||||||
);
|
);
|
||||||
$this->assertSame($loggers, $handler->setLoggers(array()));
|
$this->assertSame($loggers, $handler->setLoggers(array()));
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,10 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
||||||
$this->processArguments($argument->getArguments());
|
$this->processArguments($argument->getArguments());
|
||||||
$this->processArguments($argument->getMethodCalls());
|
$this->processArguments($argument->getMethodCalls());
|
||||||
$this->processArguments($argument->getProperties());
|
$this->processArguments($argument->getProperties());
|
||||||
|
|
||||||
|
if ($argument->getFactoryService()) {
|
||||||
|
$this->processArguments(array(new Reference($argument->getFactoryService())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,10 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($ids) > 1 && $definition->getFactoryService()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $container->getDefinition(reset($ids))->getScope() === $definition->getScope();
|
return $container->getDefinition(reset($ids))->getScope() === $definition->getScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,6 +360,10 @@ class Container implements IntrospectableContainerInterface
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->aliases[$id])) {
|
||||||
|
$id = $this->aliases[$id];
|
||||||
|
}
|
||||||
|
|
||||||
return isset($this->services[$id]) || array_key_exists($id, $this->services);
|
return isset($this->services[$id]) || array_key_exists($id, $this->services);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,28 @@ class AnalyzeServiceReferencesPassTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertSame($ref, $refs[0]->getValue());
|
$this->assertSame($ref, $refs[0]->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessDetectsReferencesFromInlinedFactoryDefinitions()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$container
|
||||||
|
->register('a')
|
||||||
|
;
|
||||||
|
|
||||||
|
$factory = new Definition();
|
||||||
|
$factory->setFactoryService('a');
|
||||||
|
|
||||||
|
$container
|
||||||
|
->register('b')
|
||||||
|
->addArgument($factory)
|
||||||
|
;
|
||||||
|
|
||||||
|
$graph = $this->process($container);
|
||||||
|
|
||||||
|
$this->assertTrue($graph->hasNode('a'));
|
||||||
|
$this->assertCount(1, $refs = $graph->getNode('a')->getInEdges());
|
||||||
|
}
|
||||||
|
|
||||||
public function testProcessDoesNotSaveDuplicateReferences()
|
public function testProcessDoesNotSaveDuplicateReferences()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
|
@ -110,6 +110,84 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertSame($a, $inlinedArguments[0]);
|
$this->assertSame($a, $inlinedArguments[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessInlinesPrivateFactoryReference()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$container->register('a')->setPublic(false);
|
||||||
|
$b = $container
|
||||||
|
->register('b')
|
||||||
|
->setPublic(false)
|
||||||
|
->setFactoryService('a')
|
||||||
|
;
|
||||||
|
|
||||||
|
$container
|
||||||
|
->register('foo')
|
||||||
|
->setArguments(array(
|
||||||
|
$ref = new Reference('b'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$inlinedArguments = $container->getDefinition('foo')->getArguments();
|
||||||
|
$this->assertSame($b, $inlinedArguments[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testProcessDoesNotInlinePrivateFactoryIfReferencedMultipleTimesWithinTheSameDefinition()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container
|
||||||
|
->register('a')
|
||||||
|
;
|
||||||
|
$container
|
||||||
|
->register('b')
|
||||||
|
->setPublic(false)
|
||||||
|
->setFactoryService('a')
|
||||||
|
;
|
||||||
|
|
||||||
|
$container
|
||||||
|
->register('foo')
|
||||||
|
->setArguments(array(
|
||||||
|
$ref1 = new Reference('b'),
|
||||||
|
$ref2 = new Reference('b'),
|
||||||
|
))
|
||||||
|
;
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$args = $container->getDefinition('foo')->getArguments();
|
||||||
|
$this->assertSame($ref1, $args[0]);
|
||||||
|
$this->assertSame($ref2, $args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testProcessDoesNotInlineReferenceWhenUsedByInlineFactory()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container
|
||||||
|
->register('a')
|
||||||
|
;
|
||||||
|
$container
|
||||||
|
->register('b')
|
||||||
|
->setPublic(false)
|
||||||
|
->setFactoryService('a')
|
||||||
|
;
|
||||||
|
|
||||||
|
$inlineFactory = new Definition();
|
||||||
|
$inlineFactory->setPublic(false);
|
||||||
|
$inlineFactory->setFactoryService('b');
|
||||||
|
|
||||||
|
$container
|
||||||
|
->register('foo')
|
||||||
|
->setArguments(array(
|
||||||
|
$ref = new Reference('b'),
|
||||||
|
$inlineFactory,
|
||||||
|
))
|
||||||
|
;
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$args = $container->getDefinition('foo')->getArguments();
|
||||||
|
$this->assertSame($ref, $args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
public function testProcessInlinesOnlyIfSameScope()
|
public function testProcessInlinesOnlyIfSameScope()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
|
@ -305,6 +305,10 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
|
$this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded');
|
||||||
$this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded');
|
$this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded');
|
||||||
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
|
$this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded');
|
||||||
|
$this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
|
||||||
|
|
||||||
|
$sc->set('bar', new \stdClass());
|
||||||
|
$this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEnterLeaveCurrentScope()
|
public function testEnterLeaveCurrentScope()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
EventDispatcher Component
|
EventDispatcher Component
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
The Symfony2 EventDispatcher component implements the Mediator pattern in a
|
The Symfony EventDispatcher component implements the Mediator pattern in a
|
||||||
simple and effective way to make your projects truly extensible.
|
simple and effective way to make your projects truly extensible.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
|
|
@ -0,0 +1,369 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\EventDispatcher\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
|
abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/* Some pseudo events */
|
||||||
|
const preFoo = 'pre.foo';
|
||||||
|
const postFoo = 'post.foo';
|
||||||
|
const preBar = 'pre.bar';
|
||||||
|
const postBar = 'post.bar';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var EventDispatcher
|
||||||
|
*/
|
||||||
|
private $dispatcher;
|
||||||
|
|
||||||
|
private $listener;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->dispatcher = $this->createEventDispatcher();
|
||||||
|
$this->listener = new TestEventListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
$this->dispatcher = null;
|
||||||
|
$this->listener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function createEventDispatcher();
|
||||||
|
|
||||||
|
public function testInitialState()
|
||||||
|
{
|
||||||
|
$this->assertEquals(array(), $this->dispatcher->getListeners());
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddListener()
|
||||||
|
{
|
||||||
|
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
||||||
|
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
||||||
|
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
|
||||||
|
$this->assertCount(1, $this->dispatcher->getListeners(self::postFoo));
|
||||||
|
$this->assertCount(2, $this->dispatcher->getListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetListenersSortsByPriority()
|
||||||
|
{
|
||||||
|
$listener1 = new TestEventListener();
|
||||||
|
$listener2 = new TestEventListener();
|
||||||
|
$listener3 = new TestEventListener();
|
||||||
|
$listener1->name = '1';
|
||||||
|
$listener2->name = '2';
|
||||||
|
$listener3->name = '3';
|
||||||
|
|
||||||
|
$this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10);
|
||||||
|
$this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10);
|
||||||
|
$this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo'));
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
array($listener2, 'preFoo'),
|
||||||
|
array($listener3, 'preFoo'),
|
||||||
|
array($listener1, 'preFoo'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $this->dispatcher->getListeners('pre.foo'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetAllListenersSortsByPriority()
|
||||||
|
{
|
||||||
|
$listener1 = new TestEventListener();
|
||||||
|
$listener2 = new TestEventListener();
|
||||||
|
$listener3 = new TestEventListener();
|
||||||
|
$listener4 = new TestEventListener();
|
||||||
|
$listener5 = new TestEventListener();
|
||||||
|
$listener6 = new TestEventListener();
|
||||||
|
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener1, -10);
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener2);
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener3, 10);
|
||||||
|
$this->dispatcher->addListener('post.foo', $listener4, -10);
|
||||||
|
$this->dispatcher->addListener('post.foo', $listener5);
|
||||||
|
$this->dispatcher->addListener('post.foo', $listener6, 10);
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
'pre.foo' => array($listener3, $listener2, $listener1),
|
||||||
|
'post.foo' => array($listener6, $listener5, $listener4),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $this->dispatcher->getListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDispatch()
|
||||||
|
{
|
||||||
|
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
||||||
|
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
||||||
|
$this->dispatcher->dispatch(self::preFoo);
|
||||||
|
$this->assertTrue($this->listener->preFooInvoked);
|
||||||
|
$this->assertFalse($this->listener->postFooInvoked);
|
||||||
|
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent'));
|
||||||
|
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
|
||||||
|
$event = new Event();
|
||||||
|
$return = $this->dispatcher->dispatch(self::preFoo, $event);
|
||||||
|
$this->assertEquals('pre.foo', $event->getName());
|
||||||
|
$this->assertSame($event, $return);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDispatchForClosure()
|
||||||
|
{
|
||||||
|
$invoked = 0;
|
||||||
|
$listener = function () use (&$invoked) {
|
||||||
|
$invoked++;
|
||||||
|
};
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener);
|
||||||
|
$this->dispatcher->addListener('post.foo', $listener);
|
||||||
|
$this->dispatcher->dispatch(self::preFoo);
|
||||||
|
$this->assertEquals(1, $invoked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStopEventPropagation()
|
||||||
|
{
|
||||||
|
$otherListener = new TestEventListener();
|
||||||
|
|
||||||
|
// postFoo() stops the propagation, so only one listener should
|
||||||
|
// be executed
|
||||||
|
// Manually set priority to enforce $this->listener to be called first
|
||||||
|
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10);
|
||||||
|
$this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo'));
|
||||||
|
$this->dispatcher->dispatch(self::postFoo);
|
||||||
|
$this->assertTrue($this->listener->postFooInvoked);
|
||||||
|
$this->assertFalse($otherListener->postFooInvoked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDispatchByPriority()
|
||||||
|
{
|
||||||
|
$invoked = array();
|
||||||
|
$listener1 = function () use (&$invoked) {
|
||||||
|
$invoked[] = '1';
|
||||||
|
};
|
||||||
|
$listener2 = function () use (&$invoked) {
|
||||||
|
$invoked[] = '2';
|
||||||
|
};
|
||||||
|
$listener3 = function () use (&$invoked) {
|
||||||
|
$invoked[] = '3';
|
||||||
|
};
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener1, -10);
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener2);
|
||||||
|
$this->dispatcher->addListener('pre.foo', $listener3, 10);
|
||||||
|
$this->dispatcher->dispatch(self::preFoo);
|
||||||
|
$this->assertEquals(array('3', '2', '1'), $invoked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveListener()
|
||||||
|
{
|
||||||
|
$this->dispatcher->addListener('pre.bar', $this->listener);
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preBar));
|
||||||
|
$this->dispatcher->removeListener('pre.bar', $this->listener);
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::preBar));
|
||||||
|
$this->dispatcher->removeListener('notExists', $this->listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddSubscriber()
|
||||||
|
{
|
||||||
|
$eventSubscriber = new TestEventSubscriber();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddSubscriberWithPriorities()
|
||||||
|
{
|
||||||
|
$eventSubscriber = new TestEventSubscriber();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
|
||||||
|
$eventSubscriber = new TestEventSubscriberWithPriorities();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
|
||||||
|
$listeners = $this->dispatcher->getListeners('pre.foo');
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertCount(2, $listeners);
|
||||||
|
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddSubscriberWithMultipleListeners()
|
||||||
|
{
|
||||||
|
$eventSubscriber = new TestEventSubscriberWithMultipleListeners();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
|
||||||
|
$listeners = $this->dispatcher->getListeners('pre.foo');
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertCount(2, $listeners);
|
||||||
|
$this->assertEquals('preFoo2', $listeners[0][1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveSubscriber()
|
||||||
|
{
|
||||||
|
$eventSubscriber = new TestEventSubscriber();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
||||||
|
$this->dispatcher->removeSubscriber($eventSubscriber);
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveSubscriberWithPriorities()
|
||||||
|
{
|
||||||
|
$eventSubscriber = new TestEventSubscriberWithPriorities();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->dispatcher->removeSubscriber($eventSubscriber);
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveSubscriberWithMultipleListeners()
|
||||||
|
{
|
||||||
|
$eventSubscriber = new TestEventSubscriberWithMultipleListeners();
|
||||||
|
$this->dispatcher->addSubscriber($eventSubscriber);
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
$this->assertCount(2, $this->dispatcher->getListeners(self::preFoo));
|
||||||
|
$this->dispatcher->removeSubscriber($eventSubscriber);
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEventReceivesTheDispatcherInstance()
|
||||||
|
{
|
||||||
|
$dispatcher = null;
|
||||||
|
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
|
||||||
|
$dispatcher = $event->getDispatcher();
|
||||||
|
});
|
||||||
|
$this->dispatcher->dispatch('test');
|
||||||
|
$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
|
||||||
|
*
|
||||||
|
* This bug affects:
|
||||||
|
* - The PHP 5.3 branch for versions < 5.3.18
|
||||||
|
* - The PHP 5.4 branch for versions < 5.4.8
|
||||||
|
* - The PHP 5.5 branch is not affected
|
||||||
|
*/
|
||||||
|
public function testWorkaroundForPhpBug62976()
|
||||||
|
{
|
||||||
|
$dispatcher = $this->createEventDispatcher();
|
||||||
|
$dispatcher->addListener('bug.62976', new CallableClass());
|
||||||
|
$dispatcher->removeListener('bug.62976', function () {});
|
||||||
|
$this->assertTrue($dispatcher->hasListeners('bug.62976'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHasListenersWhenAddedCallbackListenerIsRemoved()
|
||||||
|
{
|
||||||
|
$listener = function () {};
|
||||||
|
$this->dispatcher->addListener('foo', $listener);
|
||||||
|
$this->dispatcher->removeListener('foo', $listener);
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetListenersWhenAddedCallbackListenerIsRemoved()
|
||||||
|
{
|
||||||
|
$listener = function () {};
|
||||||
|
$this->dispatcher->addListener('foo', $listener);
|
||||||
|
$this->dispatcher->removeListener('foo', $listener);
|
||||||
|
$this->assertSame(array(), $this->dispatcher->getListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners('foo'));
|
||||||
|
$this->assertFalse($this->dispatcher->hasListeners());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CallableClass
|
||||||
|
{
|
||||||
|
public function __invoke()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestEventListener
|
||||||
|
{
|
||||||
|
public $preFooInvoked = false;
|
||||||
|
public $postFooInvoked = false;
|
||||||
|
|
||||||
|
/* Listener methods */
|
||||||
|
|
||||||
|
public function preFoo(Event $e)
|
||||||
|
{
|
||||||
|
$this->preFooInvoked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postFoo(Event $e)
|
||||||
|
{
|
||||||
|
$this->postFooInvoked = true;
|
||||||
|
|
||||||
|
$e->stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestEventSubscriberWithPriorities implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'pre.foo' => array('preFoo', 10),
|
||||||
|
'post.foo' => array('postFoo'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array('pre.foo' => array(
|
||||||
|
array('preFoo1'),
|
||||||
|
array('preFoo2', 10),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,8 +17,14 @@ use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
||||||
{
|
{
|
||||||
|
protected function createEventDispatcher()
|
||||||
|
{
|
||||||
|
$container = new Container();
|
||||||
|
return new ContainerAwareEventDispatcher($container);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddAListenerService()
|
public function testAddAListenerService()
|
||||||
{
|
{
|
||||||
$event = new Event();
|
$event = new Event();
|
||||||
|
|
|
@ -11,358 +11,12 @@
|
||||||
|
|
||||||
namespace Symfony\Component\EventDispatcher\Tests;
|
namespace Symfony\Component\EventDispatcher\Tests;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
||||||
|
|
||||||
class EventDispatcherTest extends \PHPUnit_Framework_TestCase
|
class EventDispatcherTest extends AbstractEventDispatcherTest
|
||||||
{
|
{
|
||||||
/* Some pseudo events */
|
protected function createEventDispatcher()
|
||||||
const preFoo = 'pre.foo';
|
|
||||||
const postFoo = 'post.foo';
|
|
||||||
const preBar = 'pre.bar';
|
|
||||||
const postBar = 'post.bar';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EventDispatcher
|
|
||||||
*/
|
|
||||||
private $dispatcher;
|
|
||||||
|
|
||||||
private $listener;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->dispatcher = new EventDispatcher();
|
return new EventDispatcher();
|
||||||
$this->listener = new TestEventListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->dispatcher = null;
|
|
||||||
$this->listener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInitialState()
|
|
||||||
{
|
|
||||||
$this->assertEquals(array(), $this->dispatcher->getListeners());
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddListener()
|
|
||||||
{
|
|
||||||
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
|
||||||
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
|
||||||
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
|
|
||||||
$this->assertCount(1, $this->dispatcher->getListeners(self::postFoo));
|
|
||||||
$this->assertCount(2, $this->dispatcher->getListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetListenersSortsByPriority()
|
|
||||||
{
|
|
||||||
$listener1 = new TestEventListener();
|
|
||||||
$listener2 = new TestEventListener();
|
|
||||||
$listener3 = new TestEventListener();
|
|
||||||
$listener1->name = '1';
|
|
||||||
$listener2->name = '2';
|
|
||||||
$listener3->name = '3';
|
|
||||||
|
|
||||||
$this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10);
|
|
||||||
$this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10);
|
|
||||||
$this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo'));
|
|
||||||
|
|
||||||
$expected = array(
|
|
||||||
array($listener2, 'preFoo'),
|
|
||||||
array($listener3, 'preFoo'),
|
|
||||||
array($listener1, 'preFoo'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertSame($expected, $this->dispatcher->getListeners('pre.foo'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetAllListenersSortsByPriority()
|
|
||||||
{
|
|
||||||
$listener1 = new TestEventListener();
|
|
||||||
$listener2 = new TestEventListener();
|
|
||||||
$listener3 = new TestEventListener();
|
|
||||||
$listener4 = new TestEventListener();
|
|
||||||
$listener5 = new TestEventListener();
|
|
||||||
$listener6 = new TestEventListener();
|
|
||||||
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener1, -10);
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener2);
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener3, 10);
|
|
||||||
$this->dispatcher->addListener('post.foo', $listener4, -10);
|
|
||||||
$this->dispatcher->addListener('post.foo', $listener5);
|
|
||||||
$this->dispatcher->addListener('post.foo', $listener6, 10);
|
|
||||||
|
|
||||||
$expected = array(
|
|
||||||
'pre.foo' => array($listener3, $listener2, $listener1),
|
|
||||||
'post.foo' => array($listener6, $listener5, $listener4),
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertSame($expected, $this->dispatcher->getListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDispatch()
|
|
||||||
{
|
|
||||||
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
|
||||||
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
|
||||||
$this->dispatcher->dispatch(self::preFoo);
|
|
||||||
$this->assertTrue($this->listener->preFooInvoked);
|
|
||||||
$this->assertFalse($this->listener->postFooInvoked);
|
|
||||||
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent'));
|
|
||||||
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
|
|
||||||
$event = new Event();
|
|
||||||
$return = $this->dispatcher->dispatch(self::preFoo, $event);
|
|
||||||
$this->assertEquals('pre.foo', $event->getName());
|
|
||||||
$this->assertSame($event, $return);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDispatchForClosure()
|
|
||||||
{
|
|
||||||
$invoked = 0;
|
|
||||||
$listener = function () use (&$invoked) {
|
|
||||||
$invoked++;
|
|
||||||
};
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener);
|
|
||||||
$this->dispatcher->addListener('post.foo', $listener);
|
|
||||||
$this->dispatcher->dispatch(self::preFoo);
|
|
||||||
$this->assertEquals(1, $invoked);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStopEventPropagation()
|
|
||||||
{
|
|
||||||
$otherListener = new TestEventListener();
|
|
||||||
|
|
||||||
// postFoo() stops the propagation, so only one listener should
|
|
||||||
// be executed
|
|
||||||
// Manually set priority to enforce $this->listener to be called first
|
|
||||||
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10);
|
|
||||||
$this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo'));
|
|
||||||
$this->dispatcher->dispatch(self::postFoo);
|
|
||||||
$this->assertTrue($this->listener->postFooInvoked);
|
|
||||||
$this->assertFalse($otherListener->postFooInvoked);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDispatchByPriority()
|
|
||||||
{
|
|
||||||
$invoked = array();
|
|
||||||
$listener1 = function () use (&$invoked) {
|
|
||||||
$invoked[] = '1';
|
|
||||||
};
|
|
||||||
$listener2 = function () use (&$invoked) {
|
|
||||||
$invoked[] = '2';
|
|
||||||
};
|
|
||||||
$listener3 = function () use (&$invoked) {
|
|
||||||
$invoked[] = '3';
|
|
||||||
};
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener1, -10);
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener2);
|
|
||||||
$this->dispatcher->addListener('pre.foo', $listener3, 10);
|
|
||||||
$this->dispatcher->dispatch(self::preFoo);
|
|
||||||
$this->assertEquals(array('3', '2', '1'), $invoked);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveListener()
|
|
||||||
{
|
|
||||||
$this->dispatcher->addListener('pre.bar', $this->listener);
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preBar));
|
|
||||||
$this->dispatcher->removeListener('pre.bar', $this->listener);
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::preBar));
|
|
||||||
$this->dispatcher->removeListener('notExists', $this->listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddSubscriber()
|
|
||||||
{
|
|
||||||
$eventSubscriber = new TestEventSubscriber();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddSubscriberWithPriorities()
|
|
||||||
{
|
|
||||||
$eventSubscriber = new TestEventSubscriber();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
|
|
||||||
$eventSubscriber = new TestEventSubscriberWithPriorities();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
|
|
||||||
$listeners = $this->dispatcher->getListeners('pre.foo');
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertCount(2, $listeners);
|
|
||||||
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddSubscriberWithMultipleListeners()
|
|
||||||
{
|
|
||||||
$eventSubscriber = new TestEventSubscriberWithMultipleListeners();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
|
|
||||||
$listeners = $this->dispatcher->getListeners('pre.foo');
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertCount(2, $listeners);
|
|
||||||
$this->assertEquals('preFoo2', $listeners[0][1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveSubscriber()
|
|
||||||
{
|
|
||||||
$eventSubscriber = new TestEventSubscriber();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
|
||||||
$this->dispatcher->removeSubscriber($eventSubscriber);
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveSubscriberWithPriorities()
|
|
||||||
{
|
|
||||||
$eventSubscriber = new TestEventSubscriberWithPriorities();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->dispatcher->removeSubscriber($eventSubscriber);
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveSubscriberWithMultipleListeners()
|
|
||||||
{
|
|
||||||
$eventSubscriber = new TestEventSubscriberWithMultipleListeners();
|
|
||||||
$this->dispatcher->addSubscriber($eventSubscriber);
|
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
$this->assertCount(2, $this->dispatcher->getListeners(self::preFoo));
|
|
||||||
$this->dispatcher->removeSubscriber($eventSubscriber);
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEventReceivesTheDispatcherInstance()
|
|
||||||
{
|
|
||||||
$dispatcher = null;
|
|
||||||
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
|
|
||||||
$dispatcher = $event->getDispatcher();
|
|
||||||
});
|
|
||||||
$this->dispatcher->dispatch('test');
|
|
||||||
$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
|
|
||||||
*
|
|
||||||
* This bug affects:
|
|
||||||
* - The PHP 5.3 branch for versions < 5.3.18
|
|
||||||
* - The PHP 5.4 branch for versions < 5.4.8
|
|
||||||
* - The PHP 5.5 branch is not affected
|
|
||||||
*/
|
|
||||||
public function testWorkaroundForPhpBug62976()
|
|
||||||
{
|
|
||||||
$dispatcher = new EventDispatcher();
|
|
||||||
$dispatcher->addListener('bug.62976', new CallableClass());
|
|
||||||
$dispatcher->removeListener('bug.62976', function () {});
|
|
||||||
$this->assertTrue($dispatcher->hasListeners('bug.62976'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasListenersWhenAddedCallbackListenerIsRemoved()
|
|
||||||
{
|
|
||||||
$listener = function () {};
|
|
||||||
$this->dispatcher->addListener('foo', $listener);
|
|
||||||
$this->dispatcher->removeListener('foo', $listener);
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetListenersWhenAddedCallbackListenerIsRemoved()
|
|
||||||
{
|
|
||||||
$listener = function () {};
|
|
||||||
$this->dispatcher->addListener('foo', $listener);
|
|
||||||
$this->dispatcher->removeListener('foo', $listener);
|
|
||||||
$this->assertSame(array(), $this->dispatcher->getListeners());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled()
|
|
||||||
{
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners('foo'));
|
|
||||||
$this->assertFalse($this->dispatcher->hasListeners());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CallableClass
|
|
||||||
{
|
|
||||||
public function __invoke()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestEventListener
|
|
||||||
{
|
|
||||||
public $preFooInvoked = false;
|
|
||||||
public $postFooInvoked = false;
|
|
||||||
|
|
||||||
/* Listener methods */
|
|
||||||
|
|
||||||
public function preFoo(Event $e)
|
|
||||||
{
|
|
||||||
$this->preFooInvoked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postFoo(Event $e)
|
|
||||||
{
|
|
||||||
$this->postFooInvoked = true;
|
|
||||||
|
|
||||||
$e->stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestEventSubscriberWithPriorities implements EventSubscriberInterface
|
|
||||||
{
|
|
||||||
public static function getSubscribedEvents()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'pre.foo' => array('preFoo', 10),
|
|
||||||
'post.foo' => array('postFoo'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface
|
|
||||||
{
|
|
||||||
public static function getSubscribedEvents()
|
|
||||||
{
|
|
||||||
return array('pre.foo' => array(
|
|
||||||
array('preFoo1'),
|
|
||||||
array('preFoo2', 10),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,15 +35,15 @@ class Request
|
||||||
const HEADER_CLIENT_PROTO = 'client_proto';
|
const HEADER_CLIENT_PROTO = 'client_proto';
|
||||||
const HEADER_CLIENT_PORT = 'client_port';
|
const HEADER_CLIENT_PORT = 'client_port';
|
||||||
|
|
||||||
const METHOD_HEAD = 'HEAD';
|
const METHOD_HEAD = 'HEAD';
|
||||||
const METHOD_GET = 'GET';
|
const METHOD_GET = 'GET';
|
||||||
const METHOD_POST = 'POST';
|
const METHOD_POST = 'POST';
|
||||||
const METHOD_PUT = 'PUT';
|
const METHOD_PUT = 'PUT';
|
||||||
const METHOD_PATCH = 'PATCH';
|
const METHOD_PATCH = 'PATCH';
|
||||||
const METHOD_DELETE = 'DELETE';
|
const METHOD_DELETE = 'DELETE';
|
||||||
const METHOD_PURGE = 'PURGE';
|
const METHOD_PURGE = 'PURGE';
|
||||||
const METHOD_OPTIONS = 'OPTIONS';
|
const METHOD_OPTIONS = 'OPTIONS';
|
||||||
const METHOD_TRACE = 'TRACE';
|
const METHOD_TRACE = 'TRACE';
|
||||||
const METHOD_CONNECT = 'CONNECT';
|
const METHOD_CONNECT = 'CONNECT';
|
||||||
|
|
||||||
protected static $trustedProxies = array();
|
protected static $trustedProxies = array();
|
||||||
|
@ -726,7 +726,19 @@ class Request
|
||||||
*/
|
*/
|
||||||
public function get($key, $default = null, $deep = false)
|
public function get($key, $default = null, $deep = false)
|
||||||
{
|
{
|
||||||
return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default, $deep), $deep), $deep);
|
if ($this !== $result = $this->query->get($key, $this, $deep)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this !== $result = $this->attributes->get($key, $this, $deep)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this !== $result = $this->request->get($key, $this, $deep)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -379,7 +379,6 @@ class Response
|
||||||
fastcgi_finish_request();
|
fastcgi_finish_request();
|
||||||
} elseif ('cli' !== PHP_SAPI) {
|
} elseif ('cli' !== PHP_SAPI) {
|
||||||
static::closeOutputBuffers(0, true);
|
static::closeOutputBuffers(0, true);
|
||||||
flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||||
* @see http://php.net/sessionhandler
|
* @see http://php.net/sessionhandler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
class NativeSessionHandler extends \SessionHandler
|
class NativeSessionHandler extends \SessionHandler
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,17 +52,17 @@ class WriteCheckSessionHandler implements \SessionHandlerInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function gc($maxLifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
return $this->wrappedSessionHandler->gc($maxLifetime);
|
return $this->wrappedSessionHandler->gc($maxlifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function open($savePath, $sessionId)
|
public function open($savePath, $sessionName)
|
||||||
{
|
{
|
||||||
return $this->wrappedSessionHandler->open($savePath, $sessionId);
|
return $this->wrappedSessionHandler->open($savePath, $sessionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,12 +80,12 @@ class WriteCheckSessionHandler implements \SessionHandlerInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function write($sessionId, $sessionData)
|
public function write($sessionId, $data)
|
||||||
{
|
{
|
||||||
if (isset($this->readSessions[$sessionId]) && $sessionData === $this->readSessions[$sessionId]) {
|
if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->wrappedSessionHandler->write($sessionId, $sessionData);
|
return $this->wrappedSessionHandler->write($sessionId, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
|
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
|
||||||
ini_set('session.use_cookies', 1);
|
ini_set('session.use_cookies', 1);
|
||||||
|
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
session_register_shutdown();
|
session_register_shutdown();
|
||||||
} else {
|
} else {
|
||||||
register_shutdown_function('session_write_close');
|
register_shutdown_function('session_write_close');
|
||||||
|
@ -130,11 +130,11 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=') && \PHP_SESSION_ACTIVE === session_status()) {
|
if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) {
|
||||||
throw new \RuntimeException('Failed to start the session: already started by PHP.');
|
throw new \RuntimeException('Failed to start the session: already started by PHP.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(phpversion(), '5.4.0', '<') && isset($_SESSION) && session_id()) {
|
if (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id()) {
|
||||||
// not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3
|
// not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3
|
||||||
throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
|
throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
|
||||||
}
|
}
|
||||||
|
@ -366,13 +366,13 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
||||||
$saveHandler = new SessionHandlerProxy($saveHandler);
|
$saveHandler = new SessionHandlerProxy($saveHandler);
|
||||||
} elseif (!$saveHandler instanceof AbstractProxy) {
|
} elseif (!$saveHandler instanceof AbstractProxy) {
|
||||||
$saveHandler = version_compare(phpversion(), '5.4.0', '>=') ?
|
$saveHandler = PHP_VERSION_ID >= 50400 ?
|
||||||
new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy();
|
new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy();
|
||||||
}
|
}
|
||||||
$this->saveHandler = $saveHandler;
|
$this->saveHandler = $saveHandler;
|
||||||
|
|
||||||
if ($this->saveHandler instanceof \SessionHandlerInterface) {
|
if ($this->saveHandler instanceof \SessionHandlerInterface) {
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
session_set_save_handler($this->saveHandler, false);
|
session_set_save_handler($this->saveHandler, false);
|
||||||
} else {
|
} else {
|
||||||
session_set_save_handler(
|
session_set_save_handler(
|
||||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
|
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows session to be started by PHP and managed by Symfony2
|
* Allows session to be started by PHP and managed by Symfony
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,7 +72,7 @@ abstract class AbstractProxy
|
||||||
*/
|
*/
|
||||||
public function isActive()
|
public function isActive()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
return $this->active = \PHP_SESSION_ACTIVE === session_status();
|
return $this->active = \PHP_SESSION_ACTIVE === session_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ abstract class AbstractProxy
|
||||||
*/
|
*/
|
||||||
public function setActive($flag)
|
public function setActive($flag)
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
throw new \LogicException('This method is disabled in PHP 5.4.0+');
|
throw new \LogicException('This method is disabled in PHP 5.4.0+');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
||||||
return array(
|
return array(
|
||||||
array('foo', 'bar', array('foo' => 'bar')),
|
array('foo', 'bar', array('foo' => 'bar')),
|
||||||
array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')),
|
array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')),
|
||||||
array('great', 'symfony2 is great', array('great' => 'symfony2 is great')),
|
array('great', 'symfony is great', array('great' => 'symfony is great')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetIterator()
|
public function testGetIterator()
|
||||||
{
|
{
|
||||||
$attributes = array('hello' => 'world', 'symfony2' => 'rocks');
|
$attributes = array('hello' => 'world', 'symfony' => 'rocks');
|
||||||
foreach ($attributes as $key => $val) {
|
foreach ($attributes as $key => $val) {
|
||||||
$this->session->set($key, $val);
|
$this->session->set($key, $val);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGetCount()
|
public function testGetCount()
|
||||||
{
|
{
|
||||||
$this->session->set('hello', 'world');
|
$this->session->set('hello', 'world');
|
||||||
$this->session->set('symfony2', 'rocks');
|
$this->session->set('symfony', 'rocks');
|
||||||
|
|
||||||
$this->assertCount(2, $this->session);
|
$this->assertCount(2, $this->session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testWriteWhenUsingExpiresField()
|
public function testWriteWhenUsingExpiresField()
|
||||||
{
|
{
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
'id_field' => '_id',
|
'id_field' => '_id',
|
||||||
'data_field' => 'data',
|
'data_field' => 'data',
|
||||||
'time_field' => 'time',
|
'time_field' => 'time',
|
||||||
'database' => 'sf2-test',
|
'database' => 'sf2-test',
|
||||||
|
@ -202,7 +202,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGcWhenUsingExpiresField()
|
public function testGcWhenUsingExpiresField()
|
||||||
{
|
{
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
'id_field' => '_id',
|
'id_field' => '_id',
|
||||||
'data_field' => 'data',
|
'data_field' => 'data',
|
||||||
'time_field' => 'time',
|
'time_field' => 'time',
|
||||||
'database' => 'sf2-test',
|
'database' => 'sf2-test',
|
||||||
|
|
|
@ -27,7 +27,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
|
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
|
||||||
|
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName());
|
$this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName());
|
||||||
$this->assertEquals('files', ini_get('session.save_handler'));
|
$this->assertEquals('files', ini_get('session.save_handler'));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,7 +28,7 @@ class NativeSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
// note for PHPUnit optimisers - the use of assertTrue/False
|
// note for PHPUnit optimisers - the use of assertTrue/False
|
||||||
// here is deliberate since the tests do not require the classes to exist - drak
|
// here is deliberate since the tests do not require the classes to exist - drak
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->assertFalse($handler instanceof \SessionHandler);
|
$this->assertFalse($handler instanceof \SessionHandler);
|
||||||
$this->assertTrue($handler instanceof NativeSessionHandler);
|
$this->assertTrue($handler instanceof NativeSessionHandler);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,7 +137,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
$options = array(
|
$options = array(
|
||||||
'cookie_lifetime' => 123456,
|
'cookie_lifetime' => 123456,
|
||||||
'cookie_path' => '/my/cookie/path',
|
'cookie_path' => '/my/cookie/path',
|
||||||
'cookie_domain' => 'symfony2.example.com',
|
'cookie_domain' => 'symfony.example.com',
|
||||||
'cookie_secure' => true,
|
'cookie_secure' => true,
|
||||||
'cookie_httponly' => false,
|
'cookie_httponly' => false,
|
||||||
);
|
);
|
||||||
|
@ -164,7 +164,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testSetSaveHandler53()
|
public function testSetSaveHandler53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testSetSaveHandler54()
|
public function testSetSaveHandler54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testStartedOutside53()
|
public function testStartedOutside53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testCanStartOutside54()
|
public function testCanStartOutside54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPhpSession53()
|
public function testPhpSession53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPhpSession54()
|
public function testPhpSession54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testIsActivePhp53()
|
public function testIsActivePhp53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testIsActivePhp54()
|
public function testIsActivePhp54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testSetActivePhp53()
|
public function testSetActivePhp53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testSetActivePhp54()
|
public function testSetActivePhp54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testNameExceptionPhp53()
|
public function testNameExceptionPhp53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testNameExceptionPhp54()
|
public function testNameExceptionPhp54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testIdExceptionPhp53()
|
public function testIdExceptionPhp53()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testIdExceptionPhp54()
|
public function testIdExceptionPhp54()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertFalse($this->proxy->isActive());
|
$this->assertFalse($this->proxy->isActive());
|
||||||
$this->proxy->open('name', 'id');
|
$this->proxy->open('name', 'id');
|
||||||
if (version_compare(phpversion(), '5.4.0', '<')) {
|
if (PHP_VERSION_ID < 50400) {
|
||||||
$this->assertTrue($this->proxy->isActive());
|
$this->assertTrue($this->proxy->isActive());
|
||||||
} else {
|
} else {
|
||||||
$this->assertFalse($this->proxy->isActive());
|
$this->assertFalse($this->proxy->isActive());
|
||||||
|
|
|
@ -155,24 +155,21 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||||
|
|
||||||
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
|
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
|
||||||
{
|
{
|
||||||
|
$data = fopen('php://memory', 'r+b');
|
||||||
|
|
||||||
if ('html' === $format) {
|
if ('html' === $format) {
|
||||||
$dumper = new HtmlDumper();
|
$dumper = new HtmlDumper($data);
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format));
|
throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format));
|
||||||
}
|
}
|
||||||
$dumps = array();
|
$dumps = array();
|
||||||
|
|
||||||
foreach ($this->data as $dump) {
|
foreach ($this->data as $dump) {
|
||||||
$data = '';
|
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
|
||||||
$dumper->dump(
|
rewind($data);
|
||||||
$dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth),
|
$dump['data'] = stream_get_contents($data);
|
||||||
function ($line, $depth) use (&$data) {
|
ftruncate($data, 0);
|
||||||
if (-1 !== $depth) {
|
rewind($data);
|
||||||
$data .= str_repeat(' ', $depth).$line."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$dump['data'] = $data;
|
|
||||||
$dumps[] = $dump;
|
$dumps[] = $dump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,14 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||||
'file' => $r->getFilename(),
|
'file' => $r->getFilename(),
|
||||||
'line' => $r->getStartLine(),
|
'line' => $r->getStartLine(),
|
||||||
);
|
);
|
||||||
|
} elseif (is_object($controller)) {
|
||||||
|
$r = new \ReflectionClass($controller);
|
||||||
|
$this->data['controller'] = array(
|
||||||
|
'class' => $r->getName(),
|
||||||
|
'method' => null,
|
||||||
|
'file' => $r->getFileName(),
|
||||||
|
'line' => $r->getStartLine(),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->data['controller'] = (string) $controller ?: 'n/a';
|
$this->data['controller'] = (string) $controller ?: 'n/a';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\EventListener;
|
namespace Symfony\Component\HttpKernel\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
|
||||||
|
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
|
||||||
use Symfony\Component\VarDumper\VarDumper;
|
use Symfony\Component\VarDumper\VarDumper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,30 +28,23 @@ class DumpListener implements EventSubscriberInterface
|
||||||
private $dumper;
|
private $dumper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ContainerInterface $container Service container, for lazy loading.
|
* @param ClonerInterface $cloner Cloner service.
|
||||||
* @param string $dumper var_dumper dumper service to use.
|
* @param DataDumperInterface $dumper Dumper service.
|
||||||
*/
|
*/
|
||||||
public function __construct(ContainerInterface $container, $dumper)
|
public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->cloner = $cloner;
|
||||||
$this->dumper = $dumper;
|
$this->dumper = $dumper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
if ($this->container) {
|
$cloner = $this->cloner;
|
||||||
$container = $this->container;
|
$dumper = $this->dumper;
|
||||||
$dumper = $this->dumper;
|
|
||||||
$this->container = null;
|
|
||||||
|
|
||||||
VarDumper::setHandler(function ($var) use ($container, $dumper) {
|
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
|
||||||
$dumper = $container->get($dumper);
|
$dumper->dump($cloner->cloneVar($var));
|
||||||
$cloner = $container->get('var_dumper.cloner');
|
});
|
||||||
$handler = function ($var) use ($dumper, $cloner) {$dumper->dump($cloner->cloneVar($var));};
|
|
||||||
VarDumper::setHandler($handler);
|
|
||||||
$handler($var);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
|
|
|
@ -47,7 +47,7 @@ class SaveSessionListener implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function onKernelResponse(FilterResponseEvent $event)
|
public function onKernelResponse(FilterResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
|
if (!$event->isMasterRequest()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Fragment;
|
namespace Symfony\Component\HttpKernel\Fragment;
|
||||||
|
|
||||||
if (!defined('ENT_SUBSTITUTE')) {
|
|
||||||
define('ENT_SUBSTITUTE', 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
@ -111,11 +107,16 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||||
}
|
}
|
||||||
$renderedAttributes = '';
|
$renderedAttributes = '';
|
||||||
if (count($attributes) > 0) {
|
if (count($attributes) > 0) {
|
||||||
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
|
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||||
|
} else {
|
||||||
|
$flags = ENT_QUOTES;
|
||||||
|
}
|
||||||
foreach ($attributes as $attribute => $value) {
|
foreach ($attributes as $attribute => $value) {
|
||||||
$renderedAttributes .= sprintf(
|
$renderedAttributes .= sprintf(
|
||||||
' %s="%s"',
|
' %s="%s"',
|
||||||
htmlspecialchars($attribute, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false),
|
htmlspecialchars($attribute, $flags, $this->charset, false),
|
||||||
htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false)
|
htmlspecialchars($value, $flags, $this->charset, false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||||
protected $startTime;
|
protected $startTime;
|
||||||
protected $loadClassCache;
|
protected $loadClassCache;
|
||||||
|
|
||||||
const VERSION = '2.6.0-BETA1';
|
const VERSION = '2.6.0';
|
||||||
const VERSION_ID = '20600';
|
const VERSION_ID = '20600';
|
||||||
const MAJOR_VERSION = '2.6.0-BETA1';
|
const MAJOR_VERSION = '2';
|
||||||
const MINOR_VERSION = '2.6.0-BETA1';
|
const MINOR_VERSION = '6';
|
||||||
const RELEASE_VERSION = '2.6.0-BETA1';
|
const RELEASE_VERSION = '0';
|
||||||
const EXTRA_VERSION = 'BETA1';
|
const EXTRA_VERSION = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
|
@ -29,6 +29,8 @@ final class KernelEvents
|
||||||
* receives a Symfony\Component\HttpKernel\Event\GetResponseEvent
|
* receives a Symfony\Component\HttpKernel\Event\GetResponseEvent
|
||||||
* instance.
|
* instance.
|
||||||
*
|
*
|
||||||
|
* @Event
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -43,6 +45,8 @@ final class KernelEvents
|
||||||
* a Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent
|
* a Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent
|
||||||
* instance.
|
* instance.
|
||||||
*
|
*
|
||||||
|
* @Event
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -58,6 +62,8 @@ final class KernelEvents
|
||||||
* Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
|
* Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
|
||||||
* instance.
|
* instance.
|
||||||
*
|
*
|
||||||
|
* @Event
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -72,6 +78,8 @@ final class KernelEvents
|
||||||
* request. The event listener method receives a
|
* request. The event listener method receives a
|
||||||
* Symfony\Component\HttpKernel\Event\FilterControllerEvent instance.
|
* Symfony\Component\HttpKernel\Event\FilterControllerEvent instance.
|
||||||
*
|
*
|
||||||
|
* @Event
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -86,6 +94,8 @@ final class KernelEvents
|
||||||
* replied. The event listener method receives a
|
* replied. The event listener method receives a
|
||||||
* Symfony\Component\HttpKernel\Event\FilterResponseEvent instance.
|
* Symfony\Component\HttpKernel\Event\FilterResponseEvent instance.
|
||||||
*
|
*
|
||||||
|
* @Event
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -99,6 +109,8 @@ final class KernelEvents
|
||||||
* The event listener method receives a
|
* The event listener method receives a
|
||||||
* Symfony\Component\HttpKernel\Event\PostResponseEvent instance.
|
* Symfony\Component\HttpKernel\Event\PostResponseEvent instance.
|
||||||
*
|
*
|
||||||
|
* @Event
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const TERMINATE = 'kernel.terminate';
|
const TERMINATE = 'kernel.terminate';
|
||||||
|
|
|
@ -4,7 +4,7 @@ HttpKernel Component
|
||||||
HttpKernel provides the building blocks to create flexible and fast HTTP-based
|
HttpKernel provides the building blocks to create flexible and fast HTTP-based
|
||||||
frameworks.
|
frameworks.
|
||||||
|
|
||||||
``HttpKernelInterface`` is the core interface of the Symfony2 full-stack
|
``HttpKernelInterface`` is the core interface of the Symfony full-stack
|
||||||
framework:
|
framework:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
@ -23,11 +23,11 @@ interface HttpKernelInterface
|
||||||
|
|
||||||
It takes a ``Request`` as an input and should return a ``Response`` as an
|
It takes a ``Request`` as an input and should return a ``Response`` as an
|
||||||
output. Using this interface makes your code compatible with all frameworks
|
output. Using this interface makes your code compatible with all frameworks
|
||||||
using the Symfony2 components. And this will give you many cool features for
|
using the Symfony components. And this will give you many cool features for
|
||||||
free.
|
free.
|
||||||
|
|
||||||
Creating a framework based on the Symfony2 components is really easy. Here is
|
Creating a framework based on the Symfony components is really easy. Here is
|
||||||
a very simple, but fully-featured framework based on the Symfony2 components:
|
a very simple, but fully-featured framework based on the Symfony components:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$routes = new RouteCollection();
|
$routes = new RouteCollection();
|
||||||
|
@ -54,7 +54,7 @@ $kernel = new HttpKernel($dispatcher, $resolver);
|
||||||
$kernel->handle($request)->send();
|
$kernel->handle($request)->send();
|
||||||
```
|
```
|
||||||
|
|
||||||
This is all you need to create a flexible framework with the Symfony2
|
This is all you need to create a flexible framework with the Symfony
|
||||||
components.
|
components.
|
||||||
|
|
||||||
Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side
|
Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side
|
||||||
|
|
|
@ -181,7 +181,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
||||||
$request->attributes->set('foobar', 'foobar');
|
$request->attributes->set('foobar', 'foobar');
|
||||||
$controller = array(new self(), 'controllerMethod3');
|
$controller = array(new self(), 'controllerMethod3');
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.3.16', '==')) {
|
if (PHP_VERSION_ID === 50316) {
|
||||||
$this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system');
|
$this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system');
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -59,6 +59,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||||
// make sure we always match the line number
|
// make sure we always match the line number
|
||||||
$r1 = new \ReflectionMethod($this, 'testControllerInspection');
|
$r1 = new \ReflectionMethod($this, 'testControllerInspection');
|
||||||
$r2 = new \ReflectionMethod($this, 'staticControllerMethod');
|
$r2 = new \ReflectionMethod($this, 'staticControllerMethod');
|
||||||
|
$r3 = new \ReflectionClass($this);
|
||||||
// test name, callable, expected
|
// test name, callable, expected
|
||||||
$controllerTests = array(
|
$controllerTests = array(
|
||||||
array(
|
array(
|
||||||
|
@ -132,6 +133,17 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||||
'line' => 'n/a',
|
'line' => 'n/a',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'Invokable controller',
|
||||||
|
$this,
|
||||||
|
array(
|
||||||
|
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||||
|
'method' => null,
|
||||||
|
'file' => __FILE__,
|
||||||
|
'line' => $r3->getStartLine(),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$c = new RequestDataCollector();
|
$c = new RequestDataCollector();
|
||||||
|
@ -202,4 +214,9 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
throw new \LogicException('Unexpected method call');
|
throw new \LogicException('Unexpected method call');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __invoke()
|
||||||
|
{
|
||||||
|
throw new \LogicException('Unexpected method call');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Tests\EventListener;
|
namespace Symfony\Component\HttpKernel\Tests\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
|
||||||
use Symfony\Component\HttpKernel\EventListener\DumpListener;
|
use Symfony\Component\HttpKernel\EventListener\DumpListener;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
|
||||||
|
use Symfony\Component\VarDumper\Cloner\Data;
|
||||||
|
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
|
||||||
use Symfony\Component\VarDumper\VarDumper;
|
use Symfony\Component\VarDumper\VarDumper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,34 +35,23 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testConfigure()
|
public function testConfigure()
|
||||||
{
|
{
|
||||||
$prevDumper = $this->getDumpHandler();
|
$prevDumper = VarDumper::setHandler('var_dump');
|
||||||
|
VarDumper::setHandler($prevDumper);
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$cloner = new MockCloner();
|
||||||
$container->setDefinition('var_dumper.cloner', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockCloner'));
|
$dumper = new MockDumper();
|
||||||
$container->setDefinition('mock_dumper', new Definition('Symfony\Component\HttpKernel\Tests\EventListener\MockDumper'));
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$exception = null;
|
$exception = null;
|
||||||
$listener = new DumpListener($container, 'mock_dumper');
|
$listener = new DumpListener($cloner, $dumper);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$listener->configure();
|
$listener->configure();
|
||||||
|
|
||||||
$lazyDumper = $this->getDumpHandler();
|
|
||||||
VarDumper::dump('foo');
|
VarDumper::dump('foo');
|
||||||
|
|
||||||
$loadedDumper = $this->getDumpHandler();
|
|
||||||
VarDumper::dump('bar');
|
VarDumper::dump('bar');
|
||||||
|
|
||||||
$this->assertSame('+foo-+bar-', ob_get_clean());
|
$this->assertSame('+foo-+bar-', ob_get_clean());
|
||||||
|
|
||||||
$listenerReflector = new \ReflectionClass($listener);
|
|
||||||
$lazyReflector = new \ReflectionFunction($lazyDumper);
|
|
||||||
$loadedReflector = new \ReflectionFunction($loadedDumper);
|
|
||||||
|
|
||||||
$this->assertSame($listenerReflector->getFilename(), $lazyReflector->getFilename());
|
|
||||||
$this->assertSame($listenerReflector->getFilename(), $loadedReflector->getFilename());
|
|
||||||
$this->assertGreaterThan($lazyReflector->getStartLine(), $loadedReflector->getStartLine());
|
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,28 +61,22 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDumpHandler()
|
|
||||||
{
|
|
||||||
$prevDumper = VarDumper::setHandler('var_dump');
|
|
||||||
VarDumper::setHandler($prevDumper );
|
|
||||||
|
|
||||||
return $prevDumper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockCloner
|
class MockCloner implements ClonerInterface
|
||||||
{
|
{
|
||||||
public function cloneVar($var)
|
public function cloneVar($var)
|
||||||
{
|
{
|
||||||
return $var.'-';
|
return new Data(array($var.'-'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockDumper
|
class MockDumper implements DataDumperInterface
|
||||||
{
|
{
|
||||||
public function dump($var)
|
public function dump(Data $data)
|
||||||
{
|
{
|
||||||
echo '+'.$var;
|
$rawData = $data->getRawData();
|
||||||
|
|
||||||
|
echo '+'.$rawData[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Route implements \Serializable
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $condition;
|
private $condition = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -84,7 +84,7 @@ class Route implements \Serializable
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = null)
|
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '')
|
||||||
{
|
{
|
||||||
$this->setPath($path);
|
$this->setPath($path);
|
||||||
$this->setDefaults($defaults);
|
$this->setDefaults($defaults);
|
||||||
|
|
|
@ -99,7 +99,7 @@ class JsonDecode implements DecoderInterface
|
||||||
$recursionDepth = $context['json_decode_recursion_depth'];
|
$recursionDepth = $context['json_decode_recursion_depth'];
|
||||||
$options = $context['json_decode_options'];
|
$options = $context['json_decode_options'];
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
||||||
} else {
|
} else {
|
||||||
$decodedData = json_decode($data, $associative, $recursionDepth);
|
$decodedData = json_decode($data, $associative, $recursionDepth);
|
||||||
|
|
|
@ -446,11 +446,11 @@ XML;
|
||||||
protected function getNamespacedArray()
|
protected function getNamespacedArray()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'@xmlns' => 'http://www.w3.org/2005/Atom',
|
'@xmlns' => 'http://www.w3.org/2005/Atom',
|
||||||
'@xmlns:app' => 'http://www.w3.org/2007/app',
|
'@xmlns:app' => 'http://www.w3.org/2007/app',
|
||||||
'@xmlns:media' => 'http://search.yahoo.com/mrss/',
|
'@xmlns:media' => 'http://search.yahoo.com/mrss/',
|
||||||
'@xmlns:gd' => 'http://schemas.google.com/g/2005',
|
'@xmlns:gd' => 'http://schemas.google.com/g/2005',
|
||||||
'@xmlns:yt' => 'http://gdata.youtube.com/schemas/2007',
|
'@xmlns:yt' => 'http://gdata.youtube.com/schemas/2007',
|
||||||
'qux' => "1",
|
'qux' => "1",
|
||||||
'app:foo' => "foo",
|
'app:foo' => "foo",
|
||||||
'yt:bar' => array("a", "b"),
|
'yt:bar' => array("a", "b"),
|
||||||
|
@ -469,7 +469,7 @@ XML;
|
||||||
'Barry' => array(
|
'Barry' => array(
|
||||||
'@size' => 'large',
|
'@size' => 'large',
|
||||||
'FooBar' => array(
|
'FooBar' => array(
|
||||||
'Baz' => 'Ed',
|
'Baz' => 'Ed',
|
||||||
'@gd:id' => 1,
|
'@gd:id' => 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -35,7 +35,7 @@ class RangeValidator extends ConstraintValidator
|
||||||
|
|
||||||
if (!is_numeric($value) && !$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!is_numeric($value) && !$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
$this->buildViolation($constraint->invalidMessage)
|
$this->buildViolation($constraint->invalidMessage)
|
||||||
->setParameter('{{ value }}', $this->formatValue($value))
|
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
|
||||||
->setCode(Range::INVALID_VALUE_ERROR)
|
->setCode(Range::INVALID_VALUE_ERROR)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class RangeValidator extends ConstraintValidator
|
||||||
|
|
||||||
if (null !== $constraint->max && $value > $max) {
|
if (null !== $constraint->max && $value > $max) {
|
||||||
$this->buildViolation($constraint->maxMessage)
|
$this->buildViolation($constraint->maxMessage)
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
|
||||||
->setParameter('{{ limit }}', $this->formatValue($max, self::PRETTY_DATE))
|
->setParameter('{{ limit }}', $this->formatValue($max, self::PRETTY_DATE))
|
||||||
->setCode(Range::BEYOND_RANGE_ERROR)
|
->setCode(Range::BEYOND_RANGE_ERROR)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
@ -71,7 +71,7 @@ class RangeValidator extends ConstraintValidator
|
||||||
|
|
||||||
if (null !== $constraint->min && $value < $min) {
|
if (null !== $constraint->min && $value < $min) {
|
||||||
$this->buildViolation($constraint->minMessage)
|
$this->buildViolation($constraint->minMessage)
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
|
||||||
->setParameter('{{ limit }}', $this->formatValue($min, self::PRETTY_DATE))
|
->setParameter('{{ limit }}', $this->formatValue($min, self::PRETTY_DATE))
|
||||||
->setCode(Range::BELOW_RANGE_ERROR)
|
->setCode(Range::BELOW_RANGE_ERROR)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
|
|
@ -271,9 +271,9 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
||||||
fclose($this->file);
|
fclose($this->file);
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'maxSize' => $limit,
|
'maxSize' => $limit,
|
||||||
'binaryFormat' => $binaryFormat,
|
'binaryFormat' => $binaryFormat,
|
||||||
'maxSizeMessage' => 'myMessage',
|
'maxSizeMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||||
|
|
|
@ -52,20 +52,20 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
public function getLessThanTen()
|
public function getLessThanTen()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(9.99999),
|
array(9.99999, '9.99999'),
|
||||||
array('9.99999'),
|
array('9.99999', '"9.99999"'),
|
||||||
array(5),
|
array(5, '5'),
|
||||||
array(1.0),
|
array(1.0, '1.0'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMoreThanTwenty()
|
public function getMoreThanTwenty()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(20.000001),
|
array(20.000001, '20.000001'),
|
||||||
array('20.000001'),
|
array('20.000001', '"20.000001"'),
|
||||||
array(21),
|
array(21, '21'),
|
||||||
array(30.0),
|
array(30.0, '30.0'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getLessThanTen
|
* @dataProvider getLessThanTen
|
||||||
*/
|
*/
|
||||||
public function testInvalidValuesMin($value)
|
public function testInvalidValuesMin($value, $formattedValue)
|
||||||
{
|
{
|
||||||
$constraint = new Range(array(
|
$constraint = new Range(array(
|
||||||
'min' => 10,
|
'min' => 10,
|
||||||
|
@ -115,7 +115,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMessage')
|
$this->buildViolation('myMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $formattedValue)
|
||||||
->setParameter('{{ limit }}', 10)
|
->setParameter('{{ limit }}', 10)
|
||||||
->setCode(Range::BELOW_RANGE_ERROR)
|
->setCode(Range::BELOW_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -124,7 +124,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getMoreThanTwenty
|
* @dataProvider getMoreThanTwenty
|
||||||
*/
|
*/
|
||||||
public function testInvalidValuesMax($value)
|
public function testInvalidValuesMax($value, $formattedValue)
|
||||||
{
|
{
|
||||||
$constraint = new Range(array(
|
$constraint = new Range(array(
|
||||||
'max' => 20,
|
'max' => 20,
|
||||||
|
@ -134,7 +134,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMessage')
|
$this->buildViolation('myMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $formattedValue)
|
||||||
->setParameter('{{ limit }}', 20)
|
->setParameter('{{ limit }}', 20)
|
||||||
->setCode(Range::BEYOND_RANGE_ERROR)
|
->setCode(Range::BEYOND_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -143,7 +143,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getMoreThanTwenty
|
* @dataProvider getMoreThanTwenty
|
||||||
*/
|
*/
|
||||||
public function testInvalidValuesCombinedMax($value)
|
public function testInvalidValuesCombinedMax($value, $formattedValue)
|
||||||
{
|
{
|
||||||
$constraint = new Range(array(
|
$constraint = new Range(array(
|
||||||
'min' => 10,
|
'min' => 10,
|
||||||
|
@ -155,7 +155,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMaxMessage')
|
$this->buildViolation('myMaxMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $formattedValue)
|
||||||
->setParameter('{{ limit }}', 20)
|
->setParameter('{{ limit }}', 20)
|
||||||
->setCode(Range::BEYOND_RANGE_ERROR)
|
->setCode(Range::BEYOND_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -164,7 +164,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getLessThanTen
|
* @dataProvider getLessThanTen
|
||||||
*/
|
*/
|
||||||
public function testInvalidValuesCombinedMin($value)
|
public function testInvalidValuesCombinedMin($value, $formattedValue)
|
||||||
{
|
{
|
||||||
$constraint = new Range(array(
|
$constraint = new Range(array(
|
||||||
'min' => 10,
|
'min' => 10,
|
||||||
|
@ -176,7 +176,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMinMessage')
|
$this->buildViolation('myMinMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $formattedValue)
|
||||||
->setParameter('{{ limit }}', 10)
|
->setParameter('{{ limit }}', 10)
|
||||||
->setCode(Range::BELOW_RANGE_ERROR)
|
->setCode(Range::BELOW_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -212,13 +212,13 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->setDefaultTimezone('UTC');
|
$this->setDefaultTimezone('UTC');
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
array(new \DateTime('March 20, 2013')),
|
array(new \DateTime('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'),
|
||||||
array(new \DateTime('March 9, 2014')),
|
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||||
$tests[] = array(new \DateTimeImmutable('March 20, 2013'));
|
$tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM');
|
||||||
$tests[] = array(new \DateTimeImmutable('March 9, 2014'));
|
$tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->restoreDefaultTimezone();
|
$this->restoreDefaultTimezone();
|
||||||
|
@ -233,13 +233,13 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->setDefaultTimezone('UTC');
|
$this->setDefaultTimezone('UTC');
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
array(new \DateTime('March 21, 2014')),
|
array(new \DateTime('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'),
|
||||||
array(new \DateTime('March 9, 2015')),
|
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||||
$tests[] = array(new \DateTimeImmutable('March 21, 2014'));
|
$tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM');
|
||||||
$tests[] = array(new \DateTimeImmutable('March 9, 2015'));
|
$tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->restoreDefaultTimezone();
|
$this->restoreDefaultTimezone();
|
||||||
|
@ -283,7 +283,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getSoonerThanTenthMarch2014
|
* @dataProvider getSoonerThanTenthMarch2014
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatesMin($value)
|
public function testInvalidDatesMin($value, $dateTimeAsString)
|
||||||
{
|
{
|
||||||
// Conversion of dates to string differs between ICU versions
|
// Conversion of dates to string differs between ICU versions
|
||||||
// Make sure we have the correct version loaded
|
// Make sure we have the correct version loaded
|
||||||
|
@ -297,7 +297,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMessage')
|
$this->buildViolation('myMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $dateTimeAsString)
|
||||||
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
|
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
|
||||||
->setCode(Range::BELOW_RANGE_ERROR)
|
->setCode(Range::BELOW_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -306,7 +306,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getLaterThanTwentiethMarch2014
|
* @dataProvider getLaterThanTwentiethMarch2014
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatesMax($value)
|
public function testInvalidDatesMax($value, $dateTimeAsString)
|
||||||
{
|
{
|
||||||
// Conversion of dates to string differs between ICU versions
|
// Conversion of dates to string differs between ICU versions
|
||||||
// Make sure we have the correct version loaded
|
// Make sure we have the correct version loaded
|
||||||
|
@ -320,7 +320,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMessage')
|
$this->buildViolation('myMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $dateTimeAsString)
|
||||||
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
|
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
|
||||||
->setCode(Range::BEYOND_RANGE_ERROR)
|
->setCode(Range::BEYOND_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -329,7 +329,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getLaterThanTwentiethMarch2014
|
* @dataProvider getLaterThanTwentiethMarch2014
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatesCombinedMax($value)
|
public function testInvalidDatesCombinedMax($value, $dateTimeAsString)
|
||||||
{
|
{
|
||||||
// Conversion of dates to string differs between ICU versions
|
// Conversion of dates to string differs between ICU versions
|
||||||
// Make sure we have the correct version loaded
|
// Make sure we have the correct version loaded
|
||||||
|
@ -345,7 +345,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMaxMessage')
|
$this->buildViolation('myMaxMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $dateTimeAsString)
|
||||||
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
|
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
|
||||||
->setCode(Range::BEYOND_RANGE_ERROR)
|
->setCode(Range::BEYOND_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
@ -354,7 +354,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
/**
|
/**
|
||||||
* @dataProvider getSoonerThanTenthMarch2014
|
* @dataProvider getSoonerThanTenthMarch2014
|
||||||
*/
|
*/
|
||||||
public function testInvalidDatesCombinedMin($value)
|
public function testInvalidDatesCombinedMin($value, $dateTimeAsString)
|
||||||
{
|
{
|
||||||
// Conversion of dates to string differs between ICU versions
|
// Conversion of dates to string differs between ICU versions
|
||||||
// Make sure we have the correct version loaded
|
// Make sure we have the correct version loaded
|
||||||
|
@ -370,7 +370,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->buildViolation('myMinMessage')
|
$this->buildViolation('myMinMessage')
|
||||||
->setParameter('{{ value }}', $value)
|
->setParameter('{{ value }}', $dateTimeAsString)
|
||||||
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
|
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
|
||||||
->setCode(Range::BELOW_RANGE_ERROR)
|
->setCode(Range::BELOW_RANGE_ERROR)
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
|
|
|
@ -21,7 +21,7 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
|
if (PHP_VERSION_ID < 50309) {
|
||||||
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
|
if (PHP_VERSION_ID < 50309) {
|
||||||
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testDefaultApiVersion()
|
public function testDefaultApiVersion()
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
|
if (PHP_VERSION_ID < 50309) {
|
||||||
// Old implementation on PHP < 5.3.9
|
// Old implementation on PHP < 5.3.9
|
||||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
|
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
|
||||||
} else {
|
} else {
|
||||||
|
@ -135,7 +135,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testSetApiVersion24And25()
|
public function testSetApiVersion24And25()
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
|
if (PHP_VERSION_ID < 50309) {
|
||||||
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.3.9', '<') && $apiVersion === Validation::API_VERSION_2_5_BC) {
|
if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new InvalidArgumentException(sprintf(
|
||||||
'The Validator API that is compatible with both Symfony 2.4 '.
|
'The Validator API that is compatible with both Symfony 2.4 '.
|
||||||
'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '.
|
'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '.
|
||||||
|
@ -385,7 +385,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
|
||||||
$apiVersion = $this->apiVersion;
|
$apiVersion = $this->apiVersion;
|
||||||
|
|
||||||
if (null === $apiVersion) {
|
if (null === $apiVersion) {
|
||||||
$apiVersion = version_compare(PHP_VERSION, '5.3.9', '<')
|
$apiVersion = PHP_VERSION_ID < 50309
|
||||||
? Validation::API_VERSION_2_4
|
? Validation::API_VERSION_2_4
|
||||||
: Validation::API_VERSION_2_5_BC;
|
: Validation::API_VERSION_2_5_BC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
|
|
||||||
namespace Symfony\Component\Yaml\Exception;
|
namespace Symfony\Component\Yaml\Exception;
|
||||||
|
|
||||||
if (!defined('JSON_UNESCAPED_UNICODE')) {
|
|
||||||
define('JSON_UNESCAPED_SLASHES', 64);
|
|
||||||
define('JSON_UNESCAPED_UNICODE', 256);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception class thrown when an error occurs during parsing.
|
* Exception class thrown when an error occurs during parsing.
|
||||||
*
|
*
|
||||||
|
@ -130,7 +125,12 @@ class ParseException extends RuntimeException
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->parsedFile) {
|
if (null !== $this->parsedFile) {
|
||||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
|
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
||||||
|
} else {
|
||||||
|
$jsonOptions = 0;
|
||||||
|
}
|
||||||
|
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->parsedLine >= 0) {
|
if ($this->parsedLine >= 0) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGetMessage()
|
public function testGetMessage()
|
||||||
{
|
{
|
||||||
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
||||||
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||||
} else {
|
} else {
|
||||||
$message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
|
$message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
|
||||||
|
@ -27,4 +27,16 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertEquals($message, $exception->getMessage());
|
$this->assertEquals($message, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetMessageWithUnicodeInFilename()
|
||||||
|
{
|
||||||
|
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
|
||||||
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
|
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||||
|
} else {
|
||||||
|
$message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($message, $exception->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue