Merge branch '5.1' into 5.2

* 5.1:
  Cleanup CI scripts
  fix code style
  fix code style
  take query and request parameters into account when matching routes
  mistake
  fix tests to run assertions on returned Crawler instances
  propagate groups to nested constraints
This commit is contained in:
Nicolas Grekas 2021-01-04 18:59:10 +01:00
commit 51d2da706e
37 changed files with 102 additions and 86 deletions

View File

@ -49,9 +49,8 @@ install:
- git config --global user.email ""
- git config --global user.name "Symfony"
- FOR /F "tokens=* USEBACKQ" %%F IN (`bash -c "grep branch-version composer.json | grep -o '[0-9.x]*'"`) DO (SET SYMFONY_VERSION=%%F)
- php .github/build-packages.php "HEAD^" %SYMFONY_VERSION% src\Symfony\Bridge\PhpUnit src\Symfony\Contracts
- php .github/build-packages.php HEAD^ %SYMFONY_VERSION% src\Symfony\Bridge\PhpUnit
- SET "SYMFONY_REQUIRE=>=%SYMFONY_VERSION%"
- SET COMPOSER_ROOT_VERSION=%SYMFONY_VERSION%.x-dev
- php composer.phar update --no-progress --ansi
- php phpunit install

View File

@ -6,17 +6,12 @@ if (3 > $_SERVER['argc']) {
}
chdir(dirname(__DIR__));
$json = ltrim(file_get_contents('composer.json'));
if ($json !== $package = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json)) {
file_put_contents('composer.json', $package);
}
$dirs = $_SERVER['argv'];
array_shift($dirs);
$mergeBase = trim(shell_exec(sprintf('git merge-base "%s" HEAD', array_shift($dirs))));
$version = array_shift($dirs);
$packages = array();
$packages = [];
$flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
$preferredInstall = json_decode(file_get_contents(__DIR__.'/composer-config.json'), true)['config']['preferred-install'];
@ -36,12 +31,12 @@ foreach ($dirs as $k => $dir) {
exit(1);
}
$package->repositories = array(array(
$package->repositories = [[
'type' => 'composer',
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
));
]];
if (false === strpos($json, "\n \"repositories\": [\n")) {
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
$json = rtrim(json_encode(['repositories' => $package->repositories], $flags), "\n}").','.substr($json, 1);
file_put_contents($dir.'/composer.json', $json);
}
@ -61,7 +56,7 @@ foreach ($dirs as $k => $dir) {
$versions = json_decode($versions)->packages->{$package->name};
foreach ($versions as $v => $package) {
$packages[$package->name] += array($v => $package);
$packages[$package->name] += [$v => $package];
}
}
@ -74,10 +69,12 @@ if ($dirs) {
exit(1);
}
$package->repositories = array(array(
$package->repositories[] = [
'type' => 'composer',
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
));
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
];
$json = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json);
$json = rtrim(json_encode(['repositories' => $package->repositories], $flags), "\n}").','.substr($json, 1);
file_put_contents('composer.json', $json);
}

View File

