8000 Merge branch '7.0' into 7.1 · symfony/symfony@7f3d8c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f3d8c6

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [#53153] fix merge [Workflow] Fix test [WebProfilerBundle] Fix JS error when evaluating scripts don't fail when optional dependencies are not present fix syntax error on PHP 7.2 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 0cd0c49 + 6873ab9 commit 7f3d8c6

File tree

11 files changed

+62
-34
lines changed

11 files changed

+62
-34
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.6 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.6 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
@@ -2779,21 +2779,27 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
27792779

27802780
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)) {
27812781
$container->getDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class])
2782-
->replaceArgument('$registry', new Reference(HubRegistry::class));
2782+
->replaceArgument('$registry', new Reference(HubRegistry::class))
2783+
->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2784+
->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
27832785
} elseif (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', NotifierBridge\Mercure\MercureTransportFactory::class, $parentPackages)) {
27842786
$container->removeDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class]);
27852787
}
27862788

27872789
if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier', NotifierBridge\FakeChat\FakeChatTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
27882790
$container->getDefinition($classToServices[NotifierBridge\FakeChat\FakeChatTransportFactory::class])
27892791
->replaceArgument('$mailer', new Reference('mailer'))
2790-
->replaceArgument('$logger', new Reference('logger'));
2792+
->replaceArgument('$logger', new Reference('logger'))
2793+
->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2794+
->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
27912795
}
27922796

27932797
if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier', NotifierBridge\FakeSms\FakeSmsTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
27942798
$container->getDefinition($classToServices[NotifierBridge\FakeSms\FakeSmsTransportFactory::class])
27952799
->replaceArgument('$mailer', new Reference('mailer'))
2796-
->replaceArgument('$logger', new Reference('logger'));
2800+
->replaceArgument('$logger', new Reference('logger'))
2801+
->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2802+
->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
27972803
}
27982804

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

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,9 @@
550550
/* Evaluate in global scope scripts embedded inside the toolbar */
551551
var i, scripts = [].slice.call(el.querySelectorAll('script'));
552552
for (i = 0; i < scripts.length; ++i) {
553-
eval.call({}, scripts[i].firstChild.nodeValue);
553+
if (scripts[i].firstChild) {
554+
eval.call({}, scripts[i].firstChild.nodeValue);
555+
}
554556
}
555557
556558
el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';

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
@@ -423,6 +423,15 @@ protected function instantiateObject(array &$data, string $class, array &$contex
423423

424424
unset($context['has_constructor']);
425425

426+
if (!$reflectionClass->isInstantiable()) {
427+
throw NotNormalizableValueException::createForUnexpectedDataType(
428+
sprintf('Failed to create object because the class "%s" is not instantiable.', $class),
429+
$data,
430+
['unknown'],
431+
$context['deserialization_path'] ?? null
432+
);
433+
}
434+
426435
return new $class();
427436
}
428437

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

Lines changed: 14 additions & 0 deletions
Original 10000 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
/**
@@ -280,4 +282,16 @@ public function testIgnore()
280282

281283
$this->assertSame([], $normalizer->normalize($dummy));
282284
}
285+
286+
/**
287+
* @requires PHP 8.1
288+
*/
289+
public function testDenormalizeWhenObjectNotInstantiable()
290+
{
291+
$this->expectException(NotNormalizableValueException::class);
292+
293+
$normalizer = new ObjectNormalizer();
294+
295+
$normalizer->denormalize('{}', UnitEnumDummy::class);
296+
}
283297
}

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>

src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,13 @@ public function testValid()
116116

117117
public function testWithTooManyInitialPlaces()
118118
{
119-
$this->expectException(InvalidDefinitionException::class);
120-
$this->expectExceptionMessage('The state machine "foo" cannot store many places. But the definition has 2 initial places. Only one is supported.');
121119
$places = range('a', 'c');
122120
$transitions = [];
123121
$definition = new Definition($places, $transitions, ['a', 'b']);
124122

125-
(new StateMachineValidator())->validate($definition, 'foo');
126-
127-
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
128-
$this->addToAssertionCount(1);
123+
$this->expectException(InvalidDefinitionException::class);
124+
$this->expectExceptionMessage('The state machine "foo" cannot store many places. But the definition has 2 initial places. Only one is supported.');
129125

130-
// The graph looks like:
131-
//
132-
// +----+ +----+ +---+
133-
// | a | --> | t1 | --> | b |
134-
// +----+ +----+ +---+
135-
// |
136-
// |
137-
// v
138-
// +----+ +----+
139-
// | t2 | --> | c |
140-
// +----+ +----+
126+
(new StateMachineValidator())->validate($definition, 'foo');
141127
}
142128
}

0 commit comments

Comments
 (0)
0