Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CS: Apply ternary_to_null_coalescing fixer #39632

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
Dec 27, 2020
Merged
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: Apply ternary_to_null_coalescing fixer
  • Loading branch information
derrabus committed Dec 26, 2020
commit 07c4773d98b4d3718283b5037fdaa052027bca04
1 change: 1 addition & 0 deletions 1 .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create()
'combine_nested_dirname' => true,
'list_syntax' => ['syntax' => 'short'],
'visibility_required' => ['property', 'method', 'const'],
'ternary_to_null_coalescing' => true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should then be added to the @symfony ruleset of pho-cs-fixer, too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folks, do not hesitate to raise PR for Fixer repo ;)

])
->setRiskyAllowed(true)
->setFinder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function findAndSortTags(string $tagName, ContainerBuilder $container):

foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
foreach ($tags as $attributes) {
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
$priority = $attributes['priority'] ?? 0;
$sortedTags[$priority][] = [$serviceId, $attributes];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function validate($entity, Constraint $constraint)
}

$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
$invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]];
$invalidValue = $criteria[$errorPath] ?? $criteria[$fields[0]];

$this->context->buildViolation($constraint->message)
->atPath($errorPath)
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __invoke(array $record)
'priority' => $record['level'],
'priorityName' => $record['level_name'],
'context' => $record['context'],
'channel' => isset($record['channel']) ? $record['channel'] : '',
'channel' => $record['channel'] ?? '',
];

