Merge branch '2.6' into 2.7

* 2.6:
  [HttpFoundation] MongoDbSessionHandler::read() now checks for valid session age
  Changed visibility of setUp() and tearDown to protected
  [WebProfilerBundle] Set debug+charset on the ExceptionHandler fallback
  Added default button class
  used HTML5 meta charset tag and removed hardcoded ones
  Revert "bug #13715 Enforce UTF-8 charset for core controllers (WouterJ)"
  fixed XSS in the exception handler
  Php Inspections (EA Extended) - static code analysis includes:
  [2.3] Remove most refs uses
  Test with local components instead of waiting for the subtree-splitter when possible

Conflicts:
	.travis.yml
This commit is contained in:
Fabien Potencier 2015-03-12 15:31:07 +01:00
commit 6d605a7d3e
51 changed files with 228 additions and 222 deletions

2
.gitignore vendored
View File

@ -2,4 +2,6 @@ phpunit.xml
composer.lock composer.lock
composer.phar composer.phar
autoload.php autoload.php
package*.tar
packages.json
/vendor/ /vendor/

25
.travis.sh Normal file
View File

@ -0,0 +1,25 @@
branch=$1
if [ -z "$branch" ]; then
echo 'Usage: branch dir1 dir2 ... dirN'
exit 1
fi
shift
components=$*
if [ -z "$components" ]; then
echo 'Usage: branch dir1 dir2 ... dirN'
exit 1
fi
echo '{"packages": {' > packages.json
components=$(
for c in $components; do
sed -i ':a;N;$!ba;s#^{\n\(\s*\)\("name"\)#{\n\1"repositories": \[{ "type": "composer", "url": "file://'$(pwd)'/" }\],\n\1\2#' $c/composer.json
n=$(php -r '$n=json_decode(file_get_contents("'$c'/composer.json"));echo $n->name;')
echo '"'$n'": {"'$branch'.x-dev": ' >> packages.json
cat $c/composer.json >> packages.json
echo '"version": "'$branch.x-dev'",\n "dist": {"type": "tar", "url": "file://'$(pwd)/$c'/package'$branch'.tar"}\n}},' >> packages.json
echo $c
done;
)
sed -i ':a;N;$!ba;s/\n}\n"/,\n "/g' packages.json
sed -i ':a;N;$!ba;s/}},$/\n}}\n}}/' packages.json
echo "$components" | parallel --gnu "cd {}; tar -cf package$branch.tar --exclude='package*.tar' *"

View File

@ -39,6 +39,8 @@ before_install:
install: install:
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi; - if [ "$deps" = "no" ]; then composer --prefer-source install; fi;
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
- if [ "$deps" != "no" ]; then sh .travis.sh $TRAVIS_BRANCH $components; fi;
script: script:
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n') - components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')

View File

@ -117,8 +117,10 @@ class DoctrineDataCollector extends DataCollector
private function sanitizeQuery($connectionName, $query) private function sanitizeQuery($connectionName, $query)
{ {
$query['explainable'] = true; $query['explainable'] = true;
$query['params'] = (array) $query['params']; if (!is_array($query['params'])) {
foreach ($query['params'] as $j => &$param) { $query['params'] = array($query['params']);
}
foreach ($query['params'] as $j => $param) {
if (isset($query['types'][$j])) { if (isset($query['types'][$j])) {
// Transform the param according to the type // Transform the param according to the type
$type = $query['types'][$j]; $type = $query['types'][$j];
@ -131,7 +133,7 @@ class DoctrineDataCollector extends DataCollector
} }
} }
list($param, $explainable) = $this->sanitizeParam($param); list($query['params'][$j], $explainable) = $this->sanitizeParam($param);
if (!$explainable) { if (!$explainable) {
$query['explainable'] = false; $query['explainable'] = false;
} }

View File

@ -31,7 +31,7 @@ class RuntimeInstantiatorTest extends \PHPUnit_Framework_TestCase
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() protected function setUp()
{ {
$this->instantiator = new RuntimeInstantiator(); $this->instantiator = new RuntimeInstantiator();
} }

View File

@ -31,7 +31,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setUp() protected function setUp()
{ {
$this->dumper = new ProxyDumper(); $this->dumper = new ProxyDumper();
} }

View File

@ -15,7 +15,7 @@
{%- endblock textarea_widget %} {%- endblock textarea_widget %}
{% block button_widget -%} {% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %} {% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %}
{{- parent() -}} {{- parent() -}}
{%- endblock %} {%- endblock %}

View File

@ -84,7 +84,7 @@ class TwigExtractor implements ExtractorInterface
$this->twig->parse($this->twig->tokenize($template)); $this->twig->parse($this->twig->tokenize($template));
foreach ($visitor->getMessages() as $message) { foreach ($visitor->getMessages() as $message) {
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain); $catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
} }
$visitor->disable(); $visitor->disable();

View File

@ -29,7 +29,7 @@ class ControllerNameParserTest extends TestCase
$this->loader->register(); $this->loader->register();
} }
public function tearDown() protected function tearDown()
{ {
spl_autoload_unregister(array($this->loader, 'loadClass')); spl_autoload_unregister(array($this->loader, 'loadClass'));

View File

@ -26,7 +26,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$this->deleteTmpDir(); $this->deleteTmpDir();
} }
public function tearDown() protected function tearDown()
{ {
$this->deleteTmpDir(); $this->deleteTmpDir();
} }

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8" /> <meta charset="{{ _charset }}" />
<title>{% block title %}Welcome!{% endblock %}</title> <title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}{% endblock %} {% block stylesheets %}{% endblock %}
</head> </head>

View File

