Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54c553c

Browse filesBrowse files
committed
Merge branch '2.7' into 2.8
* 2.7: Set the redraw frequency at least to 1. Setting it to 0 would otherwise produce an error. [Process] Unset callback after stop to free memory Improve error message for undefined DIC aliases [VarDumper] fixed .sf-dump z-index [DependencyInjection] Validate class names and factory methods ampq → amqp Fix typo CS: remove unneeded parentheses around control statements [TwigBridge] Clean deps now that 2.8.0 is tagged
2 parents 397ce23 + 0bbbb01 commit 54c553c
Copy full SHA for 54c553c

File tree

16 files changed

+88
-27
lines changed
Filter options

16 files changed

+88
-27
lines changed

‎src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getEntities()
8989
*/
9090
public function getEntitiesByIds($identifier, array $values)
9191
{
92-
$qb = clone ($this->queryBuilder);
92+
$qb = clone $this->queryBuilder;
9393
$alias = current($qb->getRootAliases());
9494
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
9595
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"symfony/asset": "~2.7|~3.0.0",
2424
"symfony/finder": "~2.3|~3.0.0",
25-
"symfony/form": "~2.8,>2.8-BETA1",
25+
"symfony/form": "~2.8",
2626
"symfony/http-kernel": "~2.8|~3.0.0",
2727
"symfony/polyfill-intl-icu": "~1.0",
2828
"symfony/routing": "~2.2|~3.0.0",

‎src/Symfony/Component/Console/Helper/ProgressBar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ public function __construct(OutputInterface $output, $max = 0)
6868
// disable overwrite when output does not support ANSI codes.
6969
$this->overwrite = false;
7070

71-
if ($this->max > 10) {
72-
// set a reasonable redraw frequency so output isn't flooded
73-
$this->setRedrawFrequency($max / 10);
74-
}
71+
// set a reasonable redraw frequency so output isn't flooded
72+
$this->setRedrawFrequency($max / 10);
7573
}
7674

7775
$this->startTime = time();
@@ -317,11 +315,11 @@ public function setFormat($format)
317315
/**
318316
* Sets the redraw frequency.
319317
*
320-
* @param int $freq The frequency in steps
318+
* @param int|float $freq The frequency in steps
321319
*/
322320
public function setRedrawFrequency($freq)
323321
{
324-
$this->redrawFreq = (int) $freq;
322+
$this->redrawFreq = max((int) $freq, 1);
325323
}
326324

327325
/**

‎src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public function testRegressProgress()
296296

297297
public function testRedrawFrequency()
298298
{
299-
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($output = $this->getOutputStream(), 6));
299+
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream(), 6));
300300
$bar->expects($this->exactly(4))->method('display');
301301

302302
$bar->setRedrawFrequency(2);
@@ -307,6 +307,26 @@ public function testRedrawFrequency()
307307
$bar->advance(1);
308308
}
309309

310+
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()
311+
{
312+
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
313+
314+
$bar->expects($this->exactly(2))->method('display');
315+
$bar->setRedrawFrequency(0);
316+
$bar->start();
317+
$bar->advance();
318+
}
319+
320+
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()
321+
{
322+
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
323+
324+
$bar->expects($this->exactly(2))->method('display');
325+
$bar->setRedrawFrequency(0.9);
326+
$bar->start();
327+
$bar->advance();
328+
}
329+
310330
public function testMultiByteSupport()
311331
{
312332
$bar = new ProgressBar($output = $this->getOutputStream());

‎src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function process(ContainerBuilder $container)
4545
try {
4646
$definition = $container->getDefinition($aliasId);
4747
} catch (InvalidArgumentException $e) {
48-
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e);
48+
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $id, $alias), null, $e);
4949
}
5050

5151
if ($definition->isPublic()) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+19-6Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,10 @@ private function addNewInstance($id, Definition $definition, $return, $instantia
780780
if (null !== $definition->getFactory()) {
781781
$callable = $definition->getFactory();
782782
if (is_array($callable)) {
783+
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $callable[1])) {
784+
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $callable[1] ?: 'n/a'));
785+
}
786+
783787
if ($callable[0] instanceof Reference
784788
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
785789
return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
@@ -1331,8 +1335,12 @@ private function dumpValue($value, $interpolate = true)
13311335
}
13321336

13331337
if (is_array($factory)) {
1338+
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $factory[1])) {
1339+
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $factory[1] ?: 'n/a'));
1340+
}
1341+
13341342
if (is_string($factory[0])) {
1335-
return sprintf('\\%s::%s(%s)', $factory[0], $factory[1], implode(', ', $arguments));
1343+
return sprintf('%s::%s(%s)', $this->dumpLiteralClass($this->dumpValue($factory[0])), $factory[1], implode(', ', $arguments));
13361344
}
13371345

13381346
if ($factory[0] instanceof Definition) {
@@ -1363,12 +1371,8 @@ private function dumpValue($value, $interpolate = true)
13631371
if (null === $class) {
13641372
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
13651373
}
1366-
$class = $this->dumpValue($class);
1367-
if (false !== strpos($class, '$')) {
1368-
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
1369-
}
13701374

1371-
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
1375+
return sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), implode(', ', $arguments));
13721376
} elseif ($value instanceof Variable) {
13731377
return '$'.$value;
13741378
} elseif ($value instanceof Reference) {
@@ -1409,9 +1413,18 @@ private function dumpValue($value, $interpolate = true)
14091413
* @param string $class
14101414
*
14111415
* @return string
1416+
*
1417+
* @throws RuntimeException
14121418
*/
14131419
private function dumpLiteralClass($class)
14141420
{
1421+
if (false !== strpos($class, '$')) {
1422+
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
1423+
}
1424+
if (0 !== strpos($class, "'") || !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
1425+
throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s)', $class ?: 'n/a'));
1426+
}
1427+
14151428
return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1);
14161429
}
14171430