if (!isset($this->errorCount[$hash])) {
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(FragmentHandler $handler)
*/
public function renderFragment($uri, $options = [])
{
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
$strategy = $options['strategy'] ?? 'inline';
unset($options['strategy']);

return $this->handler->render($uri, $strategy, $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function compile(Compiler $compiler)
// The "label" function expects the label in the second and
// the variables in the third argument
$label = $arguments[1];
$variables = isset($arguments[2]) ? $arguments[2] : null;
$variables = $arguments[2] ?? null;
$lineno = $label->getTemplateLine();

if ($label instanceof ConstantExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function describeCallable($callable, array $options = [])

protected function describeContainerParameter($parameter, array $options = [])
{
$key = isset($options['parameter']) ? $options['parameter'] : '';
$key = $options['parameter'] ?? '';

$this->writeData([$key => $parameter], $options);
}
Expand All @@ -156,7 +156,7 @@ protected function describeContainerEnvVars(array $envs, array $options = [])

private function writeData(array $data, array $options)
{
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
$flags = $options['json_encoding'] ?? 0;

$this->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function describeRoute(Route $route, array $options = [])
{
$tableHeaders = ['Property', 'Value'];
$tableRows = [
['Route Name', isset($options['name']) ? $options['name'] : ''],
['Route Name', $options['name'] ?? ''],
['Path', $route->getPath()],
['Path Regex', $route->compile()->getRegex()],
['Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')],
Expand Down Expand Up @@ -150,7 +150,7 @@ protected function describeContainerService($service, array $options = [], Conta
$options['output']->table(
['Service ID', 'Class'],
[
[isset($options['id']) ? $options['id'] : '-', \get_class($service)],
[$options['id'] ?? '-', \get_class($service)],
]
);
}
Expand All @@ -159,7 +159,7 @@ protected function describeContainerService($service, array $options = [], Conta
protected function describeContainerServices(ContainerBuilder $builder, array $options = [])
{
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
$showTag = isset($options['tag']) ? $options['tag'] : null;
$showTag = $options['tag'] ?? null;

if ($showHidden) {
$title = 'Symfony Container Hidden Services';
Expand Down Expand Up @@ -223,7 +223,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
foreach ($this->sortByPriority($definition->getTag($showTag)) as $key => $tag) {
$tagValues = [];
foreach ($tagsNames as $tagName) {
$tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : '';
$tagValues[] = $tag[$tagName] ?? '';
}
if (0 === $key) {
$tableRows[] = array_merge([$serviceId], $tagValues, [$definition->getClass()]);
Expand Down Expand Up @@ -257,7 +257,7 @@ protected function describeContainerDefinition(Definition $definition, array $op

$tableHeaders = ['Option', 'Value'];

$tableRows[] = ['Service ID', isset($options['id']) ? $options['id'] : '-'];
$tableRows[] = ['Service ID', $options['id'] ?? '-'];
$tableRows[] = ['Class', $definition->getClass() ?: '-'];

$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio

protected function describeRoute(Route $route, array $options = [])
{
$this->writeDocument($this->getRouteDocument($route, isset($options['name']) ? $options['name'] : null));
$this->writeDocument($this->getRouteDocument($route, $options['name'] ?? null));
}

protected function describeContainerParameters(ParameterBag $parameters, array $options = [])
Expand All @@ -62,18 +62,18 @@ protected function describeContainerService($service, array $options = [], Conta

protected function describeContainerServices(ContainerBuilder $builder, array $options = [])
{
$this->writeDocument($this->getContainerServicesDocument($builder, isset($options['tag']) ? $options['tag'] : null, isset($options['show_hidden']) && $options['show_hidden'], isset($options['show_arguments']) && $options['show_arguments'], isset($options['filter']) ? $options['filter'] : null));
$this->writeDocument($this->getContainerServicesDocument($builder, $options['tag'] ?? null, isset($options['show_hidden']) && $options['show_hidden'], isset($options['show_arguments']) && $options['show_arguments'], $options['filter'] ?? null));
}

protected function describeContainerDefinition(Definition $definition, array $options = [])
{
$this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']));
$this->writeDocument($this->getContainerDefinitionDocument($definition, $options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']));
}

protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, isset($options['id']) ? $options['id'] : null)->childNodes->item(0), true));
$dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, $options['id'] ?? null)->childNodes->item(0), true));

if (!$builder) {
$this->writeDocument($dom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function process(ContainerBuilder $container)
$collectors = new \SplPriorityQueue();
$order = \PHP_INT_MAX;
foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) {
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$priority = $attributes[0]['priority'] ?? 0;
$template = null;

if (isset($attributes[0]['template'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,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')) ?: (isset($links[$ide]) ? $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 @@ -1083,7 +1083,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
} else {
// let format fallback to main version_format
$format = $package['version_format'] ?: $config['version_format'];
$version = isset($package['version']) ? $package['version'] : null;
$version = $package['version'] ?? null;
$version = $this->createVersion($container, $version, $format, $package['json_manifest_path'], $name);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'color']);
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'color']);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'email']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'email']) ?>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php if (false !== $label): ?>
<?php if ($required) { $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '').' required'); } ?>
<?php if ($required) { $label_attr['class'] = trim(($label_attr['class'] ?? '').' required'); } ?>
<?php if (!$compound) { $label_attr['for'] = $id; } ?>
<?php if (!$label) { $label = isset($label_format)
? strtr($label_format, ['%name%' => $name, '%id%' => $id])
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'hidden']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'hidden']) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'number']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'number']) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'text']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'text']) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'password']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'password']) ?>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php $symbol = false !== $symbol ? ($symbol ? ' '.$symbol : ' %') : '' ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'text']).$view->escape($symbol) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'text']).$view->escape($symbol) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'range']);
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'range']);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'button_widget', ['type' => isset($type) ? $type : 'reset']) ?>
<?php echo $view['form']->block($form, 'button_widget', ['type' => $type ?? 'reset']) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'search']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'search']) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'button_widget', ['type' => isset($type) ? $type : 'submit']) ?>
<?php echo $view['form']->block($form, 'button_widget', ['type' => $type ?? 'submit']) ?>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'tel']);
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'tel']);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'url']) ?>
<?php echo $view['form']->block($form, 'form_widget_simple', ['type' => $type ?? 'url']) ?>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(FragmentHandler $handler)
*/
public function render($uri, array $options = [])
{
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
$strategy = $options['strategy'] ?? 'inline';
unset($options['strategy']);

return $this->handler->render($uri, $strategy, $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ protected static function createKernel(array $options = []): KernelInterface
return new $class(
static::getVarDir(),
$options['test_case'],
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']),
isset($options['debug']) ? $options['debug'] : false
$options['root_config'] ?? 'config.yml',
$options['environment'] ?? strtolower(static::getVarDir().$options['test_case']),
$options['debug'] ?? false
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ private function getParameterBag(array $params = []): ContainerInterface
->expects($this->any())
->method('get')
->willReturnCallback(function ($key) use ($params) {
return isset($params[$key]) ? $params[$key] : null;
return $params[$key] ?? null;
})
;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php $type = isset($type) ? $type : 'text'; ?>
<?php $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 @@ -283,9 +283,9 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
if (isset($firewall['request_matcher'])) {
$matcher = new Reference($firewall['request_matcher']);
} elseif (isset($firewall['pattern']) || isset($firewall['host'])) {
$pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null;
$host = isset($firewall['host']) ? $firewall['host'] : null;
$methods = isset($firewall['methods']) ? $firewall['methods'] : [];
$pattern = $firewall['pattern'] ?? null;
$host = $firewall['host'] ?? null;
$methods = $firewall['methods'] ?? [];
$matcher = $this->createRequestMatcher($container, $pattern, $host, null, $methods);
}

Expand Down Expand Up @@ -394,7 +394,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
}

// Determine default entry point
$configuredEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;
$configuredEntryPoint = $firewall['entry_point'] ?? null;

// Authentication listeners
[$authListeners, $defaultEntryPoint] = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $providerIds, $configuredEntryPoint, $contextListenerId);
Expand All @@ -415,8 +415,8 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
// Exception listener
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless']));

$config->replaceArgument(8, isset($firewall['access_denied_handler']) ? $firewall['access_denied_handler'] : null);
$config->replaceArgument(9, isset($firewall['access_denied_url']) ? $firewall['access_denied_url'] : null);
$config->replaceArgument(8, $firewall['access_denied_handler'] ?? null);
$config->replaceArgument(9, $firewall['access_denied_url'] ?? null);

$container->setAlias('security.user_checker.'.$id, new Alias($firewall['user_checker'], false));

Expand All @@ -430,7 +430,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
}

