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
This commit is contained in:
Christian Flothmann 2021-01-05 20:51:30 +01:00
commit a7600370fa
69 changed files with 223 additions and 130 deletions

View File

@ -24,7 +24,7 @@ class HttpCodeActivationStrategyTest extends TestCase
/** /**
* @group legacy * @group legacy
*/ */
public function testExclusionsWithoutCodeLegacy(): void public function testExclusionsWithoutCodeLegacy()
{ {
$this->expectException('LogicException'); $this->expectException('LogicException');
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING); new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING);
@ -33,7 +33,7 @@ class HttpCodeActivationStrategyTest extends TestCase
/** /**
* @group legacy * @group legacy
*/ */
public function testExclusionsWithoutUrlsLegacy(): void public function testExclusionsWithoutUrlsLegacy()
{ {
$this->expectException('LogicException'); $this->expectException('LogicException');
new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING); new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING);
@ -44,7 +44,7 @@ class HttpCodeActivationStrategyTest extends TestCase
* *
* @group legacy * @group legacy
*/ */
public function testIsActivatedLegacy($url, $record, $expected): void public function testIsActivatedLegacy($url, $record, $expected)
{ {
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push(Request::create($url)); $requestStack->push(Request::create($url));
@ -63,13 +63,13 @@ class HttpCodeActivationStrategyTest extends TestCase
self::assertEquals($expected, $strategy->isHandlerActivated($record)); self::assertEquals($expected, $strategy->isHandlerActivated($record));
} }
public function testExclusionsWithoutCode(): void public function testExclusionsWithoutCode()
{ {
$this->expectException('LogicException'); $this->expectException('LogicException');
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], new ErrorLevelActivationStrategy(Logger::WARNING)); new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], new ErrorLevelActivationStrategy(Logger::WARNING));
} }
public function testExclusionsWithoutUrls(): void public function testExclusionsWithoutUrls()
{ {
$this->expectException('LogicException'); $this->expectException('LogicException');
new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], new ErrorLevelActivationStrategy(Logger::WARNING)); new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], new ErrorLevelActivationStrategy(Logger::WARNING));

View File

@ -26,7 +26,7 @@ class NotFoundActivationStrategyTest extends TestCase
* *
* @group legacy * @group legacy
*/ */
public function testIsActivatedLegacy(string $url, array $record, bool $expected): void public function testIsActivatedLegacy(string $url, array $record, bool $expected)
{ {
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push(Request::create($url)); $requestStack->push(Request::create($url));
@ -39,7 +39,7 @@ class NotFoundActivationStrategyTest extends TestCase
/** /**
* @dataProvider isActivatedProvider * @dataProvider isActivatedProvider
*/ */
public function testIsActivated(string $url, array $record, bool $expected): void public function testIsActivated(string $url, array $record, bool $expected)
{ {
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push(Request::create($url)); $requestStack->push(Request::create($url));

View File

@ -74,6 +74,6 @@ final class BodyRenderer implements BodyRendererInterface
return $this->converter->convert($html); return $this->converter->convert($html);
} }
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}i', '', $html)); return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}is', '', $html));
} }
} }

View File

@ -37,6 +37,23 @@ class BodyRendererTest extends TestCase
$this->assertEquals(str_replace('=', '=3D', $html), $body->getParts()[1]->bodyToString()); $this->assertEquals(str_replace('=', '=3D', $html), $body->getParts()[1]->bodyToString());
} }
public function testRenderMultiLineHtmlOnly()
{
$html = <<<HTML
<head>
<style type="text/css">
css
</style>
</head>
<b>HTML</b>
HTML;
$email = $this->prepareEmail(null, $html);
$body = $email->getBody();
$this->assertInstanceOf(AlternativePart::class, $body);
$this->assertEquals('HTML', str_replace(["\r", "\n"], '', $body->getParts()[0]->bodyToString()));
$this->assertEquals(str_replace(['=', "\n"], ['=3D', "\r\n"], $html), $body->getParts()[1]->bodyToString());
}
public function testRenderHtmlOnlyWithTextSet() public function testRenderHtmlOnlyWithTextSet()
{ {
$email = $this->prepareEmail(null, '<b>HTML</b>'); $email = $this->prepareEmail(null, '<b>HTML</b>');

View File

@ -51,7 +51,7 @@ $container->loadFromExtension('framework', [
'fallback' => 'fr', 'fallback' => 'fr',
'paths' => ['%kernel.project_dir%/Fixtures/translations'], 'paths' => ['%kernel.project_dir%/Fixtures/translations'],
'cache_dir' => '%kernel.cache_dir%/translations', 'cache_dir' => '%kernel.cache_dir%/translations',
'enabled_locales' => ['fr', 'en'] 'enabled_locales' => ['fr', 'en'],
], ],
'validation' => [ 'validation' => [
'enabled' => true, 'enabled' => true,

View File

@ -11,7 +11,7 @@ $container->loadFromExtension('framework', [
'multiplier' => 2, 'multiplier' => 2,
'max_delay' => 0, 'max_delay' => 0,
'jitter' => 0.3, 'jitter' => 0.3,
] ],
], ],
'scoped_clients' => [ 'scoped_clients' => [
'foo' => [ 'foo' => [

View File

@ -8,7 +8,7 @@ $container->loadFromExtension('framework', [
'type' => 'state_machine', 'type' => 'state_machine',
'marking_store' => [ 'marking_store' => [
'type' => 'method', 'type' => 'method',
'property' => 'state' 'property' => 'state',
], ],
'supports' => [ 'supports' => [
FrameworkExtensionTest::class, FrameworkExtensionTest::class,
@ -33,9 +33,9 @@ $container->loadFromExtension('framework', [
'two', 'two',
], ],
'to' => [ 'to' => [
'three' 'three',
] ],
] ],
], ],
], ],
], ],

View File

@ -8,7 +8,7 @@ $container->loadFromExtension('framework', [
'type' => 'state_machine', 'type' => 'state_machine',
'marking_store' => [ 'marking_store' => [
'type' => 'method', 'type' => 'method',
'property' => 'state' 'property' => 'state',
], ],
'supports' => [ 'supports' => [
FrameworkExtensionTest::class, FrameworkExtensionTest::class,
@ -36,9 +36,9 @@ $container->loadFromExtension('framework', [
'two', 'two',
], ],
'to' => [ 'to' => [
'three' 'three',
] ],
] ],
], ],
], ],
], ],

View File

