8000 Merge branch '2.3' into 2.6 · symfony/symfony@fc009c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc009c1

Browse files
Merge branch '2.3' into 2.6
* 2.3: Changed visibility of setUp() and tearDown to protected 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: src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php src/Symfony/Component/Config/Util/XmlUtils.php src/Symfony/Component/Console/Helper/ProgressHelper.php src/Symfony/Component/Debug/ExceptionHandler.php src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php src/Symfony/Component/Filesystem/Tests/FilesystemTest.php src/Symfony/Component/OptionsResolver/Options.php src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php src/Symfony/Component/Yaml/Inline.php
2 parents 5ad671a + f68532c commit fc009c1

File tree

39 files changed

+102
-71
lines changed

39 files changed

+102
-71
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ phpunit.xml
22
composer.lock
33
composer.phar
44
autoload.php
5+
package*.tar
6+
packages.json
57
/vendor/

.travis.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
branch=$1
2+
if [ -z "$branch" ]; then
3+
echo 'Usage: branch dir1 dir2 ... dirN'
4+
exit 1
5+
fi
6+
shift
7+
components=$*
8+
if [ -z "$components" ]; then
9+
echo 'Usage: branch dir1 dir2 ... dirN'
10+
exit 1
11+
fi
12+
echo '{"packages": {' > packages.json
13+
components=$(
14+
for c in $components; do
15+
sed -i ':a;N;$!ba;s#^{\n\(\s*\)\("name"\)#{\n\1"repositories": \[{ "type": "composer", "url": "file://'$(pwd)'/" }\],\n\1\2#' $c/composer.json
16+
n=$(php -r '$n=json_decode(file_get_contents("'$c'/composer.json"));echo $n->name;')
17+
echo '"'$n'": {"'$branch'.x-dev": ' >> packages.json
18+
cat $c/composer.json >> packages.json
19+
echo '"version": "'$branch.x-dev'",\n "dist": {"type": "tar", "url": "file://'$(pwd)/$c'/package'$branch'.tar"}\n}},' >> packages.json
20+
echo $c
21+
done;
22+
)
23+
sed -i ':a;N;$!ba;s/\n}\n"/,\n "/g' packages.json
24+
sed -i ':a;N;$!ba;s/}},$/\n}}\n}}/' packages.json
25+
echo "$components" | parallel --gnu "cd {}; tar -cf package$branch.tar --exclude='package*.tar' *"

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ before_install:
4040

4141
install:
4242
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi;
43+
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
44+
- if [ "$deps" != "no" ]; then sh .travis.sh $TRAVIS_BRANCH $components; fi;
4345

