Skip to content

Commit 461524d

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: (34 commits) improve amqp connection issues [Serializer] [ObjectNormalizer] Filter int when using FILTER_BOOL Fix #53778 [PropertyInfo] Add missing test fix tests [Security][Validators] Review translations. [validator] Updated Dutch translation [FrameworkBundle] Fix wiring ConsoleProfilerListener [HttpKernel] Fix link to php doc [Validator] Update sr_Cyrl 120:This value is not a valid slug. [Validator] Update sr_Latn 120:This value is not a valid slug. 6.4 Missing translations for Italian (it) #59419 tests(notifier): avoid failing SNS test with local AWS configuration Fix typo ratio comment chore: PropertyAccess - fix typo in DocBlock [Validator] Missing translations for Brazilian Portuguese (pt_BR) fix(dependency-injection): reset env vars with kernel.reset [Translation][Validator] Review Russian translation (114 - 120) Review validator-related persian translation with id 120 [Scheduler] Clarify description of exclusion time ...
2 parents 5c34269 + ff34e9f commit 461524d

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

Normalizer/AbstractObjectNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ private function validateAndDenormalizeLegacy(array $types, string $currentClass
569569
return (float) $data;
570570
}
571571

572-
if (LegacyType::BUILTIN_TYPE_BOOL === $builtinType && \is_string($data) && ($context[self::FILTER_BOOL] ?? false)) {
572+
if (LegacyType::BUILTIN_TYPE_BOOL === $builtinType && (\is_string($data) || \is_int($data)) && ($context[self::FILTER_BOOL] ?? false)) {
573573
return filter_var($data, \FILTER_VALIDATE_BOOL, \FILTER_NULL_ON_FAILURE);
574574
}
575575

@@ -848,7 +848,7 @@ private function validateAndDenormalize(Type $type, string $currentClass, string
848848
return (float) $data;
849849
}
850850

851-
if (TypeIdentifier::BOOL === $typeIdentifier && \is_string($data) && ($context[self::FILTER_BOOL] ?? false)) {
851+
if (TypeIdentifier::BOOL === $typeIdentifier && (\is_string($data) || \is_int($data)) && ($context[self::FILTER_BOOL] ?? false)) {
852852
return filter_var($data, \FILTER_VALIDATE_BOOL, \FILTER_NULL_ON_FAILURE);
853853
}
854854

Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,15 +1216,34 @@ public static function provideDenormalizeWithFilterBoolData(): array
12161216
{
12171217
return [
12181218
[['foo' => 'true'], true],
1219+
[['foo' => 'True'], true],
1220+
[['foo' => 'TRUE'], true],
12191221
[['foo' => '1'], true],
1222+
[['foo' => 1], true],
12201223
[['foo' => 'yes'], true],
1224+
[['foo' => 'Yes'], true],
1225+
[['foo' => 'YES'], true],
1226+
[['foo' => 'on'], true],
1227+
[['foo' => 'On'], true],
1228+
[['foo' => 'ON'], true],
12211229
[['foo' => 'false'], false],
1230+
[['foo' => 'False'], false],
1231+
[['foo' => 'FALSE'], false],
12221232
[['foo' => '0'], false],
1233+
[['foo' => 0], false],
12231234
[['foo' => 'no'], false],
1235+
[['foo' => 'No'], false],
1236+
[['foo' => 'NO'], false],
1237+
[['foo' => 'off'], false],
1238+
[['foo' => 'Off'], false],
1239+
[['foo' => 'OFF'], false],
12241240
[['foo' => ''], false],
12251241
[['foo' => null], null],
12261242
[['foo' => 'null'], null],
12271243
[['foo' => 'something'], null],
1244+
[['foo' => 'foo'], null],
1245+
[['foo' => 1234567890], null],
1246+
[['foo' => -1234567890], null],
12281247
];
12291248
}
12301249

@@ -1253,10 +1272,7 @@ protected function isAllowedAttribute($classOrObject, string $attribute, ?string
12531272

12541273
public function testTemplateTypeWhenAnObjectIsPassedToDenormalize()
12551274
{
1256-
$normalizer = new class (
1257-
classMetadataFactory: new ClassMetadataFactory(new AttributeLoader()),
1258-
propertyTypeExtractor: new PropertyInfoExtractor(typeExtractors: [new PhpStanExtractor(), new ReflectionExtractor()])
1259-
) extends AbstractObjectNormalizerDummy {
1275+
$normalizer = new class(classMetadataFactory: new ClassMetadataFactory(new AttributeLoader()), propertyTypeExtractor: new PropertyInfoExtractor(typeExtractors: [new PhpStanExtractor(), new ReflectionExtractor()])) extends AbstractObjectNormalizerDummy {
12601276
protected function isAllowedAttribute($classOrObject, string $attribute, ?string $format = null, array $context = []): bool
12611277
{
12621278
return true;
@@ -1279,10 +1295,7 @@ public function testDenormalizeTemplateType()
12791295
$this->markTestSkipped('The PropertyInfo component before Symfony 7.1 does not support template types.');
12801296
}
12811297

1282-
$normalizer = new class (
1283-
classMetadataFactory: new ClassMetadataFactory(new AttributeLoader()),
1284-
propertyTypeExtractor: new PropertyInfoExtractor(typeExtractors: [new PhpStanExtractor(), new ReflectionExtractor()])
1285-
) extends AbstractObjectNormalizerDummy {
1298+
$normalizer = new class(classMetadataFactory: new ClassMetadataFactory(new AttributeLoader()), propertyTypeExtractor: new PropertyInfoExtractor(typeExtractors: [new PhpStanExtractor(), new ReflectionExtractor()])) extends AbstractObjectNormalizerDummy {
12861299
protected function isAllowedAttribute($classOrObject, string $attribute, ?string $format = null, array $context = []): bool
12871300
{
12881301
return true;
@@ -1587,7 +1600,7 @@ class TruePropertyDummy
15871600

15881601
class BoolPropertyDummy
15891602
{
1590-
/** @var null|bool */
1603+
/** @var bool|null */
15911604
public $foo;
15921605
}
15931606

0 commit comments

Comments
 (0)