8000 Merge branch '6.4' into 7.0 · symfony/symfony@b4c9fe5 · GitHub
[go: up one dir, main page]

Skip to content

Commit b4c9fe5

Browse files
Merge branch '6.4' into 7.0
* 6.4: [Translation] Improve tests coverage [Routing] Add redirection.io as sponsor of versions 6.4/7.0/7.1 don't check parameter values if they are not set [HttpClient] Add Innovative Web AG (i-web) as sponsor of version 6.4/7.0 [Serializer] Fix normalization relying on allowed attributes only Minor @var doc update [Translation] Remove `@internal` from abstract testcases [VarExporter] Work ar 8000 ound php/php-src#12695 for lazy objects, fixing nullsafe-related behavior [Validator] Add missing translations for Bulgarian #51931 [VarExporter] Fix serializing objects that implement __sleep() and that are made lazy fix typo Document BC break with $secret parameter introduction Bump Symfony version to 6.4.0 Update VERSION for 6.4.0-RC2 Update CHANGELOG for 6.4.0-RC2 [String] Fix Inflector for 'icon' [Validator] Made tests forward-compatible with ICU 72.1
2 parents 5dac6a1 + 4895a19 commit b4c9fe5

34 files changed

+434
-107
lines changed

CHANGELOG-6.4.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ in 6.4 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v6.4.0...v6.4.1
99

10+
* 6.4.0-RC2 (2023-11-26)
11+
12+
* bug #52724 [Security] make secret required for DefaultLoginRateLimiter (RobertMe)
13+
* bug #52617 [AssetMapper] Fix resolving jsdeliver default + other exports from modules (ogizanagi)
14+
* feature #52712 [AssetMapper] Exclude dot files (weaverryan)
15+
* bug #52725 [AssetMapper] Fix: also download files referenced by url() in CSS (weaverryan)
16+
* bug #52702 [AssetMapper] Fix eager imports are not deduplicated (smnandre)
17+
* bug #52719 [Mime] Add `TemplatedEmail::$locale` to the serialized props (mkrauser)
18+
* bug #52677 [Translation] [Lokalise] Fix language format on Lokalise Provider (welcoMattic)
19+
* bug #52715 [Cache] fix detecting the database server version (xabbuh)
20+
* bug #52688 [Cache] Add url decoding of password in `RedisTrait` DSN (alexandre-daubois)
21+
* bug #52172 [Serializer] Fix denormalizing empty string into `object|null` parameter (Jeroeny)
22+
* bug #52693 [Messenger] Fix message handlers with multiple `from_transports` (valtzu)
23+
* bug #52684 [PropertyInfo] Fixed promoted property type detection for `PhpStanExtractor` (LastDragon-ru)
24+
* bug #52681 [Serializer] Fix support for DiscriminatorMap in PropertyNormalizer (mtarld)
25+
* bug #52680 [Serializer] Fix access to private properties/getters when using the ``@Ignore`` annotation (mtarld)
26+
* bug #52713 [Serializer] Fix deserialization_path missing using contructor (mtarld)
27+
* bug #52683 [Serializer] Fix constructor deserialization path (mtarld)
28+
* bug #52707 [HttpKernel] Fix logging deprecations to the "php" channel when channel "deprecation" is not defined (nicolas-grekas)
29+
* bug #52589 [Serializer] Fix XML attributes not added on empty node (mtarld)
30+
* bug #52686 [Cache] fix detecting the server version with Doctrine DBAL 4 (xabbuh)
31+
* bug #52629 [Messenger] Fix support for Redis Sentinel using php-redis 6.0.0 (pepeh)
32+
* bug #52656 [FrameworkBundle] Add TemplateController to the list of allowed controllers for fragments (nicolas-grekas)
33+
* bug #52459 [Cache][HttpFoundation][Lock] Fix PDO store not creating table + add tests (HypeMC)
34+
* bug #52626 [Serializer] Fix denormalizing date intervals having both weeks and days (oneNevan)
35+
* bug #52578 [Serializer] Fix denormalize constructor arguments (mtarld)
36+
* bug #52526 Add some more non-countable English nouns (paullallier)
37+
* bug #52604 [FrameworkBundle] register the virtual request stack together with common profiling services (xabbuh)
38+
* bug #52039 [Scheduler] Continue with stored `Checkpoint::$time` on lock (Jeroeny)
39+
* bug #52631 [DomCrawler] Revert "bug #52579 UriResolver support path with colons" (lyrixx)
40+
* bug #52618 [VarExporter] Fix handling mangled property names returned by __sleep() (nicolas-grekas)
41+
1042
* 6.4.0-RC1 (2023-11-15)
1143

