Skip to content

Commit c811eff

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: Do not instantiate object if it is not instantiable Add missing translation for Uzbek (uz) [CI] Show exit code when job fails [CI] Use stable version of psalm Add check for lazy object interface [Notifier] [Bridges] Provide EventDispatcher and HttpClient to the transports
2 parents 383dbd5 + ac3141a commit c811eff

File tree

9 files changed

+56
-16
lines changed

9 files changed

+56
-16
lines changed

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
4444
export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev
4545
composer remove --dev --no-update --no-interaction symfony/phpunit-bridge
46-
composer require --no-progress --ansi --no-plugins psalm/phar phpunit/phpunit:^9.5 php-http/discovery psr/event-dispatcher mongodb/mongodb jetbrains/phpstorm-stubs
46+
composer require --no-progress --ansi --no-plugins psalm/phar:@stable phpunit/phpunit:^9.5 php-http/discovery psr/event-dispatcher mongodb/mongodb jetbrains/phpstorm-stubs
4747
4848
- name: Generate Psalm baseline
4949
run: |

.github/workflows/unit-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ jobs:
161161
local ok=0
162162
local title="$1$FLIP"
163163
local start=$(date -u +%s)
164-
OUTPUT=$(bash -xc "$2" 2>&1) || ok=1
164+
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
165165
local end=$(date -u +%s)
166166
167167
if [[ $ok -ne 0 ]]; then
168168
printf "\n%-70s%10s\n" $title $(($end-$start))s
169169
echo "$OUTPUT"
170+
echo "Job exited with: $ok"
170171
echo -e "\n::error::KO $title\\n"
171172
else
172173
printf "::group::%-68s%10s\n" $title $(($end-$start))s

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,21 +2811,27 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
28112811

28122812
if (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', NotifierBridge\Mercure\MercureTransportFactory::class, $parentPackages) && ContainerBuilder::willBeAvailable('symfony/mercure-bundle', MercureBundle::class, $parentPackages) && \in_array(MercureBundle::class, $container->getParameter('kernel.bundles'), true)) {
28132813
$container->getDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class])
2814-
->replaceArgument('$registry', new Reference(HubRegistry::class));
2814+
->replaceArgument('$registry', new Reference(HubRegistry::class))
2815+
->replaceArgument('$client', new Reference('http_client'))
2816+
->replaceArgument('$dispatcher', new Reference('event_dispatcher'));
28152817
} elseif (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', NotifierBridge\Mercure\MercureTransportFactory::class, $parentPackages)) {
28162818
$container->removeDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class]);
28172819
}
28182820

28192821
if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier', NotifierBridge\FakeChat\FakeChatTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
28202822
$container->getDefinition($classToServices[NotifierBridge\FakeChat\FakeChatTransportFactory::class])
28212823
->replaceArgument('$mailer', new Reference('mailer'))
2822-
->replaceArgument('$logger', new Reference('logger'));
2824+
->replaceArgument('$logger', new Reference('logger'))
2825+
->replaceArgument('$client', new Reference('http_client'))
2826+
->replaceArgument('$dispatcher', new Reference('event_dispatcher'));
28232827
}
28242828

28252829
if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier', NotifierBridge\FakeSms\FakeSmsTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
28262830
$container->getDefinition($classToServices[NotifierBridge\FakeSms\FakeSmsTransportFactory::class])
28272831
->replaceArgument('$mailer', new Reference('mailer'))
2828-
->replaceArgument('$logger', new Reference('logger'));
2832+
->replaceArgument('$logger', new Reference('logger'))
2833+
->replaceArgument('$client', new Reference('http_client'))
2834+
->replaceArgument('$dispatcher', new Reference('event_dispatcher'));
28292835
}
28302836

