Issue #2565337 by hussainweb, joshtaylor: Upgrade to Symfony 2.7.4

8.0.x
webchick 2015-09-09 01:00:18 -07:00
parent bcea78945f
commit c1be7e7b3f
175 changed files with 2345 additions and 1545 deletions

173
core/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "641da18dedf5e11a7de3978b8fe619d6",
"hash": "e789e5736fbe96c9b9502e89b53dcebe",
"packages": [
{
"name": "behat/mink",
@ -2109,16 +2109,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
"reference": "176905d3d74c2f99e6ab70f4f5a89460532495ae"
"reference": "277a2457776d4cc25706fbdd9d1e4ab2dac884e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/176905d3d74c2f99e6ab70f4f5a89460532495ae",
"reference": "176905d3d74c2f99e6ab70f4f5a89460532495ae",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/277a2457776d4cc25706fbdd9d1e4ab2dac884e4",
"reference": "277a2457776d4cc25706fbdd9d1e4ab2dac884e4",
"shasum": ""
},
"require": {
@ -2160,20 +2160,20 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-09-06 08:36:38"
},
{
"name": "symfony/class-loader",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/ClassLoader.git",
"reference": "2fccbc544997340808801a7410cdcb96dd12edc4"
"reference": "d957ea6295d7016e20d7eff33a6c1deef819c0d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/2fccbc544997340808801a7410cdcb96dd12edc4",
"reference": "2fccbc544997340808801a7410cdcb96dd12edc4",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/d957ea6295d7016e20d7eff33a6c1deef819c0d4",
"reference": "d957ea6295d7016e20d7eff33a6c1deef819c0d4",
"shasum": ""
},
"require": {
@ -2210,20 +2210,20 @@
],
"description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com",
"time": "2015-06-25 12:52:11"
"time": "2015-08-26 17:56:37"
},
{
"name": "symfony/console",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e"
"reference": "9ff9032151186bd66ecee727d728f1319f52d1d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/d6cf02fe73634c96677e428f840704bfbcaec29e",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e",
"url": "https://api.github.com/repos/symfony/Console/zipball/9ff9032151186bd66ecee727d728f1319f52d1d8",
"reference": "9ff9032151186bd66ecee727d728f1319f52d1d8",
"shasum": ""
},
"require": {
@ -2267,20 +2267,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 15:18:12"
"time": "2015-09-03 11:40:38"
},
{
"name": "symfony/css-selector",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/CssSelector.git",
"reference": "0b5c07b516226b7dd32afbbc82fe547a469c5092"
"reference": "ffb5f3b8a75f8d1b9801e74dc6789a0751a670ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/0b5c07b516226b7dd32afbbc82fe547a469c5092",
"reference": "0b5c07b516226b7dd32afbbc82fe547a469c5092",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/ffb5f3b8a75f8d1b9801e74dc6789a0751a670ad",
"reference": "ffb5f3b8a75f8d1b9801e74dc6789a0751a670ad",
"shasum": ""
},
"require": {
@ -2320,20 +2320,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2015-05-15 13:33:16"
"time": "2015-08-24 07:13:45"
},
{
"name": "symfony/debug",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Debug.git",
"reference": "9daa1bf9f7e615fa2fba30357e479a90141222e3"
"reference": "726bf9651d29f53243281d0b6418cfaa5e318281"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Debug/zipball/9daa1bf9f7e615fa2fba30357e479a90141222e3",
"reference": "9daa1bf9f7e615fa2fba30357e479a90141222e3",
"url": "https://api.github.com/repos/symfony/Debug/zipball/726bf9651d29f53243281d0b6418cfaa5e318281",
"reference": "726bf9651d29f53243281d0b6418cfaa5e318281",
"shasum": ""
},
"require": {
@ -2345,14 +2345,9 @@
},
"require-dev": {
"symfony/class-loader": "~2.2",
"symfony/http-foundation": "~2.1",
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2",
"symfony/phpunit-bridge": "~2.7"
},
"suggest": {
"symfony/http-foundation": "",
"symfony/http-kernel": ""
},
"type": "library",
"extra": {
"branch-alias": {
@ -2380,20 +2375,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-08-29 11:12:16"
},
{
"name": "symfony/dependency-injection",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/DependencyInjection.git",
"reference": "851e3ffe8a366b1590bdaf3df2c1395f2d27d8a6"
"reference": "c0a3a97b9450d77cd8eff81c5825efb3624c255b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/851e3ffe8a366b1590bdaf3df2c1395f2d27d8a6",
"reference": "851e3ffe8a366b1590bdaf3df2c1395f2d27d8a6",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/c0a3a97b9450d77cd8eff81c5825efb3624c255b",
"reference": "c0a3a97b9450d77cd8eff81c5825efb3624c255b",
"shasum": ""
},
"require": {
@ -2440,20 +2435,20 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 14:07:07"
"time": "2015-08-24 07:16:32"
},
{
"name": "symfony/dom-crawler",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
"reference": "9dabece63182e95c42b06967a0d929a5df78bc35"
"reference": "2a161e4ee2b2f33d4153be58df4f6f2a5506936e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/9dabece63182e95c42b06967a0d929a5df78bc35",
"reference": "9dabece63182e95c42b06967a0d929a5df78bc35",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/2a161e4ee2b2f33d4153be58df4f6f2a5506936e",
"reference": "2a161e4ee2b2f33d4153be58df4f6f2a5506936e",
"shasum": ""
},
"require": {
@ -2493,20 +2488,20 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-08-26 10:48:03"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3"
"reference": "b58c916f1db03a611b72dd702564f30ad8fe83fa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/b58c916f1db03a611b72dd702564f30ad8fe83fa",
"reference": "b58c916f1db03a611b72dd702564f30ad8fe83fa",
"shasum": ""
},
"require": {
@ -2551,20 +2546,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2015-06-18 19:21:56"
"time": "2015-08-24 07:13:45"
},
{
"name": "symfony/http-foundation",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "863af6898081b34c65d42100c370b9f3c51b70ca"
"reference": "7253c2041652353e71560bbd300d6256d170ddaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/863af6898081b34c65d42100c370b9f3c51b70ca",
"reference": "863af6898081b34c65d42100c370b9f3c51b70ca",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/7253c2041652353e71560bbd300d6256d170ddaf",
"reference": "7253c2041652353e71560bbd300d6256d170ddaf",
"shasum": ""
},
"require": {
@ -2604,20 +2599,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2015-07-22 10:11:00"
"time": "2015-08-27 06:45:45"
},
{
"name": "symfony/http-kernel",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "405d3e7a59ff7a28ec469441326a0ac79065ea98"
"reference": "fd9c7af92c9e3ade1327cc3af10b17731eebc4a7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/405d3e7a59ff7a28ec469441326a0ac79065ea98",
"reference": "405d3e7a59ff7a28ec469441326a0ac79065ea98",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/fd9c7af92c9e3ade1327cc3af10b17731eebc4a7",
"reference": "fd9c7af92c9e3ade1327cc3af10b17731eebc4a7",
"shasum": ""
},
"require": {
@ -2684,20 +2679,20 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2015-07-31 13:24:45"
"time": "2015-09-08 14:26:39"
},
{
"name": "symfony/process",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "48aeb0e48600321c272955132d7606ab0a49adb3"
"reference": "f7b3f73f70a7f8f49a1c838dc3debbf054732d8e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/48aeb0e48600321c272955132d7606ab0a49adb3",
"reference": "48aeb0e48600321c272955132d7606ab0a49adb3",
"url": "https://api.github.com/repos/symfony/Process/zipball/f7b3f73f70a7f8f49a1c838dc3debbf054732d8e",
"reference": "f7b3f73f70a7f8f49a1c838dc3debbf054732d8e",
"shasum": ""
},
"require": {
@ -2733,7 +2728,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2015-07-01 11:25:50"
"time": "2015-08-27 06:45:45"
},
{
"name": "symfony/psr-http-message-bridge",
@ -2791,16 +2786,16 @@
},
{
"name": "symfony/routing",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"reference": "ea9134f277162b02e5f80ac058b75a77637b0d26"
"reference": "20b1378cb6efffb77ea0608232f18c8f0dd25109"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/ea9134f277162b02e5f80ac058b75a77637b0d26",
"reference": "ea9134f277162b02e5f80ac058b75a77637b0d26",
"url": "https://api.github.com/repos/symfony/Routing/zipball/20b1378cb6efffb77ea0608232f18c8f0dd25109",
"reference": "20b1378cb6efffb77ea0608232f18c8f0dd25109",
"shasum": ""
},
"require": {
@ -2858,20 +2853,20 @@
"uri",
"url"
],
"time": "2015-07-09 16:07:40"
"time": "2015-08-24 07:13:45"
},
{
"name": "symfony/serializer",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Serializer.git",
"reference": "143d318457ecc298a846506acc8e80dea30d2548"
"reference": "baf24f86a8656eea9c80988f332e51461bfcb67f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Serializer/zipball/143d318457ecc298a846506acc8e80dea30d2548",
"reference": "143d318457ecc298a846506acc8e80dea30d2548",
"url": "https://api.github.com/repos/symfony/Serializer/zipball/baf24f86a8656eea9c80988f332e51461bfcb67f",
"reference": "baf24f86a8656eea9c80988f332e51461bfcb67f",
"shasum": ""
},
"require": {
@ -2883,7 +2878,7 @@
"symfony/config": "~2.2",
"symfony/phpunit-bridge": "~2.7",
"symfony/property-access": "~2.3",
"symfony/yaml": "~2.0"
"symfony/yaml": "~2.0,>=2.0.5"
},
"suggest": {
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
@ -2919,20 +2914,20 @@
],
"description": "Symfony Serializer Component",
"homepage": "https://symfony.com",
"time": "2015-07-22 19:42:44"
"time": "2015-08-31 16:44:53"
},
{
"name": "symfony/translation",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
"reference": "c8dc34cc936152c609cdd722af317e4239d10dd6"
"reference": "485877661835e188cd78345c6d4eef1290d17571"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/c8dc34cc936152c609cdd722af317e4239d10dd6",
"reference": "c8dc34cc936152c609cdd722af317e4239d10dd6",
"url": "https://api.github.com/repos/symfony/Translation/zipball/485877661835e188cd78345c6d4eef1290d17571",
"reference": "485877661835e188cd78345c6d4eef1290d17571",
"shasum": ""
},
"require": {
@ -2944,7 +2939,7 @@
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.7",
"symfony/intl": "~2.3",
"symfony/intl": "~2.4",
"symfony/phpunit-bridge": "~2.7",
"symfony/yaml": "~2.2"
},
@ -2980,20 +2975,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-09-06 08:36:38"
},
{
"name": "symfony/validator",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Validator.git",
"reference": "646df03e635a8a232804274401449ccdf5f03cad"
"reference": "356459a697e26274d44c608513c05c23dc1d8ea7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Validator/zipball/646df03e635a8a232804274401449ccdf5f03cad",
"reference": "646df03e635a8a232804274401449ccdf5f03cad",
"url": "https://api.github.com/repos/symfony/Validator/zipball/356459a697e26274d44c608513c05c23dc1d8ea7",
"reference": "356459a697e26274d44c608513c05c23dc1d8ea7",
"shasum": ""
},
"require": {
@ -3007,7 +3002,7 @@
"symfony/config": "~2.2",
"symfony/expression-language": "~2.4",
"symfony/http-foundation": "~2.1",
"symfony/intl": "~2.3",
"symfony/intl": "~2.4",
"symfony/phpunit-bridge": "~2.7",
"symfony/property-access": "~2.3",
"symfony/yaml": "~2.0,>=2.0.5"
@ -3050,20 +3045,20 @@
],
"description": "Symfony Validator Component",
"homepage": "https://symfony.com",
"time": "2015-07-31 06:49:15"
"time": "2015-09-06 08:36:38"
},
{
"name": "symfony/yaml",
"version": "v2.7.3",
"version": "v2.7.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff"
"reference": "2dc7b06c065df96cc686c66da2705e5e18aef661"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/71340e996171474a53f3d29111d046be4ad8a0ff",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661",
"reference": "2dc7b06c065df96cc686c66da2705e5e18aef661",
"shasum": ""
},
"require": {
@ -3099,7 +3094,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 14:07:07"
"time": "2015-08-24 07:13:45"
},
{
"name": "twig/twig",

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ Resources
---------
For a simple implementation of a browser based on an HTTP layer, have a look
at [Goutte](https://github.com/fabpot/Goutte).
at [Goutte](https://github.com/FriendsOfPHP/Goutte).
For an implementation based on HttpKernelInterface, have a look at the
[Client](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php)

View File

@ -118,6 +118,25 @@ class ClassMapGenerator
case T_CLASS:
case T_INTERFACE:
case SYMFONY_TRAIT:
// Skip usage of ::class constant
$isClassConstant = false;
for ($j = $i - 1; $j > 0; --$j) {
if (is_string($tokens[$j])) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0]) {
$isClassConstant = true;
break;
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
break;
}
}
if ($isClassConstant) {
continue;
}
// Find the classname
while (($t = $tokens[++$i]) && is_array($t)) {
if (T_STRING === $t[0]) {

View File

@ -47,7 +47,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getTestCreateMapTests
*/
public function testDump($directory, $expected)
public function testDump($directory)
{
$this->prepare_workspace();
@ -115,6 +115,12 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
));
}
if (PHP_VERSION_ID >= 50500) {
$data[] = array(__DIR__.'/Fixtures/php5.5', array(
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
));
}
return $data;
}
@ -134,10 +140,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
protected function assertEqualsNormalized($expected, $actual, $message = null)
{
foreach ($expected as $ns => $path) {
$expected[$ns] = strtr($path, '\\', '/');
$expected[$ns] = str_replace('\\', '/', $path);
}
foreach ($actual as $ns => $path) {
$actual[$ns] = strtr($path, '\\', '/');
$actual[$ns] = str_replace('\\', '/', $path);
}
$this->assertEquals($expected, $actual, $message);
}

