[PropertyInfo] Respect property name case when guessing from public method name

This commit is contained in:
Anto 2019-10-11 06:08:52 +02:00
parent 31fcf93253
commit 843bb76f8a
No known key found for this signature in database
GPG Key ID: D33172CA4E946C66
3 changed files with 28 additions and 2 deletions

View File

@ -103,8 +103,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if (!$propertyName || isset($properties[$propertyName])) { if (!$propertyName || isset($properties[$propertyName])) {
continue; continue;
} }
if (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName)) { if ($reflectionClass->hasProperty($lowerCasedPropertyName = lcfirst($propertyName)) || (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName))) {
$propertyName = lcfirst($propertyName); $propertyName = $lowerCasedPropertyName;
} }
$properties[$propertyName] = $propertyName; $properties[$propertyName] = $propertyName;
} }

View File

@ -59,6 +59,8 @@ class ReflectionExtractorTest extends TestCase
'123', '123',
'self', 'self',
'realParent', 'realParent',
'xTotals',
'YT',
'c', 'c',
'd', 'd',
'e', 'e',

View File

@ -93,6 +93,16 @@ class Dummy extends ParentDummy
*/ */
public $j; public $j;
/**
* @var array
*/
private $xTotals;
/**
* @var string
*/
private $YT;
/** /**
* This should not be removed. * This should not be removed.
* *
@ -166,4 +176,18 @@ class Dummy extends ParentDummy
public function setRealParent(parent $realParent) public function setRealParent(parent $realParent)
{ {
} }
/**
* @return array
*/
public function getXTotals()
{
}
/**
* @return string
*/
public function getYT()
{
}
} }