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 83e102b

Browse filesBrowse files
Merge branch '6.4' into 7.0
* 6.4: [FrameworkBundle][Validator] Replace annotation by attribute [Validator] Add annotation in Constraint [Lock] Add some missing return types in tests [Clock] Throw `DateMalformedStringException`/`DateInvalidTimeZoneException` when appropriate [VarExporter] Remove unused test files [FrameworkBundle] Remove unused test file [DependencyInjection] Remove unused test file [DomCrawler] Added argument `$default` to method `Crawler::attr()` [HttpKernel] Fix missing Request in RequestStack for StreamedResponse Psalm: Ignore UnusedClass errors fix(console): avoid multiple new line when message already ends with a new line
2 parents 1cbe8c2 + 951b11e commit 83e102b
Copy full SHA for 83e102b
Expand file treeCollapse file tree

38 files changed

+215
-159
lines changed

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"symfony/polyfill-intl-idn": "^1.10",
5454
"symfony/polyfill-intl-normalizer": "~1.0",
5555
"symfony/polyfill-mbstring": "~1.0",
56-
"symfony/polyfill-php83": "^1.27",
56+
"symfony/polyfill-php83": "^1.28",
5757
"symfony/polyfill-uuid": "^1.15"
5858
},
5959
"replace": {

‎psalm.xml

Copy file name to clipboardExpand all lines: psalm.xml
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@
3838
<referencedClass name="ReflectionIntersectionType"/>
3939
<referencedClass name="UnitEnum"/>
4040
</errorLevel>
41-
</UndefinedDocblockClass>
41+
</UndefinedDocblockClass>
42+
<UnusedClass>
43+
<errorLevel type="suppress">
44+
<!--
45+
Because we don't analyze our tests or fixtures, we will
46+
get a lot of false positives regarding unused classes.
47+
-->
48+
<directory name="src/Symfony" />
49+
</errorLevel>
50+
</UnusedClass>
4251
<UnusedConstructor>
4352
<errorLevel type="suppress">
4453
<!--

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_translator_enabled_locales.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_translator_enabled_locales.php
-20Lines changed: 0 additions & 20 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php
-10Lines changed: 0 additions & 10 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_translator_enabled_locales.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_translator_enabled_locales.xml
-18Lines changed: 0 additions & 18 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_legacy_cache.xml
-12Lines changed: 0 additions & 12 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_legacy_cache.yml
-6Lines changed: 0 additions & 6 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/SubCategory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/SubCategory.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
class SubCategory extends Category
88
{
9-
/**
10-
* @Assert\Type("string")
11-
*/
9+
#[Assert\Type("string")]
1210
public $main;
1311
}

‎src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ trait AbstractAdapterTrait
5151
* Fetches several cache items.
5252
*
5353
* @param array $ids The cache identifiers to fetch
54-
*
55-
* @return array|\Traversable
5654
*/
5755
abstract protected function doFetch(array $ids): iterable;
5856

‎src/Symfony/Component/Clock/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.4
5+
---
6+
7+
* Throw `DateMalformedStringException`/`DateInvalidTimeZoneException` when appropriate
8+
49
6.3
510
---
611

‎src/Symfony/Component/Clock/Clock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/Clock.php
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,23 @@ public function sleep(float|int $seconds): void
6262
}
6363
}
6464

65+
/**
66+
* @throws \DateInvalidTimeZoneException When $timezone is invalid
67+
*/
6568
public function withTimeZone(\DateTimeZone|string $timezone): static
6669
{
70+
if (\PHP_VERSION_ID >= 80300 && \is_string($timezone)) {
71+
$timezone = new \DateTimeZone($timezone);
72+
} elseif (\is_string($timezone)) {
73+
try {
74+
$timezone = new \DateTimeZone($timezone);
75+
} catch (\Exception $e) {
76+
throw new \DateInvalidTimeZoneException($e->getMessage(), $e->getCode(), $e);
77+
}
78+
}
79+
6780
$clone = clone $this;
68-
$clone->timezone = \is_string($timezone) ? new \DateTimeZone($timezone) : $timezone;
81+
$clone->timezone = $timezone;
6982

7083
return $clone;
7184
}

