Skip to content

Commit a81950f

Browse files
Merge branch '6.4' into 7.0
* 6.4: [Cache] Fix test failure related to Redis6Proxy on appveyor [Messenger] Fix reading pending messages with Redis [Serializer] Revert #54488 to fix BC Break [Validator] reviewed Polish translation for unit 113 [Validator] Missing translations for Croatian (hr) Add hint which version of Symfony not longer require proxy manager bridge review and fix hungarian validation message Update translation review uk translations v2 [Validator] Update message translations for unit 113 (TLD) [Intl] Remove resources data from classmap generation
2 parents 81f84e2 + 9c64eba commit a81950f

File tree

6 files changed

+5
-222
lines changed

6 files changed

+5
-222
lines changed

Mapping/Loader/AttributeLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
125125

126126
$accessorOrMutator = preg_match('/^(get|is|has|set)(.+)$/i', $method->name, $matches);
127127
if ($accessorOrMutator) {
128-
$attributeName = $reflectionClass->hasProperty($method->name) ? $method->name : lcfirst($matches[2]);
128+
$attributeName = lcfirst($matches[2]);
129129

130130
if (isset($attributesMetadata[$attributeName])) {
131131
$attributeMetadata = $attributesMetadata[$attributeName];

Normalizer/ObjectNormalizer.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,17 @@ protected function extractAttributes(object $object, ?string $format = null, arr
8686

8787
if (str_starts_with($name, 'get') || str_starts_with($name, 'has') || str_starts_with($name, 'can')) {
8888
// getters, hassers and canners
89-
$attributeName = $name;
89+
$attributeName = substr($name, 3);
9090

9191
if (!$reflClass->hasProperty($attributeName)) {
92-
$attributeName = substr($attributeName, 3);
93-
94-
if (!$reflClass->hasProperty($attributeName)) {
95-
$attributeName = lcfirst($attributeName);
96-
}
92+
$attributeName = lcfirst($attributeName);
9793
}
9894
} elseif (str_starts_with($name, 'is')) {
9995
// issers
100-
$attributeName = $name;
96+
$attributeName = substr($name, 2);
10197

10298
if (!$reflClass->hasProperty($attributeName)) {
103-
$attributeName = substr($attributeName, 2);
104-
105-
if (!$reflClass->hasProperty($attributeName)) {
106-
$attributeName = lcfirst($attributeName);
107-
}
99+
$attributeName = lcfirst($attributeName);
108100
}
109101
}
110102

Tests/Fixtures/SamePropertyAsMethodDummy.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

Tests/Fixtures/SamePropertyAsMethodWithMethodSerializedNameDummy.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

Tests/Fixtures/SamePropertyAsMethodWithPropertySerializedNameDummy.php

Lines changed: 0 additions & 57 deletions
This file was deleted.

Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy;
4343
use Symfony\Component\Serializer\Tests\Fixtures\Php74DummyPrivate;
4444
use Symfony\Component\Serializer\Tests\Fixtures\Php80Dummy;
45-
use Symfony\Component\Serializer\Tests\Fixtures\SamePropertyAsMethodDummy;
46-
use Symfony\Component\Serializer\Tests\Fixtures\SamePropertyAsMethodWithMethodSerializedNameDummy;
47-
use Symfony\Component\Serializer\Tests\Fixtures\SamePropertyAsMethodWithPropertySerializedNameDummy;
4845
use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder;
4946
use Symfony\Component\Serializer\Tests\Normalizer\Features\AttributesTestTrait;
5047
use Symfony\Component\Serializer\Tests\Normalizer\Features\CacheableObjectAttributesTestTrait;
@@ -840,53 +837,6 @@ public function testNormalizeStdClass()
840837
$this->assertSame(['baz' => 'baz'], $this->normalizer->normalize($o2));
841838
}
842839

843-
public function testSamePropertyAsMethod()
844-
{
845-
$object = new SamePropertyAsMethodDummy('free_trial', 'has_subscribe', 'get_ready', 'is_active');
846-
$expected = [
847-
'freeTrial' => 'free_trial',
848-
'hasSubscribe' => 'has_subscribe',
849-
'getReady' => 'get_ready',
850-
'isActive' => 'is_active',
851-
];
852-
853-
$this->assertSame($expected, $this->normalizer->normalize($object));
854-
}
855-
856-
public function testSamePropertyAsMethodWithPropertySerializedName()
857-
{
858-
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
859-
$this->normalizer = new ObjectNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory));
860-
$this->normalizer->setSerializer($this->serializer);
861-
862-
$object = new SamePropertyAsMethodWithPropertySerializedNameDummy('free_trial', 'has_subscribe', 'get_ready', 'is_active');
863-
$expected = [
864-
'free_trial_property' => 'free_trial',
865-
'has_subscribe_property' => 'has_subscribe',
866-
'get_ready_property' => 'get_ready',
867-
'is_active_property' => 'is_active',
868-
];
869-
870-
$this->assertSame($expected, $this->normalizer->normalize($object));
871-
}
872-
873-
public function testSamePropertyAsMethodWithMethodSerializedName()
874-
{
875-
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
876-
$this->normalizer = new ObjectNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory));
877-
$this->normalizer->setSerializer($this->serializer);
878-
879-
$object = new SamePropertyAsMethodWithMethodSerializedNameDummy('free_trial', 'has_subscribe', 'get_ready', 'is_active');
880-
$expected = [
881-
'free_trial_method' => 'free_trial',
882-
'has_subscribe_method' => 'has_subscribe',
883-
'get_ready_method' => 'get_ready',
884-
'is_active_method' => 'is_active',
885-
];
886-
887-
$this->assertSame($expected, $this->normalizer->normalize($object));
888-
}
889-
890840
public function testNormalizeWithoutSerializerSet()
891841
{
892842
$normalizer = new ObjectNormalizer(new ClassMetadataFactory(new AttributeLoader()));

0 commit comments

Comments
 (0)