Issue #2464369 by neclimdul, joshtaylor: Upgrade to Symfony 2.6.6

8.0.x
Alex Pott 2015-04-04 00:11:39 +01:00
parent 82d3eb2f65
commit eb4e371913
84 changed files with 1354 additions and 1275 deletions

142
core/composer.lock generated
View File

@ -1972,17 +1972,17 @@
},
{
"name": "symfony/browser-kit",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/BrowserKit",
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
"reference": "329bdc10bff1e365abb8a3388d60a65630daf705"
"reference": "f21189b0eccbe56528515858ca1d5089a741692f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/329bdc10bff1e365abb8a3388d60a65630daf705",
"reference": "329bdc10bff1e365abb8a3388d60a65630daf705",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/f21189b0eccbe56528515858ca1d5089a741692f",
"reference": "f21189b0eccbe56528515858ca1d5089a741692f",
"shasum": ""
},
"require": {
@ -2024,21 +2024,21 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "http://symfony.com",
"time": "2015-03-13 13:21:46"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/class-loader",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/ClassLoader",
"source": {
"type": "git",
"url": "https://github.com/symfony/ClassLoader.git",
"reference": "56bf6fe551ca013471541d866f73a6cc70ece9c5"
"reference": "861765b3e5f32979de5bd19ad2577cbb830a29d5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/56bf6fe551ca013471541d866f73a6cc70ece9c5",
"reference": "56bf6fe551ca013471541d866f73a6cc70ece9c5",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/861765b3e5f32979de5bd19ad2577cbb830a29d5",
"reference": "861765b3e5f32979de5bd19ad2577cbb830a29d5",
"shasum": ""
},
"require": {
@ -2075,21 +2075,21 @@
],
"description": "Symfony ClassLoader Component",
"homepage": "http://symfony.com",
"time": "2015-03-13 17:37:22"
"time": "2015-03-27 10:19:51"
},
{
"name": "symfony/css-selector",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/CssSelector",
"source": {
"type": "git",
"url": "https://github.com/symfony/CssSelector.git",
"reference": "86cf0aa16065ffc4545374e9479dd7878bf1d90f"
"reference": "db2c48df9658423a8c168d89f7b971b73d3d74a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/86cf0aa16065ffc4545374e9479dd7878bf1d90f",
"reference": "86cf0aa16065ffc4545374e9479dd7878bf1d90f",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/db2c48df9658423a8c168d89f7b971b73d3d74a4",
"reference": "db2c48df9658423a8c168d89f7b971b73d3d74a4",
"shasum": ""
},
"require": {
@ -2129,21 +2129,21 @@
],
"description": "Symfony CssSelector Component",
"homepage": "http://symfony.com",
"time": "2015-02-24 11:52:21"
"time": "2015-03-22 16:55:57"
},
{
"name": "symfony/debug",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Debug",
"source": {
"type": "git",
"url": "https://github.com/symfony/Debug.git",
"reference": "5c1570dea188ade0c6c5e874c2f0a6570587aa1c"
"reference": "d49a46a20a8f0544aedac54466750ad787d3d3e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Debug/zipball/5c1570dea188ade0c6c5e874c2f0a6570587aa1c",
"reference": "5c1570dea188ade0c6c5e874c2f0a6570587aa1c",
"url": "https://api.github.com/repos/symfony/Debug/zipball/d49a46a20a8f0544aedac54466750ad787d3d3e3",
"reference": "d49a46a20a8f0544aedac54466750ad787d3d3e3",
"shasum": ""
},
"require": {
@ -2190,21 +2190,21 @@
],
"description": "Symfony Debug Component",
"homepage": "http://symfony.com",
"time": "2015-03-13 17:37:22"
"time": "2015-03-22 16:55:57"
},
{
"name": "symfony/dependency-injection",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/DependencyInjection",
"source": {
"type": "git",
"url": "https://github.com/symfony/DependencyInjection.git",
"reference": "a49245b2beebe332924561c30772b16e1d32f13a"
"reference": "8e9007012226b4bd41f8afed855c452cf5edc3a6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/a49245b2beebe332924561c30772b16e1d32f13a",
"reference": "a49245b2beebe332924561c30772b16e1d32f13a",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/8e9007012226b4bd41f8afed855c452cf5edc3a6",
"reference": "8e9007012226b4bd41f8afed855c452cf5edc3a6",
"shasum": ""
},
"require": {
@ -2251,21 +2251,21 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "http://symfony.com",
"time": "2015-03-17 12:44:40"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/dom-crawler",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/DomCrawler",
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
"reference": "896d1fb78832e8c4a4e4e8565ffdf668a53e518f"
"reference": "8897ebf39c7dfb752a5494fa301845a3fbb9e53d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/896d1fb78832e8c4a4e4e8565ffdf668a53e518f",
"reference": "896d1fb78832e8c4a4e4e8565ffdf668a53e518f",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/8897ebf39c7dfb752a5494fa301845a3fbb9e53d",
"reference": "8897ebf39c7dfb752a5494fa301845a3fbb9e53d",
"shasum": ""
},
"require": {
@ -2305,11 +2305,11 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "http://symfony.com",
"time": "2015-03-12 10:28:44"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/EventDispatcher",
"source": {
"type": "git",
@ -2368,17 +2368,17 @@
},
{
"name": "symfony/http-foundation",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "d527885e37b55ec0e3dc6f4b70566d0f9b2f2388"
"reference": "8a6337233f08f7520de97f4ffd6f00e947d892f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/d527885e37b55ec0e3dc6f4b70566d0f9b2f2388",
"reference": "d527885e37b55ec0e3dc6f4b70566d0f9b2f2388",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/8a6337233f08f7520de97f4ffd6f00e947d892f9",
"reference": "8a6337233f08f7520de97f4ffd6f00e947d892f9",
"shasum": ""
},
"require": {
@ -2418,21 +2418,21 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "http://symfony.com",
"time": "2015-03-13 17:37:22"
"time": "2015-04-01 16:50:12"
},
{
"name": "symfony/http-kernel",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/HttpKernel",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "6f7b2d3ba8bf02cf77edb399696e85ef24a888a4"
"reference": "3829cacfe21eaf3f73604a62d79183d1f6e792c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/6f7b2d3ba8bf02cf77edb399696e85ef24a888a4",
"reference": "6f7b2d3ba8bf02cf77edb399696e85ef24a888a4",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/3829cacfe21eaf3f73604a62d79183d1f6e792c4",
"reference": "3829cacfe21eaf3f73604a62d79183d1f6e792c4",
"shasum": ""
},
"require": {
@ -2496,21 +2496,21 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "http://symfony.com",
"time": "2015-03-17 14:58:46"
"time": "2015-04-01 16:55:26"
},
{
"name": "symfony/process",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Process",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "4d717f34f3d1d6ab30fbe79f7132960a27f4a0dc"
"reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/4d717f34f3d1d6ab30fbe79f7132960a27f4a0dc",
"reference": "4d717f34f3d1d6ab30fbe79f7132960a27f4a0dc",
"url": "https://api.github.com/repos/symfony/Process/zipball/a8bebaec1a9dc6cde53e0250e32917579b0be552",
"reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552",
"shasum": ""
},
"require": {
@ -2546,21 +2546,21 @@
],
"description": "Symfony Process Component",
"homepage": "http://symfony.com",
"time": "2015-03-12 10:28:44"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/routing",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Routing",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"reference": "a7f3eb540e5c553c3c95993c6fc2e7edb2f3b9d2"
"reference": "4e173a645b63ff60a124f3741b4f15feebd908fa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/a7f3eb540e5c553c3c95993c6fc2e7edb2f3b9d2",
"reference": "a7f3eb540e5c553c3c95993c6fc2e7edb2f3b9d2",
"url": "https://api.github.com/repos/symfony/Routing/zipball/4e173a645b63ff60a124f3741b4f15feebd908fa",
"reference": "4e173a645b63ff60a124f3741b4f15feebd908fa",
"shasum": ""
},
"require": {
@ -2615,21 +2615,21 @@
"uri",
"url"
],
"time": "2015-03-13 17:37:22"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/serializer",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Serializer",
"source": {
"type": "git",
"url": "https://github.com/symfony/Serializer.git",
"reference": "31f3eb9f6375cec823e4b9c070b1c1c4ca67599b"
"reference": "bf30b882e15945fe8700edcd966eb3f5503820f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Serializer/zipball/31f3eb9f6375cec823e4b9c070b1c1c4ca67599b",
"reference": "31f3eb9f6375cec823e4b9c070b1c1c4ca67599b",
"url": "https://api.github.com/repos/symfony/Serializer/zipball/bf30b882e15945fe8700edcd966eb3f5503820f3",
"reference": "bf30b882e15945fe8700edcd966eb3f5503820f3",
"shasum": ""
},
"require": {
@ -2665,21 +2665,21 @@
],
"description": "Symfony Serializer Component",
"homepage": "http://symfony.com",
"time": "2015-03-15 23:12:13"
"time": "2015-03-22 16:55:57"
},
{
"name": "symfony/translation",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Translation",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
"reference": "043db5f1eef9598d1bc1d75b93304984c003d7d9"
"reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/043db5f1eef9598d1bc1d75b93304984c003d7d9",
"reference": "043db5f1eef9598d1bc1d75b93304984c003d7d9",
"url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af",
"reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af",
"shasum": ""
},
"require": {
@ -2724,21 +2724,21 @@
],
"description": "Symfony Translation Component",
"homepage": "http://symfony.com",
"time": "2015-03-14 11:42:25"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/validator",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Validator",
"source": {
"type": "git",
"url": "https://github.com/symfony/Validator.git",
"reference": "90d8a2196635fc8e107510f8575a01ef29d459a2"
"reference": "85d9b42fe71bf88e7a1e5dec2094605dc9fbff28"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Validator/zipball/90d8a2196635fc8e107510f8575a01ef29d459a2",
"reference": "90d8a2196635fc8e107510f8575a01ef29d459a2",
"url": "https://api.github.com/repos/symfony/Validator/zipball/85d9b42fe71bf88e7a1e5dec2094605dc9fbff28",
"reference": "85d9b42fe71bf88e7a1e5dec2094605dc9fbff28",
"shasum": ""
},
"require": {
@ -2796,21 +2796,21 @@
],
"description": "Symfony Validator Component",
"homepage": "http://symfony.com",
"time": "2015-03-13 17:37:22"
"time": "2015-03-30 15:54:10"
},
{
"name": "symfony/yaml",
"version": "v2.6.5",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "0cd8e72071e46e15fc072270ae39ea1b66b10a9d"
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/0cd8e72071e46e15fc072270ae39ea1b66b10a9d",
"reference": "0cd8e72071e46e15fc072270ae39ea1b66b10a9d",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4",
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4",
"shasum": ""
},
"require": {
@ -2846,7 +2846,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
"time": "2015-03-12 10:28:44"
"time": "2015-03-30 15:54:10"
},
{
"name": "twig/twig",

File diff suppressed because it is too large Load Diff

View File

@ -204,7 +204,7 @@ class Cookie
private static function parseDate($dateValue)
{
// trim single quotes around date if present
if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length-1]) {
if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
$dateValue = substr($dateValue, 1, -1);
}