@ -62,7 +62,7 @@ class ExceptionController
$code = $exception->getStatusCode(); $code = $exception->getStatusCode();
return Response::create($this->twig->render( return new Response($this->twig->render(
$this->findTemplate($request, $request->getRequestFormat(), $code, $showException), $this->findTemplate($request, $request->getRequestFormat(), $code, $showException),
array( array(
'status_code' => $code, 'status_code' => $code,
@ -71,7 +71,7 @@ class ExceptionController
'logger' => $logger, 'logger' => $logger,
'currentContent' => $currentContent, 'currentContent' => $currentContent,
) )
))->setCharset('UTF-8'); ));
} }
/** /**

View File

@ -36,13 +36,13 @@ class TwigExtension extends Extension
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('twig.xml'); $loader->load('twig.xml');
foreach ($configs as &$config) { foreach ($configs as $key => $config) {
if (isset($config['globals'])) { if (isset($config['globals'])) {
foreach ($config['globals'] as $name => $value) { foreach ($config['globals'] as $name => $value) {
if (is_array($value) && isset($value['key'])) { if (is_array($value) && isset($value['key'])) {
$config['globals'][$name] = array( $configs[$key]['globals'][$name] = array(
'key' => $name, 'key' => $name,
'value' => $config['globals'][$name], 'value' => $value,
); );
} }
} }

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8" /> <meta charset="{{ _charset }}" />
<title>An Error Occurred: {{ status_text }}</title> <title>An Error Occurred: {{ status_text }}</title>
</head> </head>
<body> <body>

View File

@ -40,8 +40,7 @@ class ExceptionControllerTest extends TestCase
$request->headers->set('X-Php-Ob-Level', 1); $request->headers->set('X-Php-Ob-Level', 1);
$controller = new ExceptionController($twig, false); $controller = new ExceptionController($twig, false);
$response = $controller->showAction($request, $flatten); $controller->showAction($request, $flatten);
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
} }
public function testShowActionCanBeForcedToShowErrorPage() public function testShowActionCanBeForcedToShowErrorPage()

View File

@ -29,7 +29,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
*/ */
private $pass; private $pass;
public function setUp() protected function setUp()
{ {
$this->builder = $this->getMock( $this->builder = $this->getMock(
'Symfony\Component\DependencyInjection\ContainerBuilder', 'Symfony\Component\DependencyInjection\ContainerBuilder',

View File

@ -17,7 +17,7 @@ use Symfony\Bundle\TwigBundle\Node\RenderNode;
class LegacyRenderTokenParserTest extends TestCase class LegacyRenderTokenParserTest extends TestCase
{ {
public function setUp() protected function setUp()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
} }

View File

@ -55,24 +55,23 @@ class ExceptionController
$template = $this->getTemplate(); $template = $this->getTemplate();
if (!$this->twig->getLoader()->exists($template)) { if (!$this->twig->getLoader()->exists($template)) {
$handler = new ExceptionHandler(); $handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html')); return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html'));
} }
$code = $exception->getStatusCode(); $code = $exception->getStatusCode();
return Response::create( return new Response($this->twig->render(
$this->twig->render($template, array( $template,
array(
'status_code' => $code, 'status_code' => $code,
'status_text' => Response::$statusTexts[$code], 'status_text' => Response::$statusTexts[$code],
'exception' => $exception, 'exception' => $exception,
'logger' => null, 'logger' => null,
'currentContent' => '', 'currentContent' => '',
)), )
200, ), 200, array('Content-Type' => 'text/html'));
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -96,16 +95,12 @@ class ExceptionController
$template = $this->getTemplate(); $template = $this->getTemplate();
if (!$this->templateExists($template)) { if (!$this->templateExists($template)) {
$handler = new ExceptionHandler(); $handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
$response = new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css')); return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
} else {
$response = new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
} }
$response->setCharset('UTF-8'); return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
return $response;
} }
protected function getTemplate() protected function getTemplate()

View File

@ -99,20 +99,16 @@ class ProfilerController
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token)); throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
} }
return Response::create( return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
$this->twig->render($this->getTemplateManager()->getName($profile, $panel), array( 'token' => $token,
'token' => $token, 'profile' => $profile,
'profile' => $profile, 'collector' => $profile->getCollector($panel),
'collector' => $profile->getCollector($panel), 'panel' => $panel,
'panel' => $panel, 'page' => $page,
'page' => $page, 'request' => $request,
'request' => $request, 'templates' => $this->getTemplateManager()->getTemplates($profile),
'templates' => $this->getTemplateManager()->getTemplates($profile), 'is_ajax' => $request->isXmlHttpRequest(),
'is_ajax' => $request->isXmlHttpRequest(), )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -151,13 +147,9 @@ class ProfilerController
$this->profiler->disable(); $this->profiler->disable();
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/info.html.twig', array( 'about' => $about,
'about' => $about, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -205,17 +197,13 @@ class ProfilerController
// the profiler is not enabled // the profiler is not enabled
} }
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array( 'position' => $position,
'position' => $position, 'profile' => $profile,
'profile' => $profile, 'templates' => $this->getTemplateManager()->getTemplates($profile),
'templates' => $this->getTemplateManager()->getTemplates($profile), 'profiler_url' => $url,
'profiler_url' => $url, 'token' => $token,
'token' => $token, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -253,7 +241,7 @@ class ProfilerController
$token = $session->get('_profiler_search_token'); $token = $session->get('_profiler_search_token');
} }
return Response::create( return new Response(
$this->twig->render('@WebProfiler/Profiler/search.html.twig', array( $this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
'token' => $token, 'token' => $token,
'ip' => $ip, 'ip' => $ip,
@ -266,7 +254,7 @@ class ProfilerController
)), )),
200, 200,
array('Content-Type' => 'text/html') array('Content-Type' => 'text/html')
)->setCharset('UTF-8'); );
} }
/** /**
@ -296,22 +284,18 @@ class ProfilerController
$end = $request->query->get('end', null); $end = $request->query->get('end', null);
$limit = $request->query->get('limit'); $limit = $request->query->get('limit');
return Response::create( return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
$this->twig->render('@WebProfiler/Profiler/results.html.twig', array( 'token' => $token,
'token' => $token, 'profile' => $profile,
'profile' => $profile, 'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end), 'ip' => $ip,
'ip' => $ip, 'method' => $method,
'method' => $method, 'url' => $url,
'url' => $url, 'start' => $start,
'start' => $start, 'end' => $end,
'end' => $end, 'limit' => $limit,
'limit' => $limit, 'panel' => null,
'panel' => null, )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
/** /**
@ -385,7 +369,7 @@ class ProfilerController
phpinfo(); phpinfo();
$phpinfo = ob_get_clean(); $phpinfo = ob_get_clean();
return Response::create($phpinfo, 200, array('Content-Type' => 'text/html'))->setCharset('UTF-8'); return new Response($phpinfo, 200, array('Content-Type' => 'text/html'));
} }
/** /**

View File

@ -68,14 +68,10 @@ class RouterController
$request = $profile->getCollector('request'); $request = $profile->getCollector('request');
return Response::create( return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array(
$this->twig->render('@WebProfiler/Router/panel.html.twig', array( 'request' => $request,
'request' => $request, 'router' => $profile->getCollector('router'),
'router' => $profile->getCollector('router'), 'traces' => $matcher->getTraces($request->getPathInfo()),
'traces' => $matcher->getTraces($request->getPathInfo()), )), 200, array('Content-Type' => 'text/html'));
)),
200,
array('Content-Type' => 'text/html')
)->setCharset('UTF-8');
} }
} }

View File

@ -1,8 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="{{ _charset }}" />
<meta name="robots" content="noindex,nofollow"> <meta name="robots" content="noindex,nofollow" />
<title>{% block title 'Profiler' %}</title> <title>{% block title 'Profiler' %}</title>
<link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/ico;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAADIvMQAyLzEIMi8xSzEuMKoyLzHkMi8x/TIvMf0yLzHlMi8xrDIvMU4yLzEJMi8xAAAAAAAAAAAAAAAAADIvMQAyLzEYMS4wkTMwMu45Njj/MS4w/zEuMP8yLzH/Mi8x/zIvMf8yLzHvMi8xlDIvMRkyLzEAAAAAADIvMQAyLzEXMS4wrTk2OPyVk5T7kI6P/nl3ef8+Oz3/MS4w/zIvMf8yLzH/Mi8x/zIvMf4yLzGxMi8xGjIvMQAyLzEGMi8xkDEuMP4/PD79wcDA+oB+gP6Ni4z/paOk/zk2OP8xLjD/Mi8x/zIvMf8yLzH/Mi8x/zIvMZQyLzEIMi8xSTIvMewyLzH/MS4w/z06PP81MjT+TktN/93c3f97eXv/MC0v/zIvMf8yLzH/Mi8x/zIvMf8yLzHuMi8xTzIvMaUyLzH/Mi8x/0lHSf9kYmP/XFpb/zs4Ov/DwsL+ycjI/zs4Ov8xLjD/Mi8x/zIvMf8yLzH/Mi8x/zIvMawyLzHfMC0v/1tYWv+opqf/YV5g/8bFxf96eHn+m5qb/u7u7v9WVFX/MC0v/zIvMf8yLzH/Mi8x/zIvMf8yLzHkMi8x+jAtL/9iYGH/mZiZ/2dlZv/p6On/oJ+g/np4ev/6+vr/dXN1/y0qLP8xLjD/Mi8x/zIvMf8yLzH/Mi8x/DIvMfoyLzH/MzAy/0A+QP7JyMj85eXl/1tYWv9XVVf/8fDx/6qpqv9ZV1j/Q0BC/zIvMf8yLzH/Mi8x/zIvMfwyLzHeMi8x/zEuMP8/PD762dnZ9JWTlP81MjT/ZmRm/+Dg4P/DwsP/YV5g/6Wkpf9BPkD/MS4w/zIvMf8yLzHjMi8xozIvMf8yLzH/Mi8x/nZ0dv2amJn4dXN0+V5bXf+Pjo//0tLS/0hFR/9vbG7/Ozg6/zEuMP8yLzH/Mi8xqTIvMUcyLzHrMi8x/zIvMf8xLjD/Ozg6/Do3OfwwLS//REFD/728vP9nZWb/TktN/4mIif05Nzn/Mi8x7jMwMkwyLzEGMi8xjDIvMf4yLzH/Mi8x/zIvMf8yLzH/Mi8x/zAtL/9XVFb/goGC+Hx6e+6qqanwOzg6/DMwMpJDQEIIMi8xADIvMRUyLzGrMi8x/jIvMf8yLzH/Mi8x/zIvMf8yLzH/MS4w/zg2N/xBPkD3OTY4/DIvMa8yLzEYMi8xAAAAAAAyLzEAMi8xGDIvMY0yLzHqMi8x/zIvMf8yLzH/Mi8x/zIvMf8yLzH/MS4w7DEuMJEyLzEaMi8xAAAAAAAAAAAAAAAAADIvMQAyLzEGMi8xQzIvMZ4yLzHdMi8x+jIvMfoyLzHeMi8xoDIvMUUyLzEGMi8xAAAAAAAAAAAA4AcAAMADAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAADAAwAA4AcAAA=="> <link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/ico;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAADIvMQAyLzEIMi8xSzEuMKoyLzHkMi8x/TIvMf0yLzHlMi8xrDIvMU4yLzEJMi8xAAAAAAAAAAAAAAAAADIvMQAyLzEYMS4wkTMwMu45Njj/MS4w/zEuMP8yLzH/Mi8x/zIvMf8yLzHvMi8xlDIvMRkyLzEAAAAAADIvMQAyLzEXMS4wrTk2OPyVk5T7kI6P/nl3ef8+Oz3/MS4w/zIvMf8yLzH/Mi8x/zIvMf4yLzGxMi8xGjIvMQAyLzEGMi8xkDEuMP4/PD79wcDA+oB+gP6Ni4z/paOk/zk2OP8xLjD/Mi8x/zIvMf8yLzH/Mi8x/zIvMZQyLzEIMi8xSTIvMewyLzH/MS4w/z06PP81MjT+TktN/93c3f97eXv/MC0v/zIvMf8yLzH/Mi8x/zIvMf8yLzHuMi8xTzIvMaUyLzH/Mi8x/0lHSf9kYmP/XFpb/zs4Ov/DwsL+ycjI/zs4Ov8xLjD/Mi8x/zIvMf8yLzH/Mi8x/zIvMawyLzHfMC0v/1tYWv+opqf/YV5g/8bFxf96eHn+m5qb/u7u7v9WVFX/MC0v/zIvMf8yLzH/Mi8x/zIvMf8yLzHkMi8x+jAtL/9iYGH/mZiZ/2dlZv/p6On/oJ+g/np4ev/6+vr/dXN1/y0qLP8xLjD/Mi8x/zIvMf8yLzH/Mi8x/DIvMfoyLzH/MzAy/0A+QP7JyMj85eXl/1tYWv9XVVf/8fDx/6qpqv9ZV1j/Q0BC/zIvMf8yLzH/Mi8x/zIvMfwyLzHeMi8x/zEuMP8/PD762dnZ9JWTlP81MjT/ZmRm/+Dg4P/DwsP/YV5g/6Wkpf9BPkD/MS4w/zIvMf8yLzHjMi8xozIvMf8yLzH/Mi8x/nZ0dv2amJn4dXN0+V5bXf+Pjo//0tLS/0hFR/9vbG7/Ozg6/zEuMP8yLzH/Mi8xqTIvMUcyLzHrMi8x/zIvMf8xLjD/Ozg6/Do3OfwwLS//REFD/728vP9nZWb/TktN/4mIif05Nzn/Mi8x7jMwMkwyLzEGMi8xjDIvMf4yLzH/Mi8x/zIvMf8yLzH/Mi8x/zAtL/9XVFb/goGC+Hx6e+6qqanwOzg6/DMwMpJDQEIIMi8xADIvMRUyLzGrMi8x/jIvMf8yLzH/Mi8x/zIvMf8yLzH/MS4w/zg2N/xBPkD3OTY4/DIvMa8yLzEYMi8xAAAAAAAyLzEAMi8xGDIvMY0yLzHqMi8x/zIvMf8yLzH/Mi8x/zIvMf8yLzH/MS4w7DEuMJEyLzEaMi8xAAAAAAAAAAAAAAAAADIvMQAyLzEGMi8xQzIvMZ4yLzHdMi8x+jIvMfoyLzHeMi8xoDIvMUUyLzEGMi8xAAAAAAAAAAAA4AcAAMADAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAADAAwAA4AcAAA==">
<style> <style>

View File

@ -69,7 +69,6 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase
$response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found'); $response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found');
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
$response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound'); $response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound');
$this->assertEquals(404, $response->getStatusCode()); $this->assertEquals(404, $response->getStatusCode());

View File

@ -41,7 +41,7 @@ class TemplateManagerTest extends TestCase
*/ */
protected $templateManager; protected $templateManager;
public function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -22,7 +22,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase
private $metaFile = null; private $metaFile = null;
public function setUp() protected function setUp()
{ {
$this->resourceFile = tempnam(sys_get_temp_dir(), '_resource'); $this->resourceFile = tempnam(sys_get_temp_dir(), '_resource');
$this->cacheFile = tempnam(sys_get_temp_dir(), 'config_'); $this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
@ -32,7 +32,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase
$this->generateMetaFile(); $this->generateMetaFile();
} }
public function tearDown() protected function tearDown()
{ {
$files = array($this->cacheFile, $this->metaFile, $this->resourceFile); $files = array($this->cacheFile, $this->metaFile, $this->resourceFile);

View File

@ -191,14 +191,14 @@ class XmlUtils
return; return;
case ctype_digit($value): case ctype_digit($value):
$raw = $value; $raw = $value;
$cast = intval($value); $cast = (int) $value;
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw); return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)): case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
$raw = $value; $raw = $value;
$cast = intval($value); $cast = intval($value);
return '0' == $value[1] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw); return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
case 'true' === $lowercaseValue: case 'true' === $lowercaseValue:
return true; return true;
case 'false' === $lowercaseValue: case 'false' === $lowercaseValue:
@ -206,9 +206,9 @@ class XmlUtils
case isset($value[1]) && '0b' == $value[0].$value[1]: case isset($value[1]) && '0b' == $value[0].$value[1]:
return bindec($value); return bindec($value);
case is_numeric($value): case is_numeric($value):
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value); return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value): case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):
return floatval($value); return (float) $value;
default: default:
return $value; return $value;
} }

