|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\PropertyInfo\Extractor;
|
13 | 13 |
|
14 |
| -use Symfony\Component\PropertyAccess\StringUtil; |
| 14 | +use Symfony\Component\Inflector\Inflector; |
15 | 15 | use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
|
16 | 16 | use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
|
17 | 17 | use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
|
@@ -317,15 +317,11 @@ private function getAccessorMethod($class, $property)
|
317 | 317 | private function getMutatorMethod($class, $property)
|
318 | 318 | {
|
319 | 319 | $ucProperty = ucfirst($property);
|
320 |
| - $singulars = $this->getSingulars($ucProperty); |
| 320 | + $names = $this->getSingulars($ucProperty); |
321 | 321 |
|
322 | 322 | foreach (self::$mutatorPrefixes as $prefix) {
|
323 |
| - |
324 |
| - if (null !== $singulars && in_array($prefix, self::$arrayMutatorPrefixes)) { |
325 |
| - $names = $singulars; |
326 |
| - $names[] = $ucProperty; |
327 |
| - } else { |
328 |
| - $names = array($ucProperty); |
| 323 | + if (in_array($prefix, self::$arrayMutatorPrefixes)) { |
| 324 | + array_unshift($names, $ucProperty); |
329 | 325 | }
|
330 | 326 |
|
331 | 327 | foreach ($names as $name) {
|
@@ -377,15 +373,11 @@ private function getPropertyName($methodName, array $reflectionProperties)
|
377 | 373 | *
|
378 | 374 | * @param string $plural
|
379 | 375 | *
|
380 |
| - * @return array|null Returns null if cannot guess. |
| 376 | + * @return array |
381 | 377 | */
|
382 | 378 | private function getSingulars($plural)
|
383 | 379 | {
|
384 |
| - if (!class_exists('Symfony\Component\PropertyAccess\StringUtil')) { |
385 |
| - return; |
386 |
| - } |
387 |
| - |
388 |
| - $singulars = StringUtil::singularify($plural); |
| 380 | + $singulars = Inflector::singularize($plural); |
389 | 381 | if (is_string($singulars)) {
|
390 | 382 | $singulars = array($singulars);
|
391 | 383 | }
|
|
0 commit comments