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

Skip to content

Commit a2fc1bb

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: fix compatibility with Twig 3.10 [Strings][EnglishInflector] Fix incorrect pluralisation of 'Album' handle union and intersection types for cascaded validations move wiring of the property info extractor to the ObjectNormalizer restore deprecated properties move Process component dep to require-dev Remove calls to `onConsecutiveCalls()` fix: remove unwanted type cast accept AbstractAsset instances when filtering schemas better distinguish URL schemes and windows drive letters handle edge cases when constructing constraints with named arguments convert empty CSV header names into numeric keys
2 parents e02306b + 440675f commit a2fc1bb

File tree

52 files changed

+547
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+547
-222
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testMiddlewareWrapsInTransactionAndFlushes()
5353
{
5454
$this->connection->expects($this->exactly(1))
5555
->method('isTransactionActive')
56-
->will($this->onConsecutiveCalls(true, true, false))
56+
->willReturn(true, true, false)
5757
;
5858

5959
$this->middleware->handle(new Envelope(new \stdClass()), $this->getStackMock());

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ public function testVerbosityChanged()
111111
$output
112112
->expects($this->exactly(2))
113113
->method('getVerbosity')
114-
->willReturnOnConsecutiveCalls(
115-
OutputInterface::VERBOSITY_QUIET,
116-
OutputInterface::VERBOSITY_DEBUG
117-
)
114+
->willReturn(OutputInterface::VERBOSITY_QUIET, OutputInterface::VERBOSITY_DEBUG)
118115
;
119116
$handler = new ConsoleHandler($output);
120117
$this->assertFalse($handler->isHandling(RecordFactory::create(Level::Notice)),

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,18 +1900,19 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
19001900
$container->setParameter('serializer.default_context', $defaultContext);
19011901
}
19021902

1903+
$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
1904+
$context = [];
1905+
19031906
if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
1904-
$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
1905-
$context = ($arguments[6] ?? $defaultContext) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
1907+
$context += ($arguments[6] ?? $defaultContext) + ['circular_reference_handler' => new Reference($config['circular_reference_handler'])];
19061908
$container->getDefinition('serializer.normalizer.object')->setArgument(5, null);
1907-
$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
19081909
}
19091910

19101911
if ($config['max_depth_handler'] ?? false) {
1911-
$arguments = $container->getDefinition('serializer.normalizer.object')->getArguments();
1912-
$context = ($arguments[6] ?? $defaultContext) + ['max_depth_handler' => new Reference($config['max_depth_handler'])];
1913-
$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
1912+
$context += ($arguments[6] ?? $defaultContext) + ['max_depth_handler' => new Reference($config['max_depth_handler'])];
19141913
}
1914+
1915+
$container->getDefinition('serializer.normalizer.object')->setArgument(6, $context);
19151916
}
19161917

19171918
private function registerPropertyInfoConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void

src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
service('property_info')->ignoreOnInvalid(),
129129
service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(),
130130
null,
131+
null,
132+
service('property_info')->ignoreOnInvalid(),
131133
])
132134
->tag('serializer.normalizer', ['priority' => -1000])
133135

@@ -139,7 +141,6 @@
139141
service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(),
140142
null,
141143
[],
142-
service('property_info')->ignoreOnInvalid(),
143144
])
144145

