Skip to content

Commit b912af9

Browse files
committed
Merge branch '5.1'
* 5.1: Fix typo Fix deprecated libxml_disable_entity_loader Add Tagalog translations for validator messages 94, 95, 96 and 99 PHPUnit's assertContains() performs strict comparisons now. [ClassLoader][Routing] Fix namespace parsing on php 8. Fix deprecated libxml_disable_entity_loader Made reference to PHPUnit\Util\XML::loadfile php5-compatible. [Validator] Add missing translations for german and vietnamese Modernized deprecated PHPUnit assertion calls [Console] The message of "class not found" errors has changed in php 8. The PHPUnit\Util\XML class has been removed in PHPUnit 9.3. [Console] Make sure we pass a numeric array of arguments to call_user_func_array(). Remove outdated references from base_js.html.twig file [String] We cannot have a "provides" function in test cases. Typo: somes styles fixed [Serializer] Fix that it will never reach DOMNode [Validator] sync translations [VarDumper] Improve previous fix on light array coloration [Cache] Fix #37667
2 parents f4668b5 + c44c606 commit b912af9

File tree

49 files changed

+278
-154
lines changed

Some content is hidden

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

49 files changed

+278
-154
lines changed

UPGRADE-5.0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ FrameworkBundle
237237
* The `Templating\Helper\TranslatorHelper::transChoice()` method has been removed, use the `trans()` one instead with a `%count%` parameter.
238238
* Removed support for legacy translations directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`, use `translations/` instead.
239239
* Support for the legacy directory structure in `translation:update` and `debug:translation` commands has been removed.
240-
* Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
240+
* Removed the `Psr\SimpleCache\CacheInterface` / `cache.app.simple` service, use `Symfony\Contracts\Cache\CacheInterface` / `cache.app` instead.
241241
* Removed support for `templating` engine in `TemplateController`, use Twig instead
242242
* Removed `ResolveControllerNameSubscriber`.
243243
* Removed `routing.loader.service`.
@@ -260,7 +260,7 @@ HttpFoundation
260260
* The `$size` argument of the `UploadedFile` constructor has been removed.
261261
* The `getClientSize()` method of the `UploadedFile` class has been removed.
262262
* The `getSession()` method of the `Request` class throws an exception when session is null.
263-
* The default value of the "$secure" and "$samesite" arguments of Cookie's constructor
263+
* The default value of the `$secure` and `$samesite` arguments of Cookie's constructor
264264
changed respectively from "false" to "null" and from "null" to "lax".
265265
* The `MimeTypeGuesserInterface` and `ExtensionGuesserInterface` interfaces have been removed,
266266
use `Symfony\Component\Mime\MimeTypesInterface` instead.
@@ -561,7 +561,7 @@ TwigBridge
561561
----------
562562

563563
* Removed argument `$rootDir` from the `DebugCommand::__construct()` method and the 5th argument must be an instance of `FileLinkFormatter`
564-
* removed the `$requestStack` and `$requestContext` arguments of the
564+
* Removed the `$requestStack` and `$requestContext` arguments of the
565565
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
566566
instance as the only argument instead
567567
* Removed support for implicit STDIN usage in the `lint:twig` command, use `lint:twig -` (append a dash) instead to make it explicit.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"psr/http-client": "^1.0",
128128
"psr/simple-cache": "^1.0",
129129
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",
130-
"symfony/phpunit-bridge": "^5.0.8",
130+
"symfony/phpunit-bridge": "^5.2",
131131
"symfony/security-acl": "~2.8|~3.0",
132132
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
133133
"twig/cssinliner-extra": "^2.12",

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testLintIncorrectFile()
4343
$ret = $tester->execute(['filename' => [$filename]], ['decorated' => false]);
4444

4545
$this->assertEquals(1, $ret, 'Returns 1 in case of error');
46-
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
46+
$this->assertMatchesRegularExpression('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
4747
}
4848

4949
public function testLintFileNotReadable()
@@ -64,7 +64,7 @@ public function testLintFileCompileTimeException()
6464
$ret = $tester->execute(['filename' => [$filename]], ['decorated' => false]);
6565

6666
$this->assertEquals(1, $ret, 'Returns 1 in case of error');
67-
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
67+
$this->assertMatchesRegularExpression('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
6868
}
6969

7070
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
8181

8282
$containerRef = new \ReflectionClass(require $containerFile);
8383
$containerFile = str_replace('tes_'.\DIRECTORY_SEPARATOR, 'test'.\DIRECTORY_SEPARATOR, $containerRef->getFileName());
84-
$this->assertRegExp(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container');
84+
$this->assertMatchesRegularExpression(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container');
8585
}
8686
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testDebugMissingMessages()
2828
$tester = $this->createCommandTester(['foo' => 'foo']);
2929
$res = $tester->execute(['locale' => 'en', 'bundle' => 'foo']);
3030

31-
$this->assertRegExp('/missing/', $tester->getDisplay());
31+
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
3232
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_MISSING, $res);
3333
}
3434

@@ -37,7 +37,7 @@ public function testDebugUnusedMessages()
3737
$tester = $this->createCommandTester([], ['foo' => 'foo']);
3838
$res = $tester->execute(['locale' => 'en', 'bundle' => 'foo']);
3939

40-
$this->assertRegExp('/unused/', $tester->getDisplay());
40+
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
4141
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_UNUSED, $res);
4242
}
4343

@@ -46,7 +46,7 @@ public function testDebugFallbackMessages()
4646
$tester = $this->createCommandTester(['foo' => 'foo'], ['foo' => 'foo']);
4747
$res = $tester->execute(['locale' => 'fr', 'bundle' => 'foo']);
4848

49-
$this->assertRegExp('/fallback/', $tester->getDisplay());
49+
$this->assertMatchesRegularExpression('/fallback/', $tester->getDisplay());
5050
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_FALLBACK, $res);
5151
}
5252

@@ -55,7 +55,7 @@ public function testNoDefinedMessages()
5555
$tester = $this->createCommandTester();
5656
$res = $tester->execute(['locale' => 'fr', 'bundle' => 'test']);
5757

58-
$this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay());
58+
$this->assertMatchesRegularExpression('/No defined or extracted messages for locale "fr"/', $tester->getDisplay());
5959
$this->assertEquals(TranslationDebugCommand::EXIT_CODE_GENERAL_ERROR, $res);
6060
}
6161

@@ -65,8 +65,8 @@ public function testDebugDefaultDirectory()
6565
$res = $tester->execute(['locale' => 'en']);
6666
$expectedExitStatus = TranslationDebugCommand::EXIT_CODE_MISSING | TranslationDebugCommand::EXIT_CODE_UNUSED;
6767

68-
$this->assertRegExp('/missing/', $tester->getDisplay());
69-
$this->assertRegExp('/unused/', $tester->getDisplay());
68+
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
69+
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
7070
$this->assertEquals($expectedExitStatus, $res);
7171
}
7272

@@ -83,8 +83,8 @@ public function testDebugDefaultRootDirectory()
8383
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar'], null, [$this->translationDir.'/trans'], [$this->translationDir.'/views']);
8484
$res = $tester->execute(['locale' => 'en']);
8585

86-
$this->assertRegExp('/missing/', $tester->getDisplay());
87-
$this->assertRegExp('/unused/', $tester->getDisplay());
86+
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
87+
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
8888
$this->assertEquals($expectedExitStatus, $res);
8989
}
9090

@@ -103,8 +103,8 @@ public function testDebugCustomDirectory()
103103
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar'], $kernel);
104104
$res = $tester->execute(['locale' => 'en', 'bundle' => $this->translationDir.'/customDir']);
105105

106-
$this->assertRegExp('/missing/', $tester->getDisplay());
107-
$this->assertRegExp('/unused/', $tester->getDisplay());
106+
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
107+
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
108108
$this->assertEquals($expectedExitStatus, $res);
109109
}
110110

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function testDumpMessagesAndClean()
2828
{
2929
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
3030
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]);
31-
$this->assertRegExp('/foo/', $tester->getDisplay());
32-
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
31+
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
32+
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
3333
}
3434

3535
public function testDumpSortedMessagesAndClean()
@@ -72,32 +72,32 @@ public function testDumpMessagesAndCleanInRootDirectory()
7272

7373
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']], [], null, [$this->translationDir.'/trans'], [$this->translationDir.'/views']);
7474
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--dump-messages' => true, '--clean' => true]);
75-
$this->assertRegExp('/foo/', $tester->getDisplay());
76-
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
75+
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
76+
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
7777
}
7878

7979
public function testDumpTwoMessagesAndClean()
8080
{
8181
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'bar' => 'bar']]);
8282
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]);
83-
$this->assertRegExp('/foo/', $tester->getDisplay());
84-
$this->assertRegExp('/bar/', $tester->getDisplay());
85-
$this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay());
83+
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
84+
$this->assertMatchesRegularExpression('/bar/', $tester->getDisplay());
85+
$this->assertMatchesRegularExpression('/2 messages were successfully extracted/', $tester->getDisplay());
8686
}
8787

8888
public function testDumpMessagesForSpecificDomain()
8989
{
9090
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]);
9191
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain']);
92-
$this->assertRegExp('/bar/', $tester->getDisplay());
93-
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
92+
$this->assertMatchesRegularExpression('/bar/', $tester->getDisplay());
93+
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
9494
}
9595

9696
public function testWriteMessages()
9797
{
9898
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
9999
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true]);
100-
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
100+
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
101101
}
102102

103103
public function testWriteMessagesInRootDirectory()
@@ -109,14 +109,14 @@ public function testWriteMessagesInRootDirectory()
109109

110110
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
111111
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]);
112-
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
112+
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
113113
}
114114

115115
public function testWriteMessagesForSpecificDomain()
116116
{
117117
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]);
118118
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain']);
119-
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
119+
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
120120
}
121121

122122
protected function setUp(): void

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{# This file is partially duplicated in TwigBundle/Resources/views/base_js.html.twig. If you
2-
make any change in this file, verify the same change is needed in the other file. #}
1+
{# This file is partially duplicated in src/Symfony/Component/ErrorHandler/Resources/assets/js/exception.js.
2+
If you make any change in this file, verify the same change is needed in the other file. #}
33
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
44
{# Caution: the contents of this file are processed by Twig before loading
55
them as JavaScript source code. Always use '/*' comments instead

src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class IconTest extends TestCase
2020
*/
2121
public function testIconFileContents($iconFilePath)
2222
{
23-
$this->assertRegExp('~<svg xmlns="http://www.w3.org/2000/svg" width="\d+" height="\d+" viewBox="0 0 \d+ \d+">.*</svg>~s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath));
23+
$this->assertMatchesRegularExpression('~<svg xmlns="http://www.w3.org/2000/svg" width="\d+" height="\d+" viewBox="0 0 \d+ \d+">.*</svg>~s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath));
2424
}
2525

2626
public function provideIconFilePaths()

src/Symfony/Component/Cache/Adapter/ArrayAdapter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ public function save(CacheItemInterface $item)
196196

197197
$now = microtime(true);
198198

199+
if (0 === $expiry) {
200+
$expiry = PHP_INT_MAX;
201+
}
202+
199203
if (null !== $expiry && $expiry <= $now) {
200204
$this->deleteItem($key);
201205

src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Psr\Cache\CacheItemInterface;
1616
use Psr\Cache\CacheItemPoolInterface;
1717
use Symfony\Component\Cache\Adapter\AdapterInterface;
18+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1819
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1920
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
2021
use Symfony\Component\Cache\PruneableInterface;
@@ -162,6 +163,25 @@ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemAndOnlyHasTags()
162163
$this->assertFalse($anotherPool->hasItem($itemKey));
163164
}
164165

166+
public function testInvalidateTagsWithArrayAdapter()
167+
{
168+
$adapter = new TagAwareAdapter(new ArrayAdapter());
169+
170+
$item = $adapter->getItem('foo');
171+
172+
$this->assertFalse($item->isHit());
173+
174+
$item->tag('bar');
175+
$item->expiresAfter(100);
176+
$adapter->save($item);
177+
178+
$this->assertTrue($adapter->getItem('foo')->isHit());
179+
180+
$adapter->invalidateTags(['bar']);
181+
182+
$this->assertFalse($adapter->getItem('foo')->isHit());
183+
}
184+
165185
public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags()
166186
{
167187
$pool = $this->createCachePool();

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testLoadFile()
8181
XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate']);
8282
$this->fail();
8383
} catch (\InvalidArgumentException $e) {
84-
$this->assertRegExp('/The XML file ".+" is not valid\./', $e->getMessage());
84+
$this->assertMatchesRegularExpression('/The XML file ".+" is not valid\./', $e->getMessage());
8585
}
8686

8787
$this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate']));
@@ -199,7 +199,9 @@ public function testLoadEmptyXmlFile()
199199
// test for issue https://github.com/symfony/symfony/issues/9731
200200
public function testLoadWrongEmptyXMLWithErrorHandler()
201201
{
202-
$originalDisableEntities = libxml_disable_entity_loader(false);
202+
if (LIBXML_VERSION < 20900) {
203+
$originalDisableEntities = libxml_disable_entity_loader(false);
204+
}
203205
$errorReporting = error_reporting(-1);
204206

205207
set_error_handler(function ($errno, $errstr) {
@@ -219,12 +221,13 @@ public function testLoadWrongEmptyXMLWithErrorHandler()
219221
error_reporting($errorReporting);
220222
}
221223

222-
$disableEntities = libxml_disable_entity_loader(true);
223-
libxml_disable_entity_loader($disableEntities);
224-
225-
libxml_disable_entity_loader($originalDisableEntities);
224+
if (LIBXML_VERSION < 20900) {
225+
$disableEntities = libxml_disable_entity_loader(true);
226+
libxml_disable_entity_loader($disableEntities);
226227

227-
$this->assertFalse($disableEntities);
228+
libxml_disable_entity_loader($originalDisableEntities);
229+
$this->assertFalse($disableEntities);
230+
}
228231

229232
// should not throw an exception
230233
XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/valid.xml', __DIR__.'/../Fixtures/Util/schema.xsd');

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,27 @@ public static function parse(string $content, $schemaOrCallable = null)
5151
}
5252

5353
$internalErrors = libxml_use_internal_errors(true);
54-
$disableEntities = libxml_disable_entity_loader(true);
54+
if (LIBXML_VERSION < 20900) {
55+
$disableEntities = libxml_disable_entity_loader(true);
56+
}
5557
libxml_clear_errors();
5658

5759
$dom = new \DOMDocument();
5860
$dom->validateOnParse = true;
5961
if (!$dom->loadXML($content, LIBXML_NONET | (\defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
60-
libxml_disable_entity_loader($disableEntities);
62+
if (LIBXML_VERSION < 20900) {
63+
libxml_disable_entity_loader($disableEntities);
64+
}
6165

6266
throw new XmlParsingException(implode("\n", static::getXmlErrors($internalErrors)));
6367
}
6468

6569
$dom->normalizeDocument();
6670

6771
libxml_use_internal_errors($internalErrors);
68-
libxml_disable_entity_loader($disableEntities);
72+
if (LIBXML_VERSION < 20900) {
73+
libxml_disable_entity_loader($disableEntities);
74+
}
6975

7076
foreach ($dom->childNodes as $child) {
7177
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected function describeApplication(Application $application, array $options
212212
// calculate max. width based on available commands per namespace
213213
$width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
214214
return array_intersect($namespace['commands'], array_keys($commands));
215-
}, $namespaces))));
215+
}, array_values($namespaces)))));
216216

217217
if ($describedNamespace) {
218218
$this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);

0 commit comments

Comments
 (0)