Skip to content

Commit 668c441

Browse files
Merge branch '5.4' into 6.3
* 5.4: [Serializer] Fix normalization relying on allowed attributes only [Validator] Add missing translations for Bulgarian symfony#51931 [String] Fix Inflector for 'icon'
2 parents 2a00e60 + 80b5ce4 commit 668c441

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ protected function getAttributes(object $object, ?string $format, array $context
269269
$allowedAttributes = $this->getAllowedAttributes($object, $context, true);
270270

271271
if (false !== $allowedAttributes) {
272-
$attributes = array_intersect($attributes, $allowedAttributes);
272+
$attributes = $attributes ? array_intersect($attributes, $allowedAttributes) : $allowedAttributes;
273273
}
274274

275275
if ($context['cache_key'] && \stdClass::class !== $class) {

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

+32-2
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,39 @@ public function testDenormalizeWithCorrectOrderOfAttributeAndProperty()
847847
public function testNormalizeWithIgnoreAnnotationAndPrivateProperties()
848848
{
849849
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
850-
$serializer = new Serializer([new ObjectNormalizer($classMetadataFactory)]);
850+
$normalizer = new ObjectNormalizer($classMetadataFactory);
851851

852-
$this->assertSame(['foo' => 'foo'], $serializer->normalize(new ObjectDummyWithIgnoreAnnotationAndPrivateProperty()));
852+
$this->assertSame(['foo' => 'foo'], $normalizer->normalize(new ObjectDummyWithIgnoreAnnotationAndPrivateProperty()));
853+
}
854+
855+
public function testNormalizeBasedOnAllowedAttributes()
856+
{
857+
$normalizer = new class() extends AbstractObjectNormalizer {
858+
protected function getAllowedAttributes($classOrObject, array $context, bool $attributesAsString = false)
859+
{
860+
return ['foo'];
861+
}
862+
863+
protected function extractAttributes(object $object, string $format = null, array $context = []): array
864+
{
865+
return [];
866+
}
867+
868+
protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = [])
869+
{
870+
return $object->$attribute;
871+
}
872+
873+
protected function setAttributeValue(object $object, string $attribute, $value, string $format = null, array $context = [])
874+
{
875+
}
876+
};
877+
878+
$object = new Dummy();
879+
$object->foo = 'foo';
880+
$object->bar = 'bar';
881+
882+
$this->assertSame(['foo' => 'foo'], $normalizer->normalize($object));
853883
}
854884

855885
public function testDenormalizeUntypedFormat()

src/Symfony/Component/String/Inflector/EnglishInflector.php

+3
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ final class EnglishInflector implements InflectorInterface
253253
// seasons (season), treasons (treason), poisons (poison), lessons (lesson)
254254
['nos', 3, true, true, 'sons'],
255255

256+
// icons (icon)
257+
['noc', 3, true, true, 'cons'],
258+
256259
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
257260
['no', 2, true, true, 'a'],
258261

src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ public static function pluralizeProvider()
295295
['tree', 'trees'],
296296
['waltz', 'waltzes'],
297297
['wife', 'wives'],
298+
['icon', 'icons'],
298299

299300
// test casing: if the first letter was uppercase, it should remain so
300301
['Man', 'Men'],

src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf

+24
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>Стойността на мрежовата маска трябва да бъде между {{ min }} и {{ max }}.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>Името на файла е твърде дълго. Трябва да съдържа не повече от {{ filename_max_length }} символ.|Името на файла е твърде дълго. Трябва да съдържа не повече от {{ filename_max_length }} символа.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>Сложността на паролата е твърде малка. Моля използвайте по-сложна парола.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>Стойността съдържа символи, които не са позволени от текущото ниво на ограничение.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>Използването на невидими символи не е позволено.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>Смесването на числа от различни скриптове не е позволено.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>Използването на скрити насложени символи не е позволено.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

0 commit comments

Comments
 (0)