@ -1393,7 +1393,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals($expected, $chain->getArguments()); $this->assertEquals($expected, $chain->getArguments());
} }
public function testRedisTagAwareAdapter(): void public function testRedisTagAwareAdapter()
{ {
$container = $this->createContainerFromFile('cache', [], true); $container = $this->createContainerFromFile('cache', [], true);

View File

@ -629,7 +629,7 @@ class SecurityExtensionTest extends TestCase
yield [['user_checker' => TestUserChecker::class], TestUserChecker::class]; yield [['user_checker' => TestUserChecker::class], TestUserChecker::class];
} }
public function testConfigureCustomFirewallListener(): void public function testConfigureCustomFirewallListener()
{ {
$container = $this->getRawContainer(); $container = $this->getRawContainer();
/** @var SecurityExtension $extension */ /** @var SecurityExtension $extension */

View File

@ -52,7 +52,7 @@ class RequestTest extends TestCase
$this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request'); $this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request');
} }
public function testAllParameterValuesAreConvertedToString(): void public function testAllParameterValuesAreConvertedToString()
{ {
$parameters = [ $parameters = [
'foo' => 1, 'foo' => 1,

View File

@ -15,7 +15,6 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Version;
use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\PdoAdapter; use Symfony\Component\Cache\Adapter\PdoAdapter;
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;

View File

@ -215,7 +215,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
if ($child->isRequired()) { if ($child->isRequired()) {
$message = sprintf('The child config "%s" under "%s" must be configured', $name, $this->getPath()); $message = sprintf('The child config "%s" under "%s" must be configured', $name, $this->getPath());
if ($child->getInfo()) { if ($child->getInfo()) {
$message .= sprintf(": %s", $child->getInfo()); $message .= sprintf(': %s', $child->getInfo());
} else { } else {
$message .= '.'; $message .= '.';
} }

View File

@ -110,7 +110,7 @@ class DirectoryResourceTest extends TestCase
{ {
$resource = new DirectoryResource($this->directory); $resource = new DirectoryResource($this->directory);
$time = time(); $time = time();
sleep(1); usleep(1500000);
unlink($this->directory.'/tmp.xml'); unlink($this->directory.'/tmp.xml');
$this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed'); $this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed');
} }

View File

@ -23,7 +23,7 @@ class DummyOutput extends BufferedOutput
public function getLogs(): array public function getLogs(): array
{ {
$logs = []; $logs = [];
foreach (explode(PHP_EOL, trim($this->fetch())) as $message) { foreach (explode(\PHP_EOL, trim($this->fetch())) as $message) {
preg_match('/^\[(.*)\] (.*)/', $message, $matches); preg_match('/^\[(.*)\] (.*)/', $message, $matches);
$logs[] = sprintf('%s %s', $matches[1], $matches[2]); $logs[] = sprintf('%s %s', $matches[1], $matches[2]);
} }

View File

@ -26,7 +26,7 @@ class SignalRegistryTest extends TestCase
pcntl_signal(\SIGUSR2, \SIG_DFL); pcntl_signal(\SIGUSR2, \SIG_DFL);
} }
public function testOneCallbackForASignal_signalIsHandled() public function testOneCallbackForASignalSignalIsHandled()
{ {
$signalRegistry = new SignalRegistry(); $signalRegistry = new SignalRegistry();
@ -40,7 +40,7 @@ class SignalRegistryTest extends TestCase
$this->assertTrue($isHandled); $this->assertTrue($isHandled);
} }
public function testTwoCallbacksForASignal_bothCallbacksAreCalled() public function testTwoCallbacksForASignalBothCallbacksAreCalled()
{ {
$signalRegistry = new SignalRegistry(); $signalRegistry = new SignalRegistry();
@ -60,7 +60,7 @@ class SignalRegistryTest extends TestCase
$this->assertTrue($isHandled2); $this->assertTrue($isHandled2);
} }
public function testTwoSignals_signalsAreHandled() public function testTwoSignalsSignalsAreHandled()
{ {
$signalRegistry = new SignalRegistry(); $signalRegistry = new SignalRegistry();
@ -85,7 +85,7 @@ class SignalRegistryTest extends TestCase
$this->assertTrue($isHandled2); $this->assertTrue($isHandled2);
} }
public function testTwoCallbacksForASignal_previousAndRegisteredCallbacksWereCalled() public function testTwoCallbacksForASignalPreviousAndRegisteredCallbacksWereCalled()
{ {
$signalRegistry = new SignalRegistry(); $signalRegistry = new SignalRegistry();
@ -105,7 +105,7 @@ class SignalRegistryTest extends TestCase
$this->assertTrue($isHandled2); $this->assertTrue($isHandled2);
} }
public function testTwoCallbacksForASignal_previousCallbackFromAnotherRegistry() public function testTwoCallbacksForASignalPreviousCallbackFromAnotherRegistry()
{ {
$signalRegistry1 = new SignalRegistry(); $signalRegistry1 = new SignalRegistry();

View File

@ -21,7 +21,6 @@ use Symfony\Component\DependencyInjection\Argument\ServiceLocator;
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass; use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass;
use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge;
use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode; use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode;
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;

View File

@ -604,6 +604,8 @@ class XmlFileLoader extends FileLoader
array_shift($parts); array_shift($parts);
$locationstart = 'phar:///'; $locationstart = 'phar:///';
} }
} elseif ('\\' === \DIRECTORY_SEPARATOR && 0 === strpos($location, '\\\\')) {
$locationstart = '';
} }
$drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; $drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
$location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts)); $location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts));

View File

@ -611,7 +611,13 @@ class Finder implements \IteratorAggregate, \Countable
} }
if (1 === \count($this->dirs) && 0 === \count($this->iterators)) { if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
return $this->searchInDirectory($this->dirs[0]); $iterator = $this->searchInDirectory($this->dirs[0]);
if ($this->sort || $this->reverseSorting) {
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
}
return $iterator;
} }
$iterator = new \AppendIterator(); $iterator = new \AppendIterator();
@ -623,6 +629,10 @@ class Finder implements \IteratorAggregate, \Countable
$iterator->append($it); $iterator->append($it);
} }
if ($this->sort || $this->reverseSorting) {
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
}
return $iterator; return $iterator;
} }
@ -767,11 +777,6 @@ class Finder implements \IteratorAggregate, \Countable
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths); $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
} }
if ($this->sort || $this->reverseSorting) {
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting);
$iterator = $iteratorAggregate->getIterator();
}
return $iterator; return $iterator;
} }

View File