28312837
if (isset($config['admin_recipients'])) {

src/Symfony/Component/Notifier/Bridge/FakeChat/FakeChatTransportFactory.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1818
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1919
use Symfony\Component\Notifier\Transport\Dsn;
20+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Contracts\HttpClient\HttpClientInterface;
2022

2123
/**
2224
* @author Oskar Stark <oskarstark@googlemail.com>
@@ -27,9 +29,9 @@ final class FakeChatTransportFactory extends AbstractTransportFactory
2729
private ?MailerInterface $mailer;
2830
private ?LoggerInterface $logger;
2931

30-
public function __construct(MailerInterface $mailer = null, LoggerInterface $logger = null)
32+
public function __construct(MailerInterface $mailer = null, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
3133
{
32-
parent::__construct();
34+
parent::__construct($dispatcher, $client);
3335

3436
$this->mailer = $mailer;
3537
$this->logger = $logger;
@@ -48,15 +50,15 @@ public function create(Dsn $dsn): FakeChatEmailTransport|FakeChatLoggerTransport
4850
$to = $dsn->getRequiredOption('to');
4951
$from = $dsn->getRequiredOption('from');
5052

51-
return (new FakeChatEmailTransport($this->mailer, $to, $from))->setHost($mailerTransport);
53+
return (new FakeChatEmailTransport($this->mailer, $to, $from, $this->client, $this->dispatcher))->setHost($mailerTransport);
5254
}
5355

5456
if ('fakechat+logger' === $scheme) {
5557
if (null === $this->logger) {
5658
$this->throwMissingDependencyException($scheme, LoggerInterface::class, 'psr/log');
5759
}
5860

59-
return new FakeChatLoggerTransport($this->logger);
61+
return new FakeChatLoggerTransport($this->logger, $this->client, $this->dispatcher);
6062
}
6163

6264
throw new UnsupportedSchemeException($dsn, 'fakechat', $this->getSupportedSchemes());

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1818
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1919
use Symfony\Component\Notifier\Transport\Dsn;
20+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Contracts\HttpClient\HttpClientInterface;
2022

2123
/**
2224
* @author James Hemery <james@yieldstudio.fr>
@@ -28,9 +30,9 @@ final class FakeSmsTransportFactory extends AbstractTransportFactory
2830
private ?MailerInterface $mailer;
2931
private ?LoggerInterface $logger;
3032

31-
public function __construct(MailerInterface $mailer = null, LoggerInterface $logger = null)
33+
public function __construct(MailerInterface $mailer = null, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
3234
{
33-
parent::__construct();
35+
parent::__construct($dispatcher, $client);
3436

3537
$this->mailer = $mailer;
3638
$this->logger = $logger;
@@ -49,15 +51,15 @@ public function create(Dsn $dsn): FakeSmsEmailTransport|FakeSmsLoggerTransport
4951
$to = $dsn->getRequiredOption('to');
5052
$from = $dsn->getRequiredOption('from');
5153

52-
return (new FakeSmsEmailTransport($this->mailer, $to, $from))->setHost($mailerTransport);
54+
return (new FakeSmsEmailTransport($this->mailer, $to, $from, $this->client, $this->dispatcher))->setHost($mailerTransport);
5355
}
5456

5557
if ('fakesms+logger' === $scheme) {
5658
if (null === $this->logger) {
5759
$this->throwMissingDependencyException($scheme, LoggerInterface::class, 'psr/log');
5860
}
5961

60-
return new FakeSmsLoggerTransport($this->logger);
62+
return new FakeSmsLoggerTransport($this->logger, $this->client, $this->dispatcher);
6163
}
6264

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

src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransportFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
1818
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
1919
use Symfony\Component\Notifier\Transport\Dsn;
20+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Contracts\HttpClient\HttpClientInterface;
2022

2123
/**
2224
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
@@ -25,9 +27,9 @@ final class MercureTransportFactory extends AbstractTransportFactory
2527
{
2628
private HubRegistry $registry;
2729

28-
public function __construct(HubRegistry $registry)
30+
public function __construct(HubRegistry $registry, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
2931
{
30-
parent::__construct();
32+
parent::__construct($dispatcher, $client);
3133

3234
$this->registry = $registry;
3335
}
@@ -47,7 +49,7 @@ public function create(Dsn $dsn): MercureTransport
4749
throw new IncompleteDsnException(sprintf('Hub "%s" not found. Did you mean one of: "%s"?', $hubId, implode('", "', array_keys($this->registry->all()))));
4850
}
4951

50-
return new MercureTransport($hub, $hubId, $topic);
52+
return new MercureTransport($hub, $hubId, $topic, $this->client, $this->dispatcher);
5153
}
5254

5355
protected function getSupportedSchemes(): array

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,15 @@ protected function instantiateObject(array &$data, string $class, array &$contex
445445

446446
unset($context['has_constructor']);
447447

448+
if (!$reflectionClass->isInstantiable()) {
449+
throw NotNormalizableValueException::createForUnexpectedDataType(
450+
sprintf('Failed to create object because the class "%s" is not instantiable.', $class),
451+
$data,
452+
['unknown'],
453+
$context['deserialization_path'] ?? null,
454+
);
455+
}
456+
448457
return new $class();
449458
}
450459

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1717
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1818
use Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException;
19+
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
1920
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
2021
use Symfony\Component\Serializer\Mapping\ClassMetadata;
2122
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
@@ -33,6 +34,7 @@
3334
use Symfony\Component\Serializer\Tests\Fixtures\NullableOptionalConstructorArgumentDummy;
3435
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy;
3536
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer;
37+
use Symfony\Component\Serializer\Tests\Fixtures\UnitEnumDummy;
3638
use Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorTypedArgsDummy;
3739

3840
/**
@@ -287,4 +289,16 @@ public function testIgnore()
287289

288290
$this->assertSame([], $normalizer->normalize($dummy));
289291
}
292+
293+
/**
294+
* @requires PHP 8.1
295+
*/
296+
public function testDenormalizeWhenObjectNotInstantiable()
297+
{
298+
$this->expectException(NotNormalizableValueException::class);
299+
300+
$normalizer = new ObjectNormalizer();
301+
302+
$normalizer->denormalize('{}', UnitEnumDummy::class);
303+
}
290304
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@
426426
<source>Using hidden overlay characters is not allowed.</source>
427427
<target>Yashirin qoplamali belgilardan foydalanish taqiqlangan.</target>
428428
</trans-unit>
429+
<trans-unit id="110">
430+
<source>The extension of the file is invalid ({{ extension }}). Allowed extensions are {{ extensions }}.</source>
431+
<target>Fayl kengaytmasi yaroqsiz ({{ extension }}). Ruxsat berilgan kengaytmalar {{ extensions }}.</target>
432+
</trans-unit>
429433
</body>
430434
</file>
431435
</xliff>

0 commit comments

Comments
 (0)