‎src/Symfony/Component/Clock/MockClock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/MockClock.php
+40-11Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,30 @@ final class MockClock implements ClockInterface
2222
{
2323
private \DateTimeImmutable $now;
2424

25+
/**
26+
* @throws \DateMalformedStringException When $now is invalid
27+
* @throws \DateInvalidTimeZoneException When $timezone is invalid
28+
*/
2529
public function __construct(\DateTimeImmutable|string $now = 'now', \DateTimeZone|string $timezone = null)
2630
{
27-
if (\is_string($timezone)) {
31+
if (\PHP_VERSION_ID >= 80300 && \is_string($timezone)) {
2832
$timezone = new \DateTimeZone($timezone);
33+
} elseif (\is_string($timezone)) {
34+
try {
35+
$timezone = new \DateTimeZone($timezone);
36+
} catch (\Exception $e) {
37+
throw new \DateInvalidTimeZoneException($e->getMessage(), $e->getCode(), $e);
38+
}
2939
}
3040

31-
if (\is_string($now)) {
41+
if (\PHP_VERSION_ID >= 80300 && \is_string($now)) {
3242
$now = new \DateTimeImmutable($now, $timezone ?? new \DateTimeZone('UTC'));
43+
} elseif (\is_string($now)) {
44+
try {
45+
$now = new \DateTimeImmutable($now, $timezone ?? new \DateTimeZone('UTC'));
46+
} catch (\Exception $e) {
47+
throw new \DateMalformedStringException($e->getMessage(), $e->getCode(), $e);
48+
}
3349
}
3450

3551
$this->now = null !== $timezone ? $now->setTimezone($timezone) : $now;
@@ -49,24 +65,37 @@ public function sleep(float|int $seconds): void
4965
$this->now = (new \DateTimeImmutable($now, $timezone))->setTimezone($timezone);
5066
}
5167

68+
/**
69+
* @throws \DateMalformedStringException When $modifier is invalid
70+
*/
5271
public function modify(string $modifier): void
5372
{
54-
try {
55-
$modifiedNow = @$this->now->modify($modifier);
56-
} catch (\DateMalformedStringException) {
57-
$modifiedNow = false;
58-
}
59-
if (false === $modifiedNow) {
60-
throw new \InvalidArgumentException(sprintf('Invalid modifier: "%s". Could not modify MockClock.', $modifier));
73+
if (\PHP_VERSION_ID < 80300) {
74+
$this->now = @$this->now->modify($modifier) ?: throw new \DateMalformedStringException(error_get_last()['message'] ?? sprintf('Invalid modifier: "%s". Could not modify MockClock.', $modifier));
75+
76+
return;
6177
}
6278

63-
$this->now = $modifiedNow;
79+
$this->now = $this->now->modify($modifier);
6480
}
6581

82+
/**
83+
* @throws \DateInvalidTimeZoneException When the timezone name is invalid
84+
*/
6685
public function withTimeZone(\DateTimeZone|string $timezone): static
6786
{
87+
if (\PHP_VERSION_ID >= 80300 && \is_string($timezone)) {
88+
$timezone = new \DateTimeZone($timezone);
89+
} elseif (\is_string($timezone)) {
90+
try {
91+
$timezone = new \DateTimeZone($timezone);
92+
} catch (\Exception $e) {
93+
throw new \DateInvalidTimeZoneException($e->getMessage(), $e->getCode(), $e);
94+
}
95+
}
96+
6897
$clone = clone $this;
69-
$clone->now = $clone->now->setTimezone(\is_string($timezone) ? new \DateTimeZone($timezone) : $timezone);
98+
$clone->now = $clone->now->setTimezone($timezone);
7099

71100
return $clone;
72101
}

‎src/Symfony/Component/Clock/MonotonicClock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/MonotonicClock.php
+18-6Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ final class MonotonicClock implements ClockInterface
2222
private int $usOffset;
2323
private \DateTimeZone $timezone;
2424

25+
/**
26+
* @throws \DateInvalidTimeZoneException When $timezone is invalid
27+
*/
2528
public function __construct(\DateTimeZone|string $timezone = null)
2629
{
2730
if (false === $offset = hrtime()) {
@@ -32,11 +35,7 @@ public function __construct(\DateTimeZone|string $timezone = null)
3235
$this->sOffset = $time[1] - $offset[0];
3336
$this->usOffset = (int) ($time[0] * 1000000) - (int) ($offset[1] / 1000);
3437

35-
if (\is_string($timezone ??= date_default_timezone_get())) {
36-
$this->timezone = new \DateTimeZone($timezone);
37-
} else {
38-
$this->timezone = $timezone;
39-
}
38+
$this->timezone = \is_string($timezone ??= date_default_timezone_get()) ? $this->withTimeZone($timezone)->timezone : $timezone;
4039
}
4140

4241
public function now(): \DateTimeImmutable
@@ -71,10 +70,23 @@ public function sleep(float|int $seconds): void
7170
}
7271
}
7372

73+
/**
74+
* @throws \DateInvalidTimeZoneException When $timezone is invalid
75+
*/
7476
public function withTimeZone(\DateTimeZone|string $timezone): static
7577
{
78+
if (\PHP_VERSION_ID >= 80300 && \is_string($timezone)) {
79+
$timezone = new \DateTimeZone($timezone);
80+
} elseif (\is_string($timezone)) {
81+
try {
82+
$timezone = new \DateTimeZone($timezone);
83+
} catch (\Exception $e) {
84+
throw new \DateInvalidTimeZoneException($e->getMessage(), $e->getCode(), $e);
85+
}
86+
}
87+
7688
$clone = clone $this;
77-
$clone->timezone = \is_string($timezone) ? new \DateTimeZone($timezone) : $timezone;
89+
$clone->timezone = $timezone;
7890

7991
return $clone;
8092
}

‎src/Symfony/Component/Clock/NativeClock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/NativeClock.php
+18-6Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ final class NativeClock implements ClockInterface
2020
{
2121
private \DateTimeZone $timezone;
2222

23+
/**
24+
* @throws \DateInvalidTimeZoneException When $timezone is invalid
25+
*/
2326
public function __construct(\DateTimeZone|string $timezone = null)
2427
{
25-
if (\is_string($timezone ??= date_default_timezone_get())) {
26-
$this->timezone = new \DateTimeZone($timezone);
27-
} else {
28-
$this->timezone = $timezone;
29-
}
28+
$this->timezone = \is_string($timezone ??= date_default_timezone_get()) ? $this->withTimeZone($timezone)->timezone : $timezone;
3029
}
3130

3231
public function now(): \DateTimeImmutable
@@ -45,10 +44,23 @@ public function sleep(float|int $seconds): void
4544
}
4645
}
4746

47+
/**
48+
* @throws \DateInvalidTimeZoneException When $timezone is invalid
49+
*/
4850
public function withTimeZone(\DateTimeZone|string $timezone): static
4951
{
52+
if (\PHP_VERSION_ID >= 80300 && \is_string($timezone)) {
53+
$timezone = new \DateTimeZone($timezone);
54+
} elseif (\is_string($timezone)) {
55+
try {
56+
$timezone = new \DateTimeZone($timezone);
57+
} catch (\Exception $e) {
58+
throw new \DateInvalidTimeZoneException($e->getMessage(), $e->getCode(), $e);
59+
}
60+
}
61+
5062
$clone = clone $this;
51-
$clone->timezone = \is_string($timezone) ? new \DateTimeZone($timezone) : $timezone;
63+
$clone->timezone = $timezone;
5264

5365
return $clone;
5466
}

‎src/Symfony/Component/Clock/Tests/MockClockTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/Tests/MockClockTest.php
+5-12Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,19 @@ public function testModifyWithSpecificDateTime(string $modifiedNow, string $expe
9292

9393
public static function provideInvalidModifyStrings(): iterable
9494
{
95-
yield 'Named holiday is not recognized' => [
96-
'Halloween',
97-
'Invalid modifier: "Halloween". Could not modify MockClock.',
98-
];
99-
100-
yield 'empty string' => [
101-
'',
102-
'Invalid modifier: "". Could not modify MockClock.',
103-
];
95+
yield 'Named holiday is not recognized' => ['Halloween'];
96+
yield 'empty string' => [''];
10497
}
10598

10699
/**
107100
* @dataProvider provideInvalidModifyStrings
108101
*/
109-
public function testModifyThrowsOnInvalidString(string $modifiedNow, string $expectedMessage)
102+
public function testModifyThrowsOnInvalidString(string $modifiedNow)
110103
{
111104
$clock = new MockClock((new \DateTimeImmutable('2112-09-17 23:53:00.999Z'))->setTimezone(new \DateTimeZone('UTC')));
112105

113-
$this->expectException(\InvalidArgumentException::class);
114-
$this->expectExceptionMessage($expectedMessage);
106+
$this->expectException(\DateMalformedStringException::class);
107+
$this->expectExceptionMessage("Failed to parse time string ($modifiedNow)");
115108

116109
$clock->modify($modifiedNow);
117110
}

‎src/Symfony/Component/Clock/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Clock/composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
},
2121
"require": {
2222
"php": ">=8.2",
23-
"psr/clock": "^1.0"
23+
"psr/clock": "^1.0",
24+
"symfony/polyfill-php83": "^1.28"
2425
},
2526
"autoload": {
2627
"files": [ "Resources/now.php" ],

‎src/Symfony/Component/Console/Output/ConsoleSectionOutput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Output/ConsoleSectionOutput.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ public function addContent(string $input, bool $newline = true): int
115115
// re-add the line break (that has been removed in the above `explode()` for
116116
// - every line that is not the last line
117117
// - if $newline is required, also add it to the last line
118-
// - if it's not new line, but input ending with `\PHP_EOL`
119-
if ($i < $count || $newline || str_ends_with($input, \PHP_EOL)) {
118+
if ($i < $count || $newline) {
120119
$lineContent .= \PHP_EOL;
121120
}
122121

@@ -161,6 +160,12 @@ public function addNewLineOfInputSubmit(): void
161160

162161
protected function doWrite(string $message, bool $newline): void
163162
{
163+
// Simulate newline behavior for consistent output formatting, avoiding extra logic
164+
if (!$newline && str_ends_with($message, \PHP_EOL)) {
165+
$message = substr($message, 0, -\strlen(\PHP_EOL));
166+
$newline = true;
167+
}
168+
164169
if (!$this->isDecorated()) {
165170
parent::doWrite($message, $newline);
166171

0 commit comments

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