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

Skip to content

Commit b11e8a2

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: Mitigate PHPUnit deprecations [TwigBundle] Add support for resetting globals between HTTP requests [Validator] Add Catalan and Spanish translation for `Week` constraint Don't use is_resource() on non-streams [Ldap] Fix extension deprecation
2 parents 76df329 + 7518cc7 commit b11e8a2

File tree

14 files changed

+44
-34
lines changed

14 files changed

+44
-34
lines changed

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineCloseConnectionMiddlewareTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testInvalidEntityManagerThrowsException()
6363
$managerRegistry
6464
->method('getManager')
6565
->with('unknown_manager')
66-
->will($this->throwException(new \InvalidArgumentException()));
66+
->willThrowException(new \InvalidArgumentException());
6767

6868
$middleware = new DoctrineCloseConnectionMiddleware($managerRegistry, 'unknown_manager');
6969

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrinePingConnectionMiddlewareTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testInvalidEntityManagerThrowsException()
101101
$managerRegistry
102102
->method('getManager')
103103
->with('unknown_manager')
104-
->will($this->throwException(new \InvalidArgumentException()));
104+
->willThrowException(new \InvalidArgumentException());
105105

106106
$middleware = new DoctrinePingConnectionMiddleware($managerRegistry, 'unknown_manager');
107107

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testInvalidEntityManagerThrowsException()
7575
$managerRegistry
7676
->method('getManager')
7777
->with('unknown_manager')
78-
->will($this->throwException(new \InvalidArgumentException()));
78+
->willThrowException(new \InvalidArgumentException());
7979

8080
$middleware = new DoctrineTransactionMiddleware($managerRegistry, 'unknown_manager');
8181

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\Translation\LocaleSwitcher;
2626
use Symfony\Component\Translation\Translator;
2727
use Symfony\Contracts\Service\ResetInterface;
28+
use Twig\Environment;
2829
use Twig\Extension\ExtensionInterface;
2930
use Twig\Extension\RuntimeExtensionInterface;
3031
use Twig\Loader\LoaderInterface;
@@ -45,6 +46,10 @@ public function load(array $configs, ContainerBuilder $container)
4546
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
4647
$loader->load('twig.php');
4748

49+
if (method_exists(Environment::class, 'resetGlobals')) {
50+
$container->getDefinition('twig')->addTag('kernel.reset', ['method' => 'resetGlobals']);
51+
}
52+
4853
if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'])) {
4954
$loader->load('form.php');
5055

src/Symfony/Component/Console/Terminal.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ private static function readFromProcess(string|array $command): ?string
217217

218218
$cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;
219219

220-
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
221-
if (!\is_resource($process)) {
220+
if (!$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true])) {
222221
return null;
223222
}
224223

src/Symfony/Component/HttpKernel/Log/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(?string $minLevel = null, $output = null, ?callable
7979

8080
$this->minLevelIndex = self::LEVELS[$minLevel];
8181
$this->formatter = null !== $formatter ? $formatter(...) : $this->format(...);
82-
if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
82+
if ($output && false === $this->handle = \is_string($output) ? @fopen($output, 'a') : $output) {
8383
throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output));
8484
}
8585
$this->debug = $debug;

