8000 CS fixes by nicolas-grekas · Pull Request #46788 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

CS fixes #46788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2022
Merged

CS fixes #46788

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
CS fixes
  • Loading branch information
nicolas-grekas committed Jun 27, 2022
commit 76f5031cea0274356f2038fbf4ef7e7684c39708
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance);
$cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))]);
break;
case 'redis':
case 'redis':
$redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%';
$redisInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.redis_instance.class').'%';
$redisHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.redis_host').'%';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ public function getTypes($class, $property, array $context = [])
$fieldName = $associationMapping['indexBy'];
if (null === ($typeOfField = $subMetadata->getTypeOfField($fieldName))) {
$fieldName = $subMetadata->getFieldForColumn($associationMapping['indexBy']);
//Not a property, maybe a column name?
// Not a property, maybe a column name?
if (null === ($typeOfField = $subMetadata->getTypeOfField($fieldName))) {
//Maybe the column name is the association join column?
// Maybe the column name is the association join column?
$associationMapping = $subMetadata->getAssociationMapping($fieldName);

/** @var ClassMetadataInfo $subMetadata */
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName);
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);

//Not a property, maybe a column name?
// Not a property, maybe a column name?
if (null === ($typeOfField = $subMetadata->getTypeOfField($indexProperty))) {
$fieldName = $subMetadata->getFieldForColumn($indexProperty);
$typeOfField = $subMetadata->getTypeOfField($fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public function testExtractEnum()
}
$this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', []));
$this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumInt', []));
$this->assertEquals(null, $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', []));
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', []));
$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class))], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumIntArray', []));
$this->assertEquals(null, $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', []));
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', []));
}

public function typesProvider()
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
$phpunitConfigFilename = $phpunitConfigFilename ?: $getPhpUnitConfig('phpunit.xml');

if ($phpunitConfigFilename) {
$phpunitConfig = new DomDocument();
$phpunitConfig = new DOMDocument();
$phpunitConfig->load($phpunitConfigFilename);
} else {
$phpunitConfig = false;
}
}
if (false !== $phpunitConfig) {
$var = new DOMXpath($phpunitConfig);
$var = new DOMXPath($phpunitConfig);
foreach ($var->query('//php/server[@name="'.$name.'"]') as $var) {
return $var->getAttribute('value');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Extension/CodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CodeExtension extends AbstractExtension
*/
public function __construct($fileLinkFormat, string $projectDir, string $charset)
{
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->projectDir = str_replace('\\', '/', $projectDir).'/';
$this->charset = $charset;
}
Expand Down Expand Up @@ -241,7 +241,7 @@ public function formatLogMessage(string $message, array $context): string
if ($context && str_contains($message, '{')) {
$replacements = [];
foreach ($context as $key => $val) {
if (is_scalar($val)) {
if (\is_scalar($val)) {
$replacements['{'.$key.'}'] = $val;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testCompile()
sprintf(
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], true);',
$this->getVariableGetter('form')
),
),
trim($compiler->compile($node)->getSource())
);

Expand All @@ -74,7 +74,7 @@ public function testCompile()
sprintf(
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], false);',
$this->getVariableGetter('form')
),
),
trim($compiler->compile($node)->getSource())
);

Expand All @@ -86,7 +86,7 @@ public function testCompile()
sprintf(
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1", true);',
$this->getVariableGetter('form')
),
),
trim($compiler->compile($node)->getSource())
);

Expand All @@ -96,7 +96,7 @@ public function testCompile()
sprintf(
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, "tpl1", false);',
$this->getVariableGetter('form')
),
),
trim($compiler->compile($node)->getSource())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testCompileWidget()
sprintf(
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\')',
$this->getVariableGetter('form')
),
),
trim($compiler->compile($node)->getSource())
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function testCompileStrict()
'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");',
$this->getVariableGetterWithoutStrictCheck('var'),
$this->getVariableGetterWithStrictCheck('foo')
),
trim($compiler->compile($node)->getSource())
),
trim($compiler->compile($node)->getSource())
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
['Architecture', (\PHP_INT_SIZE * 8).' bits'],
['Intl locale', class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'],
['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
['OPcache', \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
['APCu', \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ protected function configure()
<info>php %command.full_name% @AcmeDemoBundle</info>

EOF
);
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function load(array $configs, ContainerBuilder $container)
// mark any env vars found in the ide setting as used
$container->resolveEnvPlaceholders($ide);

$container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: ($links[$ide] ?? $ide));
$container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: ($links[$ide] ?? $ide));
}
$container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%');
}
Expand Down Expand Up @@ -719,7 +719,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
if ('method' === $workflow['marking_store']['type']) {
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
'state_machine' === $type, // single state
$workflow['marking_store']['property'] ?? 'marking',
]);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ private function resolve($value)

$resolved = ($this->paramFetcher)($match[1]);

