8000 Merge branch '5.2' into 5.x · symfony/symfony@a760037 · GitHub
[go: up one dir, main page]

Skip to content

Commit a760037

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: fix code style [Uid] Hardcode UuidV3 & UuidV5 TYPE conditional constants [Uid] Use the Uuid constructor when reconstructing an Ulid from its RFC-4122 version stop using void in test files parse cookie values containing the equal sign make some time dependent tests more resilient fix code style Remove full head content in HTML to text converter do not break when loading schemas from network paths on Windows apply the sort callback on the whole search result
2 parents 80bde1e + d3739d4 commit a760037

File tree

69 files changed

+225
-132
lines changed

Some content is hidden

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

69 files changed

+225
-132
lines changed

src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HttpCodeActivationStrategyTest extends TestCase
2424
/**
2525
* @group legacy
2626
*/
27-
public function testExclusionsWithoutCodeLegacy(): void
27+
public function testExclusionsWithoutCodeLegacy()
2828
{
2929
$this->expectException('LogicException');
3030
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING);
@@ -33,7 +33,7 @@ public function testExclusionsWithoutCodeLegacy(): void
3333
/**
3434
* @group legacy
3535
*/
36-
public function testExclusionsWithoutUrlsLegacy(): void
36+
public function testExclusionsWithoutUrlsLegacy()
3737
{
3838
$this->expectException('LogicException');
3939
new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING);
@@ -44,7 +44,7 @@ public function testExclusionsWithoutUrlsLegacy(): void
4444
*
4545
* @group legacy
4646
*/
47-
public function testIsActivatedLegacy($url, $record, $expected): void
47+
public function testIsActivatedLegacy($url, $record, $expected)
4848
{
4949
$requestStack = new RequestStack();
5050
$requestStack->push(Request::create($url));
@@ -63,13 +63,13 @@ public function testIsActivatedLegacy($url, $record, $expected): void
6363
self::assertEquals($expected, $strategy->isHandlerActivated($record));
6464
}
6565

66-
public function testExclusionsWithoutCode(): void
66+
public function testExclusionsWithoutCode()
6767
{
6868
$this->expectException('LogicException');
6969
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], new ErrorLevelActivationStrategy(Logger::WARNING));
7070
}
7171

72-
public function testExclusionsWithoutUrls(): void
72+
public function testExclusionsWithoutUrls()
7373
{
7474
$this->expectException('LogicException');
7575
new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], new ErrorLevelActivationStrategy(Logger::WARNING));

src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NotFoundActivationStrategyTest extends TestCase
2626
*
2727
* @group legacy
2828
*/
29-
public function testIsActivatedLegacy(string $url, array $record, bool $expected): void
29+
public function testIsActivatedLegacy(string $url, array $record, bool $expected)
3030
{
3131
$requestStack = new RequestStack();
3232
$requestStack->push(Request::create($url));
@@ -39,7 +39,7 @@ public function testIsActivatedLegacy(string $url, array $record, bool $expected
3939
/**
4040
* @dataProvider isActivatedProvider
4141
*/
42-
public function testIsActivated(string $url, array $record, bool $expected): void
42+
public function testIsActivated(string $url, array $record, bool $expected)
4343
{
4444
$requestStack = new RequestStack();
4545
$requestStack->push(Request::create($url));

src/Symfony/Bridge/Twig/Mime/BodyRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ private function convertHtmlToText(string $html): string
7474
return $this->converter->convert($html);
7575
}
7676

77-
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}i', '', $html));
77+
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}is', '', $html));
7878
}
7979
}

src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ public function testRenderHtmlOnly()
3737
$this->assertEquals(str_replace('=', '=3D', $html), $body->getParts()[1]->bodyToString());
3838
}
3939

40+
public function testRenderMultiLineHtmlOnly()
41+
{
42+
$html = <<<HTML
43+
<head>
44+
<style type="text/css">
45+
css
46+
</style>
47+
</head>
48+
<b>HTML</b>
49+
HTML;
50+
$email = $this->prepareEmail(null, $html);
51+
$body = $email->getBody();
52+
$this->assertInstanceOf(AlternativePart::class, $body);
53+
$this->assertEquals('HTML', str_replace(["\r", "\n"], '', $body->getParts()[0]->bodyToString()));
54+
$this->assertEquals(str_replace(['=', "\n"], ['=3D', "\r\n"], $html), $body->getParts()[1]->bodyToString());
55+
}
56+
4057
public function testRenderHtmlOnlyWithTextSet()
4158
{
4259
$email = $this->prepareEmail(null, '<b>HTML</b>');

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
'fallback' => 'fr',
5252
'paths' => ['%kernel.project_dir%/Fixtures/translations'],
5353
'cache_dir' => '%kernel.cache_dir%/translations',
54-
'enabled_locales' => ['fr', 'en']
54+
'enabled_locales' => ['fr', 'en'],
5555
],
5656
'validation' => [
5757
'enabled' => true,

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_retry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'multiplier' => 2,
1212
'max_delay' => 0,
1313
'jitter' => 0.3,
14-
]
14+
],
1515
],
1616
'scoped_clients' => [
1717
'foo' => [

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_no_events_to_dispatch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'type' => 'state_machine',
99
'marking_store' => [
1010
'type' => 'method',
11-
'property' => 'state'
11+
'property' => 'state',
1212
],
1313
'supports' => [
1414
FrameworkExtensionTest::class,
@@ -33,9 +33,9 @@
3333
'two',
3434
],
3535
'to' => [
36-
'three'
37-
]
38-
]
36+
'three',
37+
],
38+
],
3939
],
4040
],
4141
],

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_specified_events_to_dispatch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'type' => 'state_machine',
99
'marking_store' => [
1010
'type' => 'method',
11-
'property' => 'state'
11+
'property' => 'state',
1212
],
1313
'supports' => [
1414
FrameworkExtensionTest::class,
@@ -36,9 +36,9 @@
3636
'two',
3737
],
3838
'to' => [
39-
'three'
40-
]
41-
]
39+
'three',
40+
],
41+
],
4242
],
4343
],
4444
],

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ public function testCachePoolServices()
13931393
$this->assertEquals($expected, $chain->getArguments());
13941394
}
13951395