View File

@ -45,7 +45,9 @@ class FormatterHelper extends Helper
*/ */
public function formatBlock($messages, $style, $large = false) public function formatBlock($messages, $style, $large = false)
{ {
$messages = (array) $messages; if (!is_array($messages)) {
$messages = array($messages);
}
$len = 0; $len = 0;
$lines = array(); $lines = array();
@ -56,15 +58,15 @@ class FormatterHelper extends Helper
} }
$messages = $large ? array(str_repeat(' ', $len)) : array(); $messages = $large ? array(str_repeat(' ', $len)) : array();
foreach ($lines as $line) { for ($i = 0; isset($lines[$i]); ++$i) {
$messages[] = $line.str_repeat(' ', $len - $this->strlen($line)); $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
} }
if ($large) { if ($large) {
$messages[] = str_repeat(' ', $len); $messages[] = str_repeat(' ', $len);
} }
foreach ($messages as &$message) { for ($i = 0; isset($messages[$i]); ++$i) {
$message = sprintf('<%s>%s</%s>', $style, $message, $style); $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
} }
return implode("\n", $messages); return implode("\n", $messages);

View File

@ -267,11 +267,11 @@ class ProgressHelper extends Helper
$redraw = true; $redraw = true;
} }
$prevPeriod = intval($this->current / $this->redrawFreq); $prevPeriod = (int) ($this->current / $this->redrawFreq);
$this->current = $current; $this->current = $current;
$currPeriod = intval($this->current / $this->redrawFreq); $currPeriod = (int) ($this->current / $this->redrawFreq);
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) { if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
$this->display(); $this->display();
} }

