Skip to content

Commit f38b40b

Browse files
Merge branch '5.4' into 6.2
* 5.4: [VarDumper] Dumping DateTime throws error if getTimezone is false Only update autoload_runtime.php when it changed [Intl] Update the ICU data to 73.2 [HttpClient] Force int conversion for floated multiplier for GenericRetryStrategy [Validator][Translator] Fix xlf files for en & fr translations. Bug introduced by symfony#50590 Add missing EN and FR translations for newest constraints
2 parents eacea7f + 46cda10 commit f38b40b

File tree

10 files changed

+124
-11
lines changed

10 files changed

+124
-11
lines changed

src/Symfony/Component/HttpClient/Retry/GenericRetryStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function getDelay(AsyncContext $context, ?string $responseContent, ?Trans
102102
$delay = $this->delayMs * $this->multiplier ** $context->getInfo('retry_count');
103103

104104
if ($this->jitter > 0) {
105-
$randomness = $delay * $this->jitter;
105+
$randomness = (int) ($delay * $this->jitter);
106106
$delay = $delay + random_int(-$randomness, +$randomness);
107107
}
108108

src/Symfony/Component/HttpClient/Tests/Retry/GenericRetryStrategyTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testGetDelay(int $delay, int $multiplier, int $maxDelay, int $pr
6767

6868
public static function provideDelay(): iterable
6969
{
70-
// delay, multiplier, maxDelay, retries, expectedDelay
70+
// delay, multiplier, maxDelay, previousRetries, expectedDelay
7171
yield [1000, 1, 5000, 0, 1000];
7272
yield [1000, 1, 5000, 1, 1000];
7373
yield [1000, 1, 5000, 2, 1000];
@@ -90,13 +90,16 @@ public static function provideDelay(): iterable
9090
yield [0, 2, 10000, 1, 0];
9191
}
9292

93-
public function testJitter()
93+
/**
94+
* @dataProvider provideJitter
95+
*/
96+
public function testJitter(float $multiplier, int $previousRetries)
9497
{
95-
$strategy = new GenericRetryStrategy([], 1000, 1, 0, 1);
98+
$strategy = new GenericRetryStrategy([], 1000, $multiplier, 0, 1);
9699
$min = 2000;
97100
$max = 0;
98101
for ($i = 0; $i < 50; ++$i) {
99-
$delay = $strategy->getDelay($this->getContext(0, 'GET', 'http://example.com/', 200), null, null);
102+
$delay = $strategy->getDelay($this->getContext($previousRetries, 'GET', 'http://example.com/', 200), null, null);
100103
$min = min($min, $delay);
101104
$max = max($max, $delay);
102105
}
@@ -105,6 +108,13 @@ public function testJitter()
105108
$this->assertLessThanOrEqual(1000, $min);
106109
}
107110

111+
public static function provideJitter(): iterable
112+
{
113+
// multiplier, previousRetries
114+
yield [1, 0];
115+
yield [1.1, 2];
116+
}
117+
108118
private function getContext($retryCount, $method, $url, $statusCode): AsyncContext
109119
{
110120
$passthru = null;

src/Symfony/Component/Intl/Intl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static function getIcuDataVersion(): string
106106
*/
107107
public static function getIcuStubVersion(): string
108108
{
109-
return '73.1';
109+
return '73.2';
110110
}
111111

112112
/**

src/Symfony/Component/Intl/Resources/data/git-info.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Git information
22
===============
33

44
URL: https://github.com/unicode-org/icu.git
5-
Revision: 5861e1fd52f1d7673eee38bc3c965aa18b336062
5+
Revision: 680f521746a3bd6a86f25f25ee50a62d88b489cf
66
Author: Peter Edberg
7-
Date: 2023-04-11T10:32:35-07:00
7+
Date: 2023-06-07T19:19:55-07:00
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
73.1
1+
73.2

src/Symfony/Component/Runtime/Internal/ComposerPlugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ public function updateAutoloadFile(): void
105105
'%runtime_options%' => '['.substr(var_export($extra, true), 7, -1)." 'project_dir' => {$projectDir},\n]",
106106
]);
107107

108-
file_put_contents(substr_replace($autoloadFile, '_runtime', -4, 0), $code);
108+
// could use Composer\Util\Filesystem::filePutContentsIfModified once Composer 1.x support is dropped for this plugin
109+
$path = substr_replace($autoloadFile, '_runtime', -4, 0);
110+
$currentContent = @file_exists($path) ? @file_get_contents($path) : false;
111+
if (false === $currentContent || $currentContent !== $code) {
112+
file_put_contents($path, $code);
113+
}
109114
}
110115

111116
public static function getSubscribedEvents(): array

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,26 @@
406406
<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>
407407
<target>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.</target>
408408
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>The password strength is too low. Please use a stronger password.</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>This value contains characters that are not allowed by the current restriction-level.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>Using invisible characters is not allowed.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>Mixing numbers from different scripts is not allowed.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>Using hidden overlay characters is not allowed.</target>
428+
</trans-unit>
409429
</body>
410430
</file>
411431
</xliff>

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

Lines changed: 24 additions & 0 deletions
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>La valeur du masque de réseau doit être comprise entre {{ min }} et {{ 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>Le nom du fichier est trop long. Il doit contenir au maximum {{ filename_max_length }} caractère.|Le nom de fichier est trop long. Il doit contenir au maximum {{ filename_max_length }} caractères.</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>La force du mot de passe est trop faible. Veuillez utiliser un mot de passe plus fort.</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>Cette valeur contient des caractères qui ne sont pas autorisés par le niveau de restriction actuel.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>Utiliser des caractères invisibles n'est pas autorisé.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>Mélanger des chiffres provenant de différents scripts n'est pas autorisé.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>Utiliser des caractères de superposition cachés n'est pas autorisé.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

src/Symfony/Component/VarDumper/Caster/DateCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DateCaster
2727
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter)
2828
{
2929
$prefix = Caster::PREFIX_VIRTUAL;
30-
$location = $d->getTimezone()->getLocation();
30+
$location = $d->getTimezone() ? $d->getTimezone()->getLocation() : null;
3131
$fromNow = (new \DateTimeImmutable())->diff($d);
3232

3333
$title = $d->format('l, F j, Y')

src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,52 @@ public static function provideDateTimes()
106106
];
107107
}
108108

109+
/**
110+
* @dataProvider provideNoTimezoneDateTimes
111+
*/
112+
public function testCastDateTimeNoTimezone($time, $xDate, $xInfos)
113+
{
114+
$stub = new Stub();
115+
$date = new NoTimezoneDate($time);
116+
$cast = DateCaster::castDateTime($date, Caster::castObject($date, \DateTime::class), $stub, false, 0);
117+
118+
$xDump = <<<EODUMP
119+
array:1 [
120+
"\\x00~\\x00date" => $xDate
121+
]
122+
EODUMP;
123+
124+
$this->assertDumpEquals($xDump, $cast);
125+
126+
$xDump = <<<EODUMP
127+
Symfony\Component\VarDumper\Caster\ConstStub {
128+
+type: 1
129+
+class: "$xDate"
130+
+value: "%A$xInfos%A"
131+
+cut: 0
132+
+handle: 0
133+
+refCount: 0
134+
+position: 0
135+
+attr: []
136+
}
137+
EODUMP;
138+
139+
$this->assertDumpMatchesFormat($xDump, $cast["\0~\0date"]);
140+
}
141+
142+
public static function provideNoTimezoneDateTimes()
143+
{
144+
return [
145+
['2017-04-30 00:00:00.000000', '2017-04-30 00:00:00.0 +00:00', 'Sunday, April 30, 2017'],
146+
['2017-04-30 00:00:00.100000', '2017-04-30 00:00:00.100 +00:00', 'Sunday, April 30, 2017'],
147+
['2017-04-30 00:00:00.120000', '2017-04-30 00:00:00.120 +00:00', 'Sunday, April 30, 2017'],
148+
['2017-04-30 00:00:00.123000', '2017-04-30 00:00:00.123 +00:00', 'Sunday, April 30, 2017'],
149+
['2017-04-30 00:00:00.123400', '2017-04-30 00:00:00.123400 +00:00', 'Sunday, April 30, 2017'],
150+
['2017-04-30 00:00:00.123450', '2017-04-30 00:00:00.123450 +00:00', 'Sunday, April 30, 2017'],
151+
['2017-04-30 00:00:00.123456', '2017-04-30 00:00:00.123456 +00:00', 'Sunday, April 30, 2017'],
152+
];
153+
}
154+
109155
public function testCastDateTimeWithAdditionalChildProperty()
110156
{
111157
$stub = new Stub();
@@ -423,3 +469,11 @@ private function createInterval($intervalSpec, $ms, $invert)
423469
return $interval;
424470
}
425471
}
472+
473+
class NoTimezoneDate extends \DateTime
474+
{
475+
public function getTimezone(): \DateTimeZone|false
476+
{
477+
return false;
478+
}
479+
}

0 commit comments

Comments
 (0)