1396-
public function testRedisTagAwareAdapter(): void
1396+
public function testRedisTagAwareAdapter()
13971397
{
13981398
$container = $this->createContainerFromFile('cache', [], true);
13991399

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public function provideUserCheckerConfig()
629629
yield [['user_checker' => TestUserChecker::class], TestUserChecker::class];
630630
}
631631

632-
public function testConfigureCustomFirewallListener(): void
632+
public function testConfigureCustomFirewallListener()
633633
{
634634
$container = $this->getRawContainer();
635635
/** @var SecurityExtension $extension */

src/Symfony/Component/BrowserKit/Tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testGetServer()
5252
$this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request');
5353
}
5454

55-
public function testAllParameterValuesAreConvertedToString(): void
55+
public function testAllParameterValuesAreConvertedToString()
5656
{
5757
$parameters = [
5858
'foo' => 1,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
1616
use Doctrine\DBAL\DriverManager;
1717
use Doctrine\DBAL\Schema\Schema;
18-
use Doctrine\DBAL\Version;
1918
use Psr\Cache\CacheItemPoolInterface;
2019
use Symfony\Component\Cache\Adapter\PdoAdapter;
2120
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ protected function finalizeValue($value)
215215
if ($child->isRequired()) {
216216
$message = sprintf('The child config "%s" under "%s" must be configured', $name, $this->getPath());
217217
if ($child->getInfo()) {
218-
$message .= sprintf(": %s", $child->getInfo());
218+
$message .= sprintf(': %s', $child->getInfo());
219219
} else {
220220
$message .= '.';
221221
}

src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testIsFreshDeleteFile()
110110
{
111111
$resource = new DirectoryResource($this->directory);
112112
$time = time();
113-
sleep(1);
113+
usleep(1500000);
114114
unlink($this->directory.'/tmp.xml');
115115
$this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed');
116116
}

src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DummyOutput extends BufferedOutput
2323
public function getLogs(): array
2424
{
2525
$logs = [];
26-
foreach (explode(PHP_EOL, trim($this->fetch())) as $message) {
26+
foreach (explode(\PHP_EOL, trim($this->fetch())) as $message) {
2727
preg_match('/^\[(.*)\] (.*)/', $message, $matches);
2828
$logs[] = sprintf('%s %s', $matches[1], $matches[2]);
2929
}

src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function tearDown(): void
2626
pcntl_signal(\SIGUSR2, \SIG_DFL);
2727
}
2828

29-
public function testOneCallbackForASignal_signalIsHandled()
29+
public function testOneCallbackForASignalSignalIsHandled()
3030
{
3131
$signalRegistry = new SignalRegistry();
3232

@@ -40,7 +40,7 @@ public function testOneCallbackForASignal_signalIsHandled()
4040
$this->assertTrue($isHandled);
4141
}
4242

43-
public function testTwoCallbacksForASignal_bothCallbacksAreCalled()
43+
public function testTwoCallbacksForASignalBothCallbacksAreCalled()
4444
{
4545
$signalRegistry = new SignalRegistry();
4646

@@ -60,7 +60,7 @@ public function testTwoCallbacksForASignal_bothCallbacksAreCalled()
6060
$this->assertTrue($isHandled2);
6161
}
6262

63-
public function testTwoSignals_signalsAreHandled()
63+
public function testTwoSignalsSignalsAreHandled()
6464
{
6565
$signalRegistry = new SignalRegistry();
6666

@@ -85,7 +85,7 @@ public function testTwoSignals_signalsAreHandled()
8585
$this->assertTrue($isHandled2);
8686
}
8787

88-
public function testTwoCallbacksForASignal_previousAndRegisteredCallbacksWereCalled()
88+
public function testTwoCallbacksForASignalPreviousAndRegisteredCallbacksWereCalled()
8989
{
9090
$signalRegistry = new SignalRegistry();
9191

@@ -105,7 +105,7 @@ public function testTwoCallbacksForASignal_previousAndRegisteredCallbacksWereCal
105105
$this->assertTrue($isHandled2);
106106
}
107107

108-
public function testTwoCallbacksForASignal_previousCallbackFromAnotherRegistry()
108+
public function testTwoCallbacksForASignalPreviousCallbackFromAnotherRegistry()
109109
{
110110
$signalRegistry1 = new SignalRegistry();
111111

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
2222
use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
2323
use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass;
24-
use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge;
2524
use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode;
2625
use Symfony\Component\DependencyInjection\Container;
2726
use Symfony\Component\DependencyInjection\ContainerBuilder;

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,8 @@ public function validateSchema(\DOMDocument $dom)
604604
array_shift($parts);
605605
$locationstart = 'phar:///';
606606
}
607+
} elseif ('\\' === \DIRECTORY_SEPARATOR && 0 === strpos($location, '\\\\')) {
608+
$locationstart = '';
607609
}
608610
$drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
609611
$location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts));

src/Symfony/Component/Finder/Finder.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,13 @@ public function getIterator()
611611
}
612612