View File

@ -177,6 +177,7 @@ class ExceptionHandler
foreach ($exception->getHeaders() as $name => $value) { foreach ($exception->getHeaders() as $name => $value) {
header($name.': '.$value, false); header($name.': '.$value, false);
} }
header('Content-Type: text/html; charset='.$this->charset);
} }
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
@ -195,7 +196,7 @@ class ExceptionHandler
$exception = FlattenException::create($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);
} }
/** /**
@ -251,7 +252,7 @@ EOF
} catch (\Exception $e) { } catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore // something nasty happened and we cannot throw an exception anymore
if ($this->debug) { 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), self::utf8Htmlize($e->getMessage()));
} else { } else {
$title = 'Whoops, looks like something went wrong.'; $title = 'Whoops, looks like something went wrong.';
} }

View File

@ -1004,9 +1004,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
public function resolveServices($value) public function resolveServices($value)
{ {
if (is_array($value)) { if (is_array($value)) {
foreach ($value as &$v) { $value = array_map(array($this, 'resolveServices'), $value);
$v = $this->resolveServices($v);
}
} elseif ($value instanceof Reference) { } elseif ($value instanceof Reference) {
$value = $this->get((string) $value, $value->getInvalidBehavior()); $value = $this->get((string) $value, $value->getInvalidBehavior());
} elseif ($value instanceof Definition) { } elseif ($value instanceof Definition) {

View File

@ -1483,13 +1483,13 @@ EOF;
if ('' === $name) { if ('' === $name) {
$name .= $firstChars[$i%$firstCharsLength]; $name .= $firstChars[$i%$firstCharsLength];
$i = intval($i/$firstCharsLength); $i = (int) ($i/$firstCharsLength);
} }
while ($i > 0) { while ($i > 0) {
--$i; --$i;
$name .= $nonFirstChars[$i%$nonFirstCharsLength]; $name .= $nonFirstChars[$i%$nonFirstCharsLength];
$i = intval($i/$nonFirstCharsLength); $i = (int) ($i/$nonFirstCharsLength);
} }
++$this->variableCount; ++$this->variableCount;

View File

@ -154,7 +154,7 @@ class Link
} }
if ('.' === substr($path, -1)) { if ('.' === substr($path, -1)) {
$path = $path.'/'; $path .= '/';
} }
$output = array(); $output = array();

View File

@ -23,7 +23,7 @@ class FilesystemTest extends FilesystemTestCase
*/ */
private $filesystem = null; private $filesystem = null;
public function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$this->filesystem = new Filesystem(); $this->filesystem = new Filesystem();