145146
->set('serializer.denormalizer.array', ArrayDenormalizer::class)

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ protected function getLoader()
260260
$loader
261261
->expects($this->exactly(7))
262262
->method('load')
263-
->willReturnOnConsecutiveCalls(
263+
->willReturn(
264264
$this->getCatalogue('fr', [
265265
'foo' => 'foo (FR)',
266266
]),

src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension;
1616
use Symfony\Component\VarDumper\Cloner\VarCloner;
1717
use Twig\Environment;
18+
use Twig\Loader\ArrayLoader;
1819

1920
class WebProfilerExtensionTest extends TestCase
2021
{
@@ -23,7 +24,7 @@ class WebProfilerExtensionTest extends TestCase
2324
*/
2425
public function testDumpHeaderIsDisplayed(string $message, array $context, bool $dump1HasHeader, bool $dump2HasHeader)
2526
{
26-
$twigEnvironment = $this->mockTwigEnvironment();
27+
10000 $twigEnvironment = new Environment(new ArrayLoader());
2728
$varCloner = new VarCloner();
2829

2930
$webProfilerExtension = new WebProfilerExtension();
@@ -44,13 +45,4 @@ public static function provideMessages(): iterable
4445
yield ['Some message {foo}', ['foo' => 'foo', 'bar' => 'bar'], true, false];
4546
yield ['Some message {foo}', ['bar' => 'bar'], false, true];
4647
}
47-
48-
private function mockTwigEnvironment()
49-
{
50-
$twigEnvironment = $this->createMock(Environment::class);
51-
52-
$twigEnvironment->expects($this->any())->method('getCharset')->willReturn('UTF-8');
53-
54-
return $twigEnvironment;
55-
}
5648
}

src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Twig\Extension\EscaperExtension;
1818
use Twig\Extension\ProfilerExtension;
1919
use Twig\Profiler\Profile;
20+
use Twig\Runtime\EscaperRuntime;
2021
use Twig\TwigFunction;
2122

2223
/**
@@ -108,6 +109,12 @@ public function getName(): string
108109

109110
private static function escape(Environment $env, string $s): string
110111
{
112+
// Twig 3.10 and above
113+
if (class_exists(EscaperRuntime::class)) {
114+
return $env->getRuntime(EscaperRuntime::class)->escape($s);
115+
}
116+
117+
// Twig 3.9
111118
if (method_exists(EscaperExtension::class, 'escape')) {
112119
return EscaperExtension::escape($env, $s);
113120
}

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ protected function doClear(string $namespace): bool
523523
}
524524
$this->doDelete($keys);
525525
}
526-
} while ($cursor = (int) $cursor);
526+
} while ($cursor);
527527
}
528528

529529
return $cleared;

src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ public function testImportWithFileLocatorDelegation()
2525
$locatorMock = $this->createMock(FileLocatorInterface::class);
2626

2727
$locatorMockForAdditionalLoader = $this->createMock(FileLocatorInterface::class);
28-
$locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
29-
['path/to/file1'], // Default
30-
['path/to/file1', 'path/to/file2'], // First is imported
31-
['path/to/file1', 'path/to/file2'], // Second is imported
32-
['path/to/file1'], // Exception
33-
['path/to/file1', 'path/to/file2'] // Exception
34-
));
28+
$locatorMockForAdditionalLoader->expects($this->any())
29+
->method('locate')
30+
->willReturn(
31+
['path/to/file1'],
32+
['path/to/file1', 'path/to/file2'],
33+
['path/to/file1', 'path/to/file2'],
34+
['path/to/file1'],
35+
['path/to/file1', 'path/to/file2']
36+
);
3537

3638
$fileLoader = new TestFileLoader($locatorMock);
3739
$fileLoader->setSupports(false);

src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public function testLoadFile()
7676
}
7777

7878
$mock = $this->createMock(Validator::class);
79-
$mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true));
79+
$mock->expects($this->exactly(2))->method('validate')
80+
->willReturn(false, true);
8081

8182
try {
8283
XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate']);

src/Symfony/Component/Dotenv/Command/DebugCommand.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@
3030
#[AsCommand(name: 'debug:dotenv', description: 'List all dotenv files with variables and values')]
3131
final class DebugCommand extends Command
3232
{
33-
public function __construct(
34-
private string $kernelEnvironment,
35-
private string $projectDirectory,
36-
) {
33+
/**
34+
* @deprecated since Symfony 6.1
35+
*/
36+
protected static $defaultName = 'debug:dotenv';
37+
38+
/**
39+
* @deprecated since Symfony 6.1
40+
*/
41+
protected static $defaultDescription = 'List all dotenv files with variables and values';
42+
43+
private string $kernelEnvironment;
44+
private string $projectDirectory;
45+
46+
public function __construct(string $kernelEnvironment, string $projectDirectory)
47+
{
48+
$this->kernelEnvironment = $kernelEnvironment;
49+
$this->projectDirectory = $projectDirectory;
50+
3751
parent::__construct();
3852
}
3953

src/Symfony/Component/Filesystem/Path.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line number< 741A /th>Diff line change
@@ -365,7 +365,7 @@ public static function isAbsolute(string $path): bool
365365
}
366366

367367
// Strip scheme
368-
if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
368+
if (false !== ($schemeSeparatorPosition = strpos($path, '://')) && 1 !== $schemeSeparatorPosition) {
369369
$path = substr($path, $schemeSeparatorPosition + 3);
370370
}
371371

src/Symfony/Component/Filesystem/Tests/PathTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ public static function provideIsAbsolutePathTests(): \Generator
375375

376376
yield ['C:/css/style.css', true];
377377
yield ['D:/', true];
378+
yield ['C:///windows', true];
379+
yield ['C://test', true];
378380

379381
yield ['E:\\css\\style.css', true];
380382
yield ['F:\\', true];

src/Symfony/Component/Filesystem/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/polyfill-ctype": "~1.8",
21-
"symfony/polyfill-mbstring": "~1.8",
21+
"symfony/polyfill-mbstring": "~1.8"
22+
},
23+
"require-dev": {
2224
"symfony/process": "^6.4|^7.0"
2325
},
2426
"autoload": {

src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SessionListenerTest extends TestCase
4444
public function testSessionCookieOptions(array $phpSessionOptions, array $sessionOptions, array $expectedSessionOptions)
4545
{
4646
$session = $this->createMock(Session::class);
47-
$session->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1));
47+
$session->method('getUsageIndex')->willReturn(0, 1);
4848
$session->method('getId')->willReturn('123456');
4949
$session->method('getName')->willReturn('PHPSESSID');
5050
$session->method('save');
@@ -491,7 +491,7 @@ public function testResponseIsStillPublicIfSessionStartedAndHeaderPresent()
491491
public function testSessionSaveAndResponseHasSessionCookie()
492492
{
493493
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
494-
$session->expects($this->exactly(1))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1));
494+
$session->expects($this->exactly(1))->method('getUsageIndex')->willReturn(0);
495495
$session->expects($this->exactly(1))->method('getId')->willReturn('123456');
496496
$session->expects($this->exactly(1))->method('getName')->willReturn('PHPSESSID');
497497
$session->expects($this->exactly(1))->method('save');
@@ -644,7 +644,7 @@ public function testSurrogateMainRequestIsPublic()
644644
{
645645
$session = $this->createMock(Session::class);
646646
$session->expects($this->exactly(1))->method('getName')->willReturn('PHPSESSID');
647-
$session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1));
647+
$session->expects($this->exactly(2))->method('getUsageIndex')->willReturn(0, 1);
648648
$sessionFactory = $this->createMock(SessionFactory::class);
649649
$sessionFactory->expects($this->once())->method('createSession')->willReturn($session);
650650