@ -11,7 +11,7 @@ $dirs = $_SERVER['argv'];
function getRelevantContent(array $composerJson)
{
$relevantKeys = array(
$relevantKeys = [
'name',
'require',
'require-dev',
@ -22,9 +22,9 @@ function getRelevantContent(array $composerJson)
'prefer-stable',
'repositories',
'extra',
);
];
$relevantContent = array();
$relevantContent = [];
foreach (array_intersect($relevantKeys, array_keys($composerJson)) as $key) {
$relevantContent[$key] = $composerJson[$key];
@ -44,7 +44,7 @@ function getContentHash(array $composerJson)
return md5(json_encode($relevantContent));
}
$composerJsons = array();
$composerJsons = [];
foreach ($dirs as $dir) {
if (!file_exists($dir.'/composer.lock') || !$composerLock = @json_decode(file_get_contents($dir.'/composer.lock'), true)) {
@ -61,11 +61,11 @@ foreach ($dirs as $dir) {
@unlink($dir.'/composer.lock');
continue;
}
$composerLock += array('packages' => array(), 'packages-dev' => array());
$composerJsons[$composerJson['name']] = array($dir, $composerLock['packages'] + $composerLock['packages-dev'], getRelevantContent($composerJson));
$composerLock += ['packages' => [], 'packages-dev' => []];
$composerJsons[$composerJson['name']] = [$dir, $composerLock['packages'] + $composerLock['packages-dev'], getRelevantContent($composerJson)];
}
$referencedCommits = array();
$referencedCommits = [];
foreach ($composerJsons as list($dir, $lockedPackages)) {
foreach ($lockedPackages as $lockedJson) {
@ -85,7 +85,7 @@ foreach ($composerJsons as list($dir, $lockedPackages)) {
continue;
}
foreach (array('minimum-stability', 'prefer-stable') as $key) {
foreach (['minimum-stability', 'prefer-stable'] as $key) {
if (array_key_exists($key, $composerJsons[$name][2])) {
$lockedJson[$key] = $composerJsons[$name][2][$key];
}
@ -116,10 +116,10 @@ $sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
$chs = array();
$chs = [];
foreach ($referencedCommits as $name => $dirsByCommit) {
$chs[] = $ch = array(curl_init(), fopen($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '$').'.json', 'wb'));
$chs[] = $ch = [curl_init(), fopen($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '$').'.json', 'wb')];
curl_setopt($ch[0], CURLOPT_URL, 'https://repo.packagist.org/p/'.$name.'.json');
curl_setopt($ch[0], CURLOPT_FILE, $ch[1]);
curl_setopt($ch[0], CURLOPT_SHARE, $sh);

View File

@ -155,7 +155,7 @@ jobs:
run: |
echo "::group::composer update"
composer require --dev --no-update mongodb/mongodb:@stable
composer update --no-progress --no-suggest --ansi
composer update --no-progress --ansi
echo "::endgroup::"
echo "::group::install phpunit"
./phpunit install

View File

@ -185,7 +185,7 @@ install:
export SYMFONY_VERSION=$(grep branch-version composer.json | grep -o '[0-9.x]*')
if [[ ! $deps ]]; then
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit src/Symfony/Contracts
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
else
export SYMFONY_DEPRECATIONS_HELPER=weak &&
cp composer.json composer.json.orig &&
@ -228,7 +228,6 @@ install:
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git ls-remote -q --heads | cut -f2 | grep -FA1 /$SYMFONY_VERSION | tail -n 1 | grep -o '[0-9]*' | head -n 1) ]] && export LEGACY=,legacy
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
- |
@ -268,7 +267,6 @@ install:
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
git fetch --depth=2 origin $SYMFONY_VERSION
git checkout -m FETCH_HEAD
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort)
@ -287,8 +285,6 @@ install:
else
if [[ $PHP = 7.4* ]]; then
# add return types before running the test suite
rm src/Symfony/Contracts -Rf && mv vendor/symfony/contracts src/Symfony/Contracts
ln -sd $(realpath src/Symfony/Contracts) vendor/symfony/contracts
sed -i 's/"\*\*\/Tests\/"//' composer.json
composer install --optimize-autoloader
SYMFONY_PATCH_TYPE_DECLARATIONS=force=object php .github/patch-types.php

View File

@ -45,10 +45,10 @@ class HttpCodeActivationStrategy extends ErrorLevelActivationStrategy implements
foreach ($exclusions as $exclusion) {
if (!\array_key_exists('code', $exclusion)) {
throw new \LogicException(sprintf('An exclusion must have a "code" key.'));
throw new \LogicException('An exclusion must have a "code" key.');
}
if (!\array_key_exists('urls', $exclusion)) {
throw new \LogicException(sprintf('An exclusion must have a "urls" key.'));
throw new \LogicException('An exclusion must have a "urls" key.');
}
}

View File

@ -302,7 +302,7 @@ abstract class AbstractDescriptorTest extends TestCase
}
/** @dataProvider getDescribeContainerBuilderWithPriorityTagsTestData */
public function testDescribeContainerBuilderWithPriorityTags(ContainerBuilder $builder, $expectedDescription, array $options): void
public function testDescribeContainerBuilderWithPriorityTags(ContainerBuilder $builder, $expectedDescription, array $options)
{
$this->assertDescription($expectedDescription, $builder, $options);
}

View File