View File

@ -37,7 +37,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
} }
} }
public function setUp() protected function setUp()
{ {
$this->umask = umask(0); $this->umask = umask(0);
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000); $this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
@ -45,7 +45,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
$this->workspace = realpath($this->workspace); $this->workspace = realpath($this->workspace);
} }
public function tearDown() protected function tearDown()
{ {
$this->clean($this->workspace); $this->clean($this->workspace);
umask($this->umask); umask($this->umask);

View File

@ -436,9 +436,9 @@ class Finder implements \IteratorAggregate, \Countable
public function ignoreDotFiles($ignoreDotFiles) public function ignoreDotFiles($ignoreDotFiles)
{ {
if ($ignoreDotFiles) { if ($ignoreDotFiles) {
$this->ignore = $this->ignore | static::IGNORE_DOT_FILES; $this->ignore |= static::IGNORE_DOT_FILES;
} else { } else {
$this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES; $this->ignore &= ~static::IGNORE_DOT_FILES;
} }
return $this; return $this;
@ -458,9 +458,9 @@ class Finder implements \IteratorAggregate, \Countable
public function ignoreVCS($ignoreVCS) public function ignoreVCS($ignoreVCS)
{ {
if ($ignoreVCS) { if ($ignoreVCS) {
$this->ignore = $this->ignore | static::IGNORE_VCS_FILES; $this->ignore |= static::IGNORE_VCS_FILES;
} else { } else {
$this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES; $this->ignore &= ~static::IGNORE_VCS_FILES;
} }
return $this; return $this;

View File

@ -134,7 +134,7 @@ class ChoiceType extends AbstractType
// Add "[]" to the name in case a select tag with multiple options is // Add "[]" to the name in case a select tag with multiple options is
// displayed. Otherwise only one of the selected options is sent in the // displayed. Otherwise only one of the selected options is sent in the
// POST request. // POST request.
$view->vars['full_name'] = $view->vars['full_name'].'[]'; $view->vars['full_name'] .= '[]';
} }
} }

View File

@ -44,7 +44,7 @@ class ServerParams
} elseif (0 === strpos($max, '0')) { } elseif (0 === strpos($max, '0')) {
$max = intval($max, 8); $max = intval($max, 8);
} else { } else {
$max = intval($max); $max = (int) $max;
} }
switch (substr($iniMax, -1)) { switch (substr($iniMax, -1)) {

View File

@ -270,7 +270,7 @@ class UploadedFile extends File
} elseif (0 === strpos($max, '0')) { } elseif (0 === strpos($max, '0')) {
$max = intval($max, 8); $max = intval($max, 8);
} else { } else {
$max = intval($max); $max = (int) $max;
} }
switch (substr($iniMax, -1)) { switch (substr($iniMax, -1)) {

View File

@ -1018,7 +1018,7 @@ class Request
} }
if (false !== $pos) { if (false !== $pos) {
return intval(substr($host, $pos + 1)); return (int) substr($host, $pos + 1);
} }
return 'https' === $this->getScheme() ? 443 : 80; return 'https' === $this->getScheme() ? 443 : 80;