@ -832,6 +832,39 @@ class FinderTest extends Iterator\RealIteratorTestCase
]), $finder->in(self::$tmpDir)->getIterator()); ]), $finder->in(self::$tmpDir)->getIterator());
} }
public function testSortAcrossDirectories()
{
$finder = $this->buildFinder()
->in([
self::$tmpDir,
self::$tmpDir.'/qux',
self::$tmpDir.'/foo',
])
->depth(0)
->files()
->filter(static function (\SplFileInfo $file): bool {
return '' !== $file->getExtension();
})
->sort(static function (\SplFileInfo $a, \SplFileInfo $b): int {
return strcmp($a->getExtension(), $b->getExtension()) ?: strcmp($a->getFilename(), $b->getFilename());
})
;
$this->assertOrderedIterator($this->toAbsolute([
'qux_0_1.php',
'qux_1000_1.php',
'qux_1002_0.php',
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
'test.php',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
'test.py',
'foo/bar.tmp',
]), $finder->getIterator());
}
public function testFilter() public function testFilter()
{ {
$finder = $this->buildFinder(); $finder = $this->buildFinder();

View File

@ -31,7 +31,8 @@ abstract class IteratorTestCase extends TestCase
protected function assertOrderedIterator($expected, \Traversable $iterator) protected function assertOrderedIterator($expected, \Traversable $iterator)
{ {
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)); $values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', \DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator));
$expected = array_map(function ($path) { return str_replace('/', \DIRECTORY_SEPARATOR, $path); }, $expected);
$this->assertEquals($expected, array_values($values)); $this->assertEquals($expected, array_values($values));
} }

View File

@ -214,7 +214,7 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
{ {
if (null !== $this->scale && null !== $this->roundingMode) { if (null !== $this->scale && null !== $this->roundingMode) {
// shift number to maintain the correct scale during rounding // shift number to maintain the correct scale during rounding
$roundingCoef = pow(10, $this->scale); $roundingCoef = 10 ** $this->scale;
if (self::FRACTIONAL == $this->type) { if (self::FRACTIONAL == $this->type) {
$roundingCoef *= 100; $roundingCoef *= 100;

View File

@ -77,7 +77,7 @@ class NumberTypeTest extends BaseTypeTest
$this->assertSame('12345,68', $form->createView()->vars['value']); $this->assertSame('12345,68', $form->createView()->vars['value']);
} }
public function testStringInputWithFloatData(): void public function testStringInputWithFloatData()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->expectExceptionMessage('Expected a numeric string.'); $this->expectExceptionMessage('Expected a numeric string.');
@ -88,7 +88,7 @@ class NumberTypeTest extends BaseTypeTest
]); ]);
} }
public function testStringInputWithIntData(): void public function testStringInputWithIntData()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->expectExceptionMessage('Expected a numeric string.'); $this->expectExceptionMessage('Expected a numeric string.');

View File

@ -83,6 +83,7 @@ class TraceableResponse implements ResponseInterface, StreamableInterface
if (false === $this->content) { if (false === $this->content) {
return $this->response->getContent($throw); return $this->response->getContent($throw);
} }
return $this->content = $this->response->getContent(false); return $this->content = $this->response->getContent(false);
} finally { } finally {
if ($this->event && $this->event->isStarted()) { if ($this->event && $this->event->isStarted()) {
@ -100,6 +101,7 @@ class TraceableResponse implements ResponseInterface, StreamableInterface
if (false === $this->content) { if (false === $this->content) {
return $this->response->toArray($throw); return $this->response->toArray($throw);
} }
return $this->content = $this->response->toArray(false); return $this->content = $this->response->toArray(false);
} finally { } finally {
if ($this->event && $this->event->isStarted()) { if ($this->event && $this->event->isStarted()) {

View File

@ -33,7 +33,7 @@ class MockResponseTest extends TestCase
$response->toArray(); $response->toArray();
} }
public function testUrlHttpMethodMockResponse(): void public function testUrlHttpMethodMockResponse()
{ {
$responseMock = new MockResponse(json_encode(['foo' => 'bar'])); $responseMock = new MockResponse(json_encode(['foo' => 'bar']));
$url = 'https://example.com/some-endpoint'; $url = 'https://example.com/some-endpoint';

View File

@ -251,17 +251,23 @@ class HeaderUtils
return $query; return $query;
} }
private static function groupParts(array $matches, string $separators): array private static function groupParts(array $matches, string $separators, bool $first = true): array
{ {
$separator = $separators[0]; $separator = $separators[0];
$partSeparators = substr($separators, 1); $partSeparators = substr($separators, 1);
$i = 0; $i = 0;
$partMatches = []; $partMatches = [];
$previousMatchWasSeparator = false;
foreach ($matches as $match) { foreach ($matches as $match) {
if (isset($match['separator']) && $match['separator'] === $separator) { if (!$first && $previousMatchWasSeparator && isset($match['separator']) && $match['separator'] === $separator) {
$previousMatchWasSeparator = true;
$partMatches[$i][] = $match;
} elseif (isset($match['separator']) && $match['separator'] === $separator) {
$previousMatchWasSeparator = true;
++$i; ++$i;
} else { } else {
$previousMatchWasSeparator = false;
$partMatches[$i][] = $match; $partMatches[$i][] = $match;
} }
} }
@ -269,12 +275,19 @@ class HeaderUtils
$parts = []; $parts = [];
if ($partSeparators) { if ($partSeparators) {
foreach ($partMatches as $matches) { foreach ($partMatches as $matches) {
$parts[] = self::groupParts($matches, $partSeparators); $parts[] = self::groupParts($matches, $partSeparators, false);
} }
} else { } else {
foreach ($partMatches as $matches) { foreach ($partMatches as $matches) {
$parts[] = self::unquote($matches[0][0]); $parts[] = self::unquote($matches[0][0]);
} }
if (!$first && 2 < \count($parts)) {
$parts = [
$parts[0],
implode($separator, \array_slice($parts, 1)),
];
}
} }
return $parts; return $parts;

View File

@ -72,7 +72,7 @@ class JsonResponse extends Response
*/ */
public static function create($data = null, int $status = 200, array $headers = []) public static function create($data = null, int $status = 200, array $headers = [])
{ {
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class()); trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
return new static($data, $status, $headers); return new static($data, $status, $headers);
} }

View File

@ -58,7 +58,7 @@ class RedirectResponse extends Response
*/ */
public static function create($url = '', int $status = 302, array $headers = []) public static function create($url = '', int $status = 302, array $headers = [])
{ {
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class()); trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
return new static($url, $status, $headers); return new static($url, $status, $headers);
} }

View File

@ -234,7 +234,7 @@ class Response
*/ */
public static function create(?string $content = '', int $status = 200, array $headers = []) public static function create(?string $content = '', int $status = 200, array $headers = [])
{ {
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class()); trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
return new static($content, $status, $headers); return new static($content, $status, $headers);
} }

View File

@ -52,7 +52,7 @@ class StreamedResponse extends Response
*/ */
public static function create($callback = null, int $status = 200, array $headers = []) public static function create($callback = null, int $status = 200, array $headers = [])
{ {
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class()); trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
return new static($callback, $status, $headers); return new static($callback, $status, $headers);
} }

View File

@ -326,6 +326,12 @@ class CookieTest extends TestCase
$cookie = Cookie::fromString('foo', true); $cookie = Cookie::fromString('foo', true);
$this->assertEquals(Cookie::create('foo', null, 0, '/', null, false, false, false, null), $cookie); $this->assertEquals(Cookie::create('foo', null, 0, '/', null, false, false, false, null), $cookie);
$cookie = Cookie::fromString('foo_cookie=foo=1&bar=2&baz=3; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/');
$this->assertEquals(Cookie::create('foo_cookie', 'foo=1&bar=2&baz=3', strtotime('Tue, 22-Sep-2020 06:27:09 GMT'), '/', null, false, false, true, null), $cookie);
$cookie = Cookie::fromString('foo_cookie=foo==; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/');
$this->assertEquals(Cookie::create('foo_cookie', 'foo==', strtotime('Tue, 22-Sep-2020 06:27:09 GMT'), '/', null, false, false, true, null), $cookie);
} }
public function testFromStringWithHttpOnly() public function testFromStringWithHttpOnly()