View File

@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception;
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
class ExpressionErrorException extends ParseException implements ExceptionInterface
class ExpressionErrorException extends ParseException
{
}

View File

@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception;
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
class InternalErrorException extends ParseException implements ExceptionInterface
class InternalErrorException extends ParseException
{
}

View File

@ -21,7 +21,7 @@ use Symfony\Component\CssSelector\Parser\Token;
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
class SyntaxErrorException extends ParseException implements ExceptionInterface
class SyntaxErrorException extends ParseException
{
/**
* @param string $expectedValue

View File

@ -37,23 +37,23 @@ class CssSelectorTest extends \PHPUnit_Framework_TestCase
$this->fail('->parse() throws an Exception if the css selector is not valid');
} catch (\Exception $e) {
$this->assertInstanceOf('\Symfony\Component\CssSelector\Exception\ParseException', $e, '->parse() throws an Exception if the css selector is not valid');
$this->assertEquals("Expected identifier, but <eof at 3> found.", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid');
$this->assertEquals('Expected identifier, but <eof at 3> found.', $e->getMessage(), '->parse() throws an Exception if the css selector is not valid');
}
}
public function getCssToXPathWithoutPrefixTestData()
{
return array(
array('h1', "h1"),
array('foo|h1', "foo:h1"),
array('h1, h2, h3', "h1 | h2 | h3"),
array('h1', 'h1'),
array('foo|h1', 'foo:h1'),
array('h1, h2, h3', 'h1 | h2 | h3'),
array('h1:nth-child(3n+1)', "*/*[name() = 'h1' and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"),
array('h1 > p', "h1/p"),
array('h1 > p', 'h1/p'),
array('h1#foo', "h1[@id = 'foo']"),
array('h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
array('h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"),
array('h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"),
array('h1[class]', "h1[@class]"),
array('h1[class]', 'h1[@class]'),
array('h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
array('h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"),
array('h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"),

View File

@ -90,12 +90,12 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
public function getCssToXPathTestData()
{
return array(
array('*', "*"),
array('e', "e"),
array('*|e', "e"),
array('e|f', "e:f"),
array('e[foo]', "e[@foo]"),
array('e[foo|bar]', "e[@foo:bar]"),
array('*', '*'),
array('e', 'e'),
array('*|e', 'e'),
array('e|f', 'e:f'),
array('e[foo]', 'e[@foo]'),
array('e[foo|bar]', 'e[@foo:bar]'),
array('e[foo="bar"]', "e[@foo = 'bar']"),
array('e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"),
array('e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"),
@ -105,29 +105,29 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
array('e:nth-child(1)', "*/*[name() = 'e' and (position() = 1)]"),
array('e:nth-last-child(1)', "*/*[name() = 'e' and (position() = last() - 0)]"),
array('e:nth-last-child(2n+2)', "*/*[name() = 'e' and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"),
array('e:nth-of-type(1)', "*/e[position() = 1]"),
array('e:nth-last-of-type(1)', "*/e[position() = last() - 0]"),
array('e:nth-of-type(1)', '*/e[position() = 1]'),
array('e:nth-last-of-type(1)', '*/e[position() = last() - 0]'),
array('div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"),
array('e:first-child', "*/*[name() = 'e' and (position() = 1)]"),
array('e:last-child', "*/*[name() = 'e' and (position() = last())]"),
array('e:first-of-type', "*/e[position() = 1]"),
array('e:last-of-type', "*/e[position() = last()]"),
array('e:first-of-type', '*/e[position() = 1]'),
array('e:last-of-type', '*/e[position() = last()]'),
array('e:only-child', "*/*[name() = 'e' and (last() = 1)]"),
array('e:only-of-type', "e[last() = 1]"),
array('e:empty', "e[not(*) and not(string-length())]"),
array('e:EmPTY', "e[not(*) and not(string-length())]"),
array('e:root', "e[not(parent::*)]"),
array('e:hover', "e[0]"),
array('e:only-of-type', 'e[last() = 1]'),
array('e:empty', 'e[not(*) and not(string-length())]'),
array('e:EmPTY', 'e[not(*) and not(string-length())]'),
array('e:root', 'e[not(parent::*)]'),
array('e:hover', 'e[0]'),
array('e:contains("foo")', "e[contains(string(.), 'foo')]"),
array('e:ConTains(foo)', "e[contains(string(.), 'foo')]"),
array('e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"),
array('e#myid', "e[@id = 'myid']"),
array('e:not(:nth-child(odd))', "e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]"),
array('e:nOT(*)', "e[0]"),
array('e f', "e/descendant-or-self::*/f"),
array('e > f', "e/f"),
array('e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'),
array('e:nOT(*)', 'e[0]'),
array('e f', 'e/descendant-or-self::*/f'),
array('e > f', 'e/f'),
array('e + f', "e/following-sibling::*[name() = 'f' and (position() = 1)]"),
array('e ~ f', "e/following-sibling::f"),
array('e ~ f', 'e/following-sibling::f'),
array('div#container p', "div[@id = 'container']/descendant-or-self::*/p"),
);
}

View File

@ -98,9 +98,9 @@ class HtmlExtension extends AbstractExtension
public function translateDisabled(XPathExpr $xpath)
{
return $xpath->addCondition(
"("
."@disabled and"
."("
'('
.'@disabled and'
.'('
."(name(.) = 'input' and @type != 'hidden')"
." or name(.) = 'button'"
." or name(.) = 'select'"
@ -109,14 +109,14 @@ class HtmlExtension extends AbstractExtension
." or name(.) = 'fieldset'"
." or name(.) = 'optgroup'"
." or name(.) = 'option'"
.")"
.") or ("
.')'
.') or ('
."(name(.) = 'input' and @type != 'hidden')"
." or name(.) = 'button'"
." or name(.) = 'select'"
." or name(.) = 'textarea'"
.")"
." and ancestor::fieldset[@disabled]"
.')'
.' and ancestor::fieldset[@disabled]'
);
// todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any."
}
@ -150,10 +150,10 @@ class HtmlExtension extends AbstractExtension
." or name(.) = 'textarea'"
." or name(.) = 'keygen'"
.')'
." and not (@disabled or ancestor::fieldset[@disabled])"
.' and not (@disabled or ancestor::fieldset[@disabled])'
.') or ('
."name(.) = 'option' and not("
."@disabled or ancestor::optgroup[@disabled]"
.'@disabled or ancestor::optgroup[@disabled]'
.')'
.')'
);

View File

@ -400,9 +400,9 @@ EOF;
$result = array();
foreach ($args as $key => $item) {
if ('object' === $item[0]) {
$formattedValue = sprintf("<em>object</em>(%s)", $this->formatClass($item[1]));
$formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
} elseif ('array' === $item[0]) {
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
} elseif ('null' === $item[0]) {

View File

@ -62,9 +62,6 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
$definition->setProperties(
$this->inlineArguments($container, $definition->getProperties())
);
$configurator = $this->inlineArguments($container, array($definition->getConfigurator()));
$definition->setConfigurator($configurator[0]);
}
}

View File

@ -55,10 +55,10 @@ class MergeExtensionConfigurationPass implements CompilerPassInterface
$extension->load($config, $tmpContainer);
$container->merge($tmpContainer);
$container->getParameterBag()->add($parameters);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
$container->getParameterBag()->add($parameters);
}
}

View File

@ -180,7 +180,7 @@ class GraphvizDumper extends Dumper
foreach ($container->getServiceIds() as $id) {
$service = $container->get($id);
if (in_array($id, array_keys($container->getAliases()))) {
if (array_key_exists($id, $container->getAliases())) {
continue;
}

View File

@ -560,7 +560,7 @@ class PhpDumper extends Dumper
if ($definition->isSynthetic()) {
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
} elseif ($class = $definition->getClass()) {
$return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : "\\".$class, $class);
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : "\\".$class, $class);
} elseif ($definition->getFactory()) {
$factory = $definition->getFactory();
if (is_string($factory)) {
@ -820,7 +820,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
$bagClass
/**
* $class
* $class.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
@ -1235,7 +1235,7 @@ EOF;
*
* @return bool
*/
private function hasReference($id, array $arguments, $deep = false, array $visited = array())
private function hasReference($id, array $arguments, $deep = false, array &$visited = array())
{
foreach ($arguments as $argument) {
if (is_array($argument)) {
@ -1334,7 +1334,7 @@ EOF;
} elseif (null !== $value->getFactoryService()) {
$service = $this->dumpValue($value->getFactoryService());
return sprintf("%s->%s(%s)", 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments));
return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments));
} else {
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
}
@ -1475,14 +1475,14 @@ EOF;
$i = $this->variableCount;
if ('' === $name) {
$name .= $firstChars[$i%$firstCharsLength];
$i = (int) ($i/$firstCharsLength);
$name .= $firstChars[$i % $firstCharsLength];
$i = (int) ($i / $firstCharsLength);
}
while ($i > 0) {
--$i;
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
$i = (int) ($i/$nonFirstCharsLength);
$name .= $nonFirstChars[$i % $nonFirstCharsLength];
$i = (int) ($i / $nonFirstCharsLength);
}
++$this->variableCount;

View File

@ -254,6 +254,23 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $factory[0]);
}
public function testProcessDoesNotInlineConfigurators()
{
$container = new ContainerBuilder();
$container
->register('foo.configurator')
->setPublic(false)
;
$container
->register('foo')
->setConfigurator(array(new Reference('foo.configurator'), 'getFoo'))
;
$this->process($container);
$configurator = $container->getDefinition('foo')->getConfigurator();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $configurator[0]);
}
protected function process(ContainerBuilder $container)
{
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass()));

View File

@ -1,6 +1,5 @@
<?php
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;

View File

@ -48,8 +48,8 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
'.' => 'dot as a key',
'.\'\'.' => 'concatenation as a key',
'\'\'.' => 'concatenation from the start key',
'optimize concatenation' => "string1%some_string%string2",
'optimize concatenation with empty string' => "string1%empty_value%string2",
'optimize concatenation' => 'string1%some_string%string2',
'optimize concatenation with empty string' => 'string1%empty_value%string2',
'optimize concatenation from the start' => '%empty_value%start',
'optimize concatenation at the end' => 'end%empty_value%',
));

View File

@ -145,6 +145,7 @@ class XmlDumperTest extends \PHPUnit_Framework_TestCase
{
return array(
array('container8'),
array('container9'),
array('container11'),
array('container12'),
array('container14'),

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/**
* ProjectServiceContainer
* ProjectServiceContainer.
*
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
@ -37,6 +37,7 @@ class ProjectServiceContainer extends Container
$this->methodMap = array(
'bar' => 'getBarService',
'baz' => 'getBazService',
'configurator_service' => 'getConfiguratorServiceService',
'configured_service' => 'getConfiguredServiceService',
'decorator_service' => 'getDecoratorServiceService',
'decorator_service_with_name' => 'getDecoratorServiceWithNameService',
@ -113,12 +114,9 @@ class ProjectServiceContainer extends Container
*/
protected function getConfiguredServiceService()
{
$a = new \ConfClass();
$a->setFoo($this->get('baz'));
$this->services['configured_service'] = $instance = new \stdClass();
$a->configureStdClass($instance);
$this->get('configurator_service')->configureStdClass($instance);
return $instance;
}
@ -326,6 +324,27 @@ class ProjectServiceContainer extends Container
}
}
/**
* Gets the 'configurator_service' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* This service is private.
* If you want to be able to request this service from the container directly,
* make it public, otherwise you might end up with broken code.
*
* @return \ConfClass A ConfClass instance.
*/
protected function getConfiguratorServiceService()
{
$this->services['configurator_service'] = $instance = new \ConfClass();
$instance->setFoo($this->get('baz'));
return $instance;
}
/**
* Gets the 'new_factory' service.
*

View File

@ -260,31 +260,31 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
public function testConvertDomElementToArray()
{
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo>bar</foo>');
$this->assertEquals('bar', XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo foo="bar" />');
$this->assertEquals(array('foo' => 'bar'), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo>bar</foo></foo>');
$this->assertEquals(array('foo' => 'bar'), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo>bar<foo>bar</foo></foo></foo>');
$this->assertEquals(array('foo' => array('value' => 'bar', 'foo' => 'bar')), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo></foo></foo>');
$this->assertEquals(array('foo' => null), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo><!-- foo --></foo></foo>');
$this->assertEquals(array('foo' => null), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
$doc = new \DOMDocument("1.0");
$doc = new \DOMDocument('1.0');
$doc->loadXML('<foo><foo foo="bar"/><foo foo="bar"/></foo>');
$this->assertEquals(array('foo' => array(array('foo' => 'bar'), array('foo' => 'bar'))), XmlFileLoader::convertDomElementToArray($doc->documentElement), '::convertDomElementToArray() converts a \DomElement to an array');
}

View File

@ -847,7 +847,7 @@ class Crawler extends \SplObjectStorage
}
}
return sprintf("concat(%s)", implode($parts, ', '));
return sprintf('concat(%s)', implode($parts, ', '));
}
/**
@ -1027,7 +1027,7 @@ class Crawler extends \SplObjectStorage
*/
private function findNamespacePrefixes($xpath)
{
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*):[^"\/]/i', $xpath, $matches)) {
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*):[^"\/:]/i', $xpath, $matches)) {
return array_unique($matches['prefix']);
}

View File

@ -197,9 +197,18 @@ class Form extends Link implements \ArrayAccess
{
$uri = parent::getUri();
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')) && $queryString = http_build_query($this->getValues(), null, '&')) {
$sep = false === strpos($uri, '?') ? '?' : '&';
$uri .= $sep.$queryString;
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
$query = parse_url($uri, PHP_URL_QUERY);
$currentParameters = array();
if ($query) {
parse_str($query, $currentParameters);
}
$queryString = http_build_query(array_merge($currentParameters, $this->getValues()), null, '&');
$pos = strpos($uri, '?');
$base = false === $pos ? $uri : substr($uri, 0, $pos);
$uri = rtrim($base.'?'.$queryString, '?');
}
return $uri;

View File

@ -33,16 +33,16 @@ class FormFieldRegistry
{
$segments = $this->getSegments($field->getName());
$target = & $this->fields;
$target = &$this->fields;
while ($segments) {
if (!is_array($target)) {
$target = array();
}
$path = array_shift($segments);
if ('' === $path) {
$target = & $target[];
$target = &$target[];
} else {
$target = & $target[$path];
$target = &$target[$path];
}
}
$target = $field;
@ -58,13 +58,13 @@ class FormFieldRegistry
public function remove($name)
{
$segments = $this->getSegments($name);
$target = & $this->fields;
$target = &$this->fields;
while (count($segments) > 1) {
$path = array_shift($segments);
if (!array_key_exists($path, $target)) {
return;
}
$target = & $target[$path];
$target = &$target[$path];
}
unset($target[array_shift($segments)]);
}
@ -82,13 +82,13 @@ class FormFieldRegistry
public function &get($name)
{
$segments = $this->getSegments($name);
$target = & $this->fields;
$target = &$this->fields;
while ($segments) {
$path = array_shift($segments);
if (!array_key_exists($path, $target)) {
throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path));
}
$target = & $target[$path];
$target = &$target[$path];
}
return $target;
@ -123,7 +123,7 @@ class FormFieldRegistry
*/
public function set($name, $value)
{
$target = & $this->get($name);
$target = &$this->get($name);
if (!is_array($value) || $target instanceof Field\ChoiceFormField) {
$target->setValue($value);
} else {
@ -176,7 +176,7 @@ class FormFieldRegistry
private function walk(array $array, $base = '', array &$output = array())
{
foreach ($array as $k => $v) {
$path = empty($base) ? $k : sprintf("%s[%s]", $base, $k);
$path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
if (is_array($v)) {
$this->walk($v, $path, $output);
} else {

View File

@ -417,7 +417,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
public function testMultiselectSetValues()
{
$form = $this->createForm('<form><select multiple="multiple" name="multi"><option value="foo">foo</option><option value="bar">bar</option></select><input type="submit" /></form>');
$form->setValues(array('multi' => array("foo", "bar")));
$form->setValues(array('multi' => array('foo', 'bar')));
$this->assertEquals(array('multi' => array('foo', 'bar')), $form->getValues(), '->setValue() sets the values of select');
}
@ -593,6 +593,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
array(),
'/foo?bar=bar&foo=foo',
),
array(
'replaces query values with the form values',
'<form action="/foo?bar=bar"><input type="text" name="bar" value="foo" /><input type="submit" /></form>',
array(),
'/foo?bar=foo',
),
array(
'returns an empty URI if the action is empty',
'<form><input type="submit" /></form>',

View File

@ -84,12 +84,12 @@ class Cookie
$str = urlencode($this->getName()).'=';
if ('' === (string) $this->getValue()) {
$str .= 'deleted; expires='.gmdate("D, d-M-Y H:i:s T", time() - 31536001);
$str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001);
} else {
$str .= urlencode($this->getValue());
if ($this->getExpiresTime() !== 0) {
$str .= '; expires='.gmdate("D, d-M-Y H:i:s T", $this->getExpiresTime());
$str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime());
}
}

View File

@ -140,10 +140,10 @@ class FileBag extends ParameterBag
unset($files[$k]);
}
foreach (array_keys($data['name']) as $key) {
foreach ($data['name'] as $key => $name) {
$files[$key] = $this->fixPhpFilesArray(array(
'error' => $data['error'][$key],
'name' => $data['name'][$key],
'name' => $name,
'type' => $data['type'][$key],
'tmp_name' => $data['tmp_name'][$key],
'size' => $data['size'][$key],

View File

@ -107,11 +107,11 @@ class IpUtils
$netmask = 128;
}
$bytesAddr = unpack("n*", inet_pton($address));
$bytesTest = unpack("n*", inet_pton($requestIp));
$bytesAddr = unpack('n*', inet_pton($address));
$bytesTest = unpack('n*', inet_pton($requestIp));
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; $i++) {
$left = $netmask - 16 * ($i-1);
$left = $netmask - 16 * ($i - 1);
$left = ($left <= 16) ? $left : 16;
$mask = ~(0xffff >> $left) & 0xffff;
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {

View File

@ -825,7 +825,7 @@ class Request
{
$ip = $this->server->get('REMOTE_ADDR');
if (!self::$trustedProxies) {
if (!$this->isFromTrustedProxy()) {
return array($ip);
}
@ -991,7 +991,7 @@ class Request
*/
public function getPort()
{
if (self::$trustedProxies) {
if ($this->isFromTrustedProxy()) {
if (self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) {
return $port;
}
@ -1172,7 +1172,7 @@ class Request
*/
public function isSecure()
{
if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) {
if ($this->isFromTrustedProxy() && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) {
return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1'));
}
@ -1200,7 +1200,7 @@ class Request
*/
public function getHost()
{
if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) {
if ($this->isFromTrustedProxy() && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) {
$elements = explode(',', $host);
$host = $elements[count($elements) - 1];
@ -1583,7 +1583,7 @@ class Request
foreach (array_keys($languages) as $lang) {
if (strstr($lang, '-')) {
$codes = explode('-', $lang);
if ($codes[0] == 'i') {
if ('i' === $codes[0]) {
// Language not listed in ISO 639 that are not variants
// of any listed language, which can be registered with the
// i-prefix, such as i-cherokee
@ -1592,7 +1592,7 @@ class Request
}
} else {
for ($i = 0, $max = count($codes); $i < $max; $i++) {
if ($i == 0) {
if ($i === 0) {
$lang = strtolower($codes[0]);
} else {
$lang .= '_'.strtoupper($codes[$i]);
@ -1917,4 +1917,9 @@ class Request
return new static($query, $request, $attributes, $cookies, $files, $server, $content);
}
private function isFromTrustedProxy()
{
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
}
}

View File

@ -1267,7 +1267,7 @@ class Response
protected function ensureIEOverSSLCompatibility(Request $request)
{
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
if ((int) preg_replace("/(MSIE )(.*?);/", "$2", $match[0]) < 9) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
$this->headers->remove('Cache-Control');
}
}

View File

@ -73,7 +73,7 @@ class NamespacedAttributeBag extends AttributeBag
*/
public function set($name, $value)
{
$attributes = & $this->resolveAttributePath($name, true);
$attributes = &$this->resolveAttributePath($name, true);
$name = $this->resolveKey($name);
$attributes[$name] = $value;
}
@ -84,7 +84,7 @@ class NamespacedAttributeBag extends AttributeBag
public function remove($name)
{
$retval = null;
$attributes = & $this->resolveAttributePath($name);
$attributes = &$this->resolveAttributePath($name);
$name = $this->resolveKey($name);
if (null !== $attributes && array_key_exists($name, $attributes)) {
$retval = $attributes[$name];
@ -106,7 +106,7 @@ class NamespacedAttributeBag extends AttributeBag
*/
protected function &resolveAttributePath($name, $writeContext = false)
{
$array = & $this->attributes;
$array = &$this->attributes;
$name = (strpos($name, $this->namespaceCharacter) === 0) ? substr($name, 1) : $name;
// Check if there is anything to do, else return
@ -125,14 +125,14 @@ class NamespacedAttributeBag extends AttributeBag
return $array;
}
unset($parts[count($parts)-1]);
unset($parts[count($parts) - 1]);
foreach ($parts as $part) {
if (null !== $array && !array_key_exists($part, $array)) {
$array[$part] = $writeContext ? array() : null;
}
$array = & $array[$part];
$array = &$array[$part];
}
return $array;
@ -150,7 +150,7 @@ class NamespacedAttributeBag extends AttributeBag
protected function resolveKey($name)
{
if (false !== $pos = strrpos($name, $this->namespaceCharacter)) {
$name = substr($name, $pos+1);
$name = substr($name, $pos + 1);
}
return $name;

View File

@ -159,7 +159,7 @@ class MockArraySessionStorage implements SessionStorageInterface
public function save()
{
if (!$this->started || $this->closed) {
throw new \RuntimeException("Trying to save a session that was not started yet or was already closed");
throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
}
// nothing to do since we don't persist the session data
$this->closed = false;

View File

@ -93,7 +93,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
public function save()
{
if (!$this->started) {
throw new \RuntimeException("Trying to save a session that was not started yet or was already closed");
throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
}
file_put_contents($this->getFilePath(), serialize($this->data));

View File

@ -25,9 +25,9 @@ class CookieTest extends \PHPUnit_Framework_TestCase
{
return array(
array(''),
array(",MyName"),
array(";MyName"),
array(" MyName"),
array(',MyName'),
array(';MyName'),
array(' MyName'),
array("\tMyName"),
array("\rMyName"),
array("\nMyName"),
@ -89,7 +89,7 @@ class CookieTest extends \PHPUnit_Framework_TestCase
public function testGetExpiresTimeWithStringValue()
{
$value = "+1 day";
$value = '+1 day';
$cookie = new Cookie('foo', 'bar', $value);
$expire = strtotime($value);
@ -119,14 +119,14 @@ class CookieTest extends \PHPUnit_Framework_TestCase
public function testCookieIsNotCleared()
{
$cookie = new Cookie('foo', 'bar', time()+3600*24);
$cookie = new Cookie('foo', 'bar', time() + 3600 * 24);
$this->assertFalse($cookie->isCleared(), '->isCleared() returns false if the cookie did not expire yet');
}
public function testCookieIsCleared()
{
$cookie = new Cookie('foo', 'bar', time()-20);
$cookie = new Cookie('foo', 'bar', time() - 20);
$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');
}
@ -137,7 +137,7 @@ class CookieTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly', $cookie->__toString(), '->__toString() returns string representation of the cookie');
$cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com');
$this->assertEquals('foo=deleted; expires='.gmdate("D, d-M-Y H:i:s T", time()-31536001).'; path=/admin/; domain=.myfoodomain.com; httponly', $cookie->__toString(), '->__toString() returns string representation of a cleared cookie if value is NULL');
$this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/admin/; domain=.myfoodomain.com; httponly', $cookie->__toString(), '->__toString() returns string representation of a cleared cookie if value is NULL');
$cookie = new Cookie('foo', 'bar', 0, '/', '');
$this->assertEquals('foo=bar; path=/; httponly', $cookie->__toString());

View File

@ -75,7 +75,7 @@ class MimeTypeTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Can not verify chmod operations on Windows');
}
if (in_array(get_current_user(), array('root'))) {
if ('root' === get_current_user()) {
$this->markTestSkipped('This test will fail if run under superuser');
}

View File

@ -40,7 +40,7 @@ class HeaderBagTest extends \PHPUnit_Framework_TestCase
{
$bag = new HeaderBag(array('foo' => 'bar'));
$keys = $bag->keys();
$this->assertEquals("foo", $keys[0]);
$this->assertEquals('foo', $keys[0]);
}
public function testGetDate()

View File

@ -212,13 +212,13 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array(
'flags' => FILTER_FLAG_ALLOW_HEX,
'options' => array('min_range' => 1, 'max_range' => 0xff))
), '->filter() gets a value of parameter as integer between boundaries');
'options' => array('min_range' => 1, 'max_range' => 0xff),
)), '->filter() gets a value of parameter as integer between boundaries');
$this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array(
'flags' => FILTER_FLAG_ALLOW_HEX,
'options' => array('min_range' => 1, 'max_range' => 0xff))
), '->filter() gets a value of parameter as integer between boundaries');
'options' => array('min_range' => 1, 'max_range' => 0xff),
)), '->filter() gets a value of parameter as integer between boundaries');
$this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array');
}

View File

@ -723,35 +723,37 @@ class RequestTest extends \PHPUnit_Framework_TestCase
'HTTP_X_FORWARDED_PROTO' => 'https',
'HTTP_X_FORWARDED_PORT' => '8443',
));
$port = $request->getPort();
$this->assertEquals(8443, $port, 'With PROTO and PORT set PORT takes precedence.');
$this->assertEquals(80, $request->getPort(), 'With PROTO and PORT on untrusted connection server value takes precedence.');
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$this->assertEquals(8443, $request->getPort(), 'With PROTO and PORT set PORT takes precedence.');
$request = Request::create('http://example.com', 'GET', array(), array(), array(), array(
'HTTP_X_FORWARDED_PROTO' => 'https',
));
$port = $request->getPort();
$this->assertEquals(443, $port, 'With only PROTO set getPort() defaults to 443.');
$this->assertEquals(80, $request->getPort(), 'With only PROTO set getPort() ignores trusted headers on untrusted connection.');
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$this->assertEquals(443, $request->getPort(), 'With only PROTO set getPort() defaults to 443.');
$request = Request::create('http://example.com', 'GET', array(), array(), array(), array(
'HTTP_X_FORWARDED_PROTO' => 'http',
));
$port = $request->getPort();
$this->assertEquals(80, $port, 'If X_FORWARDED_PROTO is set to HTTP return 80.');
$this->assertEquals(80, $request->getPort(), 'If X_FORWARDED_PROTO is set to HTTP getPort() ignores trusted headers on untrusted connection.');
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$this->assertEquals(80, $request->getPort(), 'If X_FORWARDED_PROTO is set to HTTP getPort() returns port of the original request.');
$request = Request::create('http://example.com', 'GET', array(), array(), array(), array(
'HTTP_X_FORWARDED_PROTO' => 'On',
));
$port = $request->getPort();
$this->assertEquals(443, $port, 'With only PROTO set and value is On, getPort() defaults to 443.');
$this->assertEquals(80, $request->getPort(), 'With only PROTO set and value is On, getPort() ignores trusted headers on untrusted connection.');
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$this->assertEquals(443, $request->getPort(), 'With only PROTO set and value is On, getPort() defaults to 443.');
$request = Request::create('http://example.com', 'GET', array(), array(), array(), array(
'HTTP_X_FORWARDED_PROTO' => '1',
));
$port = $request->getPort();
$this->assertEquals(443, $port, 'With only PROTO set and value is 1, getPort() defaults to 443.');
$this->assertEquals(80, $request->getPort(), 'With only PROTO set and value is 1, getPort() ignores trusted headers on untrusted connection.');
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$this->assertEquals(443, $request->getPort(), 'With only PROTO set and value is 1, getPort() defaults to 443.');
$request = Request::create('http://example.com', 'GET', array(), array(), array(), array(
'HTTP_X_FORWARDED_PROTO' => 'something-else',
@ -918,7 +920,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$req = new Request();
$retval = $req->getContent(true);
$this->assertInternalType('resource', $retval);
$this->assertEquals("", fread($retval, 1));
$this->assertEquals('', fread($retval, 1));
$this->assertTrue(feof($retval));
}
@ -1021,6 +1023,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$request->headers->set('X_FORWARDED_PROTO', 'https');
Request::setTrustedProxies(array('1.1.1.1'));
$this->assertFalse($request->isSecure());
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$this->assertTrue($request->isSecure());
Request::setTrustedProxies(array());
@ -1480,7 +1484,15 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(443, $request->getPort());
$this->assertTrue($request->isSecure());
// trusted proxy via setTrustedProxies()
Request::setTrustedProxies(array('3.3.3.4', '2.2.2.2'));
$this->assertEquals('3.3.3.3', $request->getClientIp());
$this->assertEquals('example.com', $request->getHost());
$this->assertEquals(80, $request->getPort());
$this->assertFalse($request->isSecure());
// check various X_FORWARDED_PROTO header values
Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2'));
$request->headers->set('X_FORWARDED_PROTO', 'ssl');
$this->assertTrue($request->isSecure());

View File

@ -114,11 +114,11 @@ class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
$bag = new ResponseHeaderBag(array());
$bag->setCookie(new Cookie('foo', 'bar'));
$this->assertContains("Set-Cookie: foo=bar; path=/; httponly", explode("\r\n", $bag->__toString()));
$this->assertContains('Set-Cookie: foo=bar; path=/; httponly', explode("\r\n", $bag->__toString()));
$bag->clearCookie('foo');
$this->assertContains("Set-Cookie: foo=deleted; expires=".gmdate("D, d-M-Y H:i:s T", time() - 31536001)."; path=/; httponly", explode("\r\n", $bag->__toString()));
$this->assertContains('Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; httponly', explode("\r\n", $bag->__toString()));
}
public function testClearCookieSecureNotHttpOnly()
@ -164,10 +164,10 @@ class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
$this->assertCount(4, $bag->getCookies());
$headers = explode("\r\n", $bag->__toString());
$this->assertContains("Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly", $headers);
$this->assertContains("Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly", $headers);
$this->assertContains("Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly", $headers);
$this->assertContains("Set-Cookie: foo=bar; path=/; httponly", $headers);
$this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers);
$this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers);
$this->assertContains('Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly', $headers);
$this->assertContains('Set-Cookie: foo=bar; path=/; httponly', $headers);
$cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
$this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo']));

View File

@ -29,8 +29,8 @@ class ResponseTest extends ResponseTestCase
{
$response = new Response();
$response = explode("\r\n", $response);
$this->assertEquals("HTTP/1.0 200 OK", $response[0]);
$this->assertEquals("Cache-Control: no-cache", $response[1]);
$this->assertEquals('HTTP/1.0 200 OK', $response[0]);
$this->assertEquals('Cache-Control: no-cache', $response[1]);
}
public function testClone()
@ -545,7 +545,7 @@ class ResponseTest extends ResponseTestCase
$response = new Response();
//array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public')
try {
$response->setCache(array("wrong option" => "value"));
$response->setCache(array('wrong option' => 'value'));
$this->fail('->setCache() throws an InvalidArgumentException if an option is not supported');
} catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported');

View File

@ -86,7 +86,7 @@ class FilterControllerEvent extends KernelEvent
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
}
return sprintf("Array(%s)", implode(', ', $a));
return sprintf('Array(%s)', implode(', ', $a));
}
if (is_resource($var)) {

View File

@ -29,6 +29,10 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
class Esi implements SurrogateInterface
{
private $contentTypes;
private $phpEscapeMap = array(
array('<?', '<%', '<s', '<S'),
array('<?php echo "<?"; ?>', '<?php echo "<%"; ?>', '<?php echo "<s"; ?>', '<?php echo "<S"; ?>'),
);
/**
* Constructor.
@ -203,10 +207,34 @@ class Esi implements SurrogateInterface
// we don't use a proper XML parser here as we can have ESI tags in a plain text response
$content = $response->getContent();
$content = str_replace(array('<?', '<%'), array('<?php echo "<?"; ?>', '<?php echo "<%"; ?>'), $content);
$content = preg_replace_callback('#<esi\:include\s+(.*?)\s*(?:/|</esi\:include)>#', array($this, 'handleEsiIncludeTag'), $content);
$content = preg_replace('#<esi\:comment[^>]*(?:/|</esi\:comment)>#', '', $content);
$content = preg_replace('#<esi\:remove>.*?</esi\:remove>#', '', $content);
$content = preg_replace('#<esi\:comment[^>]*(?:/|</esi\:comment)>#', '', $content);
$chunks = preg_split('#<esi\:include\s+(.*?)\s*(?:/|</esi\:include)>#', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
$chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]);
$i = 1;
while (isset($chunks[$i])) {
$options = array();
preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER);
foreach ($matches as $set) {
$options[$set[1]] = $set[2];
}
if (!isset($options['src'])) {
throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.');
}
$chunks[$i] = sprintf('<?php echo $this->surrogate->handle($this, %s, %s, %s) ?>'."\n",
var_export($options['src'], true),
var_export(isset($options['alt']) ? $options['alt'] : '', true),
isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false'
);
++$i;
$chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]);
++$i;
}
$content = implode('', $chunks);
$response->setContent($content);
$response->headers->set('X-Body-Eval', 'ESI');
@ -259,32 +287,4 @@ class Esi implements SurrogateInterface
}
}
}
/**
* Handles an ESI include tag (called internally).
*
* @param array $attributes An array containing the attributes.
*
* @return string The response content for the include.
*
* @throws \RuntimeException
*/
private function handleEsiIncludeTag($attributes)
{
$options = array();
preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $attributes[1], $matches, PREG_SET_ORDER);
foreach ($matches as $set) {
$options[$set[1]] = $set[2];
}
if (!isset($options['src'])) {
throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.');
}
return sprintf('<?php echo $this->surrogate->handle($this, %s, %s, %s) ?>'."\n",
var_export($options['src'], true),
var_export(isset($options['alt']) ? $options['alt'] : '', true),
isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false'
);
}
}

View File

@ -23,6 +23,10 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
class Ssi implements SurrogateInterface
{
private $contentTypes;
private $phpEscapeMap = array(
array('<?', '<%', '<s', '<S'),
array('<?php echo "<?"; ?>', '<?php echo "<%"; ?>', '<?php echo "<s"; ?>', '<?php echo "<S"; ?>'),
);
/**
* Constructor.
@ -122,8 +126,30 @@ class Ssi implements SurrogateInterface
// we don't use a proper XML parser here as we can have SSI tags in a plain text response
$content = $response->getContent();
$content = str_replace(array('<?', '<%'), array('<?php echo "<?"; ?>', '<?php echo "<%"; ?>'), $content);
$content = preg_replace_callback('#<!--\#include\s+(.*?)\s*-->#', array($this, 'handleIncludeTag'), $content);
$chunks = preg_split('#<!--\#include\s+(.*?)\s*-->#', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
$chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]);
$i = 1;
while (isset($chunks[$i])) {
$options = array();
preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER);
foreach ($matches as $set) {
$options[$set[1]] = $set[2];
}
if (!isset($options['virtual'])) {
throw new \RuntimeException('Unable to process an SSI tag without a "virtual" attribute.');
}
$chunks[$i] = sprintf('<?php echo $this->surrogate->handle($this, %s, \'\', false) ?>'."\n",
var_export($options['virtual'], true)
);
++$i;
$chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]);
++$i;
}
$content = implode('', $chunks);
$response->setContent($content);
$response->headers->set('X-Body-Eval', 'SSI');
@ -166,30 +192,4 @@ class Ssi implements SurrogateInterface
}
}
}
/**
* Handles an SSI include tag (called internally).
*
* @param array $attributes An array containing the attributes.
*
* @return string The response content for the include.
*
* @throws \RuntimeException
*/
private function handleIncludeTag($attributes)
{
$options = array();
preg_match_all('/(virtual)="([^"]*?)"/', $attributes[1], $matches, PREG_SET_ORDER);
foreach ($matches as $set) {
$options[$set[1]] = $set[2];
}
if (!isset($options['virtual'])) {
throw new \RuntimeException('Unable to process an SSI tag without a "virtual" attribute.');
}
return sprintf('<?php echo $this->surrogate->handle($this, %s, \'\', false) ?>'."\n",
var_export($options['virtual'], true)
);
}
}

View File

@ -267,7 +267,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
}
return sprintf("Array(%s)", implode(', ', $a));
return sprintf('Array(%s)', implode(', ', $a));
}
if (is_resource($var)) {

View File

@ -60,11 +60,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface
protected $startTime;
protected $loadClassCache;
const VERSION = '2.6.5';
const VERSION_ID = '20605';
const VERSION = '2.6.6';
const VERSION_ID = '20606';
const MAJOR_VERSION = '2';
const MINOR_VERSION = '6';
const RELEASE_VERSION = '5';
const RELEASE_VERSION = '6';
const EXTRA_VERSION = '';
/**

View File

@ -1,4 +1,5 @@
<?php
/*
* This file is part of the Symfony package.
*

View File

@ -124,10 +124,10 @@ class EsiTest extends \PHPUnit_Framework_TestCase
$esi = new Esi();
$request = Request::create('/');
$response = new Response('foo <?php die("foo"); ?><%= "lala" %>');
$response = new Response('<?php <? <% <script language=php>');
$esi->process($request, $response);
$this->assertEquals('foo <?php echo "<?"; ?>php die("foo"); ?><?php echo "<%"; ?>= "lala" %>', $response->getContent());
$this->assertEquals('<?php echo "<?"; ?>php <?php echo "<?"; ?> <?php echo "<%"; ?> <?php echo "<s"; ?>cript language=php>', $response->getContent());
}
/**

View File

@ -1067,7 +1067,7 @@ class HttpCacheTest extends HttpCacheTestCase
$this->setNextResponses($responses);
$this->request('GET', '/', array(), array(), true);
$this->assertEquals("Hello World! My name is Bobby.", $this->response->getContent());
$this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent());
// check for 100 or 99 as the test can be executed after a second change
$this->assertTrue(in_array($this->response->getTtl(), array(99, 100)));

View File

@ -113,10 +113,10 @@ class SsiTest extends \PHPUnit_Framework_TestCase
$ssi = new Ssi();
$request = Request::create('/');
$response = new Response('foo <?php die("foo"); ?><%= "lala" %>');
$response = new Response('<?php <? <% <script language=php>');
$ssi->process($request, $response);
$this->assertEquals('foo <?php echo "<?"; ?>php die("foo"); ?><?php echo "<%"; ?>= "lala" %>', $response->getContent());
$this->assertEquals('<?php echo "<?"; ?>php <?php echo "<?"; ?> <?php echo "<%"; ?> <?php echo "<s"; ?>cript language=php>', $response->getContent());
}
/**

View File

@ -1,4 +1,5 @@
<?php
/*
* This file is part of the Symfony package.
*
@ -16,7 +17,7 @@ abstract class AbstractProfilerStorageTest extends \PHPUnit_Framework_TestCase
{
public function testStore()
{
for ($i = 0; $i < 10; $i ++) {
for ($i = 0; $i < 10; $i++) {
$profile = new Profile('token_'.$i);
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar');

View File

@ -94,7 +94,7 @@ class FileProfilerStorageTest extends AbstractProfilerStorageTest
fwrite($h, "line1\n\n\nline2\n");
fseek($h, 0, SEEK_END);
$this->assertEquals("line2", $r->invoke(self::$storage, $h));
$this->assertEquals("line1", $r->invoke(self::$storage, $h));
$this->assertEquals('line2', $r->invoke(self::$storage, $h));
$this->assertEquals('line1', $r->invoke(self::$storage, $h));
}
}

View File

@ -254,8 +254,6 @@ class Process
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*
* @return Process The process itself
*
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
* @throws LogicException In case a callback is provided and output has been disabled
@ -798,7 +796,7 @@ class Process
$timeoutMicro = microtime(true) + $timeout;
if ($this->isRunning()) {
if ('\\' === DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) {
exec(sprintf("taskkill /F /T /PID %d 2>&1", $this->getPid()), $output, $exitCode);
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
if ($exitCode > 0) {
throw new RuntimeException('Unable to kill the process');
}

View File

@ -68,7 +68,7 @@ class ProcessBuilder
}
/**
* Adds an unescaped prefix to the command string.
* Adds a prefix to the command string.
*
* The prefix is preserved when resetting arguments.
*

View File

@ -93,7 +93,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
$proc = $pb->getProcess();
$this->assertContains("second", $proc->getCommandLine());
$this->assertContains('second', $proc->getCommandLine());
}
public function testPrefixIsPrependedToAllGeneratedProcess()

View File

@ -49,8 +49,8 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase
$cmd = 'php';
$exitCode = 1;
$exitText = 'General error';
$output = "Command output";
$errorOutput = "FATAL: Unexpected error";
$output = 'Command output';
$errorOutput = 'FATAL: Unexpected error';
$process = $this->getMock(
'Symfony\Component\Process\Process',

View File

@ -3,7 +3,7 @@
// required for signal handling
declare (ticks = 1);
pcntl_signal(SIGUSR1, function () {echo "Caught SIGUSR1"; exit;});
pcntl_signal(SIGUSR1, function () {echo 'Caught SIGUSR1'; exit;});
$n = 0;

View File

@ -64,8 +64,8 @@ class ApacheUrlMatcher extends UrlMatcher
continue;
}
if (false !== $pos = strpos($name, '_', 9)) {
$type = substr($name, 9, $pos-9);
$name = substr($name, $pos+1);
$type = substr($name, 9, $pos - 9);
$name = substr($name, $pos + 1);
} else {
$type = substr($name, 9);
}

View File

@ -76,7 +76,7 @@ class ApacheMatcherDumper extends MatcherDumper
$variables[] = sprintf('E=__ROUTING_host_%s:1', $hostRegexUnique);
foreach ($compiledRoute->getHostVariables() as $i => $variable) {
$variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i+1);
$variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i + 1);
}
$variables = implode(',', $variables);
@ -159,18 +159,18 @@ class ApacheMatcherDumper extends MatcherDumper
}
if ($compiledRoute->getHostRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique);
$rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique);
}
$rule[] = "RewriteCond %{REQUEST_URI} $regex";
$rule[] = sprintf("RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]", implode('|', $methods));
$rule[] = sprintf('RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]', implode('|', $methods));
$rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow));
}
// redirect with trailing slash appended
if ($hasTrailingSlash) {
if ($compiledRoute->getHostRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique);
$rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique);
}
$rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$';
@ -180,7 +180,7 @@ class ApacheMatcherDumper extends MatcherDumper
// the main rule
if ($compiledRoute->getHostRegex()) {
$rule[] = sprintf("RewriteCond %%{ENV:__ROUTING_host_%s} =1", $hostRegexUnique);
$rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique);
}
$rule[] = "RewriteCond %{REQUEST_URI} $regex";

View File

@ -67,7 +67,7 @@ class DumperPrefixCollection extends DumperCollection
// Prefix starts with route's prefix
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
$child = new DumperPrefixCollection();
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix)+1));
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1));
$collection->add($child);
return $child->addPrefixRoute($route);
@ -75,7 +75,7 @@ class DumperPrefixCollection extends DumperCollection
}
// Reached only if the root has a non empty prefix
throw new \LogicException("The collection root must not have a prefix");
throw new \LogicException('The collection root must not have a prefix');
}
/**

View File

@ -63,7 +63,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
/**
* {$options['class']}
* {$options['class']}.
*
* This class has been auto-generated
* by the Symfony Routing Component.

View File

@ -218,7 +218,7 @@ class RouteCompiler implements RouteCompilerInterface
$nbTokens = count($tokens);
if ($nbTokens - 1 == $index) {
// Close the optional subpatterns
$regexp .= str_repeat(")?", $nbTokens - $firstOptional - (0 === $firstOptional ? 1 : 0));
$regexp .= str_repeat(')?', $nbTokens - $firstOptional - (0 === $firstOptional ? 1 : 0));
}
}

View File

@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
/**
* ProjectUrlMatcher
* ProjectUrlMatcher.
*
* This class has been auto-generated
* by the Symfony Routing Component.

View File

@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
/**
* ProjectUrlMatcher
* ProjectUrlMatcher.
*
* This class has been auto-generated
* by the Symfony Routing Component.

View File

@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
/**
* ProjectUrlMatcher
* ProjectUrlMatcher.
*
* This class has been auto-generated
* by the Symfony Routing Component.

View File

@ -1,4 +1,5 @@
<?php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

View File

@ -368,7 +368,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
if (is_array($data) || $data instanceof \Traversable) {
foreach ($data as $key => $data) {
//Ah this is the magic @ attribute types.
if (0 === strpos($key, "@") && is_scalar($data) && $this->isElementNameValid($attributeName = substr($key, 1))) {
if (0 === strpos($key, '@') && is_scalar($data) && $this->isElementNameValid($attributeName = substr($key, 1))) {
$parentNode->setAttribute($attributeName, $data);
} elseif ($key === '#') {
$append = $this->selectNodeType($parentNode, $data);
@ -387,7 +387,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
$append = $this->appendNode($parentNode, $data, $key);
}
} elseif (is_numeric($key) || !$this->isElementNameValid($key)) {
$append = $this->appendNode($parentNode, $data, "item", $key);
$append = $this->appendNode($parentNode, $data, 'item', $key);
} else {
$append = $this->appendNode($parentNode, $data, $key);
}

View File

@ -26,7 +26,7 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase
public function testEncodeScalar()
{
$obj = new \stdClass();
$obj->foo = "foo";
$obj->foo = 'foo';
$expected = '{"foo":"foo"}';
@ -47,14 +47,14 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase
$context = array('json_encode_options' => JSON_NUMERIC_CHECK);
$arr = array();
$arr['foo'] = "3";
$arr['foo'] = '3';
$expected = '{"foo":3}';
$this->assertEquals($expected, $this->serializer->serialize($arr, 'json', $context));
$arr = array();
$arr['foo'] = "3";
$arr['foo'] = '3';
$expected = '{"foo":"3"}';
@ -72,7 +72,7 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase
$obj->foo = 'foo';
$obj->bar = array('a', 'b');
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));
$obj->qux = "1";
$obj->qux = '1';
return $obj;
}

View File

@ -32,7 +32,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
public function testEncodeScalar()
{
$obj = new ScalarDummy();
$obj->xmlFoo = "foo";
$obj->xmlFoo = 'foo';
$expected = '<?xml version="1.0"?>'."\n".
'<response>foo</response>'."\n";
@ -43,7 +43,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
public function testSetRootNodeName()
{
$obj = new ScalarDummy();
$obj->xmlFoo = "foo";
$obj->xmlFoo = 'foo';
$this->encoder->setRootNodeName('test');
$expected = '<?xml version="1.0"?>'."\n".
@ -70,11 +70,11 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
'@name' => 'Bar',
),
'Foo' => array(
'Bar' => "Test",
'Bar' => 'Test',
'@Type' => 'test',
),
'föo_bär' => 'a',
"Bar" => array(1,2,3),
'Bar' => array(1,2,3),
'a' => 'b',
);
$expected = '<?xml version="1.0"?>'."\n".
@ -356,28 +356,28 @@ XML;
$obj = new ScalarDummy();
$obj->xmlFoo = array(
'foo-bar' => array(
'@key' => "value",
'item' => array("@key" => 'key', "key-val" => 'val'),
'@key' => 'value',
'item' => array('@key' => 'key', 'key-val' => 'val'),
),
'Foo' => array(
'Bar' => "Test",
'Bar' => 'Test',
'@Type' => 'test',
),
'föo_bär' => 'a',
"Bar" => array(1,2,3),
'Bar' => array(1,2,3),
'a' => 'b',
);
$expected = array(
'foo-bar' => array(
'@key' => "value",
'key' => array('@key' => 'key', "key-val" => 'val'),
'@key' => 'value',
'key' => array('@key' => 'key', 'key-val' => 'val'),
),
'Foo' => array(
'Bar' => "Test",
'Bar' => 'Test',
'@Type' => 'test',
),
'föo_bär' => 'a',
"Bar" => array(1,2,3),
'Bar' => array(1,2,3),
'a' => 'b',
);
$xml = $this->encoder->encode($obj, 'xml');
@ -483,7 +483,7 @@ XML;
$obj->foo = 'foo';
$obj->bar = array('a', 'b');
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));
$obj->qux = "1";
$obj->qux = '1';
return $obj;
}

View File

@ -374,7 +374,7 @@ class GetSetDummy
public function otherMethod()
{
throw new \RuntimeException("Dummy::otherMethod() should not be called");
throw new \RuntimeException('Dummy::otherMethod() should not be called');
}
public function setObject($object)
@ -418,7 +418,7 @@ class GetConstructorDummy
public function otherMethod()
{
throw new \RuntimeException("Dummy::otherMethod() should not be called");
throw new \RuntimeException('Dummy::otherMethod() should not be called');
}
}
@ -456,6 +456,6 @@ class GetConstructorOptionalArgsDummy
public function otherMethod()
{
throw new \RuntimeException("Dummy::otherMethod() should not be called");
throw new \RuntimeException('Dummy::otherMethod() should not be called');
}
}

View File

@ -125,6 +125,6 @@ class EmailValidator extends ConstraintValidator
*/
private function checkHost($host)
{
return $this->checkMX($host) || (checkdnsrr($host, "A") || checkdnsrr($host, "AAAA"));
return $this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'));
}
}

View File

@ -119,7 +119,7 @@ class IssnValidator extends ConstraintValidator
for ($i = 0; $i < 7; ++$i) {
// Multiply the first digit by 8, the second by 7, etc.
$checkSum += (8-$i) * $canonical{$i};
$checkSum += (8 - $i) * $canonical{$i};
}
if (0 !== $checkSum % 11) {

View File

@ -75,16 +75,16 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
public function testAcceptOptionalConstraintAsOneElementArray()
{
$collection1 = new Collection(array(
"fields" => array(
"alternate_email" => array(
'fields' => array(
'alternate_email' => array(
new Optional(new Email()),
),
),
));
$collection2 = new Collection(array(
"fields" => array(
"alternate_email" => new Optional(new Email()),
'fields' => array(
'alternate_email' => new Optional(new Email()),
),
));
@ -94,16 +94,16 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
public function testAcceptRequiredConstraintAsOneElementArray()
{
$collection1 = new Collection(array(
"fields" => array(
"alternate_email" => array(
'fields' => array(
'alternate_email' => array(
new Required(new Email()),
),
),
));
$collection2 = new Collection(array(
"fields" => array(
"alternate_email" => new Required(new Email()),
'fields' => array(
'alternate_email' => new Required(new Email()),
),
));

View File

@ -165,7 +165,7 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
*/
public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limitAsString, $suffix)
{
fseek($this->file, $bytesWritten-1, SEEK_SET);
fseek($this->file, $bytesWritten - 1, SEEK_SET);
fwrite($this->file, '0');
fclose($this->file);
@ -213,7 +213,7 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
*/
public function testMaxSizeNotExceeded($bytesWritten, $limit)
{
fseek($this->file, $bytesWritten-1, SEEK_SET);
fseek($this->file, $bytesWritten - 1, SEEK_SET);
fwrite($this->file, '0');
fclose($this->file);

View File

@ -94,10 +94,10 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
}
return array(
array("é", "utf8", true),
array("\xE9", "CP1252", true),
array("\xE9", "XXX", false),
array("\xE9", "utf8", false),
array('é', 'utf8', true),
array("\xE9", 'CP1252', true),
array("\xE9", 'XXX', false),
array("\xE9", 'utf8', false),
);
}

View File

@ -149,6 +149,7 @@ class Inline
case Escaper::requiresDoubleQuoting($value):
return Escaper::escapeWithDoubleQuotes($value);
case Escaper::requiresSingleQuoting($value):
case preg_match(self::getHexRegex(), $value):
case preg_match(self::getTimestampRegex(), $value):
return Escaper::escapeWithSingleQuotes($value);
default:
@ -491,6 +492,7 @@ class Inline
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
case is_numeric($scalar):
case preg_match(self::getHexRegex(), $scalar):
return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
case '.inf' === $scalarLower:
case '.nan' === $scalarLower:
@ -531,4 +533,14 @@ class Inline
$~x
EOF;
}
/**
* Gets a regex that matches a YAML number in hexadecimal notation.
*
* @return string
*/
private static function getHexRegex()
{
return '~^0x[0-9a-f]++$~i';
}
}

View File

@ -94,7 +94,7 @@ class Parser
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser->refs = & $this->refs;
$parser->refs = &$this->refs;
$data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap);
} else {
if (isset($values['leadspaces'])
@ -103,7 +103,7 @@ class Parser
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
$parser = new Parser($c);
$parser->refs = & $this->refs;
$parser->refs = &$this->refs;
$block = $values['value'];
if ($this->isNextLineIndented()) {
@ -160,7 +160,7 @@ class Parser
}
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser->refs = & $this->refs;
$parser->refs = &$this->refs;
$parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap);
if (!is_array($parsed)) {
@ -211,7 +211,7 @@ class Parser
} else {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser->refs = & $this->refs;
$parser->refs = &$this->refs;
$value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport, $objectForMap);
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.

View File

@ -52,7 +52,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
$required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
if (false === setlocale(LC_ALL, $required_locales)) {
$this->markTestSkipped('Could not set any of required locales: '.implode(", ", $required_locales));
$this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales));
}
$this->assertEquals('1.2', Inline::dump(1.2));

View File

@ -259,8 +259,8 @@ bar: >-
EOF;
$expected = array(
'foo' => "one two",
'bar' => "one two",
'foo' => 'one two',
'bar' => 'one two',
);
$tests['Folded block chomping strip with single trailing newline'] = array($expected, $yaml);
@ -276,8 +276,8 @@ bar: >-
EOF;
$expected = array(
'foo' => "one two",
'bar' => "one two",
'foo' => 'one two',
'bar' => 'one two',
);
$tests['Folded block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
@ -290,8 +290,8 @@ bar: >-
two
EOF;
$expected = array(
'foo' => "one two",
'bar' => "one two",
'foo' => 'one two',
'bar' => 'one two',
);
$tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml);
@ -337,7 +337,7 @@ bar: >
EOF;
$expected = array(
'foo' => "one two\n",
'bar' => "one two",
'bar' => 'one two',
);
$tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml);
@ -383,7 +383,7 @@ bar: >+
EOF;
$expected = array(
'foo' => "one two\n",
'bar' => "one two",
'bar' => 'one two',
);
$tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml);
@ -455,9 +455,9 @@ EOF;
}
$yamls = array(
iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"),
iconv("UTF-8", "ISO-8859-15", "euro: '€'"),
iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'"),
iconv('UTF-8', 'ISO-8859-1', "foo: 'äöüß'"),
iconv('UTF-8', 'ISO-8859-15', "euro: '€'"),
iconv('UTF-8', 'CP1252', "cp1252: '©ÉÇáñ'"),
);
foreach ($yamls as $yaml) {