View File

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

View File

@ -42,6 +42,24 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
* * id_field: The field name for storing the session id [default: _id] * * id_field: The field name for storing the session id [default: _id]
* * data_field: The field name for storing the session data [default: data] * * data_field: The field name for storing the session data [default: data]
* * time_field: The field name for storing the timestamp [default: time] * * time_field: The field name for storing the timestamp [default: time]
* * expiry_field: The field name for storing the expiry-timestamp [default: expires_at]
*
* It is strongly recommended to put an index on the `expiry_field` for
* garbage-collection. Alternatively it's possible to automatically expire
* the sessions in the database as described below:
*
* A TTL collections can be used on MongoDB 2.2+ to cleanup expired sessions
* automatically. Such an index can for example look like this:
*
* db.<session-collection>.ensureIndex(
* { "<expiry-field>": 1 },
* { "expireAfterSeconds": 0 }
* )
*
* More details on: http://docs.mongodb.org/manual/tutorial/expire-data/
*
* If you use such an index, you can drop `gc_probability` to 0 since
* no garbage-collection is required.
* *
* @param \Mongo|\MongoClient $mongo A MongoClient or Mongo instance * @param \Mongo|\MongoClient $mongo A MongoClient or Mongo instance
* @param array $options An associative array of field options * @param array $options An associative array of field options
@ -65,7 +83,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
'id_field' => '_id', 'id_field' => '_id',
'data_field' => 'data', 'data_field' => 'data',
'time_field' => 'time', 'time_field' => 'time',
'expiry_field' => false, 'expiry_field' => 'expires_at',
), $options); ), $options);
} }
@ -102,21 +120,8 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {
/* Note: MongoDB 2.2+ supports TTL collections, which may be used in
* place of this method by indexing the "time_field" field with an
* "expireAfterSeconds" option. Regardless of whether TTL collections
* are used, consider indexing this field to make the remove query more
* efficient.
*
* See: http://docs.mongodb.org/manual/tutorial/expire-data/
*/
if (false !== $this->options['expiry_field']) {
return true;
}
$time = new \MongoDate(time() - $maxlifetime);
$this->getCollection()->remove(array( $this->getCollection()->remove(array(
$this->options['time_field'] => array('$lt' => $time), $this->options['expiry_field'] => array('$lt' => new \MongoDate()),
)); ));
return true; return true;
@ -127,24 +132,14 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
*/ */
public function write($sessionId, $data) public function write($sessionId, $data)
{ {
$expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime'));
$fields = array( $fields = array(
$this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY),
$this->options['time_field'] => new \MongoDate(), $this->options['time_field'] => new \MongoDate(),
$this->options['expiry_field'] => $expiry,
); );
/* Note: As discussed in the gc method of this class. You can utilise
* TTL collections in MongoDB 2.2+
* We are setting the "expiry_field" as part of the write operation here
* You will need to create the index on your collection that expires documents
* at that time
* e.g.
* db.MySessionCollection.ensureIndex( { "expireAt": 1 }, { expireAfterSeconds: 0 } )
*/
if (false !== $this->options['expiry_field']) {
$expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime'));
$fields[$this->options['expiry_field']] = $expiry;
}
$this->getCollection()->update( $this->getCollection()->update(
array($this->options['id_field'] => $sessionId), array($this->options['id_field'] => $sessionId),
array('$set' => $fields), array('$set' => $fields),
@ -160,7 +155,8 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
public function read($sessionId) public function read($sessionId)
{ {
$dbData = $this->getCollection()->findOne(array( $dbData = $this->getCollection()->findOne(array(
$this->options['id_field'] => $sessionId, $this->options['id_field'] => $sessionId,
$this->options['expiry_field'] => array('$gte' => new \MongoDate()),
)); ));
return null === $dbData ? '' : $dbData[$this->options['data_field']]->bin; return null === $dbData ? '' : $dbData[$this->options['data_field']]->bin;

View File

@ -38,7 +38,7 @@ class AutoExpireFlashBagTest extends \PHPUnit_Framework_TestCase
$this->bag->initialize($this->array); $this->bag->initialize($this->array);
} }
public function tearDown() protected function tearDown()
{ {
$this->bag = null; $this->bag = null;
parent::tearDown(); parent::tearDown();

View File

@ -38,7 +38,7 @@ class FlashBagTest extends \PHPUnit_Framework_TestCase
$this->bag->initialize($this->array); $this->bag->initialize($this->array);
} }
public function tearDown() protected function tearDown()
{ {
$this->bag = null; $this->bag = null;
parent::tearDown(); parent::tearDown();

View File

@ -40,6 +40,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
'id_field' => '_id', 'id_field' => '_id',
'data_field' => 'data', 'data_field' => 'data',
'time_field' => 'time', 'time_field' => 'time',
'expiry_field' => 'expires_at',
'database' => 'sf2-test', 'database' => 'sf2-test',
'collection' => 'session-test', 'collection' => 'session-test',
); );
@ -73,6 +74,42 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($this->storage->close(), 'The "close" method should always return true'); $this->assertTrue($this->storage->close(), 'The "close" method should always return true');
} }
public function testRead()
{
$collection = $this->createMongoCollectionMock();
$this->mongo->expects($this->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection));
$that = $this;
// defining the timeout before the actual method call
// allows to test for "greater than" values in the $criteria
$testTimeout = time();
$collection->expects($this->once())
->method('findOne')
->will($this->returnCallback(function ($criteria) use ($that, $testTimeout) {
$that->assertArrayHasKey($that->options['id_field'], $criteria);
$that->assertEquals($criteria[$that->options['id_field']], 'foo');
$that->assertArrayHasKey($that->options['expiry_field'], $criteria);
$that->assertArrayHasKey('$gte', $criteria[$that->options['expiry_field']]);
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$gte']);
$that->assertGreaterThanOrEqual($criteria[$that->options['expiry_field']]['$gte']->sec, $testTimeout);
return array(
$that->options['id_field'] => 'foo',
$that->options['data_field'] => new \MongoBinData('bar', \MongoBinData::BYTE_ARRAY),
$that->options['id_field'] => new \MongoDate(),
);
}));
$this->assertEquals('bar', $this->storage->read('foo'));
}
public function testWrite() public function testWrite()
{ {
$collection = $this->createMongoCollectionMock(); $collection = $this->createMongoCollectionMock();
@ -94,10 +131,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
$data = $updateData['$set']; $data = $updateData['$set'];
})); }));
$expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime');
$this->assertTrue($this->storage->write('foo', 'bar')); $this->assertTrue($this->storage->write('foo', 'bar'));
$this->assertEquals('bar', $data[$this->options['data_field']]->bin); $this->assertEquals('bar', $data[$this->options['data_field']]->bin);
$that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]);
$this->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]);
$this->assertGreaterThanOrEqual($expectedExpiry, $data[$this->options['expiry_field']]->sec);
} }
public function testWriteWhenUsingExpiresField() public function testWriteWhenUsingExpiresField()
@ -192,49 +232,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
$collection->expects($this->once()) $collection->expects($this->once())
->method('remove') ->method('remove')
->will($this->returnCallback(function ($criteria) use ($that) { ->will($this->returnCallback(function ($criteria) use ($that) {
$that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']); $that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$lt']);
$that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['time_field']]['$lt']->sec); $that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['expiry_field']]['$lt']->sec);
})); }));
$this->assertTrue($this->storage->gc(1)); $this->assertTrue($this->storage->gc(1));
} }
public function testGcWhenUsingExpiresField()
{
$this->options = array(
'id_field' => '_id',
'data_field' => 'data',
'time_field' => 'time',
'database' => 'sf2-test',
'collection' => 'session-test',
'expiry_field' => 'expiresAt',
);
$this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
$collection = $this->createMongoCollectionMock();
$this->mongo->expects($this->never())
->method('selectCollection');
$that = $this;
$collection->expects($this->never())
->method('remove');
$this->assertTrue($this->storage->gc(1));
}
public function testGetConnection()
{
$method = new \ReflectionMethod($this->storage, 'getMongo');
$method->setAccessible(true);
$mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? '\Mongo' : '\MongoClient';
$this->assertInstanceOf($mongoClass, $method->invoke($this->storage));
}
private function createMongoCollectionMock() private function createMongoCollectionMock()
{ {
$mongoClient = $this->getMockBuilder('MongoClient') $mongoClient = $this->getMockBuilder('MongoClient')

View File

@ -94,7 +94,7 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
} elseif (0 === strpos($max, '0')) { } elseif (0 === strpos($max, '0')) {
$max = intval($max, 8); $max = intval($max, 8);
} else { } else {
$max = intval($max); $max = (int) $max;
} }
switch (substr($memoryLimit, -1)) { switch (substr($memoryLimit, -1)) {

View File

@ -20,7 +20,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
{ {
private $path; private $path;
public function tearDown() protected function tearDown()
{ {
if ($this->path) { if ($this->path) {
// Restore path if it was changed. // Restore path if it was changed.

View File

@ -17,7 +17,7 @@ class SimpleProcessTest extends AbstractProcessTest
{ {
private $enabledSigchild = false; private $enabledSigchild = false;
public function setUp() protected function setUp()
{ {
ob_start(); ob_start();
phpinfo(INFO_GENERAL); phpinfo(INFO_GENERAL);

View File

@ -256,7 +256,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
if (null === $propertyChanges['parentAcl'][1]) { if (null === $propertyChanges['parentAcl'][1]) {
$sets[] = 'parent_object_identity_id = NULL'; $sets[] = 'parent_object_identity_id = NULL';
} else { } else {
$sets[] = 'parent_object_identity_id = '.intval($propertyChanges['parentAcl'][1]->getId()); $sets[] = 'parent_object_identity_id = '.(int) $propertyChanges['parentAcl'][1]->getId();
} }
$this->regenerateAncestorRelations($acl); $this->regenerateAncestorRelations($acl);
@ -478,7 +478,7 @@ QUERY;
$query, $query,
$this->options['entry_table_name'], $this->options['entry_table_name'],
$classId, $classId,
null === $objectIdentityId ? 'NULL' : intval($objectIdentityId), null === $objectIdentityId ? 'NULL' : (int) $objectIdentityId,
null === $field ? 'NULL' : $this->connection->quote($field), null === $field ? 'NULL' : $this->connection->quote($field),
$aceOrder, $aceOrder,
$securityIdentityId, $securityIdentityId,
@ -596,7 +596,7 @@ QUERY;
$classId, $classId,
null === $oid ? null === $oid ?
$this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id') $this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id')
: 'object_identity_id = '.intval($oid), : 'object_identity_id = '.(int) $oid,
null === $field ? null === $field ?
$this->connection->getDatabasePlatform()->getIsNullExpression('field_name') $this->connection->getDatabasePlatform()->getIsNullExpression('field_name')
: 'field_name = '.$this->connection->quote($field), : 'field_name = '.$this->connection->quote($field),
@ -879,7 +879,7 @@ QUERY;
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id'); $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true); $aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId)); $aceIdProperty->setValue($ace, (int) $aceId);
} }
} }
} }
@ -953,7 +953,7 @@ QUERY;
$aceIdProperty = new \ReflectionProperty($ace, 'id'); $aceIdProperty = new \ReflectionProperty($ace, 'id');
$aceIdProperty->setAccessible(true); $aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId)); $aceIdProperty->setValue($ace, (int) $aceId);
} }
} }
} }

