8000 Merge branch '5.1' · jeremyFreeAgent/symfony@fbcdbf9 · GitHub
[go: up one dir, main page]

Skip to content

Commit fbcdbf9

Browse files
committed
Merge branch '5.1'
* 5.1: fix: clarify parameter name to comply with deprecations from symfony#34074 [Sendgrid-Mailer] Fixed envelope recipients on sendgridApiTransport mark the AssertingContextualValidator class as internal Fix the parameter names in the SecurityFactoryInterface::create() method [Serializer][ClassDiscriminatorMapping] Fix getMappedObjectType() when a discriminator child extends another one make return type correct
2 parents a2d360b + 44caccb commit fbcdbf9

File tree

12 files changed

+79
-12
lines changed

12 files changed

+79
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,30 +207,30 @@ protected function addFlash(string $type, $message): void
207207
}
208208

209209
/**
210-
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
210+
* Checks if the attribute is granted against the current authentication token and optionally supplied subject.
211211
*
212212
* @throws \LogicException
213213
*/
214-
protected function isGranted($attributes, $subject = null): bool
214+
protected function isGranted($attribute, $subject = null): bool
215215
{
216216
if (!$this->container->has('security.authorization_checker')) {
217217
throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".');
218218
}
219219

220-
return $this->container->get('security.authorization_checker')->isGranted($attributes, $subject);
220+
return $this->container->get('security.authorization_checker')->isGranted($attribute, $subject);
221221
}
222222

223223
/**
224-
* Throws an exception unless the attributes are granted against the current authentication token and optionally
224+
* Throws an exception unless the attribute is granted against the current authentication token and optionally
225225
* supplied subject.
226226
*
227227
* @throws AccessDeniedException
228228
*/
229-
protected function denyAccessUnlessGranted($attributes, $subject = null, string $message = 'Access Denied.'): void
229+
protected function denyAccessUnlessGranted($attribute, $subject = null, string $message = 'Access Denied.'): void
230230
{
231-
if (!$this->isGranted($attributes, $subject)) {
231+
if (!$this->isGranted($attribute, $subject)) {
232232
$exception = $this->createAccessDeniedException($message);
233-
$exception->setAttributes($attributes);
233+
$exception->setAttributes($attribute);
234234
$exception->setSubject($subject);
235235

236236
throw $exception;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SecurityFactoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface SecurityFactoryInterface
2929
* - the listener id
3030
* - the entry point id
3131
*/
32-
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint);
32+
public function create(ContainerBuilder $container, string $id, array $config, string $userProviderId, ?string $defaultEntryPointId);
3333

3434
/**
3535
* Defines the position at which the provider is called.

src/Symfony/Component/Form/FormView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function offsetUnset($name)
148148
/**
149149
* Returns an iterator to iterate over children (implements \IteratorAggregate).
150150
*
151-
* @return \ArrayIterator|FormView[] The iterator
151+
* @return \ArrayIterator<string, FormView> The iterator
152152
*/
153153
public function getIterator()
154154
{

src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridApiTransportTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,34 @@ public function testReplyTo()
192192
$this->assertArrayHasKey('email', $payload['reply_to']);
193193
$this->assertSame($replyTo, $payload['reply_to']['email']);
194194
}
195+
196+
public function testEnvelopeSenderAndRecipients()
197+
{
198+
$from = 'from@example.com';
199+
$to = 'to@example.com';
200+
$envelopeFrom = 'envelopefrom@example.com';
201+
$envelopeTo = 'envelopeto@example.com';
202+
$email = new Email();
203+
$email->from($from)
204+
->to($to)
205+
->cc('cc@example.com')
206+
->bcc('bcc@example.com')
207+
->text('content');
208+
$envelope = new Envelope(new Address($envelopeFrom), [new Address($envelopeTo)]);
209+
210+
$transport = new SendgridApiTransport('ACCESS_KEY');
211+
$method = new \ReflectionMethod(SendgridApiTransport::class, 'getPayload');
212+
$method->setAccessible(true);
213+
$payload = $method->invoke($transport, $email, $envelope);
214+
215+
$this->assertArrayHasKey('from', $payload);
216+
$this->assertArrayHasKey('email', $payload['from']);
217+
$this->assertSame($envelopeFrom, $payload['from']['email']);
218+
219+
$this->assertArrayHasKey('personalizations', $payload);
220+
$this->assertArrayHasKey('to', $payload['personalizations'][0]);
221+
$this->assertArrayHasKey('email', $payload['personalizations'][0]['to'][0]);
222+
$this->assertCount(1, $payload['personalizations'][0]['to']);
223+
$this->assertSame($envelopeTo, $payload['personalizations'][0]['to'][0]['email']);
224+
}
195225
}

src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function getPayload(Email $email, Envelope $envelope): array
8484
}
8585

