Skip to content

Commit 76f3eae

Browse files
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
2 parents 5f8a196 + d1038c3 commit 76f3eae

File tree

8 files changed

+19
-20
lines changed

8 files changed

+19
-20
lines changed

src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ private function normalizeParams(array $params)
9595
}
9696

9797
// detect if the too long string must be shorten
98-
if (self::MAX_STRING_LENGTH < iconv_strlen($params[$index], 'UTF-8')) {
99-
$params[$index] = iconv_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
98+
if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) {
99+
$params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
100100
continue;
101101
}
102102
}

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
],
1818
"require": {
1919
"php": ">=5.5.9",
20-
"doctrine/common": "~2.4"
20+
"doctrine/common": "~2.4",
21+
"symfony/polyfill-mbstring": "~1.0"
2122
},
2223
"require-dev": {
2324
"symfony/stopwatch": "~2.8|~3.0",
2425
"symfony/dependency-injection": "~2.8|~3.0",
25-
"symfony/form": "~3.0,>3.0-BETA1",
26+
"symfony/form": "~3.0",
2627
"symfony/http-kernel": "~2.8|~3.0",
2728
"symfony/property-access": "~2.8|~3.0",
2829
"symfony/property-info": "~2.8|3.0",

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function createAutowiredDefinition(\ReflectionClass $typeHint, $id)
228228
* @param string $id
229229
* @param Definition $definition
230230
*
231-
* @return \ReflectionClass|null
231+
* @return \ReflectionClass|false
232232
*/
233233
private function getReflectionClass($id, Definition $definition)
234234
{
@@ -238,15 +238,17 @@ private function getReflectionClass($id, Definition $definition)
238238

239239
// Cannot use reflection if the class isn't set
240240
if (!$class = $definition->getClass()) {
241-
return;
241+
return false;
242242
}
243243

244244
$class = $this->container->getParameterBag()->resolveValue($class);
245245

246246
try {
247-
return $this->reflectionClasses[$id] = new \ReflectionClass($class);
247+
$reflector = new \ReflectionClass($class);
248248
} catch (\ReflectionException $reflectionException) {
249-
// return null
249+
$reflector = false;
250250
}
251+
252+
return $this->reflectionClasses[$id] = $reflector;
251253
}
252254
}

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ private function getAccessorMethod($class, $property)
294294
// Return null if the property doesn't exist
295295
}
296296
}
297-
298-
return;
299297
}
300298

301299
/**

src/Symfony/Component/Validator/Constraints/LengthValidator.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,10 @@ public function validate($value, Constraint $constraint)
3939

4040
$stringValue = (string) $value;
4141

42-
if ('UTF8' === $charset = strtoupper($constraint->charset)) {
43-
$charset = 'UTF-8'; // iconv on Windows requires "UTF-8" instead of "UTF8"
42+
if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) {
43+
$length = mb_strlen($stringValue, $constraint->charset);
4444
}
4545

46-
$length = @iconv_strlen($stringValue, $charset);
47-
$invalidCharset = false === $length;
48-
4946
if ($invalidCharset) {
5047
$this->context->buildViolation($constraint->charsetMessage)
5148
->setParameter('{{ value }}', $this->formatValue($stringValue))

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.5.9",
20+
"symfony/polyfill-mbstring": "~1.0",
2021
"symfony/translation": "~2.8|~3.0"
2122
},
2223
"require-dev": {

src/Symfony/Component/VarDumper/Cloner/VarCloner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ protected function doClone($var)
102102
} else {
103103
$stub->value = $v;
104104
}
105-
} elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = iconv_strlen($v, 'UTF-8') - $maxString) {
105+
} elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) {
106106
$stub = new Stub();
107107
$stub->type = Stub::TYPE_STRING;
108108
$stub->class = Stub::STRING_UTF8;
109109
$stub->cut = $cut;
110-
$stub->value = iconv_substr($v, 0, $maxString, 'UTF-8');
110+
$stub->value = mb_substr($v, 0, $maxString, 'UTF-8');
111111
}
112112
break;
113113

src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
169169
$this->dumpLine($cursor->depth, true);
170170
} else {
171171
$attr = array(
172-
'length' => 0 <= $cut ? iconv_strlen($str, 'UTF-8') + $cut : 0,
172+
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
173173
'binary' => $bin,
174174
);
175175
$str = explode("\n", $str);
@@ -195,8 +195,8 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
195195
if ($i < $m) {
196196
$str .= "\n";
197197
}
198-
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = iconv_strlen($str, 'UTF-8')) {
199-
$str = iconv_substr($str, 0, $this->maxStringWidth, 'UTF-8');
198+
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
199+
$str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
200200
$lineCut = $len - $this->maxStringWidth;
201201
}
202202
if ($m && 0 < $cursor->depth) {

0 commit comments

Comments
 (0)