Commit a2a1c6af authored by alexpott's avatar alexpott

Issue #2454393 by hussainweb: Upgrade to Symfony 2.6.5

parent d2304f84
This diff is collapsed.
This diff is collapsed.
......@@ -19,5 +19,5 @@ provided by the HttpKernel component.
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/BrowserKit/
$ composer.phar install
$ composer install
$ phpunit
......@@ -123,8 +123,9 @@ public function getHeaders()
*/
public function getHeader($header, $first = true)
{
$normalizedHeader = str_replace('-', '_', strtolower($header));
foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header))) {
if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
if ($first) {
return is_array($value) ? (count($value) ? $value[0] : '') : $value;
}
......
......@@ -20,6 +20,7 @@
"symfony/dom-crawler": "~2.0,>=2.0.5"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/process": "~2.0,>=2.0.5",
"symfony/css-selector": "~2.0,>=2.0.5"
},
......
......@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php"
>
<php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
<ini name="error_reporting" value="-16385"/>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Symfony BrowserKit Component Test Suite">
......
......@@ -81,5 +81,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/ClassLoader/
$ composer.phar install
$ composer install
$ phpunit
......@@ -13,6 +13,9 @@
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
/**
* @group legacy
*/
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
......
......@@ -13,9 +13,12 @@
use Symfony\Component\ClassLoader\UniversalClassLoader;
/**
* @group legacy
*/
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
......
......@@ -20,6 +20,7 @@
"php": ">=5.3.3"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7",
"symfony/finder": "~2.0,>=2.0.5"
},
"autoload": {
......
......@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php"
>
<php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
<ini name="error_reporting" value="-16385"/>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Symfony ClassLoader Component Test Suite">
......
......@@ -43,5 +43,5 @@ which is distributed under the BSD license.
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/CssSelector/
$ composer.phar install
$ composer install
$ phpunit
......@@ -22,6 +22,9 @@
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"autoload": {
"psr-0": { "Symfony\\Component\\CssSelector\\": "" }
},
......
......@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php"
>
<php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
<ini name="error_reporting" value="-16385"/>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Symfony CssSelector Component Test Suite">
......
......@@ -30,27 +30,37 @@
class ExceptionHandler
{
private $debug;
private $charset;
private $handler;
private $caughtBuffer;
private $caughtLength;
private $fileLinkFormat;
public function __construct($debug = true, $fileLinkFormat = null)
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
{
if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) {
// Swap $charset and $fileLinkFormat for BC reasons
$pivot = $fileLinkFormat;
$fileLinkFormat = $charset;
$charset = $pivot;
}
$this->debug = $debug;
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
}
/**
* Registers the exception handler.
*
* @param bool $debug
* @param bool $debug Enable/disable debug mode, where the stack trace is displayed
* @param string|null $charset The charset used by exception messages
* @param string|null $fileLinkFormat The IDE link template
*
* @return ExceptionHandler The registered exception handler
*/
public static function register($debug = true, $fileLinkFormat = null)
public static function register($debug = true, $charset = null, $fileLinkFormat = null)
{
$handler = new static($debug, $fileLinkFormat);
$handler = new static($debug, $charset, $fileLinkFormat);
$prev = set_exception_handler(array($handler, 'handle'));
if (is_array($prev) && $prev[0] instanceof ErrorHandler) {
......@@ -177,6 +187,7 @@ public function sendPhpResponse($exception)
foreach ($exception->getHeaders() as $name => $value) {
header($name.': '.$value, false);
}
header('Content-Type: text/html; charset='.$this->charset);
}
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
......@@ -195,7 +206,7 @@ public function createResponse($exception)
$exception = FlattenException::create($exception);
}
return new Response($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders());
return Response::create($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
}
/**
......@@ -223,7 +234,7 @@ public function getContent(FlattenException $exception)
foreach ($exception->toArray() as $position => $e) {
$ind = $count - $position + 1;
$class = $this->formatClass($e['class']);
$message = nl2br(self::utf8Htmlize($e['message']));
$message = nl2br($this->escapeHtml($e['message']));
$content .= sprintf(<<<EOF
<h2 class="block_exception clear_fix">
<span class="exception_counter">%d/%d</span>
......@@ -251,7 +262,7 @@ public function getContent(FlattenException $exception)
} catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore
if ($this->debug) {
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
} else {
$title = 'Whoops, looks like something went wrong.';
}
......@@ -337,7 +348,7 @@ private function decorate($content, $css)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta charset="{$this->charset}" />
<meta name="robots" content="noindex,nofollow" />
<style>
/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
......@@ -365,7 +376,7 @@ private function formatClass($class)
private function formatPath($path, $line)
{
$path = self::utf8Htmlize($path);
$path = $this->escapeHtml($path);
$file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
if ($linkFormat = $this->fileLinkFormat) {
......@@ -393,7 +404,7 @@ private function formatArgs(array $args)
} elseif ('array' === $item[0]) {
$formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", self::utf8Htmlize($item[1]));
$formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
} elseif ('null' === $item[0]) {
$formattedValue = '<em>null</em>';
} elseif ('boolean' === $item[0]) {
......@@ -401,7 +412,7 @@ private function formatArgs(array $args)
} elseif ('resource' === $item[0]) {
$formattedValue = '<em>resource</em>';
} else {
$formattedValue = str_replace("\n", '', var_export(self::utf8Htmlize((string) $item[1]), true));
$formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
}
$result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
......@@ -429,6 +440,14 @@ protected static function utf8Htmlize($str)
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
}
/**
* HTML-encodes a string
*/
private function escapeHtml($str)
{
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
}
/**
* @internal
*/
......
......@@ -39,5 +39,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Debug/
$ composer.phar install --dev
$ composer install
$ phpunit
......@@ -359,6 +359,9 @@ public function testHandleFatalError()
}
}
/**
* @group legacy
*/
public function testLegacyInterface()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
......
......@@ -36,6 +36,7 @@ public function testHandleClassNotFound($error, $translatedMessage)
/**
* @dataProvider provideLegacyClassNotFoundData
* @group legacy
*/
public function testLegacyHandleClassNotFound($error, $translatedMessage, $autoloader)
{
......
......@@ -23,6 +23,7 @@
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"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"
......
......@@ -7,8 +7,7 @@
bootstrap="vendor/autoload.php"
>
<php>
<!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
<ini name="error_reporting" value="-16385"/>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Symfony Debug Component Test Suite">
......
......@@ -65,9 +65,6 @@ public function process(ContainerBuilder $container)
$configurator = $this->inlineArguments($container, array($definition->getConfigurator()));
$definition->setConfigurator($configurator[0]);
$factory = $this->inlineArguments($container, array($definition->getFactory()));
$definition->setFactory($factory[0]);
}
}
......
......@@ -37,6 +37,14 @@ public function process(ContainerBuilder $container)
$definition->setClass($parameterBag->resolveValue($definition->getClass()));
$definition->setFile($parameterBag->resolveValue($definition->getFile()));
$definition->setArguments($parameterBag->resolveValue($definition->getArguments()));
$definition->setFactoryClass($parameterBag->resolveValue($definition->getFactoryClass()));
$factory = $definition->getFactory();
if (is_array($factory) && isset($factory[0])) {
$factory[0] = $parameterBag->resolveValue($factory[0]);
$definition->setFactory($factory);
}
$calls = array();
foreach ($definition->getMethodCalls() as $name => $arguments) {
......
......@@ -1004,9 +1004,7 @@ public function createService(Definition $definition, $id, $tryProxy = true)
public function resolveServices($value)
{
if (is_array($value)) {
foreach ($value as &$v) {
$v = $this->resolveServices($v);
}
$value = array_map(array($this, 'resolveServices'), $value);
} elseif ($value instanceof Reference) {
$value = $this->get((string) $value, $value->getInvalidBehavior());
} elseif ($value instanceof Definition) {
......
......@@ -1169,7 +1169,7 @@ private function getServiceCallsFromArguments(array $arguments, array &$calls, a
$behavior[$id] = $argument->getInvalidBehavior();
}
$calls[$id] += 1;
++$calls[$id];
}
}
}
......@@ -1332,7 +1332,9 @@ private function dumpValue($value, $interpolate = true)
if (null !== $value->getFactoryClass()) {
return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($value->getFactoryClass()), $value->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
} elseif (null !== $value->getFactoryService()) {
return sprintf("%s->%s(%s)", $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments));
$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));
} else {
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
}
......@@ -1474,16 +1476,16 @@ private function getNextVariableName()
if ('' === $name) {
$name .= $firstChars[$i%$firstCharsLength];
$i = intval($i/$firstCharsLength);
$i = (int) ($i/$firstCharsLength);
}
while ($i > 0) {
$i -= 1;
--$i;
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
$i = intval($i/$nonFirstCharsLength);
$i = (int) ($i/$nonFirstCharsLength);
}
$this->variableCount += 1;
++$this->variableCount;
// check that the name is not reserved
if (in_array($name, $this->reservedVariables, true)) {
......
......@@ -76,5 +76,5 @@ Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/DependencyInjection/
$ composer.phar install
$ composer install
$ phpunit
......@@ -237,6 +237,23 @@ public function testProcessDoesNotInlineWhenServiceReferencesItself()
$this->assertSame($ref, $calls[0][1][0]);
}
public function testProcessDoesNotInlineFactories()
{
$container = new ContainerBuilder();
$container
->register('foo.factory')
->setPublic(false)
;
$container
->register('foo')
->setFactory(array(new Reference('foo.factory'), 'getFoo'))
;
$this->process($container);
$factory = $container->getDefinition('foo')->getFactory();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $factory[0]);
}
protected function process(ContainerBuilder $container)
{
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass()));
......
<?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\ResolveParameterPlaceHoldersPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @group legacy
*/
class LegacyResolveParameterPlaceHoldersPassTest extends \PHPUnit_Framework_TestCase
{
public function testFactoryClassParametersShouldBeResolved()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$compilerPass = new ResolveParameterPlaceHoldersPass();
$container = new ContainerBuilder();
$container->setParameter('foo.factory.class', 'FooFactory');
$fooDefinition = $container->register('foo', '%foo.factory.class%');
$fooDefinition->setFactoryClass('%foo.factory.class%');
$compilerPass->process($container);
$fooDefinition = $container->getDefinition('foo');
$this->assertSame('FooFactory', $fooDefinition->getFactoryClass());
}
}
<?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\ResolveParameterPlaceHoldersPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class ResolveParameterPlaceHoldersPassTest extends \PHPUnit_Framework_TestCase
{
private $compilerPass;
private $container;
private $fooDefinition;
protected function setUp()
{
$this->compilerPass = new ResolveParameterPlaceHoldersPass();
$this->container = $this->createContainerBuilder();
$this->compilerPass->process($this->container);
$this->fooDefinition = $this->container->getDefinition('foo');
}
public function testClassParametersShouldBeResolved()
{
$this->assertSame('Foo', $this->fooDefinition->getClass());
}
public function testFactoryParametersShouldBeResolved()