4446
script:
45-
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
4647
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
4748
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
4849
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ private function sanitizeQueries($connectionName, $queries)
117117
private function sanitizeQuery($connectionName, $query)
118118
{
119119
$query['explainable'] = true;
120-
$query['params'] = (array) $query['params'];
121-
foreach ($query['params'] as $j => &$param) {
120+
if (!is_array($query['params'])) {
121+
$query['params'] = array($query['params']);
122+
}
123+
foreach ($query['params'] as $j => $param) {
122124
if (isset($query['types'][$j])) {
123125
// Transform the param according to the type
124126
$type = $query['types'][$j];
@@ -131,7 +133,7 @@ private function sanitizeQuery($connectionName, $query)
131133
}
132134
}
133135

134-
list($param, $explainable) = $this->sanitizeParam($param);
136+
list($query['params'][$j], $explainable) = $this->sanitizeParam($param);
135137
if (!$explainable) {
136138
$query['explainable'] = false;
137139
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class RuntimeInstantiatorTest extends \PHPUnit_Framework_TestCase
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function setUp()
34+
protected function setUp()
3535
{
3636
$this->instantiator = new RuntimeInstantiator();
3737
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function setUp()
34+
protected function setUp()
3535
{
3636
$this->dumper = new ProxyDumper();
3737
}

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
8484
$this->twig->parse($this->twig->tokenize($template));
8585

8686
foreach ($visitor->getMessages() as $message) {
87-
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain);
87+
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
8888
}
8989

9090
$visitor->disable();

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function setUp()
2929
$this->loader->register();
3030
}
3131

32-
public function tearDown()
32+
protected function tearDown()
3333
{
3434
spl_autoload_unregister(array($this->loader, 'loadClass'));
3535

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function setUp()
2626
$this->deleteTmpDir();
2727
}
2828

29-
public function tearDown()
29+
protected function tearDown()
3030
{
3131
$this->deleteTmpDir();
3232
}

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public function load(array $configs, ContainerBuilder $container)
3636
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
3737
$loader->load('twig.xml');
3838

39-
foreach ($configs as &$config) {
39+
foreach ($configs as $key => $config) {
4040
if (isset($config['globals'])) {
4141
foreach ($config['globals'] as $name => $value) {
4242
if (is_array($value) && isset($value['key'])) {
43-
$config['globals'][$name] = array(
43+
$configs[$key]['globals'][$name] = array(
4444
'key' => $name,
45-
'value' => $config['globals'][$name],
45+
'value' => $value,
4646
);
4747
}
4848
}

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
2929
*/
3030
private $pass;
3131

32-
public function setUp()
32+
protected function setUp()
3333
{
3434
$this->builder = $this->getMock(
3535
'Symfony\Component\DependencyInjection\ContainerBuilder',

src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class LegacyRenderTokenParserTest extends TestCase
1919
{
20-
public function setUp()
20+
protected function setUp()
2121
{
2222
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
2323
}

src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TemplateManagerTest extends TestCase
4141
*/
4242
protected $templateManager;
4343

44-
public function setUp()
44+
protected function setUp()
4545
{
4646
parent::setUp();
4747

src/Symfony/Component/Config/Tests/ConfigCacheTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase
2222

2323
private $metaFile = null;
2424

25-
public function setUp()
25+
protected function setUp()
2626
{
2727
$this->resourceFile = tempnam(sys_get_temp_dir(), '_resource');
2828
$this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
@@ -32,7 +32,7 @@ public function setUp()
3232
$this->generateMetaFile();
3333
}
3434

35-
public function tearDown()
35+
protected function tearDown()
3636
{
3737
$files = array($this->cacheFile, $this->metaFile, $this->resourceFile);
3838

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,24 @@ public static function phpize($value)
191191
return;
192192
case ctype_digit($value):
193193
$raw = $value;
194-
$cast = intval($value);
194+
$cast = (int) $value;
195195

196-
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
196+
return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
197197
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
198198
$raw = $value;
199199
$cast = intval($value);
200200

201-
return '0' == $value[1] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
201+
return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
202202
case 'true' === $lowercaseValue:
203203
return true;
204204
case 'false' === $lowercaseValue:
205205
return false;
206206
case isset($value[1]) && '0b' == $value[0].$value[1]:
207207
return bindec($value);
208208
case is_numeric($value):
209-
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
209+
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
210210
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):
211-
return floatval($value);
211+
return (float) $value;
212212
default:
213213
return $value;
214214
}

src/Symfony/Component/Console/Helper/FormatterHelper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public function formatSection($section, $message, $style = 'info')
4545
*/
4646
public function formatBlock($messages, $style, $large = false)
4747
{
48-
$messages = (array) $messages;
48+
if (!is_array($messages)) {
49+
$messages = array($messages);
50+
}
4951

5052
$len = 0;
5153
$lines = array();
@@ -56,15 +58,15 @@ public function formatBlock($messages, $style, $large = false)
5658
}
5759

5860
$messages = $large ? array(str_repeat(' ', $len)) : array();
59-
foreach ($lines as $line) {
60-
$messages[] = $line.str_repeat(' ', $len - $this->strlen($line));
61+
for ($i = 0; isset($lines[$i]); ++$i) {
62+
$messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
6163
}
6264
if ($large) {
6365
$messages[] = str_repeat(' ', $len);
6466
}
6567

66-
foreach ($messages as &$message) {
67-
$message = sprintf('<%s>%s</%s>', $style, $message, $style);
68+
for ($i = 0; isset($messages[$i]); ++$i) {
69+
$messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
6870
}
6971

7072
return implode("\n", $messages);

src/Symfony/Component/Console/Helper/ProgressHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ public function setCurrent($current, $redraw = false)
259259
$redraw = true;
260260
}
261261

262-
$prevPeriod = intval($this->current / $this->redrawFreq);
262+
$prevPeriod = (int) ($this->current / $this->redrawFreq);
263263

264264
$this->current = $current;
265265

266-
$currPeriod = intval($this->current / $this->redrawFreq);
266+
$currPeriod = (int) ($this->current / $this->redrawFreq);
267267
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
268268
$this->display();
269269
}

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function getContent(FlattenException $exception)
251251
} catch (\Exception $e) {
252252
// something nasty happened and we cannot throw an exception anymore
253253
if ($this->debug) {
254-
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
254+
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), self::utf8Htmlize($e->getMessage()));
255255
} else {
256256
$title = 'Whoops, looks like something went wrong.';
257257
}

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,9 +1004,7 @@ public function createService(Definition $definition, $id, $tryProxy = true)
10041004
public function resolveServices($value)
10051005
{
10061006
if (is_array($value)) {
1007-
foreach ($value as &$v) {
1008-
$v = $this->resolveServices($v);
1009-
}
1007+
$value = array_map(array($this, 'resolveServices'), $value);
10101008
} elseif ($value instanceof Reference) {
10111009
$value = $this->get((string) $value, $value->getInvalidBehavior());
10121010
} elseif ($value instanceof Definition) {

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,13 +1474,13 @@ private function getNextVariableName()
14741474

14751475
if ('' === $name) {
14761476
$name .= $firstChars[$i%$firstCharsLength];
1477-
$i = intval($i/$firstCharsLength);
1477+
$i = (int F438 ) ($i/$firstCharsLength);
14781478
}
14791479

14801480
while ($i > 0) {
14811481
--$i;
14821482
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
1483-
$i = intval($i/$nonFirstCharsLength);
1483+
$i = (int) ($i/$nonFirstCharsLength);
14841484
}
14851485

14861486
++$this->variableCount;

src/Symfony/Component/DomCrawler/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ protected function canonicalizePath($path)
154154
}
155155

156156
if ('.' === substr($path, -1)) {
157-
$path = $path.'/';
157+
$path .= '/';
158158
}
159159

160160
$output = array();

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FilesystemTest extends FilesystemTestCase
2323
*/
2424
private $filesystem = null;
2525

26-
public function setUp()
26+
protected function setUp()
2727
{
2828
parent::setUp();
2929
$this->filesystem = new Filesystem();

src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public static function setUpBeforeClass()
3737
}
3838
}
3939

40-
public function setUp()
40+
protected function setUp()
4141
{
4242
$this->umask = umask(0);
4343
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
4444
mkdir($this->workspace, 0777, true);
4545
$this->workspace = realpath($this->workspace);
4646
}
4747

48-
public function tearDown()
48+
protected function tearDown()
4949
{
5050
$this->clean($this->workspace);
5151
umask($this->umask);

src/Symfony/Component/Finder/Finder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ public function exclude($dirs)
436436
public function ignoreDotFiles($ignoreDotFiles)
437437
{
438438
if ($ignoreDotFiles) {
439-
$this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
439+
$this->ignore |= static::IGNORE_DOT_FILES;
440440
} else {
441-
$this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
441+
$this->ignore &= ~static::IGNORE_DOT_FILES;
442442
}
443443

444444
return $this;
@@ -458,9 +458,9 @@ public function ignoreDotFiles($ignoreDotFiles)
458458
public function ignoreVCS($ignoreVCS)
459459
{
460460
if ($ignoreVCS) {
461-
$this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
461+
$this->ignore |= static::IGNORE_VCS_FILES;
462462
} else {
463-
$this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
463+
$this->ignore &= ~static::IGNORE_VCS_FILES;
464464
}
465465

466466
return $this;

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
134134
// Add "[]" to the name in case a select tag with multiple options is
135135
// displayed. Otherwise only one of the selected options is sent in the
136136
// POST request.
137-
$view->vars['full_name'] = $view->vars['full_name'].'[]';
137+
$view->vars['full_name'] .= '[]';
138138
}
139139
}
140140

src/Symfony/Component/Form/Util/ServerParams.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getPostMaxSize()
4444
} elseif (0 === strpos($max, '0')) {
4545
$max = intval($max, 8);
4646
} else {
47-
$max = intval($max);
47+
$max = (int) $max;
4848
}
4949

5050
switch (substr($iniMax, -1)) {

src/Symfony/Component/HttpFoundation/File/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public static function getMaxFilesize()
270270
} elseif (0 === strpos($max, '0')) {
271271
$max = intval($max, 8);
272272
} else {
273-
$max = intval($max);
273+
$max = (int) $max;
274274
}
275275

276276
switch (substr($iniMax, -1)) {

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ public function getPort()
10091009
}
10101010

10111011
if (false !== $pos) {
1012-
return intval(substr($host, $pos + 1));
1012+
return (int) substr($host, $pos + 1);
10131013
}
10141014

10151015
return 'https' === $this->getScheme() ? 443 : 80;

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ public static function closeOutputBuffers($targetLevel, $flush)
12671267
protected function ensureIEOverSSLCompatibility(Request $request)
12681268
{
12691269
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
1270-
if (intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) {
1270+
if ((int) preg_replace("/(MSIE )(.*?);/", "$2", $match[0]) < 9) {
12711271
$this->headers->remove('Cache-Control');
12721272
}
12731273
}

src/Symfony/Component/HttpFoundation/Tests/Session/Flash/AutoExpireFlashBagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function setUp()
3838
$this->bag->initialize($this->array);
3939
}
4040

41-
public function tearDown()
41+
protected function tearDown()
4242
{
4343
$this->bag = null;
4444
parent::tearDown();

0 commit comments

Comments
 (0)
0