symfony/symfony — Issue #2863: GetSetMethodNormalizer converts property to all-lowercase
Author: lxg
Created: 2011-12-13 14:00:58+00:00
State: open

\Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer converts property to all-lowercase. I think it should maintain camel-case, and just lowercase the first letter – which I would guess is usually preferred by most users.

The solution is simple: just replace `strtolower` with `lcfirst` in two places.

```
--- GetSetMethodNormalizerOrig.php 2011-11-14 15:35:27.000000000 +0100
+++ GetSetMethodNormalizer.php 2011-12-13 14:52:29.000000000 +0100
@@ -46,7 +46,7 @@
$attributes = array();
foreach ($reflectionMethods as $method) {
if ($this->isGetMethod($method)) {
- $attributeName = strtolower(substr($method->getName(), 3));
+ $attributeName = lcfirst(substr($method->getName(), 3));

$attributeValue = $method->invoke($object);
if (null !== $attributeValue && !is_scalar($attributeValue)) {
@@ -73,7 +73,7 @@

$params = array();
foreach ($constructorParameters as $constructorParameter) {
- $paramName = strtolower($constructorParameter->getName());
+ $paramName = lcfirst($constructorParameter->getName());

if (isset($data[$paramName])) {
$params[] = $data[$paramName];

```