src/Symfony/Component/Ldap/Tests/LdapTestCase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ class LdapTestCase extends TestCase
1717
{
1818
protected function getLdapConfig()
1919
{
20-
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
20+
if (\PHP_VERSION_ID < 80300) {
21+
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
22+
} else {
23+
$h = @ldap_connect('ldap://'.getenv('LDAP_HOST').':'.getenv('LDAP_PORT'));
24+
}
25+
2126
@ldap_set_option($h, \LDAP_OPT_PROTOCOL_VERSION, 3);
2227

2328
if (!$h || !@ldap_bind($h)) {

src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function testSendFirstWork()
5757
public function testSendAllDead()
5858
{
5959
$t1 = $this->createMock(TransportInterface::class);
60-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
60+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
6161
$t2 = $this->createMock(TransportInterface::class);
62-
$t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
62+
$t2->expects($this->once())->method('send')->willThrowException(new TransportException());
6363
$t = new FailoverTransport([$t1, $t2]);
6464
$this->expectException(TransportException::class);
6565
$this->expectExceptionMessage('All transports failed.');
@@ -70,7 +70,7 @@ public function testSendAllDead()
7070
public function testSendOneDead()
7171
{
7272
$t1 = $this->createMock(TransportInterface::class);
73-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
73+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
7474
$t2 = $this->createMock(TransportInterface::class);
7575
$t2->expects($this->exactly(3))->method('send');
7676
$t = new FailoverTransport([$t1, $t2]);

src/Symfony/Component/Mailer/Tests/Transport/RoundRobinTransportTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function testSendAlternate()
5757
public function testSendAllDead()
5858
{
5959
$t1 = $this->createMock(TransportInterface::class);
60-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
60+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
6161
$t2 = $this->createMock(TransportInterface::class);
62-
$t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
62+
$t2->expects($this->once())->method('send')->willThrowException(new TransportException());
6363
$t = new RoundRobinTransport([$t1, $t2]);
6464
$p = new \ReflectionProperty($t, 'cursor');
6565
$p->setValue($t, 0);
@@ -80,7 +80,7 @@ public function testSendAllDead()
8080
public function testSendOneDead()
8181
{
8282
$t1 = $this->createMock(TransportInterface::class);
83-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
83+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
8484
$t2 = $this->createMock(TransportInterface::class);
8585
$t2->expects($this->exactly(3))->method('send');
8686
$t = new RoundRobinTransport([$t1, $t2]);
@@ -99,7 +99,7 @@ public function testSendOneDeadAndRecoveryNotWithinRetryPeriod()
9999
$t1 = $this->createMock(TransportInterface::class);
100100
$t1->expects($this->exactly(4))->method('send');
101101
$t2 = $this->createMock(TransportInterface::class);
102-
$t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
102+
$t2->expects($this->once())->method('send')->willThrowException(new TransportException());
103103
$t = new RoundRobinTransport([$t1, $t2], 60);
104104
$p = new \ReflectionProperty($t, 'cursor');
105105
$p->setValue($t, 0);
@@ -148,13 +148,13 @@ public function testFailureDebugInformation()
148148
$t1 = $this->createMock(TransportInterface::class);
149149
$e1 = new TransportException();
150150
$e1->appendDebug('Debug message 1');
151-
$t1->expects($this->once())->method('send')->will($this->throwException($e1));
151+
$t1->expects($this->once())->method('send')->willThrowException($e1);
152152
$t1->expects($this->once())->method('__toString')->willReturn('t1');
153153

154154
$t2 = $this->createMock(TransportInterface::class);
155155
$e2 = new TransportException();
156156
$e2->appendDebug('Debug message 2');
157-
$t2->expects($this->once())->method('send')->will($this->throwException($e2));
157+
$t2->expects($this->once())->method('send')->willThrowException($e2);
158158
$t2->expects($this->once())->method('__toString')->willReturn('t2');
159159

160160
$t = new RoundRobinTransport([$t1, $t2]);

src/Symfony/Component/Messenger/Tests/Middleware/DispatchAfterCurrentBusMiddlewareTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testEventsInNewTransactionAreHandledAfterMainMessage()
6868
->with($this->callback(function (Envelope $envelope) use (&$series) {
6969
return $envelope->getMessage() === array_shift($series);
7070
}))
71-
->will($this->willHandleMessage());
71+
->willReturnCallback($this->handleMessageCallback());
7272

7373
$messageBus->dispatch($message);
7474
}
@@ -278,7 +278,7 @@ public function testDispatchOutOfAnotherHandlerDispatchesAndRemoveStamp()
278278
$handlingMiddleware
279279
->method('handle')
280280
->with($this->expectHandledMessage($event))
281-
->will($this->willHandleMessage());
281+
->willReturnCallback($this->handleMessageCallback());
282282

283283
$eventBus = new MessageBus([
284284
$middleware,
@@ -295,9 +295,9 @@ private function expectHandledMessage($message): Callback
295295
return $this->callback(fn (Envelope $envelope) => $envelope->getMessage() === $message);
296296
}
297297

298-
private function willHandleMessage(): ReturnCallback
298+
private function handleMessageCallback(): \Closure
299299
{
300-
return $this->returnCallback(fn ($envelope, StackInterface $stack) => $stack->next()->handle($envelope, $stack));
300+
return fn ($envelope, StackInterface $stack) => $stack->next()->handle($envelope, $stack);
301301
}
302302
}
303303

0 commit comments

Comments
 (0)
0