8000 Merge branch '5.4' into 6.0 · symfony/symfony@d0ec840 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0ec840

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Validator] Update MIR card scheme [Notifier][FakeSms] Do not use switch [Mailer][Sendgrid] Add previous exception Remove internal from ConstraintViolationAssertion Improve phpdoc
2 parents 670f102 + 34e1972 commit d0ec840

File tree

7 files changed

+27
-22
lines changed

7 files changed

+27
-22
lines changed

src/Symfony/Component/Intl/Countries.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public static function getAlpha3Name(string $alpha3Code, string $displayLocale =
107107
/**
108108
* Gets the list of country names indexed with alpha2 codes as keys.
109109
*
110-
* @return string[]
110+
* @return array<string, string>
111111
*/
112-
public static function getNames(?string $displayLocale = null): array
112+
public static function getNames(string $displayLocale = null): array
113113
{
114114
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
115115
}
@@ -119,9 +119,9 @@ public static function getNames(?string $displayLocale = null): array
119119
*
120120
* Same as method getNames, but with alpha3 codes instead of alpha2 codes as keys.
121121
*
122-
* @return string[]
122+
* @return array<string, string>
123123
*/
124-
public static function getAlpha3Names(?string $displayLocale = null): array
124+
public static function getAlpha3Names(string $displayLocale = null): array
125125
{
126126
$alpha2Names = self::getNames($displayLocale);
127127
$alpha3Names = [];

src/Symfony/Component/Intl/Languages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function getName(string $language, string $displayLocale = null):
7676
/**
7777
* Gets the list of language names indexed with alpha2 codes as keys.
7878
*
79-
* @return string[]
79+
* @return array<string, string>
8080
*/
8181
public static function getNames(string $displayLocale = null): array
8282
{
@@ -157,7 +157,7 @@ public static function getAlpha3Name(string $language, string $displayLocale = n
157157
*
158158
* Same as method getNames, but with ISO 639-2 three-letter codes instead of ISO 639-1 codes as keys.
159159
*
160-
* @return string[]
160+
* @return array<string, string>
161161
*/
162162
public static function getAlpha3Names(string $displayLocale = null): array
163163
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
6464

6565
throw new HttpTransportException('Unable to send an email: '.implode('; ', array_column($result['errors'], 'message')).sprintf(' (code %d).', $statusCode), $response);
6666
} catch (DecodingExceptionInterface $e) {
67-
throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode), $response);
67+
throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode), $response, 0, $e);
6868
}
6969
}
7070

src/Symfony/Component/Notifier/Bridge/FakeSms/FakeSmsTransportFactory.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ public function create(Dsn $dsn): TransportInterface
4343
{
4444
$scheme = $dsn->getScheme();
4545

46-
switch ($scheme) {
47-
case 'fakesms+email':
48-
$mailerTransport = $dsn->getHost();
49-
$to = $dsn->getRequiredOption('to');
50-
$from = $dsn->getRequiredOption('from');
46+
if ('fakesms+email' === $scheme) {
47+
$mailerTransport = $dsn->getHost();
48+
$to = $dsn->getRequiredOption('to');
49+
$from = $dsn->getRequiredOption('from');
5150

52-
return (new FakeSmsEmailTransport($this->mailer, $to, $from))->setHost($mailerTransport);
53-
case 'fakesms+logger':
54-
return new FakeSmsLoggerTransport($this->logger);
< A92E code>51+
return (new FakeSmsEmailTransport($this->mailer, $to, $from))->setHost($mailerTransport);
52+
}
53+
54+
if ('fakesms+logger' === $scheme) {
55+
return new FakeSmsLoggerTransport($this->logger);
5556
}
5657

5758
throw new UnsupportedSchemeException($dsn, 'fakesms', $this->getSupportedSchemes());

src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class CardSchemeValidator extends ConstraintValidator
7777
'/^5[1-5][0-9]{14}$/',
7878
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
7979
],
80-
// Payment system MIR numbers start with 220, then 1 digit from 0 to 4, then 12 digits
80+
// Payment system MIR numbers start with 220, then 1 digit from 0 to 4, then between 12 and 15 digits
8181
CardScheme::MIR => [
82-
'/^220[0-4][0-9]{12}$/',
82+
'/^220[0-4][0-9]{12,15}$/',
8383
],
8484
// All UATP card numbers start with a 1 and have a length of 15 digits.
8585
CardScheme::UATP => [
< F438 /code>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,7 @@ protected function buildViolation(string|\Stringable $message)
295295
abstract protected function createValidator();
296296
}
297297

298-
/**
299-
* @internal
300-
*/
301-
class ConstraintViolationAssertion
298+
final class ConstraintViolationAssertion
302299
{
303300
private ExecutionContextInterface $context;
304301

@@ -316,6 +313,9 @@ class ConstraintViolationAssertion
316313
private ?Constraint $constraint;
317314
private mixed $cause = null;
318315

316+
/**
317+
* @internal
318+
*/
319319
public function __construct(ExecutionContextInterface $context, string $message, Constraint $constraint = null, array $assertions = [])
320320
{
321321
$this->context = $context;

src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ public function getValidNumbers()
127127
['MASTERCARD', '2709999999999999'],
128128
['MASTERCARD', '2720995105105100'],
129129
['MIR', '2200381427330082'],
130+
['MIR', '22003814273300821'],
131+
['MIR', '220038142733008212'],
132+
['MIR', '2200381427330082123'],
130133
['UATP', '110165309696173'],
131134
['VISA', '4111111111111111'],
132135
['VISA', '4012888888881881'],
@@ -159,7 +162,8 @@ public function getInvalidNumbers()
159162
['MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR], // Not assigned yet
160163
['MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR], // Not assigned yet
161164
['UATP', '11016530969617', CardScheme::INVALID_FORMAT_ERROR], // invalid length
162-
['MIR', '22003814273300821', CardScheme::INVALID_FORMAT_ERROR], // invalid length
165+
['MIR', '220038142733008', CardScheme::INVALID_FORMAT_ERROR], // invalid length
166+
['MIR', '22003814273300821234', CardScheme::INVALID_FORMAT_ERROR], // invalid length
163167
];
164168
}
165169
}

0 commit comments

Comments
 (0)
0