‎src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,31 @@ public function testAddServiceInvalidServiceId()
154154
$dumper->dump();
155155
}
156156

157+
/**
158+
* @dataProvider provideInvalidFactories
159+
* @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException
160+
* @expectedExceptionMessage Cannot dump definition
161+
*/
162+
public function testInvalidFactories($factory)
163+
{
164+
$container = new ContainerBuilder();
165+
$def = new Definition('stdClass');
166+
$def->setFactory($factory);
167+
$container->setDefinition('bar', $def);
168+
$dumper = new PhpDumper($container);
169+
$dumper->dump();
170+
}
171+
172+
public function provideInvalidFactories()
173+
{
174+
return array(
175+
array(array('', 'method')),
176+
array(array('class', '')),
177+
array(array('...', 'method')),
178+
array(array('class', '...')),
179+
);
180+
}
181+
157182
public function testAliases()
158183
{
159184
$container = include self::$fixturesPath.'/containers/container9.php';

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,13 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
443443
*/
444444
public function isAbsolutePath($file)
445445
{
446-
return (strspn($file, '/\\', 0, 1)
446+
return strspn($file, '/\\', 0, 1)
447447
|| (strlen($file) > 3 && ctype_alpha($file[0])
448448
&& substr($file, 1, 1) === ':'
449449
&& (strspn($file, '/\\', 2, 1))
450450
)
451451
|| null !== parse_url($file, PHP_URL_SCHEME)
452-
);
452+
;
453453
}
454454

455455
/**

‎src/Symfony/Component/Finder/Iterator/SortableIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/SortableIterator.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public function __construct(\Traversable $iterator, $sort)
5555
};
5656
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
5757
$this->sort = function ($a, $b) {
58-
return ($a->getATime() - $b->getATime());
58+
return $a->getATime() - $b->getATime();
5959
};
6060
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
6161
$this->sort = function ($a, $b) {
62-
return ($a->getCTime() - $b->getCTime());
62+
return $a->getCTime() - $b->getCTime();
6363
};
6464
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
6565
$this->sort = function ($a, $b) {
66-
return ($a->getMTime() - $b->getMTime());
66+
return $a->getMTime() - $b->getMTime();
6767
};
6868
} elseif (is_callable($sort)) {
6969
$this->sort = $sort;

‎src/Symfony/Component/HttpFoundation/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Response.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ public function getVary()
976976
* Sets the Vary header.
977977
*
978978
* @param string|array $headers
979-
* @param bool $replace Whether to replace the actual value of not (true by default)
979+
* @param bool $replace Whether to replace the actual value or not (true by default)
980980
*
981981
* @return Response
982982
*/

‎src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getSaveHandlerName()
5252
*/
5353
public function isSessionHandlerInterface()
5454
{
55-
return ($this instanceof \SessionHandlerInterface);
55+
return $this instanceof \SessionHandlerInterface;
5656
}
5757

5858
/**

‎src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function getReverseMatchingRegExp($pattern)
216216
*/
217217
public function isQuoteMatch($quoteMatch)
218218
{
219-
return ("'" === $quoteMatch[0]);
219+
return "'" === $quoteMatch[0];
220220
}
221221

222222
/**

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,11 @@ private function close()
14091409
$this->exitcode = 128 + $this->processInformation['termsig'];
14101410
}
14111411

1412+
// Free memory from self-reference callback created by buildCallback
1413+
// Doing so in other contexts like __destruct or by garbage collector is ineffective
1414+
// Now pipes are closed, so the callback is no longer necessary
1415+
$this->callback = null;
1416+
14121417
return $this->exitcode;
14131418
}
14141419

‎src/Symfony/Component/VarDumper/Caster/AmqpCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/AmqpCaster.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function castConnection(\AMQPConnection $c, array $a, Stub $stub,
4848
{
4949
$prefix = Caster::PREFIX_VIRTUAL;
5050

51-
// BC layer in the ampq lib
51+
// BC layer in the amqp lib
5252
if (method_exists($c, 'getReadTimeout')) {
5353
$timeout = $c->getReadTimeout();
5454
} else {

‎src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class HtmlDumper extends CliDumper
3131
protected $headerIsDumped = false;
3232
protected $lastDepth = -1;
3333
protected $styles = array(
34-
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000; word-break: normal',
34+
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
3535
'num' => 'font-weight:bold; color:#1299DA',
3636
'const' => 'font-weight:bold',
3737
'str' => 'font-weight:bold; color:#56DB3A',

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,6 @@ private function isNextLineUnIndentedCollection()
717717
*/
718718
private function isStringUnIndentedCollectionItem()
719719
{
720-
return (0 === strpos($this->currentLine, '- '));
720+
return 0 === strpos($this->currentLine, '- ');
721721
}
722722
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.