8000 [PropertyInfo] Respect property name case when guessing from public m… · symfony/symfony@843bb76 · GitHub
[go: up one dir, main page]

Skip to content

Commit 843bb76

Browse files
committed
[PropertyInfo] Respect property name case when guessing from public method name
1 parent 31fcf93 commit 843bb76

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public function getProperties($class, array $context = [])
103103
if (!$propertyName || isset($properties[$propertyName])) {
104104
continue;
105105
}
106-
if (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName)) {
107-
$propertyName = lcfirst($propertyName);
106+
if ($reflectionClass->hasProperty($lowerCasedPropertyName = lcfirst($propertyName)) || (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName))) {
107+
$propertyName = $lowerCasedPropertyName;
108108
}
109109
$properties[$propertyName] = $propertyName;
110110
}

src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function testGetProperties()
5959
'123',
6060
'self',
6161
'realParent',
62+
'xTotals',
63+
'YT',
6264
'c',
6365
'd',
6466
'e',

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ class Dummy extends ParentDummy
9393
*/
9494
public $j;
9595

96+
/**
97+
* @var array
98+
*/
99+
private $xTotals;
100+
101+
/**
102+
* @var string
103+
*/
104+
private $YT;
105+
96106
/**
97107
* This should not be removed.
98108
*
@@ -166,4 +176,18 @@ public function setSelf(self $self)
166176
public function setRealParent(parent $realParent)
167177
{
168178
}
179+
180+
/**
181+
* @return array
182+
*/
183+
public function getXTotals()
184+
{
185+
}
186+
187+
/**
188+
* @return string
189+
*/
190+
public function getYT()
191+
{
192+
}
169193
}

0 commit comments

Comments
 (0)
0