Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 388f5a8

Browse filesBrowse files
Merge branch '6.0' into 6.1
* 6.0: [HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache Add an invariable word in french [Serializer] Fix denormalization union types with constructor
2 parents c8d18b6 + 3a2fa91 commit 388f5a8
Copy full SHA for 388f5a8

File tree

5 files changed

+41
-10
lines changed
Filter options

5 files changed

+41
-10
lines changed

‎src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ private function mayServeStaleWhileRevalidate(Response $entry): bool
692692
$timeout = $this->options['stale_while_revalidate'];
693693
}
694694

695-
return abs($entry->getTtl()) < $timeout;
695+
return abs($entry->getTtl() ?? 0) < $timeout;
696696
}
697697

698698
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Serializer\Encoder\XmlEncoder;
2222
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
2323
use Symfony\Component\Serializer\Exception\LogicException;
24+
use Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException;
2425
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
2526
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;
2627
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
@@ -439,13 +440,16 @@ abstract protected function setAttributeValue(object $object, string $attribute,
439440
* @param Type[] $types
440441
*
441442
* @throws NotNormalizableValueException
443+
* @throws ExtraAttributesException
444+
* @throws MissingConstructorArgumentsException
442445
* @throws LogicException
443446
*/
444447
private function validateAndDenormalize(array $types, string $currentClass, string $attribute, mixed $data, ?string $format, array $context): mixed
445448
{
446449
$expectedTypes = [];
447450
$isUnionType = \count($types) > 1;
448451
$extraAttributesException = null;
452+
$missingConstructorArgumentException = null;
449453
foreach ($types as $type) {
450454
if (null === $data && $type->isNullable()) {
451455
return null;
@@ -582,13 +586,23 @@ private function validateAndDenormalize(array $types, string $currentClass, stri
582586
}
583587

584588
$extraAttributesException ??= $e;
589+
} catch (MissingConstructorArgumentsException $e) {
590+
if (!$isUnionType) {
591+
throw $e;
592+
}
593+
594+
$missingConstructorArgumentException ??= $e;
585595
}
586596
}
587597

588598
if ($extraAttributesException) {
589599
throw $extraAttributesException;
590600
}
591601

602+
if ($missingConstructorArgumentException) {
603+
throw $missingConstructorArgumentException;
604+
}
605+
592606
if ($context[self::DISABLE_TYPE_ENFORCEMENT] ?? $this->defaultContext[self::DISABLE_TYPE_ENFORCEMENT] ?? false) {
593607
return $data;
594608
}

‎src/Symfony/Component/Serializer/Tests/SerializerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/SerializerTest.php
+24-8Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,20 +764,26 @@ public function testUnionTypeDeserializableWithoutAllowedExtraAttributes()
764764
['json' => new JsonEncoder()]
765765
);
766766

767-
$actual = $serializer->deserialize('{ "v": { "a": 0 }}', DummyUnionWithAAndB::class, 'json', [
767+
$actual = $serializer->deserialize('{ "v": { "a": 0 }}', DummyUnionWithAAndCAndB::class, 'json', [
768768
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false,
769769
]);
770770

771-
$this->assertEquals(new DummyUnionWithAAndB(new DummyATypeForUnion()), $actual);
771+
$this->assertEquals(new DummyUnionWithAAndCAndB(new DummyATypeForUnion()), $actual);
772772

773-
$actual = $serializer->deserialize('{ "v": { "b": 1 }}', DummyUnionWithAAndB::class, 'json', [
773+
$actual = $serializer->deserialize('{ "v": { "b": 1 }}', DummyUnionWithAAndCAndB::class, 'json', [
774774
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false,
775775
]);
776776

777-
$this->assertEquals(new DummyUnionWithAAndB(new DummyBTypeForUnion()), $actual);
777+
$this->assertEquals(new DummyUnionWithAAndCAndB(new DummyBTypeForUnion()), $actual);
778+
779+
$actual = $serializer->deserialize('{ "v": { "c": 3 }}', DummyUnionWithAAndCAndB::class, 'json', [
780+
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false,
781+
]);
782+
783+
$this->assertEquals(new DummyUnionWithAAndCAndB(new DummyCTypeForUnion(3)), $actual);
778784

779785
$this->expectException(ExtraAttributesException::class);
780-
$serializer->deserialize('{ "v": { "b": 1, "c": "i am not allowed" }}', DummyUnionWithAAndB::class, 'json', [
786+
$serializer->deserialize('{ "v": { "b": 1, "d": "i am not allowed" }}', DummyUnionWithAAndCAndB::class, 'json', [
781787
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false,
782788
]);
783789
}
@@ -1256,13 +1262,23 @@ class DummyBTypeForUnion
12561262
public $b = 1;
12571263
}
12581264

1259-
class DummyUnionWithAAndB
1265+
class DummyCTypeForUnion
1266+
{
1267+
public $c = 2;
1268+
1269+
public function __construct($c)
1270+
{
1271+
$this->c = $c;
1272+
}
1273+
}
1274+
1275+
class DummyUnionWithAAndCAndB
12601276
{
1261-
/** @var DummyATypeForUnion|DummyBTypeForUnion */
1277+
/** @var DummyATypeForUnion|DummyCTypeForUnion|DummyBTypeForUnion */
12621278
public $v;
12631279

12641280
/**
1265-
* @param DummyATypeForUnion|DummyBTypeForUnion $v
1281+
* @param DummyATypeForUnion|DummyCTypeForUnion|DummyBTypeForUnion $v
12661282
*/
12671283
public function __construct($v)
12681284
{

‎src/Symfony/Component/String/Inflector/FrenchInflector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/Inflector/FrenchInflector.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ final class FrenchInflector implements InflectorInterface
108108
* A list of words which should not be inflected.
109109
* This list is only used by singularize.
110110
*/
111-
private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
111+
private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sans|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
112112

113113
/**
114114
* {@inheritdoc}

‎src/Symfony/Component/String/Tests/Inflector/FrenchInflectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/Tests/Inflector/FrenchInflectorTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function pluralizeProvider()
3131
['héros', 'héros'],
3232
['nez', 'nez'],
3333
['rictus', 'rictus'],
34+
['sans', 'sans'],
3435
['souris', 'souris'],
3536
['tas', 'tas'],
3637
['toux', 'toux'],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.