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); 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': case 'array':
return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE); return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE);
case 'boolean': case 'boolean':

View File

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

View File

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

View File

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

View File

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

View File

@ -154,8 +154,7 @@ class Tokenizer
*/ */
private function unescapeStringLiteral($literal) 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) { if ($matches[0][0] == '\\' && strlen($matches[0]) > 1) {
$matches[0] = substr($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'))) { 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])); return $this->dumpParameter(strtolower($match[1]));
} else { } else {
$that = $this; $that = $this;
$replaceParameters = function ($match) use ($that) $replaceParameters = function ($match) use ($that) {
{
return "'.".$that->dumpParameter(strtolower($match[2])).".'"; 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 = new ClosureLoader($container = new ContainerBuilder());
$loader->load(function ($container) $loader->load(function ($container) {
{
$container->setParameter('foo', 'foo'); $container->setParameter('foo', 'foo');
}); });

View File

@ -263,8 +263,7 @@ EOF
public function testReduce() public function testReduce()
{ {
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
$nodes = $crawler->reduce(function ($node, $i) $nodes = $crawler->reduce(function ($node, $i) {
{
return $i == 1 ? false : true; return $i == 1 ? false : true;
}); });
$this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler'); $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() public function testIsRedirectRedirection()
{ {
foreach (array(301, 302, 303, 307) as $code) foreach (array(301, 302, 303, 307) as $code) {
{
$response = new Response('', $code); $response = new Response('', $code);
$this->assertTrue($response->isRedirection()); $this->assertTrue($response->isRedirection());
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
@ -413,8 +412,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
public function testIsEmpty() public function testIsEmpty()
{ {
foreach (array(201, 204, 304) as $code) foreach (array(201, 204, 304) as $code) {
{
$response = new Response('', $code); $response = new Response('', $code);
$this->assertTrue($response->isEmpty()); $this->assertTrue($response->isEmpty());
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -152,8 +152,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
$baseData = str_repeat('*', 1024); $baseData = str_repeat('*', 1024);
$codes = array(); $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) . '!'; $data = str_repeat($baseData, $size) . '!';
foreach ($variations as $code) { foreach ($variations as $code) {
$codes[] = array($data, $code); $codes[] = array($data, $code);

View File

@ -25,8 +25,7 @@ while ($read || $write) {
die(ERR_TIMEOUT); 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); $written = fwrite(STDOUT, (binary) $out, 1024);
if (false === $written) { if (false === $written) {
die(ERR_WRITE_FAILED); die(ERR_WRITE_FAILED);
@ -37,8 +36,7 @@ while ($read || $write) {
$write = array_diff($write, array(STDOUT)); $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); $written = fwrite(STDERR, (binary) $err, 1024);
if (false === $written) { if (false === $written) {
die(ERR_WRITE_FAILED); die(ERR_WRITE_FAILED);

View File

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

View File

@ -187,8 +187,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
do { do {
$sid = $this->chooseSid(); $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; $fieldOrder[$fieldName] = array_key_exists($fieldName, $fieldOrder) ? $fieldOrder[$fieldName]+1 : 0;
if (!isset($sids[$sid])) { if (!isset($sids[$sid])) {

View File

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