View File

@ -16,33 +16,47 @@ use Symfony\Component\HttpFoundation\HeaderUtils;
class HeaderUtilsTest extends TestCase class HeaderUtilsTest extends TestCase
{ {
public function testSplit() /**
* @dataProvider provideHeaderToSplit
*/
public function testSplit(array $expected, string $header, string $separator)
{ {
$this->assertSame(['foo=123', 'bar'], HeaderUtils::split('foo=123,bar', ',')); $this->assertSame($expected, HeaderUtils::split($header, $separator));
$this->assertSame(['foo=123', 'bar'], HeaderUtils::split('foo=123, bar', ',')); }
$this->assertSame([['foo=123', 'bar']], HeaderUtils::split('foo=123; bar', ',;'));
$this->assertSame([['foo=123'], ['bar']], HeaderUtils::split('foo=123, bar', ',;'));
$this->assertSame(['foo', '123, bar'], HeaderUtils::split('foo=123, bar', '='));
$this->assertSame(['foo', '123, bar'], HeaderUtils::split(' foo = 123, bar ', '='));
$this->assertSame([['foo', '123'], ['bar']], HeaderUtils::split('foo=123, bar', ',='));
$this->assertSame([[['foo', '123']], [['bar'], ['foo', '456']]], HeaderUtils::split('foo=123, bar; foo=456', ',;='));
$this->assertSame([[['foo', 'a,b;c=d']]], HeaderUtils::split('foo="a,b;c=d"', ',;='));
$this->assertSame(['foo', 'bar'], HeaderUtils::split('foo,,,, bar', ',')); public function provideHeaderToSplit(): array
$this->assertSame(['foo', 'bar'], HeaderUtils::split(',foo, bar,', ',')); {
$this->assertSame(['foo', 'bar'], HeaderUtils::split(' , foo, bar, ', ',')); return [
$this->assertSame(['foo bar'], HeaderUtils::split('foo "bar"', ',')); [['foo=123', 'bar'], 'foo=123,bar', ','],
$this->assertSame(['foo bar'], HeaderUtils::split('"foo" bar', ',')); [['foo=123', 'bar'], 'foo=123, bar', ','],
$this->assertSame(['foo bar'], HeaderUtils::split('"foo" "bar"', ',')); [[['foo=123', 'bar']], 'foo=123; bar', ',;'],
[[['foo=123'], ['bar']], 'foo=123, bar', ',;'],
[['foo', '123, bar'], 'foo=123, bar', '='],
[['foo', '123, bar'], ' foo = 123, bar ', '='],
[[['foo', '123'], ['bar']], 'foo=123, bar', ',='],
[[[['foo', '123']], [['bar'], ['foo', '456']]], 'foo=123, bar; foo=456', ',;='],
[[[['foo', 'a,b;c=d']]], 'foo="a,b;c=d"', ',;='],
[['foo', 'bar'], 'foo,,,, bar', ','],
[['foo', 'bar'], ',foo, bar,', ','],
[['foo', 'bar'], ' , foo, bar, ', ','],
[['foo bar'], 'foo "bar"', ','],
[['foo bar'], '"foo" bar', ','],
[['foo bar'], '"foo" "bar"', ','],
[[['foo_cookie', 'foo=1&bar=2&baz=3'], ['expires', 'Tue, 22-Sep-2020 06:27:09 GMT'], ['path', '/']], 'foo_cookie=foo=1&bar=2&baz=3; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/', ';='],
[[['foo_cookie', 'foo=='], ['expires', 'Tue, 22-Sep-2020 06:27:09 GMT'], ['path', '/']], 'foo_cookie=foo==; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/', ';='],
[[['foo_cookie', 'foo=a=b'], ['expires', 'Tue, 22-Sep-2020 06:27:09 GMT'], ['path', '/']], 'foo_cookie=foo="a=b"; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/', ';='],
// These are not a valid header values. We test that they parse anyway, // These are not a valid header values. We test that they parse anyway,
// and that both the valid and invalid parts are returned. // and that both the valid and invalid parts are returned.
$this->assertSame([], HeaderUtils::split('', ',')); [[], '', ','],
$this->assertSame([], HeaderUtils::split(',,,', ',')); [[], ',,,', ','],
$this->assertSame(['foo', 'bar', 'baz'], HeaderUtils::split('foo, "bar", "baz', ',')); [['foo', 'bar', 'baz'], 'foo, "bar", "baz', ','],
$this->assertSame(['foo', 'bar, baz'], HeaderUtils::split('foo, "bar, baz', ',')); [['foo', 'bar, baz'], 'foo, "bar, baz', ','],
$this->assertSame(['foo', 'bar, baz\\'], HeaderUtils::split('foo, "bar, baz\\', ',')); [['foo', 'bar, baz\\'], 'foo, "bar, baz\\', ','],
$this->assertSame(['foo', 'bar, baz\\'], HeaderUtils::split('foo, "bar, baz\\\\', ',')); [['foo', 'bar, baz\\'], 'foo, "bar, baz\\\\', ','],
];
} }
public function testCombine() public function testCombine()

View File

@ -24,8 +24,8 @@ use Symfony\Component\Lock\Store\PostgreSqlStore;
*/ */
class PostgreSqlDbalStoreTest extends AbstractStoreTest class PostgreSqlDbalStoreTest extends AbstractStoreTest
{ {
use SharedLockStoreTestTrait;
use BlockingStoreTestTrait; use BlockingStoreTestTrait;
use SharedLockStoreTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -24,8 +24,8 @@ use Symfony\Component\Lock\Store\PostgreSqlStore;
*/ */
class PostgreSqlStoreTest extends AbstractStoreTest class PostgreSqlStoreTest extends AbstractStoreTest
{ {
use SharedLockStoreTestTrait;
use BlockingStoreTestTrait; use BlockingStoreTestTrait;
use SharedLockStoreTestTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -40,7 +40,7 @@ final class SesTransportFactory extends AbstractTransportFactory
throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component or AsyncAws package is not installed. Try running "composer require async-aws/ses".', __CLASS__)); throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component or AsyncAws package is not installed. Try running "composer require async-aws/ses".', __CLASS__));
} }
trigger_deprecation('symfony/amazon-mailer', '5.1', 'Using the "%s" transport without AsyncAws is deprecated. Try running "composer require async-aws/ses".', $scheme, \get_called_class()); trigger_deprecation('symfony/amazon-mailer', '5.1', 'Using the "%s" transport without AsyncAws is deprecated. Try running "composer require async-aws/ses".', $scheme, static::class);
$user = $this->getUser($dsn); $user = $this->getUser($dsn);
$password = $this->getPassword($dsn); $password = $this->getPassword($dsn);

View File

@ -22,6 +22,9 @@ use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Exception\InvalidArgumentException; use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\RawMessage; use Symfony\Component\Mime\RawMessage;
/**
* @group time-sensitive
*/
class SmtpTransportTest extends TestCase class SmtpTransportTest extends TestCase
{ {
public function testToString() public function testToString()
@ -83,7 +86,7 @@ class SmtpTransportTest extends TestCase
$this->assertNotContains("NOOP\r\n", $stream->getCommands()); $this->assertNotContains("NOOP\r\n", $stream->getCommands());
$stream->clearCommands(); $stream->clearCommands();
sleep(1); usleep(1500000);
$transport->send(new RawMessage('Message 3'), $envelope); $transport->send(new RawMessage('Message 3'), $envelope);
$this->assertContains("NOOP\r\n", $stream->getCommands()); $this->assertContains("NOOP\r\n", $stream->getCommands());

View File

@ -21,7 +21,7 @@ use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
class AmazonSqsSenderTest extends TestCase class AmazonSqsSenderTest extends TestCase
{ {
public function testSend(): void public function testSend()
{ {
$envelope = new Envelope(new DummyMessage('Oy')); $envelope = new Envelope(new DummyMessage('Oy'));
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]]; $encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]];
@ -38,7 +38,7 @@ class AmazonSqsSenderTest extends TestCase
$sender->send($envelope); $sender->send($envelope);
} }
public function testSendWithAmazonSqsFifoStamp(): void public function testSendWithAmazonSqsFifoStamp()
{ {
$envelope = (new Envelope(new DummyMessage('Oy'))) $envelope = (new Envelope(new DummyMessage('Oy')))
->with($stamp = new AmazonSqsFifoStamp('testGroup', 'testDeduplicationId')); ->with($stamp = new AmazonSqsFifoStamp('testGroup', 'testDeduplicationId'));

View File

@ -347,7 +347,7 @@ class ConnectionTest extends TestCase
$factory->method('createQueue')->will($this->onConsecutiveCalls($amqpQueue0, $amqpQueue1)); $factory->method('createQueue')->will($this->onConsecutiveCalls($amqpQueue0, $amqpQueue1));
$amqpExchange->expects($this->once())->method('declareExchange'); $amqpExchange->expects($this->once())->method('declareExchange');
$amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]); $amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]);
$amqpQueue0->expects($this->once())->method('declareQueue'); $amqpQueue0->expects($this->once())->method('declareQueue');
$amqpQueue0->expects($this->exactly(2))->method('bind')->withConsecutive( $amqpQueue0->expects($this->exactly(2))->method('bind')->withConsecutive(
[self::DEFAULT_EXCHANGE_NAME, 'binding_key0'], [self::DEFAULT_EXCHANGE_NAME, 'binding_key0'],

View File

@ -10,7 +10,7 @@ use Symfony\Component\Messenger\Stamp\ErrorDetailsStamp;
final class AddErrorDetailsStampListenerTest extends TestCase final class AddErrorDetailsStampListenerTest extends TestCase
{ {
public function testExceptionDetailsAreAdded(): void public function testExceptionDetailsAreAdded()
{ {
$listener = new AddErrorDetailsStampListener(); $listener = new AddErrorDetailsStampListener();

View File

@ -25,7 +25,7 @@ use Symfony\Component\Serializer\Serializer as SymfonySerializer;
class ErrorDetailsStampTest extends TestCase class ErrorDetailsStampTest extends TestCase
{ {
public function testGetters(): void public function testGetters()
{ {
$exception = new \Exception('exception message'); $exception = new \Exception('exception message');
$flattenException = FlattenException::createFromThrowable($exception); $flattenException = FlattenException::createFromThrowable($exception);
@ -37,7 +37,7 @@ class ErrorDetailsStampTest extends TestCase
$this->assertEquals($flattenException, $stamp->getFlattenException()); $this->assertEquals($flattenException, $stamp->getFlattenException());
} }
public function testUnwrappingHandlerFailedException(): void public function testUnwrappingHandlerFailedException()
{ {
$wrappedException = new \Exception('I am inside', 123); $wrappedException = new \Exception('I am inside', 123);
$envelope = new Envelope(new \stdClass()); $envelope = new Envelope(new \stdClass());
@ -52,7 +52,7 @@ class ErrorDetailsStampTest extends TestCase
$this->assertEquals($flattenException, $stamp->getFlattenException()); $this->assertEquals($flattenException, $stamp->getFlattenException());
} }
public function testDeserialization(): void public function testDeserialization()
{ {
$exception = new \Exception('exception message'); $exception = new \Exception('exception message');
$stamp = ErrorDetailsStamp::create($exception); $stamp = ErrorDetailsStamp::create($exception);

View File

@ -21,7 +21,7 @@ use Symfony\Component\Notifier\Transport\Transports;
class TransportsTest extends TestCase class TransportsTest extends TestCase
{ {
public function testSendToTransportDefinedByMessage(): void public function testSendToTransportDefinedByMessage()
{ {
$transports = new Transports([ $transports = new Transports([
'one' => $one = $this->createMock(TransportInterface::class), 'one' => $one = $this->createMock(TransportInterface::class),
@ -39,7 +39,7 @@ class TransportsTest extends TestCase
$this->assertSame('one', $sentMessage->getTransport()); $this->assertSame('one', $sentMessage->getTransport());
} }
public function testSendToFirstSupportedTransportIfMessageDoesNotDefineATransport(): void public function testSendToFirstSupportedTransportIfMessageDoesNotDefineATransport()
{ {
$transports = new Transports([ $transports = new Transports([
'one' => $one = $this->createMock(TransportInterface::class), 'one' => $one = $this->createMock(TransportInterface::class),
@ -63,7 +63,7 @@ class TransportsTest extends TestCase
$this->assertSame('two', $sentMessage->getTransport()); $this->assertSame('two', $sentMessage->getTransport());
} }
public function testThrowExceptionIfNoSupportedTransportWasFound(): void public function testThrowExceptionIfNoSupportedTransportWasFound()
{ {
$transports = new Transports([ $transports = new Transports([
'one' => $one = $this->createMock(TransportInterface::class), 'one' => $one = $this->createMock(TransportInterface::class),
@ -79,7 +79,7 @@ class TransportsTest extends TestCase
$transports->send($message); $transports->send($message);
} }
public function testThrowExceptionIfTransportDefinedByMessageIsNotSupported(): void public function testThrowExceptionIfTransportDefinedByMessageIsNotSupported()
{ {
$transports = new Transports([ $transports = new Transports([
'one' => $one = $this->createMock(TransportInterface::class), 'one' => $one = $this->createMock(TransportInterface::class),

View File

@ -55,7 +55,7 @@ abstract class TransportFactoryTestCase extends TestCase
/** /**
* @dataProvider supportsProvider * @dataProvider supportsProvider
*/ */
public function testSupports(bool $expected, string $dsn): void public function testSupports(bool $expected, string $dsn)
{ {
$factory = $this->createFactory(); $factory = $this->createFactory();
@ -65,7 +65,7 @@ abstract class TransportFactoryTestCase extends TestCase
/** /**
* @dataProvider createProvider * @dataProvider createProvider
*/ */
public function testCreate(string $expected, string $dsn): void public function testCreate(string $expected, string $dsn)
{ {
$factory = $this->createFactory(); $factory = $this->createFactory();
$transport = $factory->create(Dsn::fromString($dsn)); $transport = $factory->create(Dsn::fromString($dsn));
@ -76,7 +76,7 @@ abstract class TransportFactoryTestCase extends TestCase
/** /**
* @dataProvider unsupportedSchemeProvider * @dataProvider unsupportedSchemeProvider
*/ */
public function testUnsupportedSchemeException(string $dsn, string $message = null): void public function testUnsupportedSchemeException(string $dsn, string $message = null)
{ {
$factory = $this->createFactory(); $factory = $this->createFactory();
@ -93,7 +93,7 @@ abstract class TransportFactoryTestCase extends TestCase
/** /**
* @dataProvider incompleteDsnProvider * @dataProvider incompleteDsnProvider
*/ */
public function testIncompleteDsnException(string $dsn, string $message = null): void public function testIncompleteDsnException(string $dsn, string $message = null)
{ {
$factory = $this->createFactory(); $factory = $this->createFactory();

View File

@ -47,7 +47,7 @@ abstract class TransportTestCase extends TestCase
/** /**
* @dataProvider toStringProvider * @dataProvider toStringProvider
*/ */
public function testToString(string $expected, TransportInterface $transport): void public function testToString(string $expected, TransportInterface $transport)
{ {
$this->assertSame($expected, (string) $transport); $this->assertSame($expected, (string) $transport);
} }
@ -55,7 +55,7 @@ abstract class TransportTestCase extends TestCase
/** /**
* @dataProvider supportedMessagesProvider * @dataProvider supportedMessagesProvider
*/ */
public function testSupportedMessages(MessageInterface $message, ?TransportInterface $transport = null): void public function testSupportedMessages(MessageInterface $message, ?TransportInterface $transport = null)
{ {
if (null === $transport) { if (null === $transport) {
$transport = $this->createTransport(); $transport = $this->createTransport();
@ -67,7 +67,7 @@ abstract class TransportTestCase extends TestCase
/** /**
* @dataProvider unsupportedMessagesProvider * @dataProvider unsupportedMessagesProvider
*/ */
public function testUnsupportedMessages(MessageInterface $message, ?TransportInterface $transport = null): void public function testUnsupportedMessages(MessageInterface $message, ?TransportInterface $transport = null)
{ {
if (null === $transport) { if (null === $transport) {
$transport = $this->createTransport(); $transport = $this->createTransport();
@ -79,7 +79,7 @@ abstract class TransportTestCase extends TestCase
/** /**
* @dataProvider unsupportedMessagesProvider * @dataProvider unsupportedMessagesProvider
*/ */
public function testUnsupportedMessagesTrowUnsupportedMessageTypeExceptionWhenSend(MessageInterface $message, ?TransportInterface $transport = null): void public function testUnsupportedMessagesTrowUnsupportedMessageTypeExceptionWhenSend(MessageInterface $message, ?TransportInterface $transport = null)
{ {
if (null === $transport) { if (null === $transport) {
$transport = $this->createTransport(); $transport = $this->createTransport();
@ -90,7 +90,7 @@ abstract class TransportTestCase extends TestCase
$transport->send($message); $transport->send($message);
} }
public function testCanSetCustomHost(): void public function testCanSetCustomHost()
{ {
$transport = $this->createTransport(); $transport = $this->createTransport();
@ -99,7 +99,7 @@ abstract class TransportTestCase extends TestCase
$this->assertStringContainsString(sprintf('://%s', $customHost), (string) $transport); $this->assertStringContainsString(sprintf('://%s', $customHost), (string) $transport);
} }
public function testCanSetCustomPort(): void public function testCanSetCustomPort()
{ {
$transport = $this->createTransport(); $transport = $this->createTransport();
@ -111,7 +111,7 @@ abstract class TransportTestCase extends TestCase
$this->assertMatchesRegularExpression(sprintf('/^.*\/\/.*\:%s.*$/', $customPort), (string) $transport); $this->assertMatchesRegularExpression(sprintf('/^.*\/\/.*\:%s.*$/', $customPort), (string) $transport);
} }
public function testCanSetCustomHostAndPort(): void public function testCanSetCustomHostAndPort()
{ {
$transport = $this->createTransport(); $transport = $this->createTransport();

View File

@ -41,7 +41,7 @@ class ConstructorExtractorTest extends TestCase
$this->assertEquals([new Type(Type::BUILTIN_TYPE_STRING)], $this->extractor->getTypes('Foo', 'bar', [])); $this->assertEquals([new Type(Type::BUILTIN_TYPE_STRING)], $this->extractor->getTypes('Foo', 'bar', []));
} }
public function testGetTypes_ifNoExtractors() public function testGetTypesIfNoExtractors()
{ {
$extractor = new ConstructorExtractor([]); $extractor = new ConstructorExtractor([]);
$this->assertNull($extractor->getTypes('Foo', 'bar', [])); $this->assertNull($extractor->getTypes('Foo', 'bar', []));

View File

@ -122,7 +122,7 @@ final class PhpDocTypeHelper
$collectionKeyType = $this->getTypes($type->getKeyType())[0]; $collectionKeyType = $this->getTypes($type->getKeyType())[0];
$collectionValueTypes = $this->getTypes($type->getValueType()); $collectionValueTypes = $this->getTypes($type->getValueType());
if (\count($collectionValueTypes) != 1) { if (1 != \count($collectionValueTypes)) {
// the Type class does not support union types yet, so assume that no type was defined // the Type class does not support union types yet, so assume that no type was defined
$collectionValueType = null; $collectionValueType = null;
} else { } else {

View File

@ -35,7 +35,7 @@ abstract class AbstractAuthenticator implements AuthenticatorInterface
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
{ {
if (!$passport instanceof UserPassportInterface) { if (!$passport instanceof UserPassportInterface) {
throw new LogicException(sprintf('Passport does not contain a user, overwrite "createAuthenticatedToken()" in "%s" to create a custom authenticated token.', \get_class($this))); throw new LogicException(sprintf('Passport does not contain a user, overwrite "createAuthenticatedToken()" in "%s" to create a custom authenticated token.', static::class));
} }
return new PostAuthenticationToken($passport->getUser(), $firewallName, $passport->getUser()->getRoles()); return new PostAuthenticationToken($passport->getUser(), $firewallName, $passport->getUser()->getRoles());

View File

@ -156,7 +156,7 @@ class AuthenticatorManagerTest extends TestCase
yield [false]; yield [false];
} }
public function testAuthenticateRequestCanModifyTokenFromEvent(): void public function testAuthenticateRequestCanModifyTokenFromEvent()
{ {
$authenticator = $this->createAuthenticator(); $authenticator = $this->createAuthenticator();
$this->request->attributes->set('_security_authenticators', [$authenticator]); $this->request->attributes->set('_security_authenticators', [$authenticator]);
@ -191,7 +191,7 @@ class AuthenticatorManagerTest extends TestCase
$manager->authenticateUser($this->user, $authenticator, $this->request); $manager->authenticateUser($this->user, $authenticator, $this->request);
} }
public function testAuthenticateUserCanModifyTokenFromEvent(): void public function testAuthenticateUserCanModifyTokenFromEvent()
{ {
$authenticator = $this->createAuthenticator(); $authenticator = $this->createAuthenticator();
$authenticator->expects($this->any())->method('createAuthenticatedToken')->willReturn($this->token); $authenticator->expects($this->any())->method('createAuthenticatedToken')->willReturn($this->token);

View File

@ -7,9 +7,9 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryCompiler; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryCompiler;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\MaxDepthDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
final class ClassMetadataFactoryCompilerTest extends TestCase final class ClassMetadataFactoryCompilerTest extends TestCase
{ {

View File

@ -7,8 +7,8 @@ use Symfony\Component\Serializer\Mapping\AttributeMetadata;
use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\ClassMetadata;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Mapping\Factory\CompiledClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\CompiledClassMetadataFactory;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
/** /**
* @author Fabien Bourigault <bourigaultfabien@gmail.com> * @author Fabien Bourigault <bourigaultfabien@gmail.com>

View File

@ -18,8 +18,8 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter; use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface; use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\SerializedNameDummy;
use Symfony\Component\Serializer\Tests\Fixtures\OtherSerializedNameDummy;
/** /**
* @author Fabien Bourigault <bourigaultfabien@gmail.com> * @author Fabien Bourigault <bourigaultfabien@gmail.com>

View File

@ -14,8 +14,8 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy; use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy; use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy;
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy; use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy;
use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer; use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer;

View File

@ -27,8 +27,8 @@ use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy;
use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder; use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder;
use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait;
use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait;

View File

@ -25,9 +25,9 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummy;
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyChild; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\GroupDummyChild;
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy; use Symfony\Component\Serializer\Tests\Fixtures\Php74Dummy;
use Symfony\Component\Serializer\Tests\Fixtures\PropertyCircularReferenceDummy; use Symfony\Component\Serializer\Tests\Fixtures\PropertyCircularReferenceDummy;
use Symfony\Component\Serializer\Tests\Fixtures\PropertySiblingHolder; use Symfony\Component\Serializer\Tests\Fixtures\PropertySiblingHolder;

View File

@ -3,7 +3,6 @@
namespace Symfony\Component\Serializer\Tests\Normalizer; namespace Symfony\Component\Serializer\Tests\Normalizer;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Normalizer\UidNormalizer; use Symfony\Component\Serializer\Normalizer\UidNormalizer;
use Symfony\Component\Uid\AbstractUid; use Symfony\Component\Uid\AbstractUid;
use Symfony\Component\Uid\Ulid; use Symfony\Component\Uid\Ulid;

View File

@ -20,7 +20,7 @@ final class PseudoLocalizationTranslatorTest extends TestCase
/** /**
* @dataProvider provideTrans * @dataProvider provideTrans
*/ */
public function testTrans(string $expected, string $input, array $options = []): void public function testTrans(string $expected, string $input, array $options = [])
{ {
mt_srand(987); mt_srand(987);
$this->assertSame($expected, (new PseudoLocalizationTranslator(new IdentityTranslator(), $options))->trans($input)); $this->assertSame($expected, (new PseudoLocalizationTranslator(new IdentityTranslator(), $options))->trans($input));
@ -50,7 +50,7 @@ final class PseudoLocalizationTranslatorTest extends TestCase
/** /**
* @dataProvider provideInvalidExpansionFactor * @dataProvider provideInvalidExpansionFactor
*/ */
public function testInvalidExpansionFactor(float $expansionFactor): void public function testInvalidExpansionFactor(float $expansionFactor)
{ {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The expansion factor must be greater than or equal to 1.'); $this->expectExceptionMessage('The expansion factor must be greater than or equal to 1.');

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Uid;
*/ */
class NilUuid extends Uuid class NilUuid extends Uuid
{ {
protected const TYPE = \UUID_TYPE_NULL; protected const TYPE = -1;
public function __construct() public function __construct()
{ {

View File

@ -59,7 +59,7 @@ class Ulid extends AbstractUid
public static function fromString(string $ulid): parent public static function fromString(string $ulid): parent
{ {
if (36 === \strlen($ulid) && Uuid::isValid($ulid)) { if (36 === \strlen($ulid) && Uuid::isValid($ulid)) {
$ulid = Uuid::fromString($ulid)->toBinary(); $ulid = (new Uuid($ulid))->toBinary();
} elseif (22 === \strlen($ulid) && 22 === strspn($ulid, BinaryUtil::BASE58[''])) { } elseif (22 === \strlen($ulid) && 22 === strspn($ulid, BinaryUtil::BASE58[''])) {
$ulid = BinaryUtil::fromBase($ulid, BinaryUtil::BASE58); $ulid = BinaryUtil::fromBase($ulid, BinaryUtil::BASE58);
} }

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Uid;
*/ */
class Uuid extends AbstractUid class Uuid extends AbstractUid
{ {
protected const TYPE = \UUID_TYPE_DEFAULT; protected const TYPE = 0;
public function __construct(string $uuid) public function __construct(string $uuid)
{ {

View File

@ -20,7 +20,7 @@ namespace Symfony\Component\Uid;
*/ */
class UuidV1 extends Uuid class UuidV1 extends Uuid
{ {
protected const TYPE = \UUID_TYPE_TIME; protected const TYPE = 1;
public function __construct(string $uuid = null) public function __construct(string $uuid = null)
{ {

View File

@ -22,5 +22,5 @@ namespace Symfony\Component\Uid;
*/ */
class UuidV3 extends Uuid class UuidV3 extends Uuid
{ {
protected const TYPE = \UUID_TYPE_MD5; protected const TYPE = 3;
} }

View File

@ -20,7 +20,7 @@ namespace Symfony\Component\Uid;
*/ */
class UuidV4 extends Uuid class UuidV4 extends Uuid
{ {
protected const TYPE = \UUID_TYPE_RANDOM; protected const TYPE = 4;
public function __construct(string $uuid = null) public function __construct(string $uuid = null)
{ {

View File

@ -22,5 +22,5 @@ namespace Symfony\Component\Uid;
*/ */
class UuidV5 extends Uuid class UuidV5 extends Uuid
{ {
protected const TYPE = \UUID_TYPE_SHA1; protected const TYPE = 5;
} }

View File

@ -38,7 +38,7 @@ class Regex extends Constraint
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @param string|array $pattern The pattern to evaluate or an array of options. * @param string|array $pattern The pattern to evaluate or an array of options
*/ */
public function __construct( public function __construct(
$pattern, $pattern,

View File

@ -44,7 +44,7 @@ class Timezone extends Constraint
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @param int|array|null $zone A combination of {@see \DateTimeZone} class constants or a set of options. * @param int|array|null $zone A combination of {@see \DateTimeZone} class constants or a set of options
*/ */
public function __construct( public function __construct(
$zone = null, $zone = null,

View File

@ -34,7 +34,7 @@ class Type extends Constraint
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @param string|array $type One ore multiple types to validate against or a set of options. * @param string|array $type One ore multiple types to validate against or a set of options
*/ */
public function __construct($type, string $message = null, array $groups = null, $payload = null, array $options = []) public function __construct($type, string $message = null, array $groups = null, $payload = null, array $options = [])
{ {

View File

@ -26,7 +26,7 @@ use Symfony\Component\Validator\Tests\Dummy\DummyClassOne;
*/ */
class DebugCommandTest extends TestCase class DebugCommandTest extends TestCase
{ {
public function testOutputWithClassArgument(): void public function testOutputWithClassArgument()
{ {
$validator = $this->createMock(MetadataFactoryInterface::class); $validator = $this->createMock(MetadataFactoryInterface::class);
$classMetadata = $this->createMock(ClassMetadataInterface::class); $classMetadata = $this->createMock(ClassMetadataInterface::class);
@ -90,7 +90,7 @@ TXT
); );
} }
public function testOutputWithPathArgument(): void public function testOutputWithPathArgument()
{ {
$validator = $this->createMock(MetadataFactoryInterface::class); $validator = $this->createMock(MetadataFactoryInterface::class);
$classMetadata = $this->createMock(ClassMetadataInterface::class); $classMetadata = $this->createMock(ClassMetadataInterface::class);
@ -171,7 +171,7 @@ TXT
); );
} }
public function testOutputWithInvalidClassArgument(): void public function testOutputWithInvalidClassArgument()
{ {
$validator = $this->createMock(MetadataFactoryInterface::class); $validator = $this->createMock(MetadataFactoryInterface::class);

View File

@ -161,7 +161,6 @@ class LanguageValidatorTest extends ConstraintValidatorTestCase
eval('return new \Symfony\Component\Validator\Constraints\Language(alpha3: true, message: "myMessage");') eval('return new \Symfony\Component\Validator\Constraints\Language(alpha3: true, message: "myMessage");')
); );
$this->buildViolation('myMessage') $this->buildViolation('myMessage')
->setParameter('{{ value }}', '"DE"') ->setParameter('{{ value }}', '"DE"')
->setCode(Language::NO_SUCH_LANGUAGE_ERROR) ->setCode(Language::NO_SUCH_LANGUAGE_ERROR)

View File

@ -17,10 +17,11 @@ class ConstraintChoiceWithPreset extends Choice
{ {
public $type; public $type;
public function __construct(string $type) { public function __construct(string $type)
{
parent::__construct($type); parent::__construct($type);
if ($this->type === 'A') { if ('A' === $this->type) {
$this->choices = ['A', 'B', 'C']; $this->choices = ['A', 'B', 'C'];
} else { } else {
$this->choices = ['D', 'E', 'F']; $this->choices = ['D', 'E', 'F'];