Skip to content

Commit 9e86767

Browse files
Merge branch '7.3' into 7.4
* 7.3: [Validator] Update Romanian translations fix tests [JsonStreamer] Fix decoding iterable lists [String][Inflector] Fix edge cases [Security] Fix attribute-based chained user providers [Intl] Fix Intl::getIcuStubVersion()
2 parents 67016b9 + d5e749d commit 9e86767

File tree

8 files changed

+98
-49
lines changed

8 files changed

+98
-49
lines changed

src/Symfony/Component/JsonStreamer/Read/PhpGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ private function generateProviders(DataModelNodeInterface $node, bool $decodeFro
136136

137137
++$context['indentation_level'];
138138

139+
$collectionKeyType = $node->getType()->getCollectionKeyType();
140+
139141
$arguments = $decodeFromStream ? '$stream, $data' : '$data';
140-
$php .= ($decodeFromStream ? $this->line('$data = \\'.Splitter::class.'::'.($node->getType()->isList() ? 'splitList' : 'splitDict').'($stream, $offset, $length);', $context) : '')
142+
$php .= ($decodeFromStream ? $this->line('$data = \\'.Splitter::class.'::'.($collectionKeyType instanceof BuiltinType && TypeIdentifier::INT === $collectionKeyType->getTypeIdentifier() ? 'splitList' : 'splitDict').'($stream, $offset, $length);', $context) : '')
141143
.$this->line("\$iterable = static function ($arguments) use (\$options, \$valueTransformers, \$instantiator, &\$providers) {", $context)
142144
.$this->line(' foreach ($data as $k => $v) {', $context);
143145

src/Symfony/Component/JsonStreamer/Tests/JsonStreamReaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testReadCollection()
8787
$this->assertRead($reader, function (mixed $read) {
8888
$this->assertIsIterable($read);
8989
$this->assertSame([true, false], iterator_to_array($read));
90-
}, '{"0": true, "1": false}', Type::iterable(Type::bool(), Type::int()));
90+
}, '[true, false]', Type::iterable(Type::bool(), Type::int()));
9191
}
9292

9393
public function testReadObject()

src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
1616
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
17+
use Symfony\Component\Security\Core\User\AttributesBasedUserProviderInterface;
1718
use Symfony\Component\Security\Core\User\ChainUserProvider;
1819
use Symfony\Component\Security\Core\User\InMemoryUser;
1920
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
2021
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
2122
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
2223
use Symfony\Component\Security\Core\User\UserInterface;
24+
use Symfony\Component\Security\Core\User\UserProviderInterface;
2325

2426
class ChainUserProviderTest extends TestCase
2527
{
@@ -45,6 +47,28 @@ public function testLoadUserByIdentifier()
4547
$this->assertSame($account, $provider->loadUserByIdentifier('foo'));
4648
}
4749

50+
public function testLoadUserByIdentifierWithAttributes()
51+
{
52+
$provider1 = $this->createMock(UserProviderInterface::class);
53+
$provider1
54+
->expects($this->once())
55+
->method('loadUserByIdentifier')
56+
->with($this->equalTo('foo'))
57+
->willThrowException(new UserNotFoundException('not found'))
58+
;
59+
60+
$provider2 = $this->createMock(AttributesBasedUserProviderInterface::class);
61+
$provider2
62+
->expects($this->once())
63+
->method('loadUserByIdentifier')
64+
->with($this->equalTo('foo'), $this->equalTo(['attr' => 5]))
65+
->willReturn($account = $this->createMock(UserInterface::class))
66+
;
67+
68+
$provider = new ChainUserProvider([$provider1, $provider2]);
69+
$this->assertSame($account, $provider->loadUserByIdentifier('foo', ['attr' => 5]));
70+
}
71+
4872
public function testLoadUserByIdentifierThrowsUserNotFoundException()
4973
{
5074
$provider1 = $this->createMock(InMemoryUserProvider::class);

src/Symfony/Component/Security/Core/User/ChainUserProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@ public function getProviders(): array
4646
return $this->providers;
4747
}
4848