View File

@ -50,7 +50,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac
$authenticateHeader = sprintf('Digest realm="%s", qop="auth", nonce="%s"', $this->realmName, $nonceValueBase64); $authenticateHeader = sprintf('Digest realm="%s", qop="auth", nonce="%s"', $this->realmName, $nonceValueBase64);
if ($authException instanceof NonceExpiredException) { if ($authException instanceof NonceExpiredException) {
$authenticateHeader = $authenticateHeader.', stale="true"'; $authenticateHeader .= ', stale="true"';
} }
if (null !== $this->logger) { if (null !== $this->logger) {

View File

@ -156,7 +156,7 @@ class IsbnValidator extends ConstraintValidator
return Isbn::INVALID_CHARACTERS_ERROR; return Isbn::INVALID_CHARACTERS_ERROR;
} }
$checkSum += $digit * intval(10 - $i); $checkSum += $digit * (10 - $i);
} }
if (isset($isbn{$i})) { if (isset($isbn{$i})) {

View File

@ -129,7 +129,7 @@ class Inline
setlocale(LC_NUMERIC, 'C'); setlocale(LC_NUMERIC, 'C');
} }
if (is_float($value)) { if (is_float($value)) {
$repr = strval($value); $repr = (string) $value;
if (is_infinite($value)) { if (is_infinite($value)) {
$repr = str_ireplace('INF', '.Inf', $repr); $repr = str_ireplace('INF', '.Inf', $repr);
} elseif (floor($value) == $value && $repr == $value) { } elseif (floor($value) == $value && $repr == $value) {
@ -137,7 +137,7 @@ class Inline
$repr = '!!float '.$repr; $repr = '!!float '.$repr;
} }
} else { } else {
$repr = is_string($value) ? "'$value'" : strval($value); $repr = is_string($value) ? "'$value'" : (string) $value;
} }
if (false !== $locale) { if (false !== $locale) {
setlocale(LC_NUMERIC, $locale); setlocale(LC_NUMERIC, $locale);
@ -169,8 +169,9 @@ class Inline
{ {
// array // array
$keys = array_keys($value); $keys = array_keys($value);
if ((1 == count($keys) && '0' == $keys[0]) $keysCount = count($keys);
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) if ((1 === $keysCount && '0' == $keys[0])
|| ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2)
) { ) {
$output = array(); $output = array();
foreach ($value as $val) { foreach ($value as $val) {
@ -466,7 +467,7 @@ class Inline
case 0 === strpos($scalar, '!str'): case 0 === strpos($scalar, '!str'):
return (string) substr($scalar, 5); return (string) substr($scalar, 5);
case 0 === strpos($scalar, '! '): case 0 === strpos($scalar, '! '):
return intval(self::parseScalar(substr($scalar, 2))); return (int) self::parseScalar(substr($scalar, 2));
case 0 === strpos($scalar, '!!php/object:'): case 0 === strpos($scalar, '!!php/object:'):
if (self::$objectSupport) { if (self::$objectSupport) {
return unserialize(substr($scalar, 13)); return unserialize(substr($scalar, 13));
@ -481,23 +482,23 @@ class Inline
return (float) substr($scalar, 8); return (float) substr($scalar, 8);
case ctype_digit($scalar): case ctype_digit($scalar):
$raw = $scalar; $raw = $scalar;
$cast = intval($scalar); $cast = (int) $scalar;
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
$raw = $scalar; $raw = $scalar;
$cast = intval($scalar); $cast = (int) $scalar;
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
case is_numeric($scalar): case is_numeric($scalar):
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
case '.inf' === $scalarLower: case '.inf' === $scalarLower:
case '.nan' === $scalarLower: case '.nan' === $scalarLower:
return -log(0); return -log(0);
case '-.inf' === $scalarLower: case '-.inf' === $scalarLower:
return log(0); return log(0);
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
return floatval(str_replace(',', '', $scalar)); return (float) str_replace(',', '', $scalar);
case preg_match(self::getTimestampRegex(), $scalar): case preg_match(self::getTimestampRegex(), $scalar):
return strtotime($scalar); return strtotime($scalar);
} }

View File

@ -460,7 +460,7 @@ class Parser
if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) { if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
} }
try { try {