[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])) {
continue;
}
if (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName)) {
$propertyName = lcfirst($propertyName);
if ($reflectionClass->hasProperty($lowerCasedPropertyName = lcfirst($propertyName)) || (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName))) {
$propertyName = $lowerCasedPropertyName;
}
$properties[$propertyName] = $propertyName;
}

View File

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

View File

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