8686
$personalization = [
87-
'to' => array_map($addressStringifier, $email->getTo()),
87+
'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)),
8888
'subject' => $email->getSubject(),
8989
];
9090
if ($emails = array_map($addressStringifier, $email->getCc())) {

src/Symfony/Component/Security/Core/Authorization/AuthorizationCheckerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
interface AuthorizationCheckerInterface
2020
{
2121
/**
22-
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
22+
* Checks if the attribute is granted against the current authentication token and optionally supplied subject.
2323
*
2424
* @param mixed $attribute A single attribute to vote on (can be of any type, string and instance of Expression are supported by the core)
2525
* @param mixed $subject

src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorMapping.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ public function __construct(string $typeProperty, array $typesMapping = [])
2323
{
2424
$this->typeProperty = $typeProperty;
2525
$this->typesMapping = $typesMapping;
26+
27+
uasort($this->typesMapping, static function (string $a, string $b): int {
28+
if (is_a($a, $b, true)) {
29+
return -1;
30+
}
31+
32+
if (is_a($b, $a, true)) {
33+
return 1;
34+
}
35+
36+
return 0;
37+
});
2638
}
2739

2840
public function getTypeProperty(): string

src/Symfony/Component/Serializer/Tests/Fixtures/AbstractDummy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
/**
1717
* @DiscriminatorMap(typeProperty="type", mapping={
1818
* "first"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild",
19-
* "second"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild"
19+
* "second"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild",
20+
F987 * "third"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild",
2021
* })
2122
*/
2223
abstract class AbstractDummy
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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\Serializer\Tests\Fixtures;
13+
14+
final class AbstractDummyThirdChild extends AbstractDummyFirstChild
15+
{
16+
}

src/Symfony/Component/Serializer/Tests/Mapping/ClassDiscriminatorMappingTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
1616
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild;
1717
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild;
18+
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild;
1819

1920
/**
2021
* @author Samuel Roze <samuel.roze@gmail.com>
@@ -35,9 +36,11 @@ public function testMappedObjectType()
3536
{
3637
$mapping = new ClassDiscriminatorMapping('type', [
3738
'first' => AbstractDummyFirstChild::class,
39+
'third' => AbstractDummyThirdChild::class,
3840
]);
3941

4042
$this->assertEquals('first', $mapping->getMappedObjectType(new AbstractDummyFirstChild()));
4143
$this->assertNull($mapping->getMappedObjectType(new AbstractDummySecondChild()));
44+
$this->assertSame('third', $mapping->getMappedObjectType(new AbstractDummyThirdChild()));
4245
}
4346
}

src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild;
2222
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild;
2323
use Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy;
24+
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild;
2425
use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
2526

2627
/**
@@ -66,6 +67,7 @@ public function testLoadDiscriminatorMap()
6667
$expected = new ClassMetadata(AbstractDummy::class, new ClassDiscriminatorMapping('type', [
6768
'first' => AbstractDummyFirstChild::class,
6869
'second' => AbstractDummySecondChild::class,
70+
'third' => AbstractDummyThirdChild::class,
6971
]));
7072

7173
$expected->addAttributeMetadata(new AttributeMetadata('foo'));

src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ private function getViolation(): ConstraintViolation
385385
}
386386
}
387387

388+
/**
389+
* @internal
390+
*/
388391
class AssertingContextualValidator implements ContextualValidatorInterface
389392
{
390393
private $context;

0 commit comments

Comments
 (0)
0