49-
public function loadUserByIdentifier(string $identifier): UserInterface
49+
/**
50+
* @param array $attributes
51+
*/
52+
public function loadUserByIdentifier(string $identifier/* , array $attributes = [] */): UserInterface
5053
{
54+
$attributes = \func_num_args() > 1 ? func_get_arg(1) : [];
5155
foreach ($this->providers as $provider) {
5256
try {
57+
if ($provider instanceof AttributesBasedUserProviderInterface) {
58+
return $provider->loadUserByIdentifier($identifier, $attributes);
59+
}
60+
5361
return $provider->loadUserByIdentifier($identifier);
5462
} catch (UserNotFoundException) {
5563
// try next one

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static function normalizeUsingTimeZonePassedInContextAndExpectedFormatWit
136136
'2018-12-01T18:03:06.067634',
137137
new \DateTimeZone('UTC')
138138
),
139-
new \DateTimeZone('Europe/Kyiv'),
139+
new \DateTimeZone(\in_array('Europe/Kyiv', \DateTimeZone::listIdentifiers(), true) ? 'Europe/Kyiv' : 'Europe/Kiev'),
140140
];
141141

142142
yield [

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ final class EnglishInflector implements InflectorInterface
2525
// Fourth entry: Whether the suffix may succeed a consonant
2626
// Fifth entry: singular suffix, normal
2727

28+
// insignias (insigne), insignia (insigne)
29+
['saingisni', 9, true, true, 'insigne'],
30+
['aingisni', 8, true, true, 'insigne'],
31+
32+
// passersby (passerby)
33+
['ybsressap', 9, true, true, 'passerby'],
34+
2835
// nodes (node)
2936
['sedon', 5, true, true, 'node'],
3037

@@ -205,6 +212,12 @@ final class EnglishInflector implements InflectorInterface
205212
// Fourth entry: Whether the suffix may succeed a consonant
206213
// Fifth entry: plural suffix, normal
207214

215+
// passerby (passersby)
216+
['ybressap', 8, true, true, 'passersby'],
217+
218+
// insigne (insignia, insignias)
219+
['engisni', 7, true, true, ['insignia', 'insignias']],
220+
208221
// nodes (node)
209222
['edon', 4, true, true, 'nodes'],
210223

src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,15 @@ public static function singularizeProvider()
172172
['waltzes', ['waltz', 'waltze']],
173173
['wives', 'wife'],
174174
['zombies', 'zombie'],
175+
['passersby', 'passerby'],
176+
['rattles', 'rattle'],
177+
['insignia', 'insigne'],
178+
['insignias', 'insigne'],
175179

176180
// test casing: if the first letter was uppercase, it should remain so
177181
['Men', 'Man'],
178182
['GrandChildren', 'GrandChild'],
179183
['SubTrees', 'SubTree'],
180-
181-
// Known issues
182-
// ['insignia', 'insigne'],
183-
// ['insignias', 'insigne'],
184-
// ['rattles', 'rattle'],
185184
];
186185
}
187186

@@ -263,6 +262,7 @@ public static function pluralizeProvider()
263262
['house', 'houses'],
264263
['icon', 'icons'],
265264
['index', ['indicies', 'indexes']],
265+
['insigne', ['insignia', 'insignias']],
266266
['ion', 'ions'],
267267
['iris', 'irises'],
268268
['issue', 'issues'],
@@ -288,6 +288,7 @@ public static function pluralizeProvider()
288288
['objective', 'objectives'],
289289
['ox', 'oxen'],
290290
['party', 'parties'],
291+
['passerby', 'passersby'],
291292
['person', ['persons', 'people']],
292293
['phenomenon', 'phenomena'],
293294
['photo', 'photos'],
@@ -299,6 +300,7 @@ public static function pluralizeProvider()
299300
['quiz', 'quizzes'],
300301
['quorum', ['quora', 'quorums']],
301302
['radius', 'radii'],
303+
['rattle', 'rattles'],
302304
['roof', ['roofs', 'rooves']],
303305
['rose', 'roses'],
304306
['sandwich', 'sandwiches'],

0 commit comments

Comments
 (0)