613613
if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
614-
return $this->searchInDirectory($this->dirs[0]);
614+
$iterator = $this->searchInDirectory($this->dirs[0]);
615+
616+
if ($this->sort || $this->reverseSorting) {
617+
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
618+
}
619+
620+
return $iterator;
615621
}
616622

617623
$iterator = new \AppendIterator();
@@ -623,6 +629,10 @@ public function getIterator()
623629
$iterator->append($it);
624630
}
625631

632+
if ($this->sort || $this->reverseSorting) {
633+
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
634+
}
635+
626636
return $iterator;
627637
}
628638

@@ -767,11 +777,6 @@ private function searchInDirectory(string $dir): \Iterator
767777
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
768778
}
769779

770-
if ($this->sort || $this->reverseSorting) {
771-
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting);
772-
$iterator = $iteratorAggregate->getIterator();
773-
}
774-
775780
return $iterator;
776781
}
777782

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,39 @@ public function testSort()
832832
]), $finder->in(self::$tmpDir)->getIterator());
833833
}
834834

835+
public function testSortAcrossDirectories()
836+
{
837+
$finder = $this->buildFinder()
838+
->in([
839+
self::$tmpDir,
840+
self::$tmpDir.'/qux',
841+
self::$tmpDir.'/foo',
842+
])
843+
->depth(0)
844+
->files()
845+
->filter(static function (\SplFileInfo $file): bool {
846+
return '' !== $file->getExtension();
847+
})
848+
->sort(static function (\SplFileInfo $a, \SplFileInfo $b): int {
849+
return strcmp($a->getExtension(), $b->getExtension()) ?: strcmp($a->getFilename(), $b->getFilename());
850+
})
851+
;
852+
853+
$this->assertOrderedIterator($this->toAbsolute([
854+
'qux_0_1.php',
855+
'qux_1000_1.php',
856+
'qux_1002_0.php',
857+
'qux_10_2.php',
858+
'qux_12_0.php',
859+
'qux_2_0.php',
860+
'test.php',
861+
'qux/baz_100_1.py',
862+
'qux/baz_1_2.py',
863+
'test.py',
864+
'foo/bar.tmp',
865+
]), $finder->getIterator());
866+
}
867+
835868
public function testFilter()
836869
{
837870
$finder = $this->buildFinder();

src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ protected function assertIterator($expected, \Traversable $iterator)
3131

3232
protected function assertOrderedIterator($expected, \Traversable $iterator)
3333
{
34-
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
34+
$values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', \DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator));
35+
$expected = array_map(function ($path) { return str_replace('/', \DIRECTORY_SEPARATOR, $path); }, $expected);
3536

3637
$this->assertEquals($expected, array_values($values));
3738
}

src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private function round($number)
214214
{
215215
if (null !== $this->scale && null !== $this->roundingMode) {
216216
// shift number to maintain the correct scale during rounding
217-
$roundingCoef = pow(10, $this->scale);
217+
$roundingCoef = 10 ** $this->scale;
218218

219219
if (self::FRACTIONAL == $this->type) {
220220
$roundingCoef *= 100;

src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testDefaultFormattingWithScaleAndStringInput()
7777
$this->assertSame('12345,68', $form->createView()->vars['value']);
7878
}
7979

80-
public function testStringInputWithFloatData(): void
80+
public function testStringInputWithFloatData()
8181
{
8282
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
8383
$this->expectExceptionMessage('Expected a numeric string.');
@@ -88,7 +88,7 @@ public function testStringInputWithFloatData(): void
8888
]);
8989
}
9090

91-
public function testStringInputWithIntData(): void
91+
public function testStringInputWithIntData()
9292
{
9393
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
9494
$this->expectExceptionMessage('Expected a numeric string.');

0 commit comments

Comments
 (0)
0