View File

@ -0,0 +1,11 @@
<?php
namespace ClassCons;
class Foo
{
public function __construct()
{
\Foo\TBar/* foo */::class;
}
}

View File

@ -513,7 +513,7 @@ class Command
*/
public function getHelp()
{
return $this->help;
return $this->help ?: $this->description;
}
/**

View File

@ -102,7 +102,7 @@ class JsonDescriptor extends Descriptor
'name' => $argument->getName(),
'is_required' => $argument->isRequired(),
'is_array' => $argument->isArray(),
'description' => preg_replace('/\s*\R\s*/', ' ', $argument->getDescription()),
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
'default' => $argument->getDefault(),
);
}
@ -120,7 +120,7 @@ class JsonDescriptor extends Descriptor
'accept_value' => $option->acceptValue(),
'is_value_required' => $option->isValueRequired(),
'is_multiple' => $option->isArray(),
'description' => preg_replace('/\s*\R\s*/', ' ', $option->getDescription()),
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
'default' => $option->getDefault(),
);
}

View File

@ -36,7 +36,7 @@ class MarkdownDescriptor extends Descriptor
.'* Name: '.($argument->getName() ?: '<none>')."\n"
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $argument->getDescription() ?: '<none>')."\n"
.'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
);
}
@ -53,7 +53,7 @@ class MarkdownDescriptor extends Descriptor
.'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
.'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
.'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
.'* Description: '.preg_replace('/\s*\R\s*/', PHP_EOL.' ', $option->getDescription() ?: '<none>')."\n"
.'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
.'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
);
}

View File