1244
* bug #52588 [Messenger] Use extension_loaded call to check if pcntl extension is loaded, as SIGTERM might be set be swoole (Sergii Dolgushev)

src/Symfony/Component/AssetMapper/ImportMap/ImportMapAuditor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function audit(): array
3535
{
3636
$entries = $this->configReader->getEntries();
3737

38-
/** @var array<string, array<string, ImportMapPackageAudit>> $installed */
38+
/** @var array<string, ImportMapPackageAudit> $packageAudits */
3939
$packageAudits = [];
4040

4141
/** @var array<string, list<string>> $installed */

src/Symfony/Component/HttpClient/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ HttpClient component
33

44
The HttpClient component provides powerful methods to fetch HTTP resources synchronously or asynchronously.
55

6+
Sponsor
7+
-------
8+
9+
The HttpClient component for Symfony 7.0 is [backed][1] by [Innovative Web AG][2].
10+
11+
Innovative Web AG (i-web) is a specialist for web, applications and the
12+
digitalisation of the public sector based in Switzerland. With their i-CMS,
13+
public authorities and institutions implement modern websites and eGovernment
14+
portals and offer user-friendly eServices for residents and companies.
15+
16+
Help Symfony by [sponsoring][3] its development!
17+
618
Resources
719
---------
820

@@ -11,3 +23,7 @@ Resources
1123
* [Report issues](https://github.com/symfony/symfony/issues) and
1224
[send Pull Requests](https://github.com/symfony/symfony/pulls)
1325
in the [main Symfony repository](https://github.com/symfony/symfony)
26+
27+
[1]: https://symfony.com/backers
28+
[2]: https://www.i-web.ch
29+
[3]: https://symfony.com/sponsor

src/Symfony/Component/Routing/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ $url = $generator->generate('blog_show', [
4141
// $url = '/blog/my-blog-post'
4242
```
4343

44+
Sponsor
45+
-------
46+
47+
The Routing component for Symfony 7.0 is [backed][1] by [redirection.io][2].
48+
49+
redirection.io logs all your website’s HTTP traffic, and lets you fix errors
50+
with redirect rules in seconds. Give your marketing, SEO and IT teams the
51+
right tool to manage your website traffic efficiently!
52+
53+
Help Symfony by [sponsoring][3] its development!
54+
4455
Resources
4556
---------
4657

@@ -49,3 +60,7 @@ Resources
4960
* [Report issues](https://github.com/symfony/symfony/issues) and
5061
[send Pull Requests](https://github.com/symfony/symfony/pulls)
5162
in the [main Symfony repository](https://github.com/symfony/symfony)
63+
64+
[1]: https://symfony.com/backers
65+
[2]: https://redirection.io
66+
[3]: https://symfony.com/sponsor

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ protected function getAttributes(object $object, ?string $format, array $context
255255
$allowedAttributes = $this->getAllowedAttributes($object, $context, true);
256256

257257
if (false !== $allowedAttributes) {
258-
$attributes = array_intersect($attributes, $allowedAttributes);
258+
$attributes = $attributes ? array_intersect($attributes, $allowedAttributes) : $allowedAttributes;
259259
}
260260

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

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,39 @@ public function testDenormalizeWithCorrectOrderOfAttributeAndProperty()
840840
public function testNormalizeWithIgnoreAttributeAndPrivateProperties()
841841
{
842842
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
843-
$serializer = new Serializer([new ObjectNormalizer($classMetadataFactory)]);
843+
$normalizer = new ObjectNormalizer($classMetadataFactory);
844844

845-
$this->assertSame(['foo' => 'foo'], $serializer->normalize(new ObjectDummyWithIgnoreAttributeAndPrivateProperty()));
845+
$this->assertSame(['foo' => 'foo'], $normalizer->normalize(new ObjectDummyWithIgnoreAttributeAndPrivateProperty()));
846+
}
847+
848+
public function testNormalizeBasedOnAllowedAttributes()
849+
{
850+
$normalizer = new class() extends AbstractObjectNormalizer {
851+
protected function getAllowedAttributes($classOrObject, array $context, bool $attributesAsString = false)
852+
{
853+
return ['foo'];
854+
}
855+
856+
protected function extractAttributes(object $object, string $format = null, array $context = []): array
857+
{
858+
return [];
859+
}
860+
861+
protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = [])
862+
{
863+
return $object->$attribute;
864+
}
865+
866+
protected function setAttributeValue(object $object, string $attribute, $value, string $format = null, array $context = [])
867+
{
868+
}
869+
};
870+
871+
$object = new Dummy();
872+
$object->foo = 'foo';
873+
$object->bar = 'bar';
874+
875+
$this->assertSame(['foo' => 'foo'], $normalizer->normalize($object));
846876
}
847877

848878
public function testDenormalizeUntypedFormat()

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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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/Translation/Formatter/MessageFormatter.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public function __construct(TranslatorInterface $translator = null, IntlFormatte
3636

3737
public function format(string $message, string $locale, array $parameters = []): string
3838
{
39-
if ($this->translator instanceof TranslatorInterface) {
40-
return $this->translator->trans($message, $parameters, null, $locale);
41-
}
42-
43-
return strtr($message, $parameters);
39+
return $this->translator->trans($message, $parameters, null, $locale);
4440
}
4541

4642
public function formatIntl(string $message, string $locale, array $parameters = []): string

src/Symfony/Component/Translation/Test/ProviderFactoryTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
* A test case to ease testing a translation provider factory.
2929
*
3030
* @author Mathieu Santostefano <msantostefano@protonmail.com>
31-
*
32-
* @internal
3331
*/
3432
abstract class ProviderFactoryTestCase extends TestCase
3533
{

src/Symfony/Component/Translation/Test/ProviderTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
* A test case to ease testing a translation provider.
2626
*
2727
* @author Mathieu Santostefano <msantostefano@protonmail.com>
28-
*
29-
* @internal
3028
*/
3129
abstract class ProviderTestCase extends TestCase
3230
{

src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Translation\Tests\Catalogue;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Translation\Exception\LogicException;
1516
use Symfony\Component\Translation\MessageCatalogue;
1617
use Symfony\Component\Translation\MessageCatalogueInterface;
1718

@@ -70,5 +71,15 @@ public function testGetEmptyResult()
7071
);
7172
}
7273

74+
public function testSourceAndTargetWithDifferentLocales()
75+
{
76+
$this->expectException(LogicException::class);
77+
$this->expectExceptionMessage('Operated catalogues must belong to the same locale.');
78+
$this->createOperation(
79+
new MessageCatalogue('en'),
80+
new MessageCatalogue('fr')
81+
);
82+
}
83+
7384
abstract protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target);
7485
}

src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Translation\Tests\DataCollector;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\Response;
1517
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
1618
use Symfony\Component\Translation\DataCollectorTranslator;
1719

@@ -130,6 +132,24 @@ public function testCollect()
130132
$this->assertEquals($expectedMessages, array_values($dataCollector->getMessages()->getValue(true)));
131133
}
132134

135+
public function testCollectAndReset()
136+
{
137+
$translator = $this->getTranslator();
138+
$translator->method('getLocale')->willReturn('fr');
139+
$translator->method('getFallbackLocales')->willReturn(['en']);
140+
141+
$dataCollector = new TranslationDataCollector($translator);
142+
$dataCollector->collect($this->createMock(Request::class), $this->createMock(Response::class));
143+
144+
$this->assertSame('fr', $dataCollector->getLocale());
145+
$this->assertSame(['en'], $dataCollector->getFallbackLocales());
146+
147+
$dataCollector->reset();
148+
149+
$this->assertNull($dataCollector->getLocale());
150+
$this->assertEmpty($dataCollector->getFallbackLocales());
151+
}
152+
133153
private function getTranslator()
134154
{
135155
$translator = $this

src/Symfony/Component/Translation/Tests/Exception/ProviderExceptionTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public function testExceptionWithDebugMessage()
2323
$mock->method('getInfo')->willReturn('debug');
2424

2525
$exception = new ProviderException('Exception message', $mock, 503);
26-
27-
self::assertInstanceOf(ProviderException::class, $exception);
26+
$this->assertSame('debug', $exception->getDebug());
2827
}
2928

3029
public function testExceptionWithNullAsDebugMessage()
@@ -33,7 +32,6 @@ public function testExceptionWithNullAsDebugMessage()
3332
$mock->method('getInfo')->willReturn(null);
3433

3534
$exception = new ProviderException('Exception message', $mock, 503);
36-
37-
self::assertInstanceOf(ProviderException::class, $exception);
35+
$this->assertSame('', $exception->getDebug());
3836
}
3937
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Translation\Tests\Provider;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Translation\Provider\ProviderInterface;
16+
use Symfony\Component\Translation\Provider\TranslationProviderCollection;
17+
18+
class TranslationProviderCollectionTest extends TestCase
19+
{
20+
public function testKeys()
21+
{
22+
$this->assertSame(['foo', 'baz'], $this->createProviderCollection()->keys());
23+
}
24+
25+
public function testKeysWithGenerator()
26+
{
27+
$this->assertSame(['foo', 'baz'], (new TranslationProviderCollection(
28+
(function () {
29+
yield 'foo' => $this->createMock(ProviderInterface::class);
30+
31+
yield 'baz' => $this->createMock(ProviderInterface::class);
32+
})()
33+
))->keys());
34+
}
35+
36+
public function testToString()
37+
{
38+
$this->assertSame('[foo,baz]', (string) $this->createProviderCollection());
39+
}
40+
41+
public function testHas()
42+
{
43+
$this->assertTrue($this->createProviderCollection()->has('foo'));
44+
}
45+
46+
public function testGet()
47+
{
48+
$provider = $this->createMock(ProviderInterface::class);
49+
50+
$this->assertSame($provider, (new TranslationProviderCollection([
51+
'foo' => $provider,
52+
'baz' => $this->createMock(ProviderInterface::class),
53+
]))->get('foo'));
54+
}
55+
56+
public function testGetThrowsException()
57+
{
58+
$this->expectException(\InvalidArgumentException::class);
59+
$this->expectExceptionMessage('Provider "invalid" not found. Available: "[foo,baz]".');
60+
61+
$this->createProviderCollection()->get('invalid');
62+
}
63+
64+
private function createProviderCollection(): TranslationProviderCollection
65+
{
66+
return new TranslationProviderCollection([
67+
'foo' => $this->createMock(ProviderInterface::class),
68+
'baz' => $this->createMock(ProviderInterface::class),
69+
]);
70+
}
71+
}

src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Translation\Dumper\DumperInterface;
16+
use Symfony\Component\Translation\Exception\InvalidArgumentException;
17+
use Symfony\Component\Translation\Exception\RuntimeException;
1618
use Symfony\Component\Translation\MessageCatalogue;
1719
use Symfony\Component\Translation\Writer\TranslationWriter;
1820

@@ -29,4 +31,33 @@ public function testWrite()
2931
$writer->addDumper('test', $dumper);
3032
$writer->write(new MessageCatalogue('en'), 'test');
3133
}
34+
35+
public function testGetFormats()
36+
{
37+
$writer = new TranslationWriter();
38+
$writer->addDumper('foo', $this->createMock(DumperInterface::class));
39+
$writer->addDumper('bar', $this->createMock(DumperInterface::class));
40+
41+
$this->assertEquals(['foo', 'bar'], $writer->getFormats());
42+
}
43+
44+
public function testFormatIsNotSupported()
45+
{
46+
$this->expectException(InvalidArgumentException::class);
47+
$this->expectExceptionMessage('There is no dumper associated with format "foo".');
48+
$writer = new TranslationWriter();
49+
50+
$writer->write(new MessageCatalogue('en'), 'foo');
51+
}
52+
53+
public function testUnwritableDirectory()
54+
{
55+
$writer = new TranslationWriter();
56+
$writer->addDumper('foo', $this->createMock(DumperInterface::class));
57+
58+
$this->expectException(RuntimeException::class);
59+
$this->expectExceptionMessage('Translation Writer was not able to create directory "/foo/bar/baz".');
60+
61+
$writer->write(new MessageCatalogue('en'), 'foo', ['path' => '/foo/bar/baz']);
62+
}
3263
}

0 commit comments

Comments
 (0)
0