src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,17 @@ public function testRenderExceptionIgnoreErrors()
102102

103103
public function testRenderExceptionIgnoreErrorsWithAlt()
104104
{
105-
$strategy = new InlineFragmentRenderer($this->getKernel($this->onConsecutiveCalls(
106-
$this->throwException(new \RuntimeException('foo')),
107-
$this->returnValue(new Response('bar'))
108-
)));
105+
$strategy = new InlineFragmentRenderer($this->getKernel($this->returnCallback(function () {
106+
static $firstCall = true;
107+
108+
if ($firstCall) {
109+
$firstCall = false;
110+
111+
throw new \RuntimeException('foo');
112+
}
113+
114+
return new Response('bar');
115+
})));
109116

110117
$this->assertEquals('bar', $strategy->render('/', Request::create('/'), ['ignore_errors' => true, 'alt' => '/foo'])->getContent());
111118
}

src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ protected function getCache($request, $response)
245245
if (\is_array($response)) {
246246
$cache->expects($this->any())
247247
->method('handle')
248-
->will($this->onConsecutiveCalls(...$response))
248+
->willReturn(...$response)
249249
;
250250
} else {
251251
$cache->expects($this->any())

src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected function getCache($request, $response)
201201
if (\is_array($response)) {
202202
$cache->expects($this->any())
203203
->method('handle')
204-
->will($this->onConsecutiveCalls(...$response))
204+
->willReturn(...$response)
205205
;
206206
} else {
207207
$cache->expects($this->any())

0 commit comments

Comments
 (0)
0