From b2da76ce5b17bc2dd518743eb6cb4c748e2c4394 Mon Sep 17 00:00:00 2001 From: Zander Baldwin Date: Tue, 8 Dec 2015 14:17:35 +0000 Subject: [PATCH] [PropertyInfo] Update List Information from ReflectionExtractor --- .../PropertyInfo/Extractor/ReflectionExtractor.php | 8 ++++++-- .../Tests/Extractors/ReflectionExtractorTest.php | 13 +++++++------ .../PropertyInfo/Tests/Fixtures/Dummy.php | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 322b645b80e5..8226655f7a13 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -62,9 +62,13 @@ public function getProperties($class, array $context = array()) foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { $propertyName = $this->getPropertyName($reflectionMethod->name); - if ($propertyName) { - $properties[$propertyName] = true; + if (!$propertyName || isset($properties[$propertyName])) { + continue; } + if (!preg_match('/^[A-Z]{2,}/', $propertyName)) { + $propertyName = lcfirst($propertyName); + } + $properties[$propertyName] = true; } return array_keys($properties); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index 0740997eed00..8642c9731c0d 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -36,18 +36,19 @@ public function testGetProperties() 'bal', 'parent', 'collection', + 'B', 'foo', 'foo2', 'foo3', 'foo4', 'foo5', 'files', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', + 'a', + 'DOB', + 'c', + 'd', + 'e', + 'f', ), $this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy') ); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php index 8e80c0b59a9a..7068722c4ba7 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php @@ -46,6 +46,11 @@ class Dummy extends ParentDummy */ public $collection; + /** + * @var ParentDummy + */ + public $B; + /** * A. * @@ -63,4 +68,13 @@ public function getA() public function setB(ParentDummy $parent = null) { } + + /** + * Date of Birth. + * + * @return \DateTime + */ + public function getDOB() + { + } }