Skip to content

Commit dff2ff8

Browse files
Merge branch '7.2' into 7.3
* 7.2: [Validator] Review Latvian translations Fixed lazy-loading ghost objects generation with property hooks with default values. remove no longer used service definition [Config] Fix generated comment for multiline "info" Fix: exclude remember_me from security login authenticators
2 parents 170b631 + 4b35f2e commit dff2ff8

File tree

10 files changed

+92
-23
lines changed

10 files changed

+92
-23
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
tagged_iterator('mailer.transport_factory'),
5151
])
5252

53-
->set('mailer.default_transport', TransportInterface::class)
5453
->alias('mailer.default_transport', 'mailer.transports')
5554
->alias(TransportInterface::class, 'mailer.default_transport')
5655

src/Symfony/Bundle/SecurityBundle/Security.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ private function getAuthenticator(?string $authenticatorName, string $firewallNa
171171
$firewallAuthenticatorLocator = $this->authenticators[$firewallName];
172172

173173
if (!$authenticatorName) {
174-
$authenticatorIds = array_keys($firewallAuthenticatorLocator->getProvidedServices());
175-
174+
$authenticatorIds = array_filter(array_keys($firewallAuthenticatorLocator->getProvidedServices()), fn (string $authenticatorId) => $authenticatorId !== \sprintf('security.authenticator.remember_me.%s', $firewallName));
176175
if (!$authenticatorIds) {
177176
throw new LogicException(\sprintf('No authenticator was found for the firewall "%s".', $firewallName));
178177
}

src/Symfony/Bundle/SecurityBundle/Tests/SecurityTest.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ public function testLogin()
152152
$firewallAuthenticatorLocator
153153
->expects($this->once())
154154
->method('getProvidedServices')
155-
->willReturn(['security.authenticator.custom.dev' => $authenticator])
155+
->willReturn([
156+
'security.authenticator.custom.dev' => $authenticator,
157+
'security.authenticator.remember_me.main' => $authenticator
158+
])
156159
;
157160
$firewallAuthenticatorLocator
158161
->expects($this->once())
@@ -252,6 +255,49 @@ public function testLoginWithoutRequestContext()
252255
$security->login($user);
253256
}
254257

258+
public function testLoginFailsWhenTooManyAuthenticatorsFound()
259+
{
260+
$request = new Request();
261+
$authenticator = $this->createMock(AuthenticatorInterface::class);
262+
$requestStack = $this->createMock(RequestStack::class);
263+
$firewallMap = $this->createMock(FirewallMap::class);
264+
$firewall = new FirewallConfig('main', 'main');
265+
$userAuthenticator = $this->createMock(UserAuthenticatorInterface::class);
266+
$user = $this->createMock(UserInterface::class);
267+
$userChecker = $this->createMock(UserCheckerInterface::class);
268+
269+
$container = $this->createMock(ContainerInterface::class);
270+
$container
271+
->expects($this->atLeastOnce())
272+
->method('get')
273+
->willReturnMap([
274+
['request_stack', $requestStack],
275+
['security.firewall.map', $firewallMap],
276+
['security.authenticator.managers_locator', $this->createContainer('main', $userAuthenticator)],
277+
['security.user_checker_locator', $this->createContainer('main', $userChecker)],
278+
])
279+
;
280+
281+
$requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($request);
282+
$firewallMap->expects($this->once())->method('getFirewallConfig')->willReturn($firewall);
283+
284+
$firewallAuthenticatorLocator = $this->createMock(ServiceProviderInterface::class);
285+
$firewallAuthenticatorLocator
286+
->expects($this->once())
287+
->method('getProvidedServices')
288+
->willReturn([
289+
'security.authenticator.custom.main' => $authenticator,
290+
'security.authenticator.other.main' => $authenticator
291+
])
292+
;
293+
294+
$security = new Security($container, ['main' => $firewallAuthenticatorLocator]);
295+
296+
$this->expectException(\LogicException::class);
297+
$this->expectExceptionMessage('Too many authenticators were found for the current firewall "main". You must provide an instance of "Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface" to login programmatically. The available authenticators for the firewall "main" are "security.authenticator.custom.main" ,"security.authenticator.other.main');
298+
$security->login($user);
299+
}
300+
255301
public function testLogout()
256302
{
257303
$request = new Request();

src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,39 +412,39 @@ private function getComment(BaseNode $node): string
412412
{
413413
$comment = '';
414414
if ('' !== $info = (string) $node->getInfo()) {
415-
$comment .= ' * '.$info."\n";
415+
$comment .= $info."\n";
416416
}
417417

418418
if (!$node instanceof ArrayNode) {
419419
foreach ((array) ($node->getExample() ?? []) as $example) {
420-
$comment .= ' * @example '.$example."\n";
420+
$comment .= '@example '.$example."\n";
421421
}
422422

423423
if ('' !== $default = $node->getDefaultValue()) {
424-
$comment .= ' * @default '.(null === $default ? 'null' : var_export($default, true))."\n";
424+
$comment .= '@default '.(null === $default ? 'null' : var_export($default, true))."\n";
425425
}
426426

427427
if ($node instanceof EnumNode) {
428-
$comment .= \sprintf(' * @param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n";
428+
$comment .= \sprintf('@param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n";
429429
} else {
430430
$parameterTypes = $this->getParameterTypes($node);
431-
$comment .= ' * @param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
431+
$comment .= '@param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
432432
}
433433
} else {
434434
foreach ((array) ($node->getExample() ?? []) as $example) {
435-
$comment .= ' * @example '.json_encode($example)."\n";
435+
$comment .= '@example '.json_encode($example)."\n";
436436
}
437437

438438
if ($node->hasDefaultValue() && [] != $default = $node->getDefaultValue()) {
439-
$comment .= ' * @default '.json_encode($default)."\n";
439+
$comment .= '@default '.json_encode($default)."\n";
440440
}
441441
}
442442

443443
if ($node->isDeprecated()) {
444-
$comment .= ' * @deprecated '.$node->getDeprecation($node->getName(), $node->getParent()->getName())['message']."\n";
444+
$comment .= '@deprecated '.$node->getDeprecation($node->getName(), $node->getParent()->getName())['message']."\n";
445445
}
446446

447-
return $comment;
447+
return $comment ? ' * '.str_replace("\n", "\n * ", rtrim($comment, "\n"))."\n" : '';
448448
}
449449

450450
/**

src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ public function getConfigTreeBuilder(): TreeBuilder
3838
->arrayPrototype()
3939
->fixXmlConfig('option')
4040
->children()
41-
->scalarNode('dsn')->end()
41+
->scalarNode('dsn')
42+
->info(<<<'INFO'
43+
The DSN to use. This is a required option.
44+
The info is used to describe the DSN,
45+
it can be multi-line.
46+
INFO)
47+
->end()
4248
->scalarNode('serializer')->defaultNull()->end()
4349
->arrayNode('options')
4450
->normalizeKeys(false)

src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues/Symfony/Config/NodeInitialValues/Messenger/TransportsConfig.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class TransportsConfig
1616
private $_usedProperties = [];
1717

1818
/**
19+
* The DSN to use. This is a required option.
20+
* The info is used to describe the DSN,
21+
* it can be multi-line.
1922
* @default null
2023
* @param ParamConfigurator|mixed $value
2124
* @return $this

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,11 @@
468468
</trans-unit>
469469
<trans-unit id="120">
470470
<source>This value is not a valid slug.</source>
471-
<target state="needs-review-translation">Šī vērtība nav derīgs slug.</target>
471+
<target>Šī vērtība nav derīgs URL slug.</target>
472472
</trans-unit>
473473
<trans-unit id="121">
474474
<source>This value is not a valid Twig template.</source>
475-
<target state="needs-translation">This value is not a valid Twig template.</target>
475+
<target>Šī vērtība nav derīgs Twig šablons.</target>
476476
</trans-unit>
477477
</body>
478478
</file>

src/Symfony/Component/VarExporter/ProxyHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function generateLazyGhost(\ReflectionClass $class): string
8686
.($p->isProtected() ? 'protected' : 'public')
8787
.($p->isProtectedSet() ? ' protected(set)' : '')
8888
." {$type} \${$name}"
89-
.($p->hasDefaultValue() ? ' = '.$p->getDefaultValue() : '')
89+
.($p->hasDefaultValue() ? ' = '.VarExporter::export($p->getDefaultValue()) : '')
9090
." {\n";
9191

9292
foreach ($p->getHooks() as $hook => $method) {

src/Symfony/Component/VarExporter/Tests/Fixtures/LazyProxy/HookedWithDefaultValue.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@
44

55
class HookedWithDefaultValue
66
{
7-
public int $backedWithDefault = 321 {
8-
get => $this->backedWithDefault;
9-
set => $this->backedWithDefault = $value;
7+
public int $backedIntWithDefault = 321 {
8+
get => $this->backedIntWithDefault;
9+
set => $this->backedIntWithDefault = $value;
10+
}
11+
12+
public string $backedStringWithDefault = '321' {
13+
get => $this->backedStringWithDefault;
14+
set => $this->backedStringWithDefault = $value;
15+
}
16+
17+
public bool $backedBoolWithDefault = false {
18+
get => $this->backedBoolWithDefault;
19+
set => $this->backedBoolWithDefault = $value;
1020
}
1121
}

src/Symfony/Component/VarExporter/Tests/LegacyLazyGhostTraitTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,22 @@ public function testPropertyHooksWithDefaultValue()
332332
$initialized = true;
333333
});
334334

335-
$this->assertSame(321, $object->backedWithDefault);
335+
$this->assertSame(321, $object->backedIntWithDefault);
336+
$this->assertSame('321', $object->backedStringWithDefault);
337+
$this->assertSame(false, $object->backedBoolWithDefault);
336338
$this->assertTrue($initialized);
337339

338340
$initialized = false;
339341
$object = $this->createLazyGhost(HookedWithDefaultValue::class, function ($instance) use (&$initialized) {
340342
$initialized = true;
341343
});
342-
$object->backedWithDefault = 654;
344+
$object->backedIntWithDefault = 654;
345+
$object->backedStringWithDefault = '654';
346+
$object->backedBoolWithDefault = true;
343347
$this->assertTrue($initialized);
344-
$this->assertSame(654, $object->backedWithDefault);
348+
$this->assertSame(654, $object->backedIntWithDefault);
349+
$this->assertSame('654', $object->backedStringWithDefault);
350+
$this->assertSame(true, $object->backedBoolWithDefault);
345351
}
346352

347353
/**

0 commit comments

Comments
 (0)