@ -44,7 +44,7 @@ class TextDescriptor extends Descriptor
$argument->getName(),
str_repeat(' ', $spacingWidth),
// + 17 = 2 spaces + <info> + </info> + 2 spaces
preg_replace('/\s*\R\s*/', PHP_EOL.str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
$default
), $options);
}
@ -81,7 +81,7 @@ class TextDescriptor extends Descriptor
$synopsis,
str_repeat(' ', $spacingWidth),
// + 17 = 2 spaces + <info> + </info> + 2 spaces
preg_replace('/\s*\R\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
$default,
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
), $options);
@ -249,12 +249,16 @@ class TextDescriptor extends Descriptor
*/
private function getColumnWidth(array $commands)
{
$width = 0;
$widths = array();
foreach ($commands as $command) {
$width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;
$widths[] = strlen($command->getName());
foreach ($command->getAliases() as $alias) {
$widths[] = strlen($alias);
}
}
return $width + 2;
return max($widths) + 2;
}
/**

View File

@ -19,19 +19,19 @@ namespace Symfony\Component\Console\Event;
class ConsoleCommandEvent extends ConsoleEvent
{
/**
* The return code for skipped commands, this will also be passed into the terminate event
* The return code for skipped commands, this will also be passed into the terminate event.
*/
const RETURN_CODE_DISABLED = 113;
/**
* Indicates if the command should be run or skipped
* Indicates if the command should be run or skipped.
*
* @var bool
*/
private $commandShouldRun = true;
/**
* Disables the command, so it won't be run
* Disables the command, so it won't be run.
*
* @return bool
*/
@ -41,7 +41,7 @@ class ConsoleCommandEvent extends ConsoleEvent
}
/**
* Enables the command
* Enables the command.
*
* @return bool
*/
@ -51,7 +51,7 @@ class ConsoleCommandEvent extends ConsoleEvent
}
/**
* Returns true if the command is runnable, false otherwise
* Returns true if the command is runnable, false otherwise.
*
* @return bool
*/

View File

