10000 Integrate the new Inflector component · symfony/symfony@205c36f · GitHub
[go: up one dir, main page]

Skip to content

Commit 205c36f

Browse files
committed
Integrate the new Inflector component
1 parent 7d93fb2 commit 205c36f

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Extractor;
1313

14-
use Symfony\Component\PropertyAccess\StringUtil;
14+
use Symfony\Component\Inflector\Inflector;
1515
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
1616
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
1717
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
@@ -317,15 +317,11 @@ private function getAccessorMethod($class, $property)
317317
private function getMutatorMethod($class, $property)
318318
{
319319
$ucProperty = ucfirst($property);
320-
$singulars = $this->getSingulars($ucProperty);
320+
$names = $this->getSingulars($ucProperty);
321321

322322
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);
329325
}
330326

331327
foreach ($names as $name) {
@@ -377,15 +373,11 @@ private function getPropertyName($methodName, array $reflectionProperties)
377373
*
378374
* @param string $plural
379375
*
380-
* @return array|null Returns null if cannot guess.
376+
* @return array
381377
*/
382378
private function getSingulars($plural)
383379
{
384-
if (!class_exists('Symfony\Component\PropertyAccess\StringUtil')) {
385-
return;
386-
}
387-
388-
$singulars = StringUtil::singularify($plural);
380+
$singulars = Inflector::singularize($plural);
389381
if (is_string($singulars)) {
390382
$singulars = array($singulars);
391383
}

src/Symfony/Component/PropertyInfo/composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
}
2424
],
2525
"require": {
26-
"php": ">=5.5.9"
26+
"php": ">=5.5.9",
27+
"symfony/inflector": "~3.1"
2728
},
2829
"require-dev": {
2930
"symfony/serializer": "~2.8|~3.0",
30-
"symfony/property-access": "~2.8|~3.0",
3131
"symfony/cache": "~3.1",
3232
"phpdocumentor/reflection-docblock": "^3.0",
3333
"doctrine/annotations": "~1.0"
@@ -39,8 +39,7 @@
3939
"psr/cache-implementation": "To cache results",
4040
"symfony/doctrine-bridge": "To use Doctrine metadata",
4141
"phpdocumentor/reflection-docblock": "To use the PHPDoc",
42-
"symfony/serializer": "To use Serializer metadata",
43-
"symfony/property-access": "To detect singular adders and removers"
42+
"symfony/serializer": "To use Serializer metadata"
4443
},
4544
"autoload": {
4645
"psr-4": { "Symfony\\Component\\PropertyInfo\\": "" },

0 commit comments

Comments
 (0)
0