$config->replaceArgument(10, $listenerKeys);
$config->replaceArgument(11, isset($firewall['switch_user']) ? $firewall['switch_user'] : null);
$config->replaceArgument(11, $firewall['switch_user'] ?? null);

return [$matcher, $listeners, $exceptionListener, null !== $logoutListenerId ? new Reference($logoutListenerId) : null];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ protected static function createKernel(array $options = []): KernelInterface
return new $class(
static::getVarDir(),
$options['test_case'],
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']),
isset($options['debug']) ? $options['debug'] : false
$options['root_config'] ?? 'config.yml',
$options['environment'] ?? strtolower(static::getVarDir().$options['test_case']),
$options['debug'] ?? false
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL
(string) $this->findTemplate($request, $request->getRequestFormat(), $code, $showException),
[
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'status_text' => Response::$statusTexts[$code] ?? '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function process(ContainerBuilder $container)
$found = 0;

foreach ($container->findTaggedServiceIds('twig.loader', true) as $id => $attributes) {
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$priority = $attributes[0]['priority'] ?? 0;
$prioritizedLoaders[$priority][] = $id;
++$found;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ private function renderWithCspNonces(Request $request, string $template, array $

$nonces = $this->cspHandler ? $this->cspHandler->getNonces($request, $response) : [];

$variables['csp_script_nonce'] = isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null;
$variables['csp_style_nonce'] = isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null;
$variables['csp_script_nonce'] = $nonces['csp_script_nonce'] ?? null;
$variables['csp_style_nonce'] = $nonces['csp_style_nonce'] ?? null;

$response->setContent($this->twig->render($template, $variables));

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.