merged branch ericclemmons/2863-getsetmethodnormalize-lcfirst (PR #3051)
Commits -------707bcc3
Updated CHANGELOG with GetSetNormalizer BC change85bf553
GetSetMethodNormalizer uses lcfirst instead of strtolower when computing method names01fcb1b
Updated GetSetMethodNormalizerTest to expect camelCased functions instead of lowercased Discussion ---------- [Serializer] GetSetMethodNormalizer uses `lcfirst` instead of `strtolower` (on master) Bug fix: yes Feature addition: no Backwards compatibility break: yes Symfony2 tests pass: yes Fixes the following tickets: #2863 Rebased PR #2977 onto `master` (was on `2.0`). --------------------------------------------------------------------------- by fabpot at 2012/01/06 10:57:23 -0800 Can you add a note in the CHANGELOG to explain the change and the potential BC break? --------------------------------------------------------------------------- by ericclemmons at 2012/01/08 13:34:17 -0800 @fabpot Updated `CHANGELOG-2.1` since this is going onto `master`. --------------------------------------------------------------------------- by stof at 2012/01/08 13:48:59 -0800 @ericclemmons you should rebase your branch on top of master. github says it cannot be merged as is --------------------------------------------------------------------------- by ericclemmons at 2012/01/08 14:02:11 -0800 @stof Done. (There was another Serializer entry in the CHANGELOG that didn't exist when I made this branch.)
This commit is contained in:
commit
d7fa66acb5
@ -201,6 +201,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
||||
|
||||
### Serializer
|
||||
|
||||
* [BC BREAK] changed `GetSetMethodNormalizer`'s key names from all lowercased to camelCased (e.g. `mypropertyvalue` to `myPropertyValue`)
|
||||
* [BC BREAK] convert the `item` XML tag to an array
|
||||
|
||||
``` xml
|
||||
@ -227,7 +228,6 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
### Translation
|
||||
|
||||
* changed the default extension for XLIFF files from .xliff to .xlf
|
||||
|
@ -46,7 +46,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal
|
||||
$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 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal
|
||||
|
||||
$params = array();
|
||||
foreach ($constructorParameters as $constructorParameter) {
|
||||
$paramName = strtolower($constructorParameter->getName());
|
||||
$paramName = lcfirst($constructorParameter->getName());
|
||||
|
||||
if (isset($data[$paramName])) {
|
||||
$params[] = $data[$paramName];
|
||||
|
@ -27,7 +27,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
$obj->setFoo('foo');
|
||||
$obj->setBar('bar');
|
||||
$this->assertEquals(
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'foobar' => 'foobar'),
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar'),
|
||||
$this->normalizer->normalize($obj, 'any')
|
||||
);
|
||||
}
|
||||
@ -35,7 +35,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testDenormalize()
|
||||
{
|
||||
$obj = $this->normalizer->denormalize(
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'foobar' => 'foobar'),
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar'),
|
||||
__NAMESPACE__.'\GetSetDummy',
|
||||
'any'
|
||||
);
|
||||
@ -46,7 +46,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testConstructorDenormalize()
|
||||
{
|
||||
$obj = $this->normalizer->denormalize(
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'foobar' => 'foobar'),
|
||||
array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar'),
|
||||
__NAMESPACE__.'\GetConstructorDummy', 'any');
|
||||
$this->assertEquals('foo', $obj->getFoo());
|
||||
$this->assertEquals('bar', $obj->getBar());
|
||||
|
Reference in New Issue
Block a user