[PropertyInfo] Update List Information from ReflectionExtractor

This commit is contained in:
Zander Baldwin 2015-12-08 14:17:35 +00:00 committed by Kévin Dunglas
parent afc6ee42ca
commit b2da76ce5b
3 changed files with 27 additions and 8 deletions

View File

@ -62,9 +62,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
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);

View File

@ -36,18 +36,19 @@ class ReflectionExtractorTest extends \PHPUnit_Framework_TestCase
'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')
);

View File

@ -46,6 +46,11 @@ class Dummy extends ParentDummy
*/
public $collection;
/**
* @var ParentDummy
*/
public $B;
/**
* A.
*
@ -63,4 +68,13 @@ class Dummy extends ParentDummy
public function setB(ParentDummy $parent = null)
{
}
/**
* Date of Birth.
*
* @return \DateTime
*/
public function getDOB()
{
}
}