Merge branch '3.0'
* 3.0: [DI] Fix internal caching in AutowirePass [PropertyInfo] Remove useless return statement [Console] use ANSI escape sequences in ProgressBar overwrite method [HttpKernel] Fix wrong number of arguments in call of ExceptionListener::logException() Replace iconv_*() uses by mb_*(), add mbstring polyfill when required [DependencyInjection] Remove YAML check in CrossCheckTest [Process] Consistently use getProcess() in tests [LDAP] Free the search result after a search to free memory [DependencyInjection] fix phpDoc Conflicts: src/Symfony/Component/Ldap/LdapClient.php
This commit is contained in:
commit
357785aace
@ -95,8 +95,8 @@ class DbalLogger implements SQLLogger
|
||||
}
|
||||
|
||||
// detect if the too long string must be shorten
|
||||
if (self::MAX_STRING_LENGTH < iconv_strlen($params[$index], 'UTF-8')) {
|
||||
$params[$index] = iconv_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
|
||||
if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) {
|
||||
$params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,13 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"doctrine/common": "~2.4"
|
||||
"doctrine/common": "~2.4",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/stopwatch": "~2.8|~3.0",
|
||||
"symfony/dependency-injection": "~2.8|~3.0",
|
||||
"symfony/form": "~3.0,>3.0-BETA1",
|
||||
"symfony/form": "~3.0",
|
||||
"symfony/http-kernel": "~2.8|~3.0",
|
||||
"symfony/property-access": "~2.8|~3.0",
|
||||
"symfony/property-info": "~2.8|3.0",
|
||||
|
@ -41,7 +41,6 @@ class ProgressBar
|
||||
private $startTime;
|
||||
private $stepWidth;
|
||||
private $percent = 0.0;
|
||||
private $lastMessagesLength = 0;
|
||||
private $formatLineCount;
|
||||
private $messages;
|
||||
private $overwrite = true;
|
||||
@ -437,7 +436,7 @@ class ProgressBar
|
||||
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
|
||||
}
|
||||
|
||||
$this->overwrite(str_repeat("\n", $this->formatLineCount));
|
||||
$this->overwrite('');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,37 +476,22 @@ class ProgressBar
|
||||
*/
|
||||
private function overwrite($message)
|
||||
{
|
||||
$lines = explode("\n", $message);
|
||||
|
||||
// append whitespace to match the line's length
|
||||
if (null !== $this->lastMessagesLength) {
|
||||
foreach ($lines as $i => $line) {
|
||||
if ($this->lastMessagesLength > Helper::strlenWithoutDecoration($this->output->getFormatter(), $line)) {
|
||||
$lines[$i] = str_pad($line, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->overwrite) {
|
||||
// move back to the beginning of the progress bar before redrawing it
|
||||
// Move the cursor to the beginning of the line
|
||||
$this->output->write("\x0D");
|
||||
|
||||
// Erase the line
|
||||
$this->output->write("\x1B[2K");
|
||||
|
||||
// Erase previous lines
|
||||
if ($this->formatLineCount > 0) {
|
||||
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
|
||||
}
|
||||
} elseif ($this->step > 0) {
|
||||
// move to new line
|
||||
$this->output->writeln('');
|
||||
}
|
||||
|
||||
if ($this->formatLineCount) {
|
||||
$this->output->write(sprintf("\033[%dA", $this->formatLineCount));
|
||||
}
|
||||
$this->output->write(implode("\n", $lines));
|
||||
|
||||
$this->lastMessagesLength = 0;
|
||||
foreach ($lines as $line) {
|
||||
$len = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
|
||||
if ($len > $this->lastMessagesLength) {
|
||||
$this->lastMessagesLength = $len;
|
||||
}
|
||||
}
|
||||
$this->output->write($message);
|
||||
}
|
||||
|
||||
private function determineBestFormat()
|
||||
|
@ -233,7 +233,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
$this->generateOutput(' 0/50 [>---------------------------] 0%').
|
||||
$this->generateOutput(' 0/50 [>---------------------------] 0%').
|
||||
$this->generateOutput(' 1/50 [>---------------------------] 2%').
|
||||
$this->generateOutput(' 2/50 [=>--------------------------] '),
|
||||
$this->generateOutput(' 2/50 [=>--------------------------]'),
|
||||
stream_get_contents($output->getStream())
|
||||
);
|
||||
}
|
||||
@ -353,7 +353,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
$this->generateOutput(' 0/50 [>---------------------------] 0%').
|
||||
$this->generateOutput(' 25/50 [==============>-------------] 50%').
|
||||
$this->generateOutput(' '),
|
||||
$this->generateOutput(''),
|
||||
stream_get_contents($output->getStream())
|
||||
);
|
||||
}
|
||||
@ -551,9 +551,9 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals(
|
||||
$this->generateOutput(">---------------------------\nfoobar").
|
||||
$this->generateOutput("=========>------------------\nfoobar ").
|
||||
$this->generateOutput(" \n ").
|
||||
$this->generateOutput("============================\nfoobar "),
|
||||
$this->generateOutput("=========>------------------\nfoobar").
|
||||
"\x0D\x1B[2K\x1B[1A\x1B[2K".
|
||||
$this->generateOutput("============================\nfoobar"),
|
||||
stream_get_contents($output->getStream())
|
||||
);
|
||||
}
|
||||
@ -659,6 +659,6 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$count = substr_count($expected, "\n");
|
||||
|
||||
return "\x0D".($count ? sprintf("\033[%dA", $count) : '').$expected;
|
||||
return "\x0D\x1B[2K".($count ? str_repeat("\x1B[1A\x1B[2K", $count) : '').$expected;
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ class Alias
|
||||
private $public;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $id Alias identifier
|
||||
* @param bool $public If this alias is public
|
||||
*/
|
||||
|
@ -34,8 +34,6 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
||||
private $onlyConstructorArguments;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
|
||||
*/
|
||||
public function __construct($onlyConstructorArguments = false)
|
||||
|
@ -278,7 +278,7 @@ class AutowirePass implements CompilerPassInterface
|
||||
* @param string $id
|
||||
* @param Definition $definition
|
||||
*
|
||||
* @return \ReflectionClass|null
|
||||
* @return \ReflectionClass|false
|
||||
*/
|
||||
private function getReflectionClass($id, Definition $definition)
|
||||
{
|
||||
@ -288,16 +288,18 @@ class AutowirePass implements CompilerPassInterface
|
||||
|
||||
// Cannot use reflection if the class isn't set
|
||||
if (!$class = $definition->getClass()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$class = $this->container->getParameterBag()->resolveValue($class);
|
||||
|
||||
try {
|
||||
return $this->reflectionClasses[$id] = new \ReflectionClass($class);
|
||||
$reflector = new \ReflectionClass($class);
|
||||
} catch (\ReflectionException $reflectionException) {
|
||||
// return null
|
||||
$reflector = false;
|
||||
}
|
||||
|
||||
return $this->reflectionClasses[$id] = $reflector;
|
||||
}
|
||||
|
||||
private function addServiceToAmbiguousType($id, $type)
|
||||
|
@ -25,9 +25,6 @@ class Compiler
|
||||
private $loggingFormatter;
|
||||
private $serviceReferenceGraph;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->passConfig = new PassConfig();
|
||||
|
@ -35,9 +35,6 @@ class PassConfig
|
||||
private $optimizationPasses;
|
||||
private $removingPasses;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->mergePass = new MergeExtensionConfigurationPass();
|
||||
|
@ -32,8 +32,6 @@ class RepeatedPass implements CompilerPassInterface
|
||||
private $passes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
|
||||
*
|
||||
* @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface
|
||||
|
@ -25,8 +25,6 @@ class ServiceReferenceGraphEdge
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ServiceReferenceGraphNode $sourceNode
|
||||
* @param ServiceReferenceGraphNode $destNode
|
||||
* @param string $value
|
||||
|
@ -29,8 +29,6 @@ class ServiceReferenceGraphNode
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $id The node identifier
|
||||
* @param mixed $value The node value
|
||||
*/
|
||||
|
@ -71,8 +71,6 @@ class Container implements ResettableContainerInterface
|
||||
private $underscoreMap = array('_' => '', '.' => '_', '\\' => '_');
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ParameterBagInterface $parameterBag A ParameterBagInterface instance
|
||||
*/
|
||||
public function __construct(ParameterBagInterface $parameterBag = null)
|
||||
|
@ -42,8 +42,6 @@ class Definition
|
||||
protected $arguments;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|null $class The service class
|
||||
* @param array $arguments An array of arguments to pass to the service constructor
|
||||
*/
|
||||
|
@ -25,8 +25,6 @@ class DefinitionDecorator extends Definition
|
||||
private $changes = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $parent The id of Definition instance to decorate.
|
||||
*/
|
||||
public function __construct($parent)
|
||||
|
@ -23,8 +23,6 @@ abstract class Dumper implements DumperInterface
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerBuilder $container The service container to dump
|
||||
*/
|
||||
public function __construct(ContainerBuilder $container)
|
||||
|
@ -24,8 +24,6 @@ class ParameterNotFoundException extends InvalidArgumentException
|
||||
private $alternatives;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $key The requested parameter key
|
||||
* @param string $sourceId The service id that references the non-existent parameter
|
||||
* @param string $sourceKey The parameter key that references the non-existent parameter
|
||||
|
@ -27,9 +27,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
abstract class Extension implements ExtensionInterface, ConfigurationExtensionInterface
|
||||
{
|
||||
/**
|
||||
* Returns the base path for the XSD files.
|
||||
*
|
||||
* @return string The XSD base path
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getXsdValidationBasePath()
|
||||
{
|
||||
@ -37,9 +35,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace to be used for this extension (XML namespace).
|
||||
*
|
||||
* @return string The XML namespace
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
|
@ -26,8 +26,6 @@ class ClosureLoader extends Loader
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
*/
|
||||
public function __construct(ContainerBuilder $container)
|
||||
|
@ -25,8 +25,6 @@ abstract class FileLoader extends BaseFileLoader
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
* @param FileLocatorInterface $locator A FileLocator instance
|
||||
*/
|
||||
|
@ -21,8 +21,6 @@ class Parameter
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $id The parameter key
|
||||
*/
|
||||
public function __construct($id)
|
||||
@ -31,8 +29,6 @@ class Parameter
|
||||
}
|
||||
|
||||
/**
|
||||
* __toString.
|
||||
*
|
||||
* @return string The parameter key
|
||||
*/
|
||||
public function __toString()
|
||||
|
@ -21,8 +21,6 @@ use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
class FrozenParameterBag extends ParameterBag
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* For performance reasons, the constructor assumes that
|
||||
* all keys are already lowercased.
|
||||
*
|
||||
|
@ -26,8 +26,6 @@ class ParameterBag implements ParameterBagInterface
|
||||
protected $resolved = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $parameters An array of parameters
|
||||
*/
|
||||
public function __construct(array $parameters = array())
|
||||
@ -56,9 +54,7 @@ class ParameterBag implements ParameterBagInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service container parameters.
|
||||
*
|
||||
* @return array An array of parameters
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
@ -66,13 +62,7 @@ class ParameterBag implements ParameterBagInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a service container parameter.
|
||||
*
|
||||
* @param string $name The parameter name
|
||||
*
|
||||
* @return mixed The parameter value
|
||||
*
|
||||
* @throws ParameterNotFoundException if the parameter is not defined
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
@ -109,11 +99,7 @@ class ParameterBag implements ParameterBagInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a parameter name is defined.
|
||||
*
|
||||
* @param string $name The parameter name
|
||||
*
|
||||
* @return bool true if the parameter name is defined, false otherwise
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($name)
|
||||
{
|
||||
@ -131,7 +117,7 @@ class ParameterBag implements ParameterBagInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces parameter placeholders (%name%) by their values for all parameters.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve()
|
||||
{
|
||||
@ -264,6 +250,9 @@ class ParameterBag implements ParameterBagInterface
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function unescapeValue($value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
|
@ -22,8 +22,6 @@ class Reference
|
||||
private $invalidBehavior;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $id The service identifier
|
||||
* @param int $invalidBehavior The behavior when the service does not exist
|
||||
*
|
||||
@ -36,8 +34,6 @@ class Reference
|
||||
}
|
||||
|
||||
/**
|
||||
* __toString.
|
||||
*
|
||||
* @return string The service identifier
|
||||
*/
|
||||
public function __toString()
|
||||
|
@ -73,24 +73,17 @@ class CrossCheckTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function crossCheckLoadersDumpers()
|
||||
{
|
||||
$tests = array(
|
||||
return array(
|
||||
array('services1.xml', 'xml'),
|
||||
array('services2.xml', 'xml'),
|
||||
array('services6.xml', 'xml'),
|
||||
array('services8.xml', 'xml'),
|
||||
array('services9.xml', 'xml'),
|
||||
array('services1.yml', 'yaml'),
|
||||
array('services2.yml', 'yaml'),
|
||||
array('services6.yml', 'yaml'),
|
||||
array('services8.yml', 'yaml'),
|
||||
array('services9.yml', 'yaml'),
|
||||
);
|
||||
|
||||
if (class_exists('Symfony\Component\Yaml\Yaml')) {
|
||||
$tests = array_merge($tests, array(
|
||||
array('services1.yml', 'yaml'),
|
||||
array('services2.yml', 'yaml'),
|
||||
array('services6.yml', 'yaml'),
|
||||
array('services8.yml', 'yaml'),
|
||||
array('services9.yml', 'yaml'),
|
||||
));
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ class Variable
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name)
|
||||
|
@ -49,7 +49,7 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
try {
|
||||
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
|
||||
} catch (\Exception $e) {
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), false);
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()));
|
||||
|
||||
$wrapper = $e;
|
||||
|
||||
|
@ -294,8 +294,6 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
// Return null if the property doesn't exist
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,13 +39,10 @@ class LengthValidator extends ConstraintValidator
|
||||
|
||||
$stringValue = (string) $value;
|
||||
|
||||
if ('UTF8' === $charset = strtoupper($constraint->charset)) {
|
||||
$charset = 'UTF-8'; // iconv on Windows requires "UTF-8" instead of "UTF8"
|
||||
if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) {
|
||||
$length = mb_strlen($stringValue, $constraint->charset);
|
||||
}
|
||||
|
||||
$length = @iconv_strlen($stringValue, $charset);
|
||||
$invalidCharset = false === $length;
|
||||
|
||||
if ($invalidCharset) {
|
||||
$this->context->buildViolation($constraint->charsetMessage)
|
||||
->setParameter('{{ value }}', $this->formatValue($stringValue))
|
||||
|
@ -17,6 +17,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/translation": "~2.8|~3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
|
@ -102,12 +102,12 @@ class VarCloner extends AbstractCloner
|
||||
} else {
|
||||
$stub->value = $v;
|
||||
}
|
||||
} elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = iconv_strlen($v, 'UTF-8') - $maxString) {
|
||||
} elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) {
|
||||
$stub = new Stub();
|
||||
$stub->type = Stub::TYPE_STRING;
|
||||
$stub->class = Stub::STRING_UTF8;
|
||||
$stub->cut = $cut;
|
||||
$stub->value = iconv_substr($v, 0, $maxString, 'UTF-8');
|
||||
$stub->value = mb_substr($v, 0, $maxString, 'UTF-8');
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -169,7 +169,7 @@ class CliDumper extends AbstractDumper
|
||||
$this->dumpLine($cursor->depth, true);
|
||||
} else {
|
||||
$attr = array(
|
||||
'length' => 0 <= $cut ? iconv_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'binary' => $bin,
|
||||
);
|
||||
$str = explode("\n", $str);
|
||||
@ -198,8 +198,8 @@ class CliDumper extends AbstractDumper
|
||||
if ($i < $m) {
|
||||
$str .= "\n";
|
||||
}
|
||||
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = iconv_strlen($str, 'UTF-8')) {
|
||||
$str = iconv_substr($str, 0, $this->maxStringWidth, 'UTF-8');
|
||||
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
|
||||
$str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
|
||||
$lineCut = $len - $this->maxStringWidth;
|
||||
}
|
||||
if ($m && 0 < $cursor->depth) {
|
||||
|
Reference in New Issue
Block a user