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
This commit is contained in:
commit
54c553cce7
@ -89,7 +89,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
||||
*/
|
||||
public function getEntitiesByIds($identifier, array $values)
|
||||
{
|
||||
$qb = clone ($this->queryBuilder);
|
||||
$qb = clone $this->queryBuilder;
|
||||
$alias = current($qb->getRootAliases());
|
||||
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
|
||||
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);
|
||||
|
@ -22,7 +22,7 @@
|
||||
"require-dev": {
|
||||
"symfony/asset": "~2.7|~3.0.0",
|
||||
"symfony/finder": "~2.3|~3.0.0",
|
||||
"symfony/form": "~2.8,>2.8-BETA1",
|
||||
"symfony/form": "~2.8",
|
||||
"symfony/http-kernel": "~2.8|~3.0.0",
|
||||
"symfony/polyfill-intl-icu": "~1.0",
|
||||
"symfony/routing": "~2.2|~3.0.0",
|
||||
|
@ -68,10 +68,8 @@ class ProgressBar
|
||||
// disable overwrite when output does not support ANSI codes.
|
||||
$this->overwrite = false;
|
||||
|
||||
if ($this->max > 10) {
|
||||
// set a reasonable redraw frequency so output isn't flooded
|
||||
$this->setRedrawFrequency($max / 10);
|
||||
}
|
||||
// set a reasonable redraw frequency so output isn't flooded
|
||||
$this->setRedrawFrequency($max / 10);
|
||||
}
|
||||
|
||||
$this->startTime = time();
|
||||
@ -317,11 +315,11 @@ class ProgressBar
|
||||
/**
|
||||
* Sets the redraw frequency.
|
||||
*
|
||||
* @param int $freq The frequency in steps
|
||||
* @param int|float $freq The frequency in steps
|
||||
*/
|
||||
public function setRedrawFrequency($freq)
|
||||
{
|
||||
$this->redrawFreq = (int) $freq;
|
||||
$this->redrawFreq = max((int) $freq, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRedrawFrequency()
|
||||
{
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($output = $this->getOutputStream(), 6));
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream(), 6));
|
||||
$bar->expects($this->exactly(4))->method('display');
|
||||
|
||||
$bar->setRedrawFrequency(2);
|
||||
@ -307,6 +307,26 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
$bar->advance(1);
|
||||
}
|
||||
|
||||
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()
|
||||
{
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
|
||||
|
||||
$bar->expects($this->exactly(2))->method('display');
|
||||
$bar->setRedrawFrequency(0);
|
||||
$bar->start();
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()
|
||||
{
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
|
||||
|
||||
$bar->expects($this->exactly(2))->method('display');
|
||||
$bar->setRedrawFrequency(0.9);
|
||||
$bar->start();
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
public function testMultiByteSupport()
|
||||
{
|
||||
$bar = new ProgressBar($output = $this->getOutputStream());
|
||||
|
@ -45,7 +45,7 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface
|
||||
try {
|
||||
$definition = $container->getDefinition($aliasId);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e);
|
||||
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $id, $alias), null, $e);
|
||||
}
|
||||
|
||||
if ($definition->isPublic()) {
|
||||
|
@ -780,6 +780,10 @@ EOF;
|
||||
if (null !== $definition->getFactory()) {
|
||||
$callable = $definition->getFactory();
|
||||
if (is_array($callable)) {
|
||||
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $callable[1])) {
|
||||
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $callable[1] ?: 'n/a'));
|
||||
}
|
||||
|
||||
if ($callable[0] instanceof Reference
|
||||
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
|
||||
return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
|
||||
@ -1331,8 +1335,12 @@ EOF;
|
||||
}
|
||||
|
||||
if (is_array($factory)) {
|
||||
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $factory[1])) {
|
||||
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $factory[1] ?: 'n/a'));
|
||||
}
|
||||
|
||||
if (is_string($factory[0])) {
|
||||
return sprintf('\\%s::%s(%s)', $factory[0], $factory[1], implode(', ', $arguments));
|
||||
return sprintf('%s::%s(%s)', $this->dumpLiteralClass($this->dumpValue($factory[0])), $factory[1], implode(', ', $arguments));
|
||||
}
|
||||
|
||||
if ($factory[0] instanceof Definition) {
|
||||
@ -1363,12 +1371,8 @@ EOF;
|
||||
if (null === $class) {
|
||||
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
|
||||
}
|
||||
$class = $this->dumpValue($class);
|
||||
if (false !== strpos($class, '$')) {
|
||||
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
||||
}
|
||||
|
||||
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
|
||||
return sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), implode(', ', $arguments));
|
||||
} elseif ($value instanceof Variable) {
|
||||
return '$'.$value;
|
||||
} elseif ($value instanceof Reference) {
|
||||
@ -1409,9 +1413,18 @@ EOF;
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function dumpLiteralClass($class)
|
||||
{
|
||||
if (false !== strpos($class, '$')) {
|
||||
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
||||
}
|
||||
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)) {
|
||||
throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s)', $class ?: 'n/a'));
|
||||
}
|
||||
|
||||
return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1);
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,31 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidFactories
|
||||
* @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Cannot dump definition
|
||||
*/
|
||||
public function testInvalidFactories($factory)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$def = new Definition('stdClass');
|
||||
$def->setFactory($factory);
|
||||
$container->setDefinition('bar', $def);
|
||||
$dumper = new PhpDumper($container);
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
public function provideInvalidFactories()
|
||||
{
|
||||
return array(
|
||||
array(array('', 'method')),
|
||||
array(array('class', '')),
|
||||
array(array('...', 'method')),
|
||||
array(array('class', '...')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testAliases()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
|
@ -443,13 +443,13 @@ class Filesystem
|
||||
*/
|
||||
public function isAbsolutePath($file)
|
||||
{
|
||||
return (strspn($file, '/\\', 0, 1)
|
||||
return strspn($file, '/\\', 0, 1)
|
||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||
&& substr($file, 1, 1) === ':'
|
||||
&& (strspn($file, '/\\', 2, 1))
|
||||
)
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,15 +55,15 @@ class SortableIterator implements \IteratorAggregate
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return ($a->getATime() - $b->getATime());
|
||||
return $a->getATime() - $b->getATime();
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return ($a->getCTime() - $b->getCTime());
|
||||
return $a->getCTime() - $b->getCTime();
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return ($a->getMTime() - $b->getMTime());
|
||||
return $a->getMTime() - $b->getMTime();
|
||||
};
|
||||
} elseif (is_callable($sort)) {
|
||||
$this->sort = $sort;
|
||||
|
@ -976,7 +976,7 @@ class Response
|
||||
* Sets the Vary header.
|
||||
*
|
||||
* @param string|array $headers
|
||||
* @param bool $replace Whether to replace the actual value of not (true by default)
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ abstract class AbstractProxy
|
||||
*/
|
||||
public function isSessionHandlerInterface()
|
||||
{
|
||||
return ($this instanceof \SessionHandlerInterface);
|
||||
return $this instanceof \SessionHandlerInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,7 +216,7 @@ class FullTransformer
|
||||
*/
|
||||
public function isQuoteMatch($quoteMatch)
|
||||
{
|
||||
return ("'" === $quoteMatch[0]);
|
||||
return "'" === $quoteMatch[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1409,6 +1409,11 @@ class Process
|
||||
$this->exitcode = 128 + $this->processInformation['termsig'];
|
||||
}
|
||||
|
||||
// Free memory from self-reference callback created by buildCallback
|
||||
// Doing so in other contexts like __destruct or by garbage collector is ineffective
|
||||
// Now pipes are closed, so the callback is no longer necessary
|
||||
$this->callback = null;
|
||||
|
||||
return $this->exitcode;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class AmqpCaster
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
// BC layer in the ampq lib
|
||||
// BC layer in the amqp lib
|
||||
if (method_exists($c, 'getReadTimeout')) {
|
||||
$timeout = $c->getReadTimeout();
|
||||
} else {
|
||||
|
@ -31,7 +31,7 @@ class HtmlDumper extends CliDumper
|
||||
protected $headerIsDumped = false;
|
||||
protected $lastDepth = -1;
|
||||
protected $styles = array(
|
||||
'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',
|
||||
'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',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'str' => 'font-weight:bold; color:#56DB3A',
|
||||
|
@ -717,6 +717,6 @@ class Parser
|
||||
*/
|
||||
private function isStringUnIndentedCollectionItem()
|
||||
{
|
||||
return (0 === strpos($this->currentLine, '- '));
|
||||
return 0 === strpos($this->currentLine, '- ');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user