@ -12,7 +12,7 @@ $container->loadFromExtension('framework', [
'initial_marking' => ['draft'],
'metadata' => [
'title' => 'article workflow',
'description' => 'workflow for articles'
'description' => 'workflow for articles',
],
'places' => [
'draft',

View File

@ -4,7 +4,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;
class_alias(
ClassAliasTargetClass::class,
__NAMESPACE__ . '\ClassAliasExampleClass'
__NAMESPACE__.'\ClassAliasExampleClass'
);
if (false) {

View File

@ -6,7 +6,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class Category
{
const NAME_PATTERN = '/\w+/';
public const NAME_PATTERN = '/\w+/';
public $id;

View File

@ -313,7 +313,7 @@ class SecurityDataCollectorTest extends TestCase
*
* @dataProvider providerCollectDecisionLog
*/
public function testCollectDecisionLog(string $strategy, array $decisionLog, array $voters, array $expectedVoterClasses, array $expectedDecisionLog): void
public function testCollectDecisionLog(string $strategy, array $decisionLog, array $voters, array $expectedVoterClasses, array $expectedDecisionLog)
{
$accessDecisionManager = $this
->getMockBuilder(TraceableAccessDecisionManager::class)

View File

@ -90,7 +90,7 @@ class RouterController
$traceRequest = Request::create(
$request->getPathInfo(),
$request->getRequestServer(true)->get('REQUEST_METHOD'),
[],
\in_array($request->getMethod(), ['DELETE', 'PATCH', 'POST', 'PUT'], true) ? $request->getRequestRequest()->all() : $request->getRequestQuery()->all(),
$request->getRequestCookies(true)->all(),
[],
$request->getRequestServer(true)->all()

View File

@ -84,10 +84,10 @@ class Processor
if (isset($config[$key])) {
if (\is_string($config[$key]) || !\is_int(key($config[$key]))) {
// only one
return [$config[$key]];
return [$config[$key]];
}
return $config[$key];
return $config[$key];
}
return [];

View File

@ -478,7 +478,7 @@ class XmlFileLoader extends FileLoader
break;
case 'expression':
if (!class_exists(Expression::class)) {
throw new \LogicException(sprintf('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'));
throw new \LogicException('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".');
}
$arguments[$key] = new Expression($arg->nodeValue);

View File

@ -868,7 +868,7 @@ class YamlFileLoader extends FileLoader
}
} elseif (\is_string($value) && 0 === strpos($value, '@=')) {
if (!class_exists(Expression::class)) {
throw new \LogicException(sprintf('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'));
throw new \LogicException('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".');
}
return new Expression(substr($value, 2));

View File

@ -16,7 +16,7 @@ class Foo
public static function createCallable(): callable
{
return function() {};
return function () {};
}
public static function createArray(): array

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
class FactoryDummy extends FactoryParent
{
public static function createFactory(): FactoryDummy
public static function createFactory(): self
{
}

View File

@ -11,4 +11,3 @@ class MultipleArgumentsOptionalScalarNotReallyOptional
{
}
}

View File

@ -4,7 +4,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Psr\Log\LoggerInterface;
if (PHP_VERSION_ID >= 80000) {
if (\PHP_VERSION_ID >= 80000) {
require __DIR__.'/uniontype_classes.php';
require __DIR__.'/autowiring_classes_80.php';
}
@ -276,6 +276,7 @@ class Wither
/**
* @required
*
* @return static
*/
public function withFoo1(Foo $foo): self
@ -285,6 +286,7 @@ class Wither
/**
* @required
*
* @return static
*/
public function withFoo2(Foo $foo): self

View File

@ -247,7 +247,7 @@ abstract class AbstractCrawlerTest extends TestCase
{
$crawler = $this->createTestCrawler()->filterXPath('//li');
$this->assertNotSame($crawler, $crawler->eq(0), '->eq() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->eq() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->eq(0), '->eq() returns a new instance of a crawler');
$this->assertEquals('Two', $crawler->eq(1)->text(), '->eq() returns the nth node of the list');
$this->assertCount(0, $crawler->eq(100), '->eq() returns an empty crawler if the nth node does not exist');
@ -403,7 +403,7 @@ abstract class AbstractCrawlerTest extends TestCase
{
$crawler = $this->createTestCrawler();
$this->assertNotSame($crawler, $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filterXPath() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler');
$crawler = $this->createTestCrawler()->filterXPath('//ul');
$this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression');
@ -570,7 +570,7 @@ abstract class AbstractCrawlerTest extends TestCase
{
$crawler = $this->createTestCrawler();
$this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filter('li'), '->filter() returns a new instance of a crawler');
$crawler = $this->createTestCrawler()->filter('ul');
@ -623,7 +623,7 @@ abstract class AbstractCrawlerTest extends TestCase
{
$crawler = $this->createTestCrawler();
$this->assertNotSame($crawler, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectLink() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
$this->assertCount(1, $crawler->selectLink('Fabien\'s Foo'), '->selectLink() selects links by the node values');
$this->assertCount(1, $crawler->selectLink('Fabien\'s Bar'), '->selectLink() selects links by the alt attribute of a clickable image');
@ -642,7 +642,7 @@ abstract class AbstractCrawlerTest extends TestCase
{
$crawler = $this->createTestCrawler();
$this->assertNotSame($crawler, $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectImage() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler');
$this->assertCount(1, $crawler->selectImage('Fabien\'s Bar'), '->selectImage() selects images by alt attribute');
$this->assertCount(2, $crawler->selectImage('Fabien"s Bar'), '->selectImage() selects images by alt attribute');
@ -653,7 +653,7 @@ abstract class AbstractCrawlerTest extends TestCase
{
$crawler = $this->createTestCrawler();
$this->assertNotSame($crawler, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectButton() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler');
$this->assertEquals(1, $crawler->selectButton('FooValue')->count(), '->selectButton() selects buttons');
$this->assertEquals(1, $crawler->selectButton('FooName')->count(), '->selectButton() selects buttons');
@ -798,7 +798,7 @@ HTML;
$this->assertCount(4, $crawler->links(), '->links() returns an array');
$links = $crawler->links();
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $links[0], '->links() returns an array of Link instances');
$this->assertContainsOnlyInstancesOf('Symfony\\Component\\DomCrawler\\Link', $links, '->links() returns an array of Link instances');
$this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
}
@ -810,7 +810,7 @@ HTML;
$this->assertCount(4, $crawler->images(), '->images() returns an array');
$images = $crawler->images();
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Image', $images[0], '->images() returns an array of Image instances');
$this->assertContainsOnlyInstancesOf('Symfony\\Component\\DomCrawler\\Image', $images, '->images() returns an array of Image instances');
$this->assertEquals([], $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty');
}
@ -849,7 +849,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
$this->assertNotSame($crawler, $crawler->last(), '->last() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->last() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->last(), '->last() returns a new instance of a crawler');
$this->assertEquals('Three', $crawler->last()->text());
}
@ -858,7 +858,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//li');
$this->assertNotSame($crawler, $crawler->first(), '->first() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->first() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->first(), '->first() returns a new instance of a crawler');
$this->assertEquals('One', $crawler->first()->text());
}
@ -867,7 +867,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1);
$this->assertNotSame($crawler, $crawler->siblings(), '->siblings() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->siblings() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->siblings(), '->siblings() returns a new instance of a crawler');
$nodes = $crawler->siblings();
$this->assertEquals(2, $nodes->count());
@ -990,7 +990,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1);
$this->assertNotSame($crawler, $crawler->nextAll(), '->nextAll() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->nextAll() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->nextAll(), '->nextAll() returns a new instance of a crawler');
$nodes = $crawler->nextAll();
$this->assertEquals(1, $nodes->count());
@ -1008,7 +1008,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//li')->eq(2);
$this->assertNotSame($crawler, $crawler->previousAll(), '->previousAll() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->previousAll() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->previousAll(), '->previousAll() returns a new instance of a crawler');
$nodes = $crawler->previousAll();
$this->assertEquals(2, $nodes->count());
@ -1026,7 +1026,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//ul');
$this->assertNotSame($crawler, $crawler->children(), '->children() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->children() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->children(), '->children() returns a new instance of a crawler');
$nodes = $crawler->children();
$this->assertEquals(3, $nodes->count());
@ -1086,7 +1086,7 @@ HTML;
{
$crawler = $this->createTestCrawler()->filterXPath('//li[1]');
$this->assertNotSame($crawler, $crawler->parents(), '->parents() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->parents() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->parents(), '->parents() returns a new instance of a crawler');
$nodes = $crawler->parents();
$this->assertEquals(3, $nodes->count());

View File

@ -27,7 +27,7 @@ class Html5ParserCrawlerTest extends AbstractCrawlerTest
}
/** @dataProvider validHtml5Provider */
public function testHtml5ParserParseContentStartingWithValidHeading(string $content): void
public function testHtml5ParserParseContentStartingWithValidHeading(string $content)
{
$this->skipTestIfHTML5LibraryNotAvailable();
@ -41,7 +41,7 @@ class Html5ParserCrawlerTest extends AbstractCrawlerTest
}
/** @dataProvider invalidHtml5Provider */
public function testHtml5ParserWithInvalidHeadedContent(string $content): void
public function testHtml5ParserWithInvalidHeadedContent(string $content)
{
$this->skipTestIfHTML5LibraryNotAvailable();

View File

@ -41,7 +41,6 @@ class FinalClass4
/**
* @author John Doe
*
*
* @final multiline
* comment
*/

View File

@ -345,7 +345,7 @@ class TimeType extends AbstractType
$resolver->setNormalizer('view_timezone', function (Options $options, $viewTimezone): ?string {
if (null !== $options['model_timezone'] && $viewTimezone !== $options['model_timezone'] && null === $options['reference_date']) {
throw new LogicException(sprintf('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.'));
throw new LogicException('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.');
}
return $viewTimezone;

View File

@ -39,7 +39,7 @@ ERROR;
/**
* @dataProvider provideParseError
*/
public function testParseError(string $mimeType, string $json, string $expectedMessage): void
public function testParseError(string $mimeType, string $json, string $expectedMessage)
{
$response = $this->createMock(ResponseInterface::class);
$response

View File

@ -9,7 +9,7 @@ class LdapTestCase extends TestCase
protected function getLdapConfig()
{
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
@ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);
@ldap_set_option($h, \LDAP_OPT_PROTOCOL_VERSION, 3);
if (!$h || !@ldap_bind($h)) {
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');

View File

@ -54,7 +54,7 @@ abstract class TransportFactoryTestCase extends TestCase
/**
* @dataProvider supportsProvider
*/
public function testSupports(Dsn $dsn, bool $supports): void
public function testSupports(Dsn $dsn, bool $supports)
{
$factory = $this->getFactory();
@ -64,7 +64,7 @@ abstract class TransportFactoryTestCase extends TestCase
/**
* @dataProvider createProvider
*/
public function testCreate(Dsn $dsn, TransportInterface $transport): void
public function testCreate(Dsn $dsn, TransportInterface $transport)
{
$factory = $this->getFactory();
@ -77,7 +77,7 @@ abstract class TransportFactoryTestCase extends TestCase
/**
* @dataProvider unsupportedSchemeProvider
*/
public function testUnsupportedSchemeException(Dsn $dsn, string $message = null): void
public function testUnsupportedSchemeException(Dsn $dsn, string $message = null)
{
$factory = $this->getFactory();
@ -92,7 +92,7 @@ abstract class TransportFactoryTestCase extends TestCase
/**
* @dataProvider incompleteDsnProvider
*/
public function testIncompleteDsnException(Dsn $dsn): void
public function testIncompleteDsnException(Dsn $dsn)
{
$factory = $this->getFactory();

View File

@ -27,7 +27,7 @@ class TransportTest extends TestCase
/**
* @dataProvider fromStringProvider
*/
public function testFromString(string $dsn, TransportInterface $transport): void
public function testFromString(string $dsn, TransportInterface $transport)
{
$transportFactory = new Transport([new DummyTransportFactory()]);
@ -63,7 +63,7 @@ class TransportTest extends TestCase
/**
* @dataProvider fromDsnProvider
*/
public function testFromDsn(string $dsn, TransportInterface $transport): void
public function testFromDsn(string $dsn, TransportInterface $transport)
{
$this->assertEquals($transport, Transport::fromDsn($dsn));
}
@ -79,7 +79,7 @@ class TransportTest extends TestCase
/**
* @dataProvider fromWrongStringProvider
*/
public function testFromWrongString(string $dsn, string $error): void
public function testFromWrongString(string $dsn, string $error)
{
$transportFactory = new Transport([new DummyTransportFactory()]);
@ -116,7 +116,7 @@ class DummyTransport implements Transport\TransportInterface
public function __toString(): string
{
return sprintf('dummy://local');
return 'dummy://local';
}
}

View File

@ -40,7 +40,7 @@ $worker = new Worker(['the_receiver' => $receiver], new class() implements Messa
public function dispatch($envelope, array $stamps = []): Envelope
{
echo 'Get envelope with message: '.get_class($envelope->getMessage())."\n";
echo sprintf("with stamps: %s\n", json_encode(array_keys($envelope->all()), JSON_PRETTY_PRINT));
echo sprintf("with stamps: %s\n", json_encode(array_keys($envelope->all()), \JSON_PRETTY_PRINT));
sleep(30);
echo "Done.\n";

View File

@ -194,7 +194,7 @@ class ConnectionTest extends TestCase
'expectedAutoSetup' => true,
];
yield 'test options array' => [
yield 'test options array' => [
'dsn' => 'doctrine://default',
'options' => [
'table_name' => 'name_from_options',

View File

@ -45,7 +45,7 @@ class RoutableMessageBus implements MessageBusInterface
if (null === $busNameStamp) {
if (null === $this->fallbackBus) {
throw new InvalidArgumentException(sprintf('Envelope is missing a BusNameStamp and no fallback message bus is configured on RoutableMessageBus.'));
throw new InvalidArgumentException('Envelope is missing a BusNameStamp and no fallback message bus is configured on RoutableMessageBus.');
}
return $this->fallbackBus->dispatch($envelope, $stamps);

View File

@ -59,7 +59,7 @@ final class EmailAddressContains extends Constraint
return false;
}
throw new \LogicException(sprintf('Unable to test a message address on a non-address header.'));
throw new \LogicException('Unable to test a message address on a non-address header.');
}
/**

View File

@ -43,7 +43,7 @@ class ObjectLoaderTest extends TestCase
/**
* @dataProvider getBadResourceStrings
*/
public function testExceptionWithoutSyntax(string $resourceString): void
public function testExceptionWithoutSyntax(string $resourceString)
{
$this->expectException('InvalidArgumentException');
$loader = new TestObjectLoader();

View File

@ -34,7 +34,7 @@ class AtLeastOneOfValidator extends ConstraintValidator
$messages = [$constraint->message];
foreach ($constraint->constraints as $key => $item) {
$violations = $validator->validate($value, $item);
$violations = $validator->validate($value, $item, $this->context->getGroup());
if (0 === \count($violations)) {
return;

View File

@ -332,7 +332,7 @@
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>Aquest valor hauria de ser JSON vàlid.</target>
<target>Aquest valor hauria de ser un JSON vàlid.</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>

View File

@ -28,6 +28,7 @@ use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Component\Validator\Constraints\Unique;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\Validation;
/**
* @author Przemysław Bogusz <przemyslaw.bogusz@tubotax.pl>
@ -160,4 +161,27 @@ class AtLeastOneOfValidatorTest extends ConstraintValidatorTestCase
]],
];
}
public function testGroupsArePropagatedToNestedConstraints()
{
$validator = Validation::createValidator();
$violations = $validator->validate(50, new AtLeastOneOf([
'constraints' => [
new Range([
'groups' => 'non_default_group',
'min' => 10,
'max' => 20,
]),
new Range([
'groups' => 'non_default_group',
'min' => 30,
'max' => 40,
]),
],
'groups' => 'non_default_group',
]), 'non_default_group');
$this->assertCount(1, $violations);
}
}

View File

@ -5,7 +5,7 @@ namespace Symfony\Component\Validator\Tests\Fixtures;
/**
* This class has two paths to PropertyGetterInterface:
* PropertyGetterInterface <- AbstractPropertyGetter <- PropertyGetter
* PropertyGetterInterface <- ChildGetterInterface <- PropertyGetter
* PropertyGetterInterface <- ChildGetterInterface <- PropertyGetter.
*/
class PropertyGetter extends AbstractPropertyGetter implements ChildGetterInterface
{

View File

@ -29,7 +29,7 @@ foreach ($_SERVER as $k => $v) {
}
}
$json = json_encode($vars, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$json = json_encode($vars, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
switch ($vars['REQUEST_URI']) {
default:
@ -111,7 +111,7 @@ switch ($vars['REQUEST_URI']) {
break;
case '/post':
$output = json_encode($_POST + ['REQUEST_METHOD' => $vars['REQUEST_METHOD']], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$output = json_encode($_POST + ['REQUEST_METHOD' => $vars['REQUEST_METHOD']], \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
header('Content-Type: application/json', true);
header('Content-Length: '.strlen($output));
echo $output;