Merge branch '2.8' into 3.0

* 2.8:
  [DI] Fix internal caching in AutowirePass
  [PropertyInfo] Remove useless return statement
  Replace iconv_*() uses by mb_*(), add mbstring polyfill when required

Conflicts:
	src/Symfony/Bridge/Doctrine/composer.json
	src/Symfony/Component/Validator/composer.json
This commit is contained in:
Nicolas Grekas 2016-04-20 13:35:44 +02:00
commit 76f3eae5e1
8 changed files with 19 additions and 20 deletions

View File

@ -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;
}
}

View File

@ -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",

View File

@ -228,7 +228,7 @@ class AutowirePass implements CompilerPassInterface
* @param string $id
* @param Definition $definition
*
* @return \ReflectionClass|null
* @return \ReflectionClass|false
*/
private function getReflectionClass($id, Definition $definition)
{
@ -238,15 +238,17 @@ 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;
}
}

View File

@ -294,8 +294,6 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
// Return null if the property doesn't exist
}
}
return;
}
/**

View File

@ -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))

View File

@ -17,6 +17,7 @@
],
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0",
"symfony/translation": "~2.8|~3.0"
},
"require-dev": {

View File

@ -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;

View File

@ -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);
@ -195,8 +195,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) {