10000 [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction by SpacePossum · Pull Request #24123 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction #24123

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

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ return PhpCsFixer\Config::create()
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'long'),
'no_break_comment' => false,
'protected_to_private' => false,
))
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->append(array(__FILE__))
->exclude(array(
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
'Symfony/Component/DependencyInjection/Tests/Fixtures',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ protected function registerMappingDrivers($objectManager, ContainerBuilder $cont
if ($container->hasDefinition($mappingService)) {
$mappingDriverDef = $container->getDefinition($mappingService);
$args = $mappingDriverDef->getArguments();
if ($driverType == 'annotation') {
if ('annotation' == $driverType) {
$args[1] = array_merge(array_values($driverPaths), $args[1]);
} else {
$args[0] = array_merge(array_values($driverPaths), $args[0]);
}
$mappingDriverDef->setArguments($args);
} elseif ($driverType == 'annotation') {
} elseif ('annotation' == $driverType) {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
array_values($driverPaths),
Expand Down Expand Up @@ -333,7 +333,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
$memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%';
$memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%';
$memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%';
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && 0 === $cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
$cacheDef = new Definition($memcacheClass);
$memcacheInstance = new Definition($memcacheInstanceClass);
$memcacheInstance->addMethodCall('connect', array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getEntitiesByIds($identifier, array $values)

// Like above, but we just filter out empty strings.
$values = array_values(array_filter($values, function ($v) {
return (string) $v !== '';
return '' !== (string) $v;
}));
} else {
$parameterType = Connection::PARAM_STR_ARRAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function onBind(FormEvent $event)

// If all items were removed, call clear which has a higher
// performance on persistent collections
if ($collection instanceof Collection && count($data) === 0) {
if ($collection instanceof Collection && 0 === count($data)) {
$collection->clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function configureOptions(OptionsResolver $resolver)
$entityLoader
);

if ($hash !== null) {
if (null !== $hash) {
$choiceLoaders[$hash] = $doctrineChoiceLoader;
}

Expand Down
20 changes: 10 additions & 10 deletions src/Symfony/Bridge/Twig/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$types = array('functions', 'filters', 'tests', 'globals');

if ($input->getOption('format') === 'json') {
if ('json' === $input->getOption('format')) {
$data = array();
foreach ($types as $type) {
foreach ($twig->{'get'.ucfirst($type)}() as $name => $entity) {
Expand Down Expand Up @@ -129,13 +129,13 @@ protected function execute(InputInterface $input, OutputInterface $output)

private function getMetadata($type, $entity)
{
if ($type === 'globals') {
if ('globals' === $type) {
return $entity;
}
if ($type === 'tests') {
if ('tests' === $type) {
return;
}
if ($type === 'functions' || $type === 'filters') {
if ('functions' === $type || 'filters' === $type) {
$cb = $entity->getCallable();
if (null === $cb) {
return;
Expand Down Expand Up @@ -165,7 +165,7 @@ private function getMetadata($type, $entity)
array_shift($args);
}

if ($type === 'filters') {
if ('filters' === $type) {
// remove the value the filter is applied on
array_shift($args);
}
Expand All @@ -185,32 +185,32 @@ private function getMetadata($type, $entity)

private function getPrettyMetadata($type, $entity)
{
if ($type === 'tests') {
if ('tests' === $type) {
return '';
}

try {
$meta = $this->getMetadata($type, $entity);
if ($meta === null) {
if (null === $meta) {
return '(unknown?)';
}
} catch (\UnexpectedValueException $e) {
return ' <error>'.$e->getMessage().'</error>';
}

if ($type === 'globals') {
if ('globals' === $type) {
if (is_object($meta)) {
return ' = object('.get_class($meta).')';
}

return ' = '.substr(@json_encode($meta), 0, 50);
}

if ($type === 'functions') {
if ('functions' === $type) {
return '('.implode(', ', $meta).')';
}

if ($type === 'filters') {
if ('filters' === $type) {
return $meta ? '('.implode(', ', $meta).')' : '';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getTokenParsers()
* Some stuff which will be recorded on the timeline
* {% endstopwatch %}
*/
new StopwatchTokenParser($this->stopwatch !== null && $this->enabled),
new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function renderEnctype(FormView $view)

protected function renderLabel(FormView $view, $label = null, array $vars = array())
{
if ($label !== null) {
if (null !== $label) {
$vars += array('label' => $label);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function renderEnctype(FormView $view)

protected function renderLabel(FormView $view, $label = null, array $vars = array())
{
if ($label !== null) {
if (null !== $label) {
$vars += array('label' => $label);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function renderEnctype(FormView $view)

protected function renderLabel(FormView $view, $label = null, array $vars = array())
{
if ($label !== null) {
if (null !== $label) {
$vars += array('label' => $label);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function renderEnctype(FormView $view)

protected function renderLabel(FormView $view, $label = null, array $vars = array())
{
if ($label !== null) {
if (null !== $label) {
$vars += array('label' => $label);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output = new SymfonyStyle($input, $output);

// check presence of force or dump-message
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
if (true !== $input->getOption('force') && true !== $input->getOption('dump-messages')) {
$output->error('You must choose one of --force or --dump-messages');

return 1;
Expand Down Expand Up @@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

// show compiled list of messages
if ($input->getOption('dump-messages') === true) {
if (true === $input->getOption('dump-messages')) {
$output->newLine();
foreach ($operation->getDomains() as $domain) {
$output->section(sprintf('Displaying messages for domain <info>%s</info>:', $domain));
Expand All @@ -168,17 +168,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
));
}

if ($input->getOption('output-format') == 'xlf') {
if ('xlf' == $input->getOption('output-format')) {
$output->writeln('Xliff output version is <info>1.2</info>');
}
}

if ($input->getOption('no-backup') === true) {
if (true === $input->getOption('no-backup')) {
$writer->disableBackup();
}

// save the files
if ($input->getOption('force') === true) {
if (true === $input->getOption('force')) {
$output->text('Writing files');

$bundleTransPath = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private function findAlternative($nonExistentBundleName)
}

$lev = levenshtein($nonExistentBundleName, $bundleName);
if ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) {
if ($lev <= strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) {
$alternative = $bundleName;
$shortest = $lev;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function urlRedirectAction(Request $request, $path, $permanent = false, $

$qs = $request->getQueryString();
if ($qs) {
if (strpos($path, '?') === false) {
if (false === strpos($path, '?')) {
$qs = '?'.$qs;
} else {
$qs = '&'.$qs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function templateAction($template, $maxAge = null, $sharedAge = null, $pr

if ($private) {
$response->setPrivate();
} elseif ($private === false || (null === $private && ($maxAge || $sharedAge))) {
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
$response->setPublic();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<tr>
<td></td>
<td>
<?php echo $view['form']->widget($form) ?>
<?php echo $view['form']->widget($form); ?>
</td>
</tr>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<tr>
<td>
<?php echo $view['form']->label($form) ?>
<?php echo $view['form']->label($form); ?>
</td>
<td>
<?php echo $view['form']->errors($form) ?>
<?php echo $view['form']->widget($form) ?>
<?php echo $view['form']->errors($form); ?>
<?php echo $view['form']->widget($form); ?>
</td>
</tr>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<table <?php echo $view['form']->block($form, 'widget_container_attributes') ?>>
<table <?php echo $view['form']->block($form, 'widget_container_attributes'); ?>>
<?php if (!$form->parent && $errors): ?>
<tr>
<td colspan="2">
<?php echo $view['form']->errors($form) ?>
<?php echo $view['form']->errors($form); ?>
</td>
</tr>
<?php endif ?>
<?php echo $view['form']->block($form, 'form_rows') ?>
<?php echo $view['form']->rest($form) ?>
<?php endif; ?>
<?php echo $view['form']->block($form, 'form_rows'); ?>
<?php echo $view['form']->rest($form); ?>
</table>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tr style="display: none">
<td colspan="2">
<?php echo $view['form']->widget($form) ?>
<?php echo $view['form']->widget($form); ?>
</td>
</tr>
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static function getPhpUnitCliConfigArgument()
$dir = null;
$reversedArgs = array_reverse($_SERVER['argv']);
foreach ($reversedArgs as $argIndex => $testArg) {
if (preg_match('/^-[^ \-]*c$/', $testArg) || $testArg === '--configuration') {
if (preg_match('/^-[^ \-]*c$/', $testArg) || '--configuration' === $testArg) {
$dir = realpath($reversedArgs[$argIndex - 1]);
break;
} elseif (0 === strpos($testArg, '--configuration=')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function parse($name)
{
list($bundle, $controller, $template) = explode(':', $name, 3);

if ($template[0] == '_') {
if ('_' == $template[0]) {
$path = $this->rootTheme.'/Custom/'.$template;
} elseif ($bundle === 'TestBundle') {
} elseif ('TestBundle' === $bundle) {
$path = $this->rootTheme.'/'.$controller.'/'.$template;
} else {
$path = $this->root.'/'.$controller.'/'.$template;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<label><?php echo $global ?>child</label>
<label><?php echo $global; ?>child</label>
10000
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php $type = isset($type) ? $type : 'text' ?>
<input type="<?php echo $type ?>" <?php $view['form']->block($form, 'widget_attributes') ?> value="<?php echo $value ?>" rel="theme" />
<?php $type = isset($type) ? $type : 'text'; ?>
<input type="<?php echo $type; ?>" <?php $view['form']->block($form, 'widget_attributes'); ?> value="<?php echo $value; ?>" rel="theme" />
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testParseFromFilename($file, $ref)
{
$template = $this->parser->parse($file);

if ($ref === false) {
if (false === $ref) {
$this->assertFalse($template);
} else {
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($userOption as $user) {
$data = explode(':', $user, 2);

if (count($data) === 1) {
if (1 === count($data)) {
throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
}

Expand Down
17AE
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private function addProvidersSection(ArrayNodeDefinition $rootNode)
->thenInvalid('You cannot set multiple provider types for the same provider')
->end()
->validate()
->ifTrue(function ($v) { return count($v) === 0; })
->ifTrue(function ($v) { return 0 === count($v); })
->thenInvalid('You must set a provider definition for the provider.')
->end()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
$userProviders[] = new Reference('security.user.provider.concrete.'.$providerName);
}
}
if (count($userProviders) === 0) {
if (0 === count($userProviders)) {
throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function testAccess()

$rules = array();
foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) {
if ($call[0] == 'add') {
if ('add' == $call[0]) {
$rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function add(Request $request)
*/
public function isEmpty()
{
return count($this->stack) == 0;
return 0 == count($this->stack);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public static function fixNamespaceDeclarations($source)
do {
$token = $tokens[++$i];
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
} while ($token[0] !== T_END_HEREDOC);
} while (T_END_HEREDOC !== $token[0]);
$output .= "\n";
$rawChunk = '';
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/ClassMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function createMap($dir)

$path = $file->getRealPath() ?: $file->getPathname();

if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) {
continue;
}

Expand Down
Loading
0