if (is_scalar($resolved)) {
if (\is_scalar($resolved)) {
$this->collectedParameters[$match[1]] = $resolved;

if (\is_string($resolved)) {
$resolved = $this->resolve($resolved);
}

if (is_scalar($resolved)) {
if (\is_scalar($resolved)) {
return false === $resolved ? '0' : (string) $resolved;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CodeHelper extends Helper
*/
public function __construct($fileLinkFormat, string $projectDir, string $charset)
{
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->rootDir = str_replace('\\', '/', $projectDir).'/';
$this->charset = $charset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ public function testAnnotations()

public function testFileLinkFormat()
{
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
if (\ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
$this->markTestSkipped('A custom file_link_format is defined.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$message = sprintf('Server listening on all interfaces, port %s -- see http://%s', $config->getPort(), $displayAddress);
}
$io->success($message);
if (ini_get('xdebug.profiler_enable_trigger')) {
if (\ini_get('xdebug.profiler_enable_trigger')) {
$io->comment('Xdebug profiler trigger enabled.');
}
$io->comment('Quit the server with CONTROL-C.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$message = sprintf('Server listening on all interfaces, port %s -- see http://%s', $config->getPort(), $displayAddress);
}
$io->success($message);
if (ini_get('xdebug.profiler_enable_trigger')) {
if (\ini_get('xdebug.profiler_enable_trigger')) {
$io->comment('Xdebug profiler trigger enabled.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/WebServerBundle/WebServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function createServerProcess(WebServerConfig $config): Process
throw new \RuntimeException('Unable to find the PHP binary.');
}

$xdebugArgs = ini_get('xdebug.profiler_enable_trigger') ? ['-dxdebug.profiler_enable_trigger=1'] : [];
$xdebugArgs = \ini_get('xdebug.profiler_enable_trigger') ? ['-dxdebug.profiler_enable_trigger=1'] : [];

$process = new Process(array_merge([$binary], $finder->findArguments(), $xdebugArgs, ['-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()]));
$process->setWorkingDirectory($config->getDocumentRoot());
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
return $opcache;
}

if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
return $opcache;
}

Expand Down
B41A
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ChainAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(array $adapters, int $defaultLifetime = 0)
if (!$adapter instanceof CacheItemPoolInterface) {
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($adapter), CacheItemPoolInterface::class));
}
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
continue; // skip putting APCu in the chain when the backend is disabled
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static function log(?LoggerInterface $logger, string $message, array $con
} else {
$replace = [];
foreach ($context as $k => $v) {
if (is_scalar($v)) {
if (\is_scalar($v)) {
$replace['{'.$k.'}'] = $v;
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,19 @@ public function testDontSaveWhenAskedNotTo()

$cache = $this->createCachePool(0, __FUNCTION__);

$v1 = $cache->get('some-key', function($item, &$save){
$save = false;
return 1;
$v1 = $cache->get('some-key', function ($item, &$save) {
$save = false;

return 1;
});
$this->assertSame($v1, 1);

$v2 = $cache->get('some-key', function(){
$v2 = $cache->get('some-key', function () {
return 2;
});
$this->assertSame($v2, 2, 'First value was cached and should not have been');

$v3 = $cache->get('some-key', function(){
$v3 = $cache->get('some-key', function () {
$this->fail('Value should have come from cache');
});
$this->assertSame($v3, 2);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class ApcuAdapterTest extends AdapterTestCase

public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterface
{
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) {
if (!\function_exists('apcu_fetch') || !filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN)) {
$this->markTestSkipped('APCu extension is required.');
}
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
if ('testWithCliSapi' !== $this->getName()) {
$this->markTestSkipped('apc.enable_cli=1 is required.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function provideServersSetting(): iterable
'localhost',
11222,
];
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
if (filter_var(\ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
yield [
'memcached://user:password@127.0.0.1?weight=50',
'127.0.0.1',
Expand All @@ -165,7 +165,7 @@ public function provideServersSetting(): iterable
'/var/local/run/memcached.socket',
0,
];
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
if (filter_var(\ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
yield [
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
'/var/local/run/memcached.socket',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemTags()
$anotherPool = $this->createCachePool();

$adapter = new FilesystemAdapter();
$adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair
$adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); // simulate item losing tags pair

$this->assertFalse($anotherPool->hasItem($itemKey));
}
Expand All @@ -139,7 +139,7 @@ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemTags()
$anotherPool = $this->createCachePool();

$adapter = new FilesystemAdapter();
$adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); //simulate item losing tags pair
$adapter->deleteItem(TagAwareAdapter::TAGS_PREFIX.$itemKey); // simulate item losing tags pair

$item = $anotherPool->getItem($itemKey);
$this->assertFalse($item->isHit());
Expand All @@ -156,7 +156,7 @@ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemAndOnlyHasTags()
$anotherPool = $this->createCachePool();

$adapter = new FilesystemAdapter();
$adapter->deleteItem($itemKey); //simulate losing item but keeping tags
$adapter->deleteItem($itemKey); // simulate losing item but keeping tags

$this->assertFalse($anotherPool->hasItem($itemKey));
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags
$anotherPool = $this->createCachePool();

$adapter = new FilesystemAdapter();
$adapter->deleteItem($itemKey); //simulate losing item but keeping tags
$adapter->deleteItem($itemKey); // simulate losing item but keeping tags

$item = $anotherPool->getItem($itemKey);
$this->assertFalse($item->isHit());
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ApcuCacheTest extends CacheTestCase

public function createSimpleCache(int $defaultLifetime = 0): CacheInterface
{
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
if (!\function_exists('apcu_fetch') || !filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
$this->markTestSkipped('APCu extension is required.');
}
if ('\\' === \DIRECTORY_SEPARATOR) {
Expand Down
Loading
0