@ -25,7 +25,7 @@ class DebugFormatterHelper extends Helper
private $count = -1;
/**
* Starts a debug formatting session
* Starts a debug formatting session.
*
* @param string $id The id of the formatting session
* @param string $message The message to display
@ -41,7 +41,7 @@ class DebugFormatterHelper extends Helper
}
/**
* Adds progress to a formatting session
* Adds progress to a formatting session.
*
* @param string $id The id of the formatting session
* @param string $buffer The message to display
@ -61,7 +61,7 @@ class DebugFormatterHelper extends Helper
unset($this->started[$id]['out']);
}
if (!isset($this->started[$id]['err'])) {
$message .= sprintf("%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix);
$message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
$this->started[$id]['err'] = true;
}
@ -72,7 +72,7 @@ class DebugFormatterHelper extends Helper
unset($this->started[$id]['err']);
}
if (!isset($this->started[$id]['out'])) {
$message .= sprintf("%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix);
$message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
$this->started[$id]['out'] = true;
}
@ -83,7 +83,7 @@ class DebugFormatterHelper extends Helper
}
/**
* Stops a formatting session
* Stops a formatting session.
*
* @param string $id The id of the formatting session
* @param string $message The message to display

View File

@ -77,7 +77,7 @@ class QuestionHelper extends Helper
}
/**
* Returns the helper's input stream
* Returns the helper's input stream.
*
* @return resource
*/
@ -150,7 +150,7 @@ class QuestionHelper extends Helper
* Outputs the question prompt.
*
* @param OutputInterface $output
* @param Question $question
* @param Question $question
*/
protected function writePrompt(OutputInterface $output, Question $question)
{
@ -222,7 +222,7 @@ class QuestionHelper extends Helper
// Backspace Character
if ("\177" === $c) {
if (0 === $numMatches && 0 !== $i) {
$i--;
--$i;
// Move cursor backwards
$output->write("\033[1D");
}
@ -275,7 +275,7 @@ class QuestionHelper extends Helper
} else {
$output->write($c);
$ret .= $c;
$i++;
++$i;
$numMatches = 0;
$ofs = 0;

View File

@ -245,7 +245,7 @@ class Table
}
$markup = $this->style->getCrossingChar();
for ($column = 0; $column < $count; $column++) {
for ($column = 0; $column < $count; ++$column) {
$markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->getColumnWidth($column)).$this->style->getCrossingChar();
}
@ -338,7 +338,7 @@ class Table
private function buildTableRows($rows)
{
$unmergedRows = array();
for ($rowKey = 0; $rowKey < count($rows); $rowKey++) {
for ($rowKey = 0; $rowKey < count($rows); ++$rowKey) {
$rows = $this->fillNextRows($rows, $rowKey);
// Remove any new line breaks and replace it with a new line

View File

@ -18,9 +18,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
/**
* PSR-3 compliant console logger
* PSR-3 compliant console logger.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @link http://www.php-fig.org/psr/psr-3/
*/
class ConsoleLogger extends AbstractLogger
@ -93,7 +94,7 @@ class ConsoleLogger extends AbstractLogger
}
/**
* Interpolates context values into the message placeholders
* Interpolates context values into the message placeholders.
*
* @author PHP Framework Interoperability Group
*

View File

@ -23,8 +23,8 @@ class ConfirmationQuestion extends Question
/**
* Constructor.
*
* @param string $question The question to ask to the user
* @param bool $default The default answer to return, true or false
* @param string $question The question to ask to the user
* @param bool $default The default answer to return, true or false
* @param string $trueAnswerRegex A regex to match the "yes" answer
*/
public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')

View File

@ -16,7 +16,7 @@ use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Decorates output to add console style guide helpers
* Decorates output to add console style guide helpers.
*
* @author Kevin Bond <kevinbond@gmail.com>
*/

View File

@ -553,6 +553,10 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRenderExceptionWithDoubleWidthCharacters()
{
if (!function_exists('mb_strwidth')) {
$this->markTestSkipped('The "mb_strwidth" function is not available');
}
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application->setAutoExit(false);
$application->expects($this->any())

View File

@ -131,6 +131,8 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$ret = $command->setHelp('help1');
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
$command->setHelp('');
$this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description');
}
public function testGetProcessedHelp()

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Console\Tests\Fixtures;
use Symfony\Component\Console\Output\BufferedOutput;
/**
* Dummy output
* Dummy output.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/

View File

@ -106,7 +106,7 @@
<usage>afoobar</usage>
</usages>
<description>The foo:bar command</description>
<help/>
<help>The foo:bar command</help>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">

View File

@ -7,7 +7,7 @@
<usage>afoobar</usage>
</usages>
<description>The foo:bar command</description>
<help/>
<help>The foo:bar command</help>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">

View File

@ -75,7 +75,7 @@ EOT;
EOT;
$syntaxErrorOutputDebug = <<<EOT
RUN php -r "fwrite(STDERR, 'error message');usleep(50000);fwrite(STDOUT, 'out message');exit(252);"
RUN php -r "fwrite(STDERR, 'error message');usleep(500000);fwrite(STDOUT, 'out message');exit(252);"
ERR error message
OUT out message
RES 252 Command did not run successfully
@ -94,10 +94,10 @@ EOT;
array($successOutputDebugWithTags, 'php -r "echo \'<info>42</info>\';"', StreamOutput::VERBOSITY_DEBUG, null),
array('', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null),
array($syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null),
array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null),
array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null),
array($errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage),
array($syntaxErrorOutputVerbose.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage),
array($syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage),
array($syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage),
array($successOutputProcessDebug, array('php', '-r', 'echo 42;'), StreamOutput::VERBOSITY_DEBUG, null),
array($successOutputDebug, new Process('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null),
);

View File

@ -315,7 +315,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
$bar = new ProgressBar($output = $this->getOutputStream(false), 200);
$bar->start();
for ($i = 0; $i < 200; $i++) {
for ($i = 0; $i < 200; ++$i) {
$bar->advance();
}
@ -384,7 +384,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
$output->write("\n");
$bar3->start();
for ($i = 1; $i <= 3; $i++) {
for ($i = 1; $i <= 3; ++$i) {
// up two lines
$output->write("\033[2A");
if ($i <= 2) {
@ -492,6 +492,9 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
);
}
/**
* @requires extension mbstring
*/
public function testAnsiColorsAndEmojis()
{
$bar = new ProgressBar($output = $this->getOutputStream(), 15);

View File

@ -427,7 +427,7 @@ TABLE
array('ISBN', 'Author'),
array(
array(
new TableCell("9971-5-0210-0", array('rowspan' => 3, 'colspan' => 1)),
new TableCell('9971-5-0210-0', array('rowspan' => 3, 'colspan' => 1)),
'Dante Alighieri',
),
array(new TableSeparator()),

View File

@ -18,7 +18,7 @@ use Symfony\Component\Console\Tests\Fixtures\DummyOutput;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Console logger test
* Console logger test.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/

View File

@ -78,7 +78,7 @@ class Specificity
/**
* Returns -1 if the object specificity is lower than the argument,
* 0 if they are equal, and 1 if the argument is lower
* 0 if they are equal, and 1 if the argument is lower.
*
* @param Specificity $specificity
*

View File

@ -32,6 +32,7 @@ class DebugClassLoader
private static $caseCheck;
private static $deprecated = array();
private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
private static $darwinCache = array('/' => array('/', array()));
/**
* Constructor.
@ -220,33 +221,73 @@ class DebugClassLoader
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
}
if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*)+\.(php|hh)$#D', $file, $tail)) {
if (self::$caseCheck && preg_match('#(?:[/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*+)++\.(?:php|hh)$#D', $file, $tail)) {
$tail = $tail[0];
$tailLen = strlen($tail);
$real = $refl->getFileName();
if (2 === self::$caseCheck) {
// realpath() on MacOSX doesn't normalize the case of characters
$cwd = getcwd();
$basename = strrpos($real, '/');
chdir(substr($real, 0, $basename));
$basename = substr($real, $basename + 1);
// glob() patterns are case-sensitive even if the underlying fs is not
if (!in_array($basename, glob($basename.'*', GLOB_NOSORT), true)) {
$real = getcwd().'/';
$h = opendir('.');
while (false !== $f = readdir($h)) {
if (0 === strcasecmp($f, $basename)) {
$real .= $f;
break;
$i = 1 + strrpos($real, '/');
$file = substr($real, $i);
$real = substr($real, 0, $i);
if (isset(self::$darwinCache[$real])) {
$kDir = $real;
} else {
$kDir = strtolower($real);
if (isset(self::$darwinCache[$kDir])) {
$real = self::$darwinCache[$kDir][0];
} else {
$dir = getcwd();
chdir($real);
$real = getcwd().'/';
chdir($dir);
$dir = $real;
$k = $kDir;
$i = strlen($dir) - 1;
while (!isset(self::$darwinCache[$k])) {
self::$darwinCache[$k] = array($dir, array());
self::$darwinCache[$dir] = &self::$darwinCache[$k];
while ('/' !== $dir[--$i]) {
}
$k = substr($k, 0, ++$i);
$dir = substr($dir, 0, $i--);
}
}
closedir($h);
}
chdir($cwd);
$dirFiles = self::$darwinCache[$kDir][1];
if (isset($dirFiles[$file])) {
$kFile = $file;
} else {
$kFile = strtolower($file);
if (!isset($dirFiles[$kFile])) {
foreach (scandir($real, 2) as $f) {
if ('.' !== $f[0]) {
$dirFiles[$f] = $f;
if ($f === $file) {
$kFile = $k = $file;
} elseif ($f !== $k = strtolower($f)) {
$dirFiles[$k] = $f;
}
}
}
self::$darwinCache[$kDir][1] = $dirFiles;
}
}
$real .= $dirFiles[$kFile];
}
if (0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true)
&& 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false)
if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
&& 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
) {
throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real));
}

View File

@ -251,7 +251,7 @@ class ErrorHandler
public function throwAt($levels, $replace = false)
{
$prev = $this->thrownErrors;
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
$this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
if (!$replace) {
$this->thrownErrors |= $prev;
}
@ -352,7 +352,7 @@ class ErrorHandler
*/
public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
{
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR;
$level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
$log = $this->loggedErrors & $type;
$throw = $this->thrownErrors & $type & $level;
$type &= $level | $this->screamedErrors;
@ -445,7 +445,7 @@ class ErrorHandler
}
/**
* Handles an exception by logging then forwarding it to an other handler.
* Handles an exception by logging then forwarding it to another handler.
*
* @param \Exception|\Throwable $exception An exception to handle
* @param array $error An array as returned by error_get_last()

View File

@ -38,7 +38,7 @@ class ExceptionHandler
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{
if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) {
if (false !== strpos($charset, '%')) {
// Swap $charset and $fileLinkFormat for BC reasons
$pivot = $fileLinkFormat;
$fileLinkFormat = $charset;
@ -153,19 +153,22 @@ class ExceptionHandler
* it will fallback to plain PHP functions.
*
* @param \Exception $exception An \Exception instance
*
* @see sendPhpResponse()
* @see createResponse()
*/
private function failSafeHandle(\Exception $exception)
{
if (class_exists('Symfony\Component\HttpFoundation\Response', false)) {
if (class_exists('Symfony\Component\HttpFoundation\Response', false)
&& __CLASS__ !== get_class($this)
&& ($reflector = new \ReflectionMethod($this, 'createResponse'))
&& __CLASS__ !== $reflector->class
) {
$response = $this->createResponse($exception);
$response->sendHeaders();
$response->sendContent();
} else {
$this->sendPhpResponse($exception);
return;
}
$this->sendPhpResponse($exception);
}
/**

View File

@ -56,7 +56,7 @@ Symfony\Component\Debug\Exception\UndefinedFunctionException Object
[message:protected] => Attempted to call function "notexist" from namespace "Symfony\Component\Debug".
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => -
[file:protected] => %s
[line:protected] => %d
[trace:Exception:private] => Array
(

View File

@ -268,6 +268,28 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
}
}
public function testHandleDeprecation()
{
$that = $this;
$logArgCheck = function ($level, $message, $context) use ($that) {
$that->assertEquals(LogLevel::INFO, $level);
$that->assertArrayHasKey('level', $context);
$that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
$that->assertArrayHasKey('stack', $context);
};
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger
->expects($this->once())
->method('log')
->will($this->returnCallback($logArgCheck))
;
$handler = new ErrorHandler();
$handler->setDefaultLogger($logger);
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array());
}
public function testHandleException()
{
try {

View File

@ -13,71 +13,97 @@ namespace Symfony\Component\Debug\Tests;
use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\Debug\Exception\OutOfMemoryException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
require_once __DIR__.'/HeaderMock.php';
class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
testHeader();
}
protected function tearDown()
{
testHeader();
}
public function testDebug()
{
$handler = new ExceptionHandler(false);
$response = $handler->createResponse(new \RuntimeException('Foo'));
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response->getContent());
$this->assertNotContains('<h2 class="block_exception clear_fix">', $response->getContent());
ob_start();
$handler->sendPhpResponse(new \RuntimeException('Foo'));
$response = ob_get_clean();
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response);
$this->assertNotContains('<h2 class="block_exception clear_fix">', $response);
$handler = new ExceptionHandler(true);
$response = $handler->createResponse(new \RuntimeException('Foo'));
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response->getContent());
$this->assertContains('<h2 class="block_exception clear_fix">', $response->getContent());
ob_start();
$handler->sendPhpResponse(new \RuntimeException('Foo'));
$response = ob_get_clean();
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response);
$this->assertContains('<h2 class="block_exception clear_fix">', $response);
}
public function testStatusCode()
{
$handler = new ExceptionHandler(false);
$handler = new ExceptionHandler(false, 'iso8859-1');
$response = $handler->createResponse(new \RuntimeException('Foo'));
$this->assertEquals('500', $response->getStatusCode());
$this->assertContains('Whoops, looks like something went wrong.', $response->getContent());
ob_start();
$handler->sendPhpResponse(new NotFoundHttpException('Foo'));
$response = ob_get_clean();
$response = $handler->createResponse(new NotFoundHttpException('Foo'));
$this->assertEquals('404', $response->getStatusCode());
$this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent());
$this->assertContains('Sorry, the page you are looking for could not be found.', $response);
$expectedHeaders = array(
array('HTTP/1.0 404', true, null),
array('Content-Type: text/html; charset=iso8859-1', true, null),
);
$this->assertSame($expectedHeaders, testHeader());
}
public function testHeaders()
{
$handler = new ExceptionHandler(false);
$handler = new ExceptionHandler(false, 'iso8859-1');
$response = $handler->createResponse(new MethodNotAllowedHttpException(array('POST')));
$this->assertEquals('405', $response->getStatusCode());
$this->assertEquals('POST', $response->headers->get('Allow'));
ob_start();
$handler->sendPhpResponse(new MethodNotAllowedHttpException(array('POST')));
$response = ob_get_clean();
$expectedHeaders = array(
array('HTTP/1.0 405', true, null),
array('Allow: POST', false, null),
array('Content-Type: text/html; charset=iso8859-1', true, null),
);
$this->assertSame($expectedHeaders, testHeader());
}
public function testNestedExceptions()
{
$handler = new ExceptionHandler(true);
$response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
ob_start();
$handler->sendPhpResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
$response = ob_get_clean();
$this->assertStringMatchesFormat('%A<span class="exception_message">Foo</span>%A<span class="exception_message">Bar</span>%A', $response);
}
public function testHandle()
{
$exception = new \Exception('foo');
if (class_exists('Symfony\Component\HttpFoundation\Response')) {
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse'));
$handler
->expects($this->exactly(2))
->method('createResponse')
->will($this->returnValue(new Response()));
} else {
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler
->expects($this->exactly(2))
->method('sendPhpResponse');
}
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler
->expects($this->exactly(2))
->method('sendPhpResponse');
$handler->handle($exception);
@ -93,18 +119,10 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
if (class_exists('Symfony\Component\HttpFoundation\Response')) {
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse'));
$handler
->expects($this->once())
->method('createResponse')
->will($this->returnValue(new Response()));
} else {
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler
->expects($this->once())
->method('sendPhpResponse');
}
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
$handler
->expects($this->once())
->method('sendPhpResponse');
$that = $this;
$handler->setHandler(function ($e) use ($that) {

View File

@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Debug;
function headers_sent()
{
return false;
}
function header($str, $replace = true, $status = null)
{
Tests\testHeader($str, $replace, $status);
}
namespace Symfony\Component\Debug\Tests;
function testHeader()
{
static $headers = array();
if (!$h = func_get_args()) {
$h = $headers;
$headers = array();
return $h;
}
$headers[] = func_get_args();
}

View File

@ -25,12 +25,7 @@
"require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/class-loader": "~2.2",
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2",
"symfony/http-foundation": "~2.1"
},
"suggest": {
"symfony/http-foundation": "",
"symfony/http-kernel": ""
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Debug\\": "" }

View File

@ -94,6 +94,7 @@ class Definition
* @return Definition The current instance
*
* @api
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryClass($factoryClass)
@ -111,6 +112,7 @@ class Definition
* @return string|null The factory class name
*
* @api
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryClass($triggerDeprecationError = true)
@ -130,6 +132,7 @@ class Definition
* @return Definition The current instance
*
* @api
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryMethod($factoryMethod)
@ -182,6 +185,7 @@ class Definition
* @return string|null The factory method name
*
* @api
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryMethod($triggerDeprecationError = true)
@ -201,6 +205,7 @@ class Definition
* @return Definition The current instance
*
* @api
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryService($factoryService)
@ -218,6 +223,7 @@ class Definition
* @return string|null The factory service id
*
* @api
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryService($triggerDeprecationError = true)

View File

@ -166,14 +166,18 @@ class GraphvizDumper extends Dumper
$container = $this->cloneContainer();
foreach ($container->getDefinitions() as $id => $definition) {
$className = $definition->getClass();
$class = $definition->getClass();
if ('\\' === substr($class, 0, 1)) {
$class = substr($class, 1);
}
try {
$className = $this->container->getParameterBag()->resolveValue($className);
$class = $this->container->getParameterBag()->resolveValue($class);
} catch (ParameterNotFoundException $e) {
}
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted')));
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted')));
$container->setDefinition($id, new Definition('stdClass'));
}

View File

@ -372,7 +372,13 @@ class PhpDumper extends Dumper
*/
private function addServiceInstance($id, $definition)
{
$class = $this->dumpValue($definition->getClass());
$class = $definition->getClass();
if ('\\' === substr($class, 0, 1)) {
$class = substr($class, 1);
}
$class = $this->dumpValue($class);
if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
@ -560,7 +566,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' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
} elseif ($definition->getFactory()) {
$factory = $definition->getFactory();
if (is_string($factory)) {

View File

@ -114,8 +114,12 @@ class XmlDumper extends Dumper
if (null !== $id) {
$service->setAttribute('id', $id);
}
if ($definition->getClass()) {
$service->setAttribute('class', $definition->getClass());
if ($class = $definition->getClass()) {
if ('\\' === substr($class, 0, 1)) {
$class = substr($class, 1);
}
$service->setAttribute('class', $class);
}
if ($definition->getFactoryMethod(false)) {
$service->setAttribute('factory-method', $definition->getFactoryMethod(false));

View File

@ -64,8 +64,12 @@ class YamlDumper extends Dumper
private function addService($id, $definition)
{
$code = " $id:\n";
if ($definition->getClass()) {
$code .= sprintf(" class: %s\n", $definition->getClass());
if ($class = $definition->getClass()) {
if ('\\' === substr($class, 0, 1)) {
$class = substr($class, 1);
}
$code .= sprintf(" class: %s\n", $class);
}
if (!$definition->isPublic()) {
@ -212,7 +216,7 @@ class YamlDumper extends Dumper
}
/**
* Dumps callable to YAML format
* Dumps callable to YAML format.
*
* @param callable $callable
*

View File

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass;

View File

@ -1,5 +1,14 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
@ -35,7 +44,7 @@ class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase
$provider = $this->getMock('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface');
$container = new ContainerBuilder(new ParameterBag());
$container->registerExtension($extension);
$container->prependExtensionConfig('foo', array('bar' => true ));
$container->prependExtensionConfig('foo', array('bar' => true));
$container->addExpressionLanguageProvider($provider);
$pass = new MergeExtensionConfigurationPass();

View File

@ -10,7 +10,7 @@ use Symfony\Component\ExpressionLanguage\Expression;
$container = new ContainerBuilder();
$container
->register('foo', 'Bar\FooClass')
->register('foo', '\Bar\FooClass')
->addTag('foo', array('foo' => 'foo'))
->addTag('foo', array('bar' => 'bar', 'baz' => 'baz'))
->setFactory(array('Bar\\FooClass', 'getInstance'))

View File

@ -22,8 +22,8 @@ class LegacyDefinitionTest extends \PHPUnit_Framework_TestCase
{
$def = new Definition('stdClass');
$this->assertNull($def->getFactoryClass());
$this->assertSame($def, $def->setFactoryClass('stdClass2'), "->setFactoryClass() implements a fluent interface.");
$this->assertEquals('stdClass2', $def->getFactoryClass(), "->getFactoryClass() returns current class to construct this service.");
$this->assertSame($def, $def->setFactoryClass('stdClass2'), '->setFactoryClass() implements a fluent interface.');
$this->assertEquals('stdClass2', $def->getFactoryClass(), '->getFactoryClass() returns current class to construct this service.');
}
public function testSetGetFactoryMethod()
@ -38,7 +38,7 @@ class LegacyDefinitionTest extends \PHPUnit_Framework_TestCase
{
$def = new Definition('stdClass');
$this->assertNull($def->getFactoryService());
$this->assertSame($def, $def->setFactoryService('foo.bar'), "->setFactoryService() implements a fluent interface.");
$this->assertEquals('foo.bar', $def->getFactoryService(), "->getFactoryService() returns current service to construct this service.");
$this->assertSame($def, $def->setFactoryService('foo.bar'), '->setFactoryService() implements a fluent interface.');
$this->assertEquals('foo.bar', $def->getFactoryService(), '->getFactoryService() returns current service to construct this service.');
}
}

View File

@ -166,20 +166,43 @@ class Crawler extends \SplObjectStorage
$dom = new \DOMDocument('1.0', $charset);
$dom->validateOnParse = true;
if (function_exists('mb_convert_encoding')) {
$hasError = false;
set_error_handler(function () use (&$hasError) {
$hasError = true;
});
$tmpContent = @mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
set_error_handler(function () {throw new \Exception();});
restore_error_handler();
try {
// Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
if (!$hasError) {
$content = $tmpContent;
if (function_exists('mb_convert_encoding')) {
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
} elseif (function_exists('iconv')) {
$content = preg_replace_callback(
'/[\x80-\xFF]+/',
function ($m) {
$m = unpack('C*', $m[0]);
$i = 1;
$entities = '';
while (isset($m[$i])) {
if (0xF0 <= $m[$i]) {
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
} elseif (0xE0 <= $m[$i]) {
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
} else {
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
}
$entities .= '&#'.$c.';';
}
return $entities;
},
iconv($charset, 'UTF-8', $content)
);
}
} catch (\Exception $e) {
}
restore_error_handler();
if ('' !== trim($content)) {
@$dom->loadHTML($content);
}

View File

@ -355,7 +355,7 @@ class Form extends Link implements \ArrayAccess
}
/**
* Disables validation
* Disables validation.
*
* @return self
*/

View File

@ -81,6 +81,7 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase
/**
* @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
* @requires extension mbstring
*/
public function testAddHtmlContentCharset()
{
@ -115,6 +116,7 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase
/**
* @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
* @requires extension mbstring
*/
public function testAddHtmlContentCharsetGbk()
{
@ -235,7 +237,7 @@ EOF
$this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset');
$crawler = new Crawler();
$crawler->addContent(mb_convert_encoding('<html><head><meta charset="Shift_JIS"></head><body>日本語</body></html>', 'SJIS', 'UTF-8'));
$crawler->addContent(iconv('UTF-8', 'SJIS', '<html><head><meta charset="Shift_JIS"></head><body>日本語</body></html>'));
$this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag');
}

View File

@ -135,7 +135,7 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
{
$invoked = 0;
$listener = function () use (&$invoked) {
$invoked++;
++$invoked;
};
$this->dispatcher->addListener('pre.foo', $listener);
$this->dispatcher->addListener('post.foo', $listener);

View File

@ -110,8 +110,8 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$tdispatcher->addListener('foo', $listener1 = function () {; });
$tdispatcher->addListener('foo', $listener2 = function () {; });
$logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\".");
$logger->expects($this->at(1))->method('debug')->with("Notified event \"foo\" to listener \"closure\".");
$logger->expects($this->at(0))->method('debug')->with('Notified event "foo" to listener "closure".');
$logger->expects($this->at(1))->method('debug')->with('Notified event "foo" to listener "closure".');
$tdispatcher->dispatch('foo');
}
@ -125,9 +125,9 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); });
$tdispatcher->addListener('foo', $listener2 = function () {; });
$logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\".");
$logger->expects($this->at(1))->method('debug')->with("Listener \"closure\" stopped propagation of the event \"foo\".");
$logger->expects($this->at(2))->method('debug')->with("Listener \"closure\" was not called for event \"foo\".");
$logger->expects($this->at(0))->method('debug')->with('Notified event "foo" to listener "closure".');
$logger->expects($this->at(1))->method('debug')->with('Listener "closure" stopped propagation of the event "foo".');
$logger->expects($this->at(2))->method('debug')->with('Listener "closure" was not called for event "foo".');
$tdispatcher->dispatch('foo');
}

View File

@ -308,6 +308,7 @@ class BinaryFileResponse extends Response
/**
* If this is set to true, the file will be unlinked after the request is send
* Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used.
*
* @param bool $shouldDelete
*
* @return BinaryFileResponse

View File

@ -1577,7 +1577,7 @@ class Request
// Content passed in parameter (test)
if (is_string($this->content)) {
$resource = fopen('php://temp','r+');
$resource = fopen('php://temp', 'r+');
fwrite($resource, $this->content);
rewind($resource);
@ -1852,9 +1852,9 @@ class Request
return $prefix;
}
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/').'/')) {
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR).'/')) {
// directory portion of $baseUrl matches
return rtrim($prefix, '/');
return rtrim($prefix, '/'.DIRECTORY_SEPARATOR);
}
$truncatedRequestUri = $requestUri;
@ -1875,7 +1875,7 @@ class Request
$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
}
return rtrim($baseUrl, '/');
return rtrim($baseUrl, '/'.DIRECTORY_SEPARATOR);
}
/**
@ -2001,7 +2001,7 @@ class Request
if (self::$requestFactory) {
$request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content);
if (!$request instanceof Request) {
if (!$request instanceof self) {
throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.');
}

View File

@ -630,7 +630,7 @@ class Response
*/
public function mustRevalidate()
{
return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->has('proxy-revalidate');
return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->hasCacheControlDirective('proxy-revalidate');
}
/**

View File

@ -260,7 +260,7 @@ class LegacyPdoSessionHandler implements \SessionHandlerInterface
}
/**
* Return a PDO instance
* Return a PDO instance.
*
* @return \PDO
*/

View File

@ -108,7 +108,7 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
}
/**
* Return a Memcache instance
* Return a Memcache instance.
*
* @return \Memcache
*/

View File

@ -114,7 +114,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
}
/**
* Return a Memcached instance
* Return a Memcached instance.
*
* @return \Memcached
*/

View File

@ -177,7 +177,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
}
/**
* Return a Mongo instance
* Return a Mongo instance.
*
* @return \Mongo
*/

View File

@ -51,7 +51,7 @@ class StreamedResponse extends Response
}
/**
* Factory method for chainability
* Factory method for chainability.
*
* @param callable|null $callback A valid PHP callback or null to set it later
* @param int $status The response status code

View File

@ -54,7 +54,7 @@ class BinaryFileResponseTest extends ResponseTestCase
*/
public function testRequests($requestRange, $offset, $length, $responseRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag();
// do a request to get the ETag
$request = Request::create('/');
@ -96,7 +96,7 @@ class BinaryFileResponseTest extends ResponseTestCase
*/
public function testFullFileRequests($requestRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag();
// prepare a request for a range of the testing file
$request = Request::create('/');
@ -131,7 +131,7 @@ class BinaryFileResponseTest extends ResponseTestCase
*/
public function testInvalidRequests($requestRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag();
// prepare a request for a range of the testing file
$request = Request::create('/');
@ -159,7 +159,7 @@ class BinaryFileResponseTest extends ResponseTestCase
$request->headers->set('X-Sendfile-Type', 'X-Sendfile');
BinaryFileResponse::trustXSendfileTypeHeader();
$response = BinaryFileResponse::create(__DIR__.'/../README.md');
$response = BinaryFileResponse::create(__DIR__.'/../README.md', 200, array('Content-Type' => 'application/octet-stream'));
$response->prepare($request);
$this->expectOutputString('');
@ -180,7 +180,7 @@ class BinaryFileResponseTest extends ResponseTestCase
$file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test');
BinaryFileResponse::trustXSendfileTypeHeader();
$response = new BinaryFileResponse($file);
$response = new BinaryFileResponse($file, 200, array('Content-Type' => 'application/octet-stream'));
$reflection = new \ReflectionObject($response);
$property = $reflection->getProperty('file');
$property->setAccessible(true);
@ -199,7 +199,7 @@ class BinaryFileResponseTest extends ResponseTestCase
$realPath = realpath($path);
$this->assertFileExists($realPath);
$response = new BinaryFileResponse($realPath);
$response = new BinaryFileResponse($realPath, 200, array('Content-Type' => 'application/octet-stream'));
$response->deleteFileAfterSend(true);
$response->prepare($request);
@ -211,7 +211,7 @@ class BinaryFileResponseTest extends ResponseTestCase
public function testAcceptRangeOnUnsafeMethods()
{
$request = Request::create('/', 'POST');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'));
$response->prepare($request);
$this->assertEquals('none', $response->headers->get('Accept-Ranges'));
@ -220,7 +220,7 @@ class BinaryFileResponseTest extends ResponseTestCase
public function testAcceptRangeNotOverriden()
{
$request = Request::create('/', 'POST');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'));
$response->headers->set('Accept-Ranges', 'foo');
$response->prepare($request);
@ -237,7 +237,7 @@ class BinaryFileResponseTest extends ResponseTestCase
protected function provideResponse()
{
return new BinaryFileResponse(__DIR__.'/../README.md');
return new BinaryFileResponse(__DIR__.'/../README.md', 200, array('Content-Type' => 'application/octet-stream'));
}
public static function tearDownAfterClass()

View File

@ -45,6 +45,9 @@ class FileTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('gif', $file->guessExtension());
}
/**
* @requires extension fileinfo
*/
public function testGuessExtensionWithReset()
{
$file = new File(__DIR__.'/Fixtures/other-file.example');

View File

@ -14,17 +14,16 @@ namespace Symfony\Component\HttpFoundation\Tests\File\MimeType;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
/**
* @requires extension fileinfo
*/
class MimeTypeTest extends \PHPUnit_Framework_TestCase
{
protected $path;
public function testGuessImageWithoutExtension()
{
if (extension_loaded('fileinfo')) {
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}
public function testGuessImageWithDirectory()
@ -38,29 +37,17 @@ class MimeTypeTest extends \PHPUnit_Framework_TestCase
{
$guesser = MimeTypeGuesser::getInstance();
$guesser->register(new FileBinaryMimeTypeGuesser());
if (extension_loaded('fileinfo')) {
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}
public function testGuessImageWithKnownExtension()
{
if (extension_loaded('fileinfo')) {
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
}
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
}
public function testGuessFileWithUnknownExtension()
{
if (extension_loaded('fileinfo')) {
$this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
}
$this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
}
public function testGuessWithIncorrectPath()
@ -75,7 +62,7 @@ class MimeTypeTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Can not verify chmod operations on Windows');
}
if ('root' === get_current_user()) {
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}
@ -83,7 +70,7 @@ class MimeTypeTest extends \PHPUnit_Framework_TestCase
touch($path);
@chmod($path, 0333);
if (get_current_user() != 'root' && substr(sprintf('%o', fileperms($path)), -4) == '0333') {
if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
MimeTypeGuesser::getInstance()->guess($path);
} else {

View File

@ -980,7 +980,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
public function testContentAsResource()
{
$resource = fopen('php://memory','r+');
$resource = fopen('php://memory', 'r+');
fwrite($resource, 'My other content');
rewind($resource);

View File

@ -105,6 +105,22 @@ class ResponseTest extends ResponseTestCase
$this->assertFalse($response->mustRevalidate());
}
public function testMustRevalidateWithMustRevalidateCacheControlHeader()
{
$response = new Response();
$response->headers->set('cache-control', 'must-revalidate');
$this->assertTrue($response->mustRevalidate());
}
public function testMustRevalidateWithProxyRevalidateCacheControlHeader()
{
$response = new Response();
$response->headers->set('cache-control', 'proxy-revalidate');
$this->assertTrue($response->mustRevalidate());
}
public function testSetNotModified()
{
$response = new Response();

View File

@ -205,7 +205,7 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
}
/**
* Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace)
* Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace).
*/
public function testWriteDifferentSessionIdThanRead()
{

View File

@ -157,7 +157,7 @@ class ControllerResolver implements ControllerResolverInterface
}
/**
* Returns an instantiated controller
* Returns an instantiated controller.
*
* @param string $class A class name
*

View File

@ -120,7 +120,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
}
if (false === $name) {
$name = strtr($file, '\\', '/');
$name = str_replace('\\', '/', $file);
$name = substr($name, strrpos($name, '/') + 1);
}

View File

@ -97,15 +97,46 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
private function sanitizeLogs($logs)
{
foreach ($logs as $i => $log) {
$errorContextById = array();
$sanitizedLogs = array();
foreach ($logs as $log) {
$context = $this->sanitizeContext($log['context']);
if (isset($context['type'], $context['level']) && !($context['type'] & $context['level'])) {
$context['scream'] = true;
if (isset($context['type'], $context['file'], $context['line'], $context['level'])) {
$errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\x00{$log['message']}", true);
$silenced = !($context['type'] & $context['level']);
if (isset($errorContextById[$errorId])) {
if (isset($errorContextById[$errorId]['errorCount'])) {
++$errorContextById[$errorId]['errorCount'];
} else {
$errorContextById[$errorId]['errorCount'] = 2;
}
if (!$silenced && isset($errorContextById[$errorId]['scream'])) {
unset($errorContextById[$errorId]['scream']);
$errorContextById[$errorId]['level'] = $context['level'];
}
continue;
}
$errorContextById[$errorId] = &$context;
if ($silenced) {
$context['scream'] = true;
}
$log['context'] = &$context;
unset($context);
} else {
$log['context'] = $context;
}
$logs[$i]['context'] = $context;
$sanitizedLogs[] = $log;
}
return $logs;
return $sanitizedLogs;
}
private function sanitizeContext($context)

View File

@ -54,7 +54,7 @@ class ValueExporter
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
}
return sprintf("[%s]", implode(', ', $a));
return sprintf('[%s]', implode(', ', $a));
}
if (is_resource($value)) {

View File

@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* Adds configured formats to each request
* Adds configured formats to each request.
*
* @author Gildas Quemener <gildas.quemener@gmail.com>
*/
@ -36,7 +36,7 @@ class AddRequestFormatsListener implements EventSubscriberInterface
}
/**
* Adds request formats
* Adds request formats.
*
* @param GetResponseEvent $event
*/

View File

@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates
* SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates.
*
* @author Fabien Potencier <fabien@symfony.com>
*/

View File

@ -48,7 +48,7 @@ abstract class TestSessionListener implements EventSubscriberInterface
/**
* Checks if session was initialized and saves if current request is master
* Runs on 'kernel.response' in test environment
* Runs on 'kernel.response' in test environment.
*
* @param FilterResponseEvent $event
*/

View File

@ -15,8 +15,6 @@
namespace Symfony\Component\HttpKernel\HttpCache;
@trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategyInterface class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategyInterface class instead.', E_USER_DEPRECATED);
/**
* ResponseCacheStrategyInterface implementations know how to compute the
* Response cache HTTP header based on the different response cache headers.

View File

@ -156,6 +156,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
* Gets the Surrogate instance.
*
* @throws \LogicException
*
* @return SurrogateInterface A Surrogate instance
*/
public function getSurrogate()

View File

@ -45,7 +45,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
$this->maxAges[] = $response->getMaxAge();
}
$this->embeddedResponses++;
++$this->embeddedResponses;
}
/**

View File

@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\Response;
interface SurrogateInterface
{
/**
* Returns surrogate name
* Returns surrogate name.
*
* @return string
*/

View File

@ -60,11 +60,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface
protected $startTime;
protected $loadClassCache;
const VERSION = '2.7.3';
const VERSION_ID = '20703';
const VERSION = '2.7.4';
const VERSION_ID = '20704';
const MAJOR_VERSION = '2';
const MINOR_VERSION = '7';
const RELEASE_VERSION = '3';
const RELEASE_VERSION = '4';
const EXTRA_VERSION = '';
const END_OF_MAINTENANCE = '05/2018';
@ -356,7 +356,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
{
if (null === $this->rootDir) {
$r = new \ReflectionObject($this);
$this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
$this->rootDir = dirname($r->getFileName());
}
return $this->rootDir;

View File

@ -75,8 +75,18 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
),
array(
1,
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG')),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')),
0,
1,
),
array(
1,
array(
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123), 'priority' => 100, 'priorityName' => 'DEBUG'),
),
array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => -1, 'file' => __FILE__, 'line' => 123, 'errorCount' => 2), 'priority' => 100, 'priorityName' => 'DEBUG')),
0,
1,
),

View File

@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Test AddRequestFormatsListener class
* Test AddRequestFormatsListener class.
*
* @author Gildas Quemener <gildas.quemener@gmail.com>
*/

View File

@ -25,7 +25,7 @@ use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* DebugHandlersListenerTest
* DebugHandlersListenerTest.
*
* @author Nicolas Grekas <p@tchwork.com>
*/

View File

@ -19,7 +19,7 @@ use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
use Symfony\Component\VarDumper\VarDumper;
/**
* DumpListenerTest
* DumpListenerTest.
*
* @author Nicolas Grekas <p@tchwork.com>
*/

View File

@ -23,7 +23,7 @@ use Symfony\Component\HttpKernel\Kernel;
class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
{
/**
* Test to ensure BC without RequestStack
* Test to ensure BC without RequestStack.
*
* @group legacy
*/
@ -79,7 +79,7 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
$subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
->disableOriginalConstructor()
->getMock();

View File

@ -765,7 +765,7 @@ EOF;
}
/**
* Returns a mock for the BundleInterface
* Returns a mock for the BundleInterface.
*
* @return BundleInterface
*/

View File

@ -43,7 +43,7 @@ class UriSignerTest extends \PHPUnit_Framework_TestCase
$signer = new UriSigner('foobar');
$this->assertSame(
"http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D",
'http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D',
$signer->sign('http://example.com/foo?foo=bar&baz=bay')
);
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));

