merged 2.0

This commit is contained in:
Fabien Potencier 2012-05-20 18:16:37 +02:00
commit 9b7aab5e94
19 changed files with 42 additions and 84 deletions

View File

@ -48,8 +48,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
return new TypeGuess('entity', array('em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple), Guess::HIGH_CONFIDENCE);
}
switch ($metadata->getTypeOfField($property))
{
switch ($metadata->getTypeOfField($property)) {
case 'array':
return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE);
case 'boolean':

View File

@ -195,8 +195,7 @@ class Configuration implements ConfigurationInterface
private function addTemplatingSection(ArrayNodeDefinition $rootNode)
{
$organizeUrls = function($urls)
{
$organizeUrls = function($urls) {
$urls += array(
'http' => array(),
'ssl' => array(),

View File

@ -48,8 +48,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$kernel = new HttpKernel($dispatcher, $container, $resolver);
$controller = function() use($expected)
{
$controller = function() use($expected) {
return $expected;
};
@ -96,8 +95,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$kernel = new HttpKernel($dispatcher, $container, $resolver);
$controller = function() use ($expected)
{
$controller = function() use ($expected) {
throw $expected;
};

View File

@ -31,8 +31,7 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase
{
$node = new ArrayNode('root');
try
{
try {
$node->normalize(array('foo' => 'bar'));
$this->fail('An exception should have been throw for a bad child node');
} catch (\Exception $e) {

View File

@ -224,8 +224,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase
public function testSetCode()
{
$command = new \TestCommand();
$ret = $command->setCode(function (InputInterface $input, OutputInterface $output)
{
$ret = $command->setCode(function (InputInterface $input, OutputInterface $output) {
$output->writeln('from the code...');
});
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');

View File

@ -154,8 +154,7 @@ class Tokenizer
*/
private function unescapeStringLiteral($literal)
{
return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal)
{
return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal) {
if ($matches[0][0] == '\\' && strlen($matches[0]) > 1) {
$matches[0] = substr($matches[0], 1);
if (in_array($matches[0][0], array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'))) {

View File

@ -1037,8 +1037,7 @@ EOF;
return $this->dumpParameter(strtolower($match[1]));
} else {
$that = $this;
$replaceParameters = function ($match) use ($that)
{
$replaceParameters = function ($match) use ($that) {
return "'.".$that->dumpParameter(strtolower($match[2])).".'";
};

View File

@ -41,8 +41,7 @@ class ClosureLoaderTest extends \PHPUnit_Framework_TestCase
{
$loader = new ClosureLoader($container = new ContainerBuilder());
$loader->load(function ($container)
{
$loader->load(function ($container) {
$container->setParameter('foo', 'foo');
});

View File

@ -263,8 +263,7 @@ EOF
public function testReduce()
{
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
$nodes = $crawler->reduce(function ($node, $i)
{
$nodes = $crawler->reduce(function ($node, $i) {
return $i == 1 ? false : true;
});
$this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler');

View File

@ -378,8 +378,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
public function testIsRedirectRedirection()
{
foreach (array(301, 302, 303, 307) as $code)
{
foreach (array(301, 302, 303, 307) as $code) {
$response = new Response('', $code);
$this->assertTrue($response->isRedirection());
$this->assertTrue($response->isRedirect());
@ -413,8 +412,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
public function testIsEmpty()
{
foreach (array(201, 204, 304) as $code)
{
foreach (array(201, 204, 304) as $code) {
$response = new Response('', $code);
$this->assertTrue($response->isEmpty());
}

View File

@ -169,8 +169,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$time = new \DateTime();
$this->setNextResponse(200, array(), '', function ($request, $response) use ($time)
{
$this->setNextResponse(200, array(), '', function ($request, $response) use ($time) {
$response->setStatusCode(200);
$response->headers->set('ETag', '12345');
$response->headers->set('Last-Modified', $time->format(DATE_RFC2822));
@ -197,8 +196,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testValidatesPrivateResponsesCachedOnTheClient()
{
$this->setNextResponse(200, array(), '', function ($request, $response)
{
$this->setNextResponse(200, array(), '', function ($request, $response) {
$etags = preg_split('/\s*,\s*/', $request->headers->get('IF_NONE_MATCH'));
if ($request->cookies->has('authenticated')) {
$response->headers->set('Cache-Control', 'private, no-store');
@ -257,8 +255,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$count = 0;
$this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count)
{
$this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) {
++$count;
$response->setContent(1 == $count ? 'Hello World' : 'Goodbye World');
});
@ -285,8 +282,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$count = 0;
$this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count)
{
$this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) {
++$count;
$response->setContent(1 == $count ? 'Hello World' : 'Goodbye World');
});
@ -317,8 +313,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$count = 0;
$this->setNextResponse(200, array(), '', function ($request, $response) use (&$count)
{
$this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) {
++$count;
$response->headers->set('Cache-Control', 'public, max-age=10000');
$response->setETag($count);
@ -348,8 +343,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$count = 0;
$this->setNextResponse(200, array(), '', function ($request, $response) use (&$count)
{
$this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) {
++$count;
$response->headers->set('Cache-Control', 'public, max-age=10000');
$response->setETag($count);
@ -658,8 +652,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInformation()
{
$time = \DateTime::createFromFormat('U', time());
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) {
$response->headers->set('Cache-Control', 'public');
$response->headers->set('Last-Modified', $time->format(DATE_RFC2822));
if ($time->format(DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) {
@ -695,8 +688,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation()
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) {
$response->headers->set('Cache-Control', 'public');
$response->headers->set('ETag', '"12345"');
if ($response->getETag() == $request->headers->get('IF_NONE_MATCH')) {
@ -733,8 +725,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$time = \DateTime::createFromFormat('U', time());
$count = 0;
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count) {
$response->headers->set('Last-Modified', $time->format(DATE_RFC2822));
$response->headers->set('Cache-Control', 'public');
switch (++$count) {
@ -772,8 +763,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testPassesHeadRequestsThroughDirectlyOnPass()
{
$that = $this;
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) {
$response->setContent('');
$response->setStatusCode(200);
$that->assertEquals('HEAD', $request->getMethod());
@ -787,8 +777,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testUsesCacheToRespondToHeadRequestsWhenFresh()
{
$that = $this;
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) {
$response->headers->set('Cache-Control', 'public, max-age=10');
$response->setContent('Hello World');
$response->setStatusCode(200);
@ -810,8 +799,7 @@ class HttpCacheTest extends HttpCacheTestCase
{
$time = \DateTime::createFromFormat('U', time());
$that = $this;
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) {
$response->headers->set('Cache-Control', 'public, max-age=10');
$response->headers->set('Last-Modified', $time->format(DATE_RFC2822));
});
@ -828,8 +816,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testInvalidatesCachedResponsesOnPost()
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response)
{
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) {
if ('GET' == $request->getMethod()) {
$response->setStatusCode(200);
$response->headers->set('Cache-Control', 'public, max-age=500');
@ -878,8 +865,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testServesFromCacheWhenHeadersMatch()
{
$count = 0;
$this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count)
{
$this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) {
$response->headers->set('Vary', 'Accept User-Agent Foo');
$response->headers->set('Cache-Control', 'public, max-age=10');
$response->headers->set('X-Response-Count', ++$count);
@ -903,8 +889,7 @@ class HttpCacheTest extends HttpCacheTestCase
public function testStoresMultipleResponsesWhenHeadersDiffer()
{
$count = 0;
$this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count)
{
$this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) {
$response->headers->set('Vary', 'Accept User-Agent Foo');
$response->headers->set('Cache-Control', 'public, max-age=10');
$response->headers->set('X-Response-Count', ++$count);

View File

@ -162,8 +162,7 @@ class HttpCacheTestCase extends \PHPUnit_Framework_TestCase
$fp = opendir($directory);
while (false !== $file = readdir($fp)) {
if (!in_array($file, array('.', '..')))
{
if (!in_array($file, array('.', '..'))) {
if (is_link($directory.'/'.$file)) {
unlink($directory.'/'.$file);
} elseif (is_dir($directory.'/'.$file)) {

View File

@ -54,8 +54,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event)
{
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) {
$event->setResponse(new Response($event->getException()->getMessage()));
});
@ -67,8 +66,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
public function testHandleWhenAListenerReturnsAResponse()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(KernelEvents::REQUEST, function ($event)
{
$dispatcher->addListener(KernelEvents::REQUEST, function ($event) {
$event->setResponse(new Response('hello'));
});
@ -154,8 +152,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(KernelEvents::VIEW, function ($event)
{
$dispatcher->addListener(KernelEvents::VIEW, function ($event) {
$event->setResponse(new Response($event->getControllerResult()));
});
$kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; }));
@ -166,8 +163,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
public function testHandleWithAResponseListener()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(KernelEvents::RESPONSE, function ($event)
{
$dispatcher->addListener(KernelEvents::RESPONSE, function ($event) {
$event->setResponse(new Response('foo'));
});
$kernel = new HttpKernel($dispatcher, $this->getResolver());

View File

@ -441,8 +441,7 @@ foreach ($bundle->get('Currencies') as $code => $data) {
}
// Countries.
$countriesConstraint = function($code)
{
$countriesConstraint = function($code) {
// Global countries (f.i. "America") have numeric codes
// Countries have alphabetic codes
// "ZZ" is the code for unknown country
@ -456,8 +455,7 @@ $countriesConstraint = function($code)
$countries = get_data('Countries', 'region', $defaultLocale, $countriesConstraint);
// Languages
$languagesConstraint = function($code)
{
$languagesConstraint = function($code) {
// "mul" is the code for multiple languages
if ('mul' !== $code) {
return true;

View File

@ -152,8 +152,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
$baseData = str_repeat('*', 1024);
$codes = array();
foreach (array(1, 16, 64, 1024, 4096) as $size)
{
foreach (array(1, 16, 64, 1024, 4096) as $size) {
$data = str_repeat($baseData, $size) . '!';
foreach ($variations as $code) {
$codes[] = array($data, $code);

View File

@ -25,8 +25,7 @@ while ($read || $write) {
die(ERR_TIMEOUT);
}
if (in_array(STDOUT, $w) && strlen($out) > 0)
{
if (in_array(STDOUT, $w) && strlen($out) > 0) {
$written = fwrite(STDOUT, (binary) $out, 1024);
if (false === $written) {
die(ERR_WRITE_FAILED);
@ -37,8 +36,7 @@ while ($read || $write) {
$write = array_diff($write, array(STDOUT));
}
if (in_array(STDERR, $w) && strlen($err) > 0)
{
if (in_array(STDERR, $w) && strlen($err) > 0) {
$written = fwrite(STDERR, (binary) $err, 1024);
if (false === $written) {
die(ERR_WRITE_FAILED);

View File

@ -48,8 +48,7 @@ class ClosureLoaderTest extends \PHPUnit_Framework_TestCase
$loader = new ClosureLoader();
$route = new Route('/');
$routes = $loader->load(function () use ($route)
{
$routes = $loader->load(function () use ($route) {
$routes = new RouteCollection();
$routes->add('foo', $route);

View File

@ -187,8 +187,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
do {
$sid = $this->chooseSid();
}
while (array_key_exists($sid, $sids) && in_array($fieldName, $sids[$sid], true));
} while (array_key_exists($sid, $sids) && in_array($fieldName, $sids[$sid], true));
$fieldOrder[$fieldName] = array_key_exists($fieldName, $fieldOrder) ? $fieldOrder[$fieldName]+1 : 0;
if (!isset($sids[$sid])) {

View File

@ -445,8 +445,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
*
* @return string the escaped value
*/
function ($value) use ($that)
{
function ($value) use ($that) {
// Numbers and Boolean values get turned into strings which can cause problems
// with type comparisons (e.g. === or is_int() etc).
return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $that->getCharset(), false) : $value;
@ -460,14 +459,12 @@ class PhpEngine implements EngineInterface, \ArrayAccess
* @param string $value the value to escape
* @return string the escaped value
*/
function ($value) use ($that)
{
function ($value) use ($that) {
if ('UTF-8' != $that->getCharset()) {
$value = $that->convertEncoding($value, 'UTF-8', $that->getCharset());
}
$callback = function ($matches) use ($that)
{
$callback = function ($matches) use ($that) {
$char = $matches[0];
// \xHH