View File

@ -54,7 +54,7 @@ abstract class AbstractPipes implements PipesInterface
}
/**
* Unblocks streams
* Unblocks streams.
*/
protected function unblock()
{

View File

@ -200,7 +200,7 @@ class UnixPipes extends AbstractPipes
}
/**
* Creates a new UnixPipes instance
* Creates a new UnixPipes instance.
*
* @param Process $process
* @param string|resource $input

View File

@ -173,7 +173,7 @@ class WindowsPipes extends AbstractPipes
}
/**
* Removes temporary files
* Removes temporary files.
*/
private function removeFiles()
{
@ -186,7 +186,7 @@ class WindowsPipes extends AbstractPipes
}
/**
* Writes input to stdin
* Writes input to stdin.
*
* @param bool $blocking
* @param bool $close

View File

@ -172,6 +172,9 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testSetStreamAsInput($code, $size)
{
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestIncomplete('This test fails with a timeout on Windows, can someone investigate please?');
}
$expected = str_repeat(str_repeat('*', 1024), $size).'!';
$expectedLength = (1024 * $size) + 1;
@ -179,7 +182,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
fwrite($stream, $expected);
rewind($stream);
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)), null, null, null, 5);
$p->setInput($stream);
$p->run();
@ -524,7 +527,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$process = $this->getProcess('echo foo');
$this->assertSame($process, $process->mustRun());
$this->assertEquals("foo".PHP_EOL, $process->getOutput());
$this->assertEquals('foo'.PHP_EOL, $process->getOutput());
}
public function testSuccessfulMustRunHasCorrectExitCode()
@ -559,7 +562,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$start = microtime(true);
$process->start();
$end = microtime(true);
$this->assertLessThan(0.2, $end-$start);
$this->assertLessThan(0.4, $end - $start);
$process->wait();
}
@ -637,8 +640,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
{
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
$process->start();
$this->assertFalse($process->isSuccessful());
while ($process->isRunning()) {
$this->assertFalse($process->isSuccessful());
usleep(300000);
}
@ -844,6 +849,9 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testIdleTimeoutNotExceededWhenOutputIsSent()
{
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestIncomplete('This test fails with a timeout on Windows, can someone investigate please?');
}
$process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }')));
$process->setTimeout(2);
$process->setIdleTimeout(1);

View File

@ -91,7 +91,7 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase
/**
* Tests that ProcessFailedException does not extract information from
* process output if it was previously disabled
* process output if it was previously disabled.
*/
public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
{

View File

@ -139,7 +139,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
foreach ($method->getParameters() as $param) {
if (!isset($defaults[$param->getName()]) && $param->isOptional()) {
if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
$defaults[$param->getName()] = $param->getDefaultValue();
}
}

View File

@ -355,7 +355,9 @@ class Router implements RouterInterface, RequestMatcherInterface
/**
* This method is public because it needs to be callable from a closure in PHP 5.3. It should be converted back to protected in 3.0.
*
* @internal
*
* @return GeneratorDumperInterface
*/
public function getGeneratorDumperInstance()
@ -365,7 +367,9 @@ class Router implements RouterInterface, RequestMatcherInterface
/**
* This method is public because it needs to be callable from a closure in PHP 5.3. It should be converted back to protected in 3.0.
*
* @internal
*
* @return MatcherDumperInterface
*/
public function getMatcherDumperInstance()

View File

@ -0,0 +1,19 @@
<?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\Routing\Tests\Fixtures\OtherAnnotatedClasses;
class VariadicClass
{
public function routeAction(...$params)
{
}
}

View File

@ -16,6 +16,7 @@ use Symfony\Component\Routing\Annotation\Route;
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
{
protected $loader;
private $reader;
protected function setUp()
{
@ -151,14 +152,14 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
$classRouteData = array(
'path' => '/prefix',
'schemes' => array('https'),
'methods' => array('GET')
'methods' => array('GET'),
);
$methodRouteData = array(
'name' => 'route1',
'path' => '/path',
'schemes' => array('http'),
'methods' => array('POST', 'PUT')
'methods' => array('POST', 'PUT'),
);
$this->reader

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Routing\Tests\Loader;
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Routing\Annotation\Route;
class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
{
@ -34,6 +35,19 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
}
/**
* @requires PHP 5.6
*/
public function testLoadVariadic()
{
$route = new Route(array('path' => '/path/to/{id}'));
$this->reader->expects($this->once())->method('getClassAnnotation');
$this->reader->expects($this->once())->method('getMethodAnnotations')
->will($this->returnValue(array($route)));
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
}
public function testSupports()
{
$fixture = __DIR__.'/../Fixtures/annotated.php';

View File

@ -57,7 +57,6 @@ class JsonDecode implements DecoderInterface
*
* @deprecated since version 2.5, to be removed in 3.0.
* The {@self decode()} method throws an exception if error found.
*
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
*/
public function getLastError()

View File

@ -35,7 +35,6 @@ class JsonEncode implements EncoderInterface
*
* @deprecated since version 2.5, to be removed in 3.0.
* The {@self encode()} throws an exception if error found.
*
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
*/
public function getLastError()

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Serializer\Exception;
/**
* CircularReferenceException
* CircularReferenceException.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Serializer\Exception;
/**
* MappingException
* MappingException.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/

View File

@ -38,7 +38,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
/**
* @param LoaderInterface $loader
* @param Cache|null $cache
* @param Cache|null $cache
*/
public function __construct(LoaderInterface $loader, Cache $cache = null)
{

View File

@ -26,7 +26,7 @@ class YamlFileLoader extends FileLoader
private $yamlParser;
/**
* An array of YAML class descriptions
* An array of YAML class descriptions.
*
* @var array
*/

View File

@ -46,7 +46,7 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
$snakeCasedName = '';
$len = strlen($propertyName);
for ($i = 0; $i < $len; $i++) {
for ($i = 0; $i < $len; ++$i) {
if (ctype_upper($propertyName[$i])) {
$snakeCasedName .= '_'.strtolower($propertyName[$i]);
} else {

View File

@ -22,6 +22,7 @@ interface NameConverterInterface
* Converts a property name to its normalized value.
*
* @param string $propertyName
*
* @return string
*/
public function normalize($propertyName);
@ -30,6 +31,7 @@ interface NameConverterInterface
* Converts a property name to its denormalized value.
*
* @param string $propertyName
*
* @return string
*/
public function denormalize($propertyName);

Some files were not shown because too many files have changed in this diff Show More