Merge branch '4.4' into 5.1

* 4.4:
  CS: Apply ternary_to_null_coalescing fixer
This commit is contained in:
Alexander M. Turek 2020-12-27 14:02:18 +01:00
commit eb4b003bc1
116 changed files with 237 additions and 241 deletions

View File

@ -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,
])
->setRiskyAllowed(true)
->setFinder(

View File

@ -134,7 +134,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
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];
}
}

View File

@ -165,7 +165,7 @@ class UniqueEntityValidator extends ConstraintValidator
}
$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)

View File

@ -38,7 +38,7 @@ class DebugProcessor implements DebugLoggerInterface, ResetInterface
'priority' => $record['level'],
'priorityName' => $record['level_name'],
'context' => $record['context'],
'channel' => isset($record['channel']) ? $record['channel'] : '',
'channel' => $record['channel'] ?? '',
];
if (!isset($this->errorCount[$hash])) {

View File

@ -37,7 +37,7 @@ final class HttpKernelRuntime
*/
public function renderFragment($uri, array $options = []): string
{
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
$strategy = $options['strategy'] ?? 'inline';
unset($options['strategy']);
return $this->handler->render($uri, $strategy, $options);

View File

@ -40,7 +40,7 @@ final class SearchAndRenderBlockNode extends FunctionExpression
// 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) {

View File

@ -145,7 +145,7 @@ class JsonDescriptor extends Descriptor
protected function describeContainerParameter($parameter, array $options = [])
{
$key = isset($options['parameter']) ? $options['parameter'] : '';
$key = $options['parameter'] ?? '';
$this->writeData([$key => $parameter], $options);
}
@ -181,7 +181,7 @@ class JsonDescriptor extends Descriptor
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");
}

View File

@ -89,7 +89,7 @@ class TextDescriptor extends Descriptor
$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')],
@ -155,7 +155,7 @@ class TextDescriptor extends Descriptor
$options['output']->table(
['Service ID', 'Class'],
[
[isset($options['id']) ? $options['id'] : '-', \get_class($service)],
[$options['id'] ?? '-', \get_class($service)],
]
);
}
@ -164,7 +164,7 @@ class TextDescriptor extends Descriptor
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';
@ -228,7 +228,7 @@ class TextDescriptor extends Descriptor
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()]);
@ -262,7 +262,7 @@ class TextDescriptor extends Descriptor
$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'];

View File

@ -39,7 +39,7 @@ class XmlDescriptor extends Descriptor
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 = [])
@ -63,18 +63,18 @@ class XmlDescriptor extends Descriptor
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);

View File

@ -34,7 +34,7 @@ class ProfilerPass implements CompilerPassInterface
$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'])) {

View File

@ -253,7 +253,7 @@ class FrameworkExtension extends Extension
// mark any env vars found in the ide setting as used
$container->resolveEnvPlaceholders($ide);
$container->setParameter('debug.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('debug.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: ($links[$ide] ?? $ide));
}
if (!empty($config['test'])) {
@ -1020,7 +1020,7 @@ class FrameworkExtension extends Extension
} 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);
}

View File

@ -61,9 +61,9 @@ abstract class AbstractWebTestCase extends BaseWebTestCase
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
);
}

View File

@ -551,7 +551,7 @@ class RouterTest extends TestCase
->expects($this->any())
->method('get')
->willReturnCallback(function ($key) use ($params) {
return isset($params[$key]) ? $params[$key] : null;
return $params[$key] ?? null;
})
;

View File

@ -318,9 +318,9 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
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);
}
@ -445,7 +445,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
}
// Determine default entry point
$configuredEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;
$configuredEntryPoint = $firewall['entry_point'] ?? null;
// Authentication listeners
$firewallAuthenticationProviders = [];
@ -503,8 +503,8 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
// 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));
@ -518,7 +518,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
}
$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];
}

View File

@ -33,7 +33,7 @@ class TwigLoaderPass implements CompilerPassInterface
$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;
}

View File

@ -397,8 +397,8 @@ class ProfilerController
$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));

View File

@ -126,8 +126,8 @@ class WebDebugToolbarListener implements EventSubscriberInterface
'excluded_ajax_paths' => $this->excludedAjaxPaths,
'token' => $response->headers->get('X-Debug-Token'),
'request' => $request,
'csp_script_nonce' => isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null,
'csp_style_nonce' => isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null,
'csp_script_nonce' => $nonces['csp_script_nonce'] ?? null,
'csp_style_nonce' => $nonces['csp_style_nonce'] ?? null,
]
))."\n";
$content = substr($content, 0, $pos).$toolbar.substr($content, $pos);

View File

@ -63,6 +63,6 @@ class JsonManifestVersionStrategy implements VersionStrategyInterface
}
}
return isset($this->manifestData[$path]) ? $this->manifestData[$path] : null;
return $this->manifestData[$path] ?? null;
}
}

View File

@ -147,7 +147,7 @@ abstract class AbstractBrowser
*/
public function getServerParameter(string $key, $default = '')
{
return isset($this->server[$key]) ? $this->server[$key] : $default;
return $this->server[$key] ?? $default;
}
public function xmlHttpRequest(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true): Crawler
@ -647,7 +647,7 @@ abstract class AbstractBrowser
} else {
$currentUri = sprintf('http%s://%s/',
isset($this->server['HTTPS']) ? 's' : '',
isset($this->server['HTTP_HOST']) ? $this->server['HTTP_HOST'] : 'localhost'
$this->server['HTTP_HOST'] ?? 'localhost'
);
}

View File

@ -152,7 +152,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
$missing = [];
$misses = [];
$nextAdapterIndex = $adapterIndex + 1;
$nextAdapter = isset($this->adapters[$nextAdapterIndex]) ? $this->adapters[$nextAdapterIndex] : null;
$nextAdapter = $this->adapters[$nextAdapterIndex] ?? null;
foreach ($items as $k => $item) {
if (!$nextAdapter || $item->isHit()) {

View File

@ -163,7 +163,7 @@ This conversation was marked as resolved by lstrojny
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
}
$params += [
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'host' => $params['host'] ?? $params['path'],
'port' => isset($params['host']) ? 11211 : null,
'weight' => 0,
];

View File

@ -86,14 +86,14 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, get_debug_type($connOrDsn)));
}
$this->table = isset($options['db_table']) ? $options['db_table'] : $this->table;
$this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol;
$this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol;
$this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol;
$this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol;
$this->username = isset($options['db_username']) ? $options['db_username'] : $this->username;
$this->password = isset($options['db_password']) ? $options['db_password'] : $this->password;
$this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions;
$this->table = $options['db_table'] ?? $this->table;
$this->idCol = $options['db_id_col'] ?? $this->idCol;
$this->dataCol = $options['db_data_col'] ?? $this->dataCol;
$this->lifetimeCol = $options['db_lifetime_col'] ?? $this->lifetimeCol;
$this->timeCol = $options['db_time_col'] ?? $this->timeCol;
$this->username = $options['db_username'] ?? $this->username;
$this->password = $options['db_password'] ?? $this->password;
$this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
$this->namespace = $namespace;
$this->marshaller = $marshaller ?? new DefaultMarshaller();

View File

@ -280,7 +280,7 @@ EOLUA;
foreach ($this->getHosts() as $host) {
$info = $host->info('Memory');
$info = isset($info['Memory']) ? $info['Memory'] : $info;
$info = $info['Memory'] ?? $info;
return $this->redisEvictionPolicy = $info['maxmemory_policy'];
}

View File

@ -151,7 +151,7 @@ trait MemcachedTrait
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
}
$params += [
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'host' => $params['host'] ?? $params['path'],
'port' => isset($params['host']) ? 11211 : null,
'weight' => 0,
];

View File

@ -356,7 +356,7 @@ trait RedisTrait
}
$info = $host->info('Server');
$info = isset($info['Server']) ? $info['Server'] : $info;
$info = $info['Server'] ?? $info;
if (!version_compare($info['redis_version'], '2.8', '>=')) {
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS

View File

@ -107,7 +107,7 @@ abstract class BaseNode implements NodeInterface
*/
public function getAttribute(string $key, $default = null)
{
return isset($this->attributes[$key]) ? $this->attributes[$key] : $default;
return $this->attributes[$key] ?? $default;
}
/**

View File

@ -277,7 +277,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
->beforeNormalization()
->ifArray()
->then(function ($v) {
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
$v['enabled'] = $v['enabled'] ?? true;
return $v;
})

View File

@ -357,7 +357,7 @@ class PrototypedArrayNode extends ArrayNode
*/
private function getPrototypeForChild(string $key)
{
$prototype = isset($this->valuePrototypes[$key]) ? $this->valuePrototypes[$key] : $this->prototype;
$prototype = $this->valuePrototypes[$key] ?? $this->prototype;
$prototype->setName($key);
return $prototype;

View File

@ -90,7 +90,7 @@ abstract class FileLoader extends Loader
}
if ($isSubpath) {
return isset($ret[1]) ? $ret : (isset($ret[0]) ? $ret[0] : null);
return isset($ret[1]) ? $ret : ($ret[0] ?? null);
}
}

View File

@ -219,8 +219,8 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
}
$props = [
'file' => isset($callerFrame['file']) ? $callerFrame['file'] : null,
'line' => isset($callerFrame['line']) ? $callerFrame['line'] : null,
'file' => $callerFrame['file'] ?? null,
'line' => $callerFrame['line'] ?? null,
'trace' => \array_slice($trace, 1 + $i),
];

View File

@ -836,11 +836,11 @@ class Application implements ResetInterface
]);
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
$function = isset($trace[$i]['function']) ? $trace[$i]['function'] : '';
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
$class = $trace[$i]['class'] ?? '';
$type = $trace[$i]['type'] ?? '';
$function = $trace[$i]['function'] ?? '';
$file = $trace[$i]['file'] ?? 'n/a';
$line = $trace[$i]['line'] ?? 'n/a';
$output->writeln(sprintf(' %s%s at <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
}

View File

@ -80,7 +80,7 @@ class ApplicationDescription
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
}
return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
return $this->commands[$name] ?? $this->aliases[$name];
}
private function inspectApplication()

View File

@ -63,7 +63,7 @@ class JsonDescriptor extends Descriptor
*/
protected function describeApplication(Application $application, array $options = [])
{
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
$describedNamespace = $options['namespace'] ?? null;
$description = new ApplicationDescription($application, $describedNamespace, true);
$commands = [];
@ -95,7 +95,7 @@ class JsonDescriptor extends Descriptor
*/
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));
}

View File

@ -147,7 +147,7 @@ class MarkdownDescriptor extends Descriptor
*/
protected function describeApplication(Application $application, array $options = [])
{
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
$describedNamespace = $options['namespace'] ?? null;
$description = new ApplicationDescription($application, $describedNamespace);
$title = $this->getApplicationTitle($application);

View File

@ -39,7 +39,7 @@ class TextDescriptor extends Descriptor
$default = '';
}
$totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
$totalWidth = $options['total_width'] ?? Helper::strlen($argument->getName());
$spacingWidth = $totalWidth - \strlen($argument->getName());
$this->writeText(sprintf(' <info>%s</info> %s%s%s',
@ -71,7 +71,7 @@ class TextDescriptor extends Descriptor
}
}
$totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions([$option]);
$totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
$synopsis = sprintf('%s%s',
$option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
sprintf('--%s%s', $option->getName(), $value)
@ -176,7 +176,7 @@ class TextDescriptor extends Descriptor
*/
protected function describeApplication(Application $application, array $options = [])
{
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
$describedNamespace = $options['namespace'] ?? null;
$description = new ApplicationDescription($application, $describedNamespace);
if (isset($options['raw_text']) && $options['raw_text']) {

View File

@ -152,7 +152,7 @@ class XmlDescriptor extends Descriptor
*/
protected function describeApplication(Application $application, array $options = [])
{
$this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
$this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null));
}
/**

View File

@ -161,7 +161,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
if ($open = '/' != $text[1]) {
$tag = $matches[1][$i][0];
} else {
$tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
$tag = $matches[3][$i][0] ?? '';
}
if (!$open && !$tag) {

View File

@ -113,7 +113,7 @@ final class ProgressBar
self::$formatters = self::initPlaceholderFormatters();
}
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
return self::$formatters[$name] ?? null;
}
/**
@ -146,7 +146,7 @@ final class ProgressBar
self::$formats = self::initFormats();
}
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
return self::$formats[$name] ?? null;
}
/**

View File

@ -142,7 +142,7 @@ class ProgressIndicator
self::$formats = self::initFormats();
}
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
return self::$formats[$name] ?? null;
}
/**
@ -170,7 +170,7 @@ class ProgressIndicator
self::$formatters = self::initPlaceholderFormatters();
}
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
return self::$formatters[$name] ?? null;
}
private function display()

View File

@ -172,13 +172,13 @@ class QuestionHelper extends Helper
$choices = $question->getChoices();
if (!$question->isMultiselect()) {
return isset($choices[$default]) ? $choices[$default] : $default;
return $choices[$default] ?? $default;
}
$default = explode(',', $default);
foreach ($default as $k => $v) {
$v = $question->isTrimmable() ? trim($v) : $v;
$default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
$default[$k] = $choices[$v] ?? $v;
}
}

View File

@ -58,7 +58,7 @@ class SymfonyQuestionHelper extends QuestionHelper
case $question instanceof ChoiceQuestion:
$choices = $question->getChoices();
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
break;

View File

@ -491,7 +491,7 @@ class Table
*/
private function renderCell(array $row, int $column, string $cellFormat): string
{
$cell = isset($row[$column]) ? $row[$column] : '';
$cell = $row[$column] ?? '';
$width = $this->effectiveColumnWidths[$column];
if ($cell instanceof TableCell && $cell->getColspan() > 1) {
// add the width of the following columns(numbers of colspan).
@ -625,7 +625,7 @@ class Table
// create a two dimensional array (rowspan x colspan)
$unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, []), $unmergedRows);
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
$value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
$value = $lines[$unmergedRowKey - $line] ?? '';
$unmergedRows[$unmergedRowKey][$column] = new TableCell($value, ['colspan' => $cell->getColspan()]);
if ($nbLines === $unmergedRowKey - $line) {
break;
@ -763,7 +763,7 @@ class Table
$cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
}
$columnWidth = isset($this->columnWidths[$column]) ? $this->columnWidths[$column] : 0;
$columnWidth = $this->columnWidths[$column] ?? 0;
$cellWidth = max($cellWidth, $columnWidth);
return isset($this->columnMaxWidths[$column]) ? min($this->columnMaxWidths[$column], $cellWidth) : $cellWidth;

View File

@ -110,7 +110,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
}
/**

View File

@ -290,7 +290,7 @@ class SymfonyStyle extends OutputStyle
{
if (null !== $default) {
$values = array_flip($choices);
$default = isset($values[$default]) ? $values[$default] : $default;
$default = $values[$default] ?? $default;
}
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));

View File

@ -139,8 +139,8 @@ trait TesterTrait
}
} else {
$this->output = new ConsoleOutput(
isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL,
isset($options['decorated']) ? $options['decorated'] : null
$options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL,
$options['decorated'] ?? null
);
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));

View File

@ -84,7 +84,7 @@ class Parser implements ParserInterface
}
$split = explode('n', $joined);
$first = isset($split[0]) ? $split[0] : null;
$first = $split[0] ?? null;
return [
$first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1,

View File

@ -479,7 +479,7 @@ class Definition
*/
public function getTag(string $name)
{
return isset($this->tags[$name]) ? $this->tags[$name] : [];
return $this->tags[$name] ?? [];
}
/**

View File

@ -559,7 +559,7 @@ class YamlFileLoader extends FileLoader
}
}
$tags = isset($service['tags']) ? $service['tags'] : [];
$tags = $service['tags'] ?? [];
if (!\is_array($tags)) {
throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file));
}
@ -615,8 +615,8 @@ class YamlFileLoader extends FileLoader
throw new InvalidArgumentException(sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean "exception", "ignore" or null in "%s"?', $decorationOnInvalid, $id, $file));
}
$renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null;
$priority = isset($service['decoration_priority']) ? $service['decoration_priority'] : 0;
$renameId = $service['decoration_inner_name'] ?? null;
$priority = $service['decoration_priority'] ?? 0;
$definition->setDecoratedService($decorates, $renameId, $priority, $invalidBehavior);
}
@ -666,8 +666,8 @@ class YamlFileLoader extends FileLoader
if (!\is_string($service['resource'])) {
throw new InvalidArgumentException(sprintf('A "resource" attribute must be of type string for service "%s" in "%s". Check your YAML syntax.', $id, $file));
}
$exclude = isset($service['exclude']) ? $service['exclude'] : null;
$namespace = isset($service['namespace']) ? $service['namespace'] : $id;
$exclude = $service['exclude'] ?? null;
$namespace = $service['namespace'] ?? $id;
$this->registerClasses($definition, $namespace, $service['resource'], $exclude);
} else {
$this->setDefinition($id, $definition);
@ -841,7 +841,7 @@ class YamlFileLoader extends FileLoader
$instanceof = $this->instanceof;
$this->instanceof = [];
$id = sprintf('.%d_%s', ++$this->anonymousServicesCount, preg_replace('/^.*\\\\/', '', isset($argument['class']) ? $argument['class'] : '').$this->anonymousServicesSuffix);
$id = sprintf('.%d_%s', ++$this->anonymousServicesCount, preg_replace('/^.*\\\\/', '', $argument['class'] ?? '').$this->anonymousServicesSuffix);
$this->parseDefinition($id, $argument, $file, []);
if (!$this->container->hasDefinition($id)) {

View File

@ -17,10 +17,10 @@ class ProjectExtension implements ExtensionInterface
}
$configuration->register('project.service.bar', 'FooClass')->setPublic(true);
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
$configuration->setParameter('project.parameter.bar', $config['foo'] ?? 'foobar');
$configuration->register('project.service.foo', 'FooClass')->setPublic(true);
$configuration->setParameter('project.parameter.foo', isset($config['foo']) ? $config['foo'] : 'foobar');
$configuration->setParameter('project.parameter.foo', $config['foo'] ?? 'foobar');
return $configuration;
}

View File

@ -1074,7 +1074,7 @@ class Crawler implements \Countable, \IteratorAggregate
*/
public function getNode(int $position)
{
return isset($this->nodes[$position]) ? $this->nodes[$position] : null;
return $this->nodes[$position] ?? null;
}
/**

View File

@ -312,7 +312,7 @@ final class Dotenv
throw $this->createFormatException('Whitespace are not supported before the value');
}
$loadedVars = array_flip(explode(',', isset($_SERVER['SYMFONY_DOTENV_VARS']) ? $_SERVER['SYMFONY_DOTENV_VARS'] : (isset($_ENV['SYMFONY_DOTENV_VARS']) ? $_ENV['SYMFONY_DOTENV_VARS'] : '')));
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? ($_ENV['SYMFONY_DOTENV_VARS'] ?? '')));
unset($loadedVars['']);
$v = '';

View File

@ -665,7 +665,7 @@ class ErrorHandler
if ($error && $error['type'] &= \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR) {
// Let's not throw anymore but keep logging
$handler->throwAt(0, true);
$trace = isset($error['backtrace']) ? $error['backtrace'] : null;
$trace = $error['backtrace'] ?? null;
if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
$fatalError = new OutOfMemoryError($handler->levels[$error['type']].': '.$error['message'], 0, $error, 2, false, $trace);

View File

@ -300,11 +300,11 @@ class FlattenException
$this->trace[] = [
'namespace' => $namespace,
'short_class' => $class,
'class' => isset($entry['class']) ? $entry['class'] : '',
'type' => isset($entry['type']) ? $entry['type'] : '',
'function' => isset($entry['function']) ? $entry['function'] : null,
'file' => isset($entry['file']) ? $entry['file'] : null,
'line' => isset($entry['line']) ? $entry['line'] : null,
'class' => $entry['class'] ?? '',
'type' => $entry['type'] ?? '',
'function' => $entry['function'] ?? null,
'file' => $entry['file'] ?? null,
'line' => $entry['line'] ?? null,
'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : [],
];
}

View File

@ -83,7 +83,7 @@ class RegisterListenersPass implements CompilerPassInterface
$noPreload = 0;
foreach ($events as $event) {
$priority = isset($event['priority']) ? $event['priority'] : 0;
$priority = $event['priority'] ?? 0;
if (!isset($event['event'])) {
if ($container->getDefinition($id)->hasTag($this->subscriberTag)) {

View File

@ -184,10 +184,10 @@ class EventDispatcher implements EventDispatcherInterface
if (\is_string($params)) {
$this->addListener($eventName, [$subscriber, $params]);
} elseif (\is_string($params[0])) {
$this->addListener($eventName, [$subscriber, $params[0]], isset($params[1]) ? $params[1] : 0);
$this->addListener($eventName, [$subscriber, $params[0]], $params[1] ?? 0);
} else {
foreach ($params as $listener) {
$this->addListener($eventName, [$subscriber, $listener[0]], isset($listener[1]) ? $listener[1] : 0);
$this->addListener($eventName, [$subscriber, $listener[0]], $listener[1] ?? 0);
}
}
}

View File

@ -555,7 +555,7 @@ class Filesystem
} elseif (is_dir($file)) {
$this->mkdir($target);
} elseif (is_file($file)) {
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
$this->copy($file, $target, $options['override'] ?? false);
} else {
throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
}

View File

@ -36,7 +36,7 @@ class DateComparator extends Comparator
throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
}
$operator = isset($matches[1]) ? $matches[1] : '==';
$operator = $matches[1] ?? '==';
if ('since' === $operator || 'after' === $operator) {
$operator = '>';
}

View File

@ -74,6 +74,6 @@ class NumberComparator extends Comparator
}
$this->setTarget($target);
$this->setOperator(isset($matches[1]) ? $matches[1] : '==');
$this->setOperator($matches[1] ?? '==');
}
}

View File

@ -84,9 +84,8 @@ abstract class AbstractExtension implements FormExtensionInterface
$this->initTypeExtensions();
}
return isset($this->typeExtensions[$name])
? $this->typeExtensions[$name]
: [];
return $this->typeExtensions[$name]
?? [];
}
/**

View File

@ -186,7 +186,7 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
$label,
// The attributes may be a callable or a mapping from choice indices
// to nested arrays
\is_callable($attr) ? $attr($choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : [])
\is_callable($attr) ? $attr($choice, $key, $value) : ($attr[$key] ?? [])
);
// $isPreferred may be null if no choices are preferred

View File

@ -95,7 +95,7 @@ class JsonDescriptor extends Descriptor
private function writeData(array $data, array $options)
{
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
$flags = $options['json_encoding'] ?? 0;
$this->output->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n");
}

View File

@ -31,7 +31,7 @@ class CheckboxType extends AbstractType
// transformer handles this case).
// We cannot solve this case via overriding the "data" option, because
// doing so also calls setDataLocked(true).
$builder->setData(isset($options['data']) ? $options['data'] : false);
$builder->setData($options['data'] ?? false);
$builder->addViewTransformer(new BooleanToStringTransformer($options['value'], $options['false_values']));
}

View File

@ -105,7 +105,7 @@ class DateIntervalType extends AbstractType
'required' => $options['required'],
'translation_domain' => $options['translation_domain'],
// when compound the array entries are ignored, we need to cascade the configuration here
'empty_data' => isset($options['empty_data'][$part]) ? $options['empty_data'][$part] : null,
'empty_data' => $options['empty_data'][$part] ?? null,
];
if ('choice' === $options['widget']) {
$childOptions['choice_translation_domain'] = false;

View File

@ -114,7 +114,7 @@ class DateTimeType extends AbstractType
return static function (FormInterface $form) use ($emptyData, $option) {
$emptyData = $emptyData($form->getParent());
return isset($emptyData[$option]) ? $emptyData[$option] : '';
return $emptyData[$option] ?? '';
};
};

View File

@ -88,7 +88,7 @@ class DateType extends AbstractType
return static function (FormInterface $form) use ($emptyData, $option) {
$emptyData = $emptyData($form->getParent());
return isset($emptyData[$option]) ? $emptyData[$option] : '';
return $emptyData[$option] ?? '';
};
};

View File

@ -67,7 +67,7 @@ class TimeType extends AbstractType
if ($options['with_seconds']) {
// handle seconds ignored by user's browser when with_seconds enabled
// https://codereview.chromium.org/450533009/
$e->setData(sprintf('%s:%s:%s', $matches['hours'], $matches['minutes'], isset($matches['seconds']) ? $matches['seconds'] : '00'));
$e->setData(sprintf('%s:%s:%s', $matches['hours'], $matches['minutes'], $matches['seconds'] ?? '00'));
} else {
$e->setData(sprintf('%s:%s', $matches['hours'], $matches['minutes']));
}
@ -101,7 +101,7 @@ class TimeType extends AbstractType
return static function (FormInterface $form) use ($emptyData, $option) {
$emptyData = $emptyData($form->getParent());
return isset($emptyData[$option]) ? $emptyData[$option] : '';
return $emptyData[$option] ?? '';
};
};

View File

@ -286,9 +286,8 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
$hash = spl_object_hash($form);
$output = &$outputByHash[$hash];
$output = isset($this->dataByForm[$hash])
? $this->dataByForm[$hash]
: [];
$output = $this->dataByForm[$hash]
?? [];
$output['children'] = [];
@ -316,16 +315,14 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
$output = &$outputByHash[$formHash];
}
$output = isset($this->dataByView[$viewHash])
? $this->dataByView[$viewHash]
: [];
$output = $this->dataByView[$viewHash]
?? [];
if (null !== $formHash) {
$output = array_replace(
$output,
isset($this->dataByForm[$formHash])
? $this->dataByForm[$formHash]
: []
$this->dataByForm[$formHash]
?? []
);
}

View File

@ -138,8 +138,8 @@ class FormDataExtractor implements FormDataExtractorInterface
public function extractViewVariables(FormView $view)
{
$data = [
'id' => isset($view->vars['id']) ? $view->vars['id'] : null,
'name' => isset($view->vars['name']) ? $view->vars['name'] : null,
'id' => $view->vars['id'] ?? null,
'name' => $view->vars['name'] ?? null,
'view_vars' => [],
];

View File

@ -60,7 +60,7 @@ class MappingRule
{
$length = \strlen($propertyPath);
$prefix = substr($this->propertyPath, 0, $length);
$next = isset($this->propertyPath[$length]) ? $this->propertyPath[$length] : null;
$next = $this->propertyPath[$length] ?? null;
return $prefix === $propertyPath && ('[' === $next || '.' === $next);
}

View File

@ -174,7 +174,7 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface
if (\count($this->typeGuessers) > 1) {
$typeGuesser = new FormTypeGuesserChain($this->typeGuessers);
} else {
$typeGuesser = isset($this->typeGuessers[0]) ? $this->typeGuessers[0] : null;
$typeGuesser = $this->typeGuessers[0] ?? null;
}
$extensions[] = new PreloadedExtension($this->types, $this->typeExtensions, $typeGuesser);

View File

@ -65,9 +65,8 @@ class PreloadedExtension implements FormExtensionInterface
*/
public function getTypeExtensions(string $name)
{
return isset($this->typeExtensions[$name])
? $this->typeExtensions[$name]
: [];
return $this->typeExtensions[$name]
?? [];
}
/**

View File

@ -100,7 +100,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
}
// Should be decoupled from the specific option at some point
$dataClass = isset($options['data_class']) ? $options['data_class'] : null;
$dataClass = $options['data_class'] ?? null;
$builder = $this->newBuilder($name, $dataClass, $factory, $options);
$builder->setType($this);

View File

@ -51,7 +51,7 @@ class CallbackChoiceLoaderTest extends TestCase
return self::$choices;
});
self::$value = function ($choice) {
return isset($choice->value) ? $choice->value : null;
return $choice->value ?? null;
};
self::$choices = [
(object) ['value' => 'choice_one'],

View File

@ -78,7 +78,7 @@ class ViolationMapperTest extends TestCase
$config = new FormConfigBuilder($name, $dataClass, $this->dispatcher, [
'error_mapping' => $errorMapping,
] + $options);
$config->setMapped(isset($options['mapped']) ? $options['mapped'] : true);
$config->setMapped($options['mapped'] ?? true);
$config->setInheritData($inheritData);
$config->setPropertyPath($propertyPath);
$config->setCompound(true);

View File

@ -36,7 +36,7 @@ class TestExtension implements FormExtensionInterface
public function getType($name): FormTypeInterface
{
return isset($this->types[$name]) ? $this->types[$name] : null;
return $this->types[$name] ?? null;
}
public function hasType($name): bool
@ -57,7 +57,7 @@ class TestExtension implements FormExtensionInterface
public function getTypeExtensions($name): array
{
return isset($this->extensions[$name]) ? $this->extensions[$name] : [];
return $this->extensions[$name] ?? [];
}
public function hasTypeExtensions($name): bool

View File

@ -146,7 +146,7 @@ class AcceptHeaderItem
*/
public function getAttribute(string $name, $default = null)
{
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
return $this->attributes[$name] ?? $default;
}
/**

View File

@ -278,7 +278,7 @@ class UploadedFile extends File
$errorCode = $this->error;
$maxFilesize = \UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';
$message = $errors[$errorCode] ?? 'The file "%s" was not uploaded due to an unknown error.';
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
}

View File

@ -1295,7 +1295,7 @@ class Request
static::initializeFormats();
}
return isset(static::$formats[$format]) ? static::$formats[$format] : [];
return static::$formats[$format] ?? [];
}
/**
@ -1588,7 +1588,7 @@ class Request
$preferredLanguages = $this->getLanguages();
if (empty($locales)) {
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null;
return $preferredLanguages[0] ?? null;
}
if (!$preferredLanguages) {
@ -1608,7 +1608,7 @@ class Request
$preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
return $preferredLanguages[0] ?? $locales[0];
}
/**

View File

@ -470,7 +470,7 @@ class Response
}
if (null === $text) {
$this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : 'unknown status';
$this->statusText = self::$statusTexts[$code] ?? 'unknown status';
return $this;
}

View File

@ -38,7 +38,7 @@ class ServerBag extends ParameterBag
if (isset($this->parameters['PHP_AUTH_USER'])) {
$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
$headers['PHP_AUTH_PW'] = $this->parameters['PHP_AUTH_PW'] ?? '';
} else {
/*
* php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default

View File

@ -51,7 +51,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
}
$this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
$this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
$this->prefix = $options['prefix'] ?? 'sf2s';
}
/**

View File

@ -185,15 +185,15 @@ class PdoSessionHandler extends AbstractSessionHandler
$this->dsn = $pdoOrDsn;
}
$this->table = isset($options['db_table']) ? $options['db_table'] : $this->table;
$this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol;
$this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol;
$this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol;
$this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol;
$this->username = isset($options['db_username']) ? $options['db_username'] : $this->username;
$this->password = isset($options['db_password']) ? $options['db_password'] : $this->password;
$this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions;
$this->lockMode = isset($options['lock_mode']) ? $options['lock_mode'] : $this->lockMode;
$this->table = $options['db_table'] ?? $this->table;
$this->idCol = $options['db_id_col'] ?? $this->idCol;
$this->dataCol = $options['db_data_col'] ?? $this->dataCol;
$this->lifetimeCol = $options['db_lifetime_col'] ?? $this->lifetimeCol;
$this->timeCol = $options['db_time_col'] ?? $this->timeCol;
$this->username = $options['db_username'] ?? $this->username;
$this->password = $options['db_password'] ?? $this->password;
$this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
$this->lockMode = $options['lock_mode'] ?? $this->lockMode;
}
/**
@ -479,7 +479,7 @@ class PdoSessionHandler extends AbstractSessionHandler
'sqlite3' => 'sqlite',
];
$driver = isset($driverAliasMap[$params['scheme']]) ? $driverAliasMap[$params['scheme']] : $params['scheme'];
$driver = $driverAliasMap[$params['scheme']] ?? $params['scheme'];
// Doctrine DBAL supports passing its internal pdo_* driver names directly too (allowing both dashes and underscores). This allows supporting the same here.
if (0 === strpos($driver, 'pdo_') || 0 === strpos($driver, 'pdo-')) {

View File

@ -242,7 +242,7 @@ class MockArraySessionStorage implements SessionStorageInterface
foreach ($bags as $bag) {
$key = $bag->getStorageKey();
$this->data[$key] = isset($this->data[$key]) ? $this->data[$key] : [];
$this->data[$key] = $this->data[$key] ?? [];
$bag->initialize($this->data[$key]);
}

View File

@ -180,7 +180,7 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
*/
public function getPhpVersionExtra()
{
return isset($this->data['php_version_extra']) ? $this->data['php_version_extra'] : null;
return $this->data['php_version_extra'] ?? null;
}
/**

View File

@ -79,32 +79,32 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
public function getLogs()
{
return isset($this->data['logs']) ? $this->data['logs'] : [];
return $this->data['logs'] ?? [];
}
public function getPriorities()
{
return isset($this->data['priorities']) ? $this->data['priorities'] : [];
return $this->data['priorities'] ?? [];
}
public function countErrors()
{
return isset($this->data['error_count']) ? $this->data['error_count'] : 0;
return $this->data['error_count'] ?? 0;
}
public function countDeprecations()
{
return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0;
return $this->data['deprecation_count'] ?? 0;
}
public function countWarnings()
{
return isset($this->data['warning_count']) ? $this->data['warning_count'] : 0;
return $this->data['warning_count'] ?? 0;
}
public function countScreams()
{
return isset($this->data['scream_count']) ? $this->data['scream_count'] : 0;
return $this->data['scream_count'] ?? 0;
}
public function getCompilerLogs()

View File

@ -86,7 +86,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
'format' => $request->getRequestFormat(),
'content' => $content,
'content_type' => $response->headers->get('Content-Type', 'text/html'),
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '',
'status_text' => Response::$statusTexts[$statusCode] ?? '',
'status_code' => $statusCode,
'request_query' => $request->query->all(),
'request_request' => $request->request->all(),
@ -337,12 +337,12 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
*/
public function getRedirect()
{
return isset($this->data['redirect']) ? $this->data['redirect'] : false;
return $this->data['redirect'] ?? false;
}
public function getForwardToken()
{
return isset($this->data['forward_token']) ? $this->data['forward_token'] : null;
return $this->data['forward_token'] ?? null;
}
public function onKernelController(ControllerEvent $event)

View File

@ -116,7 +116,7 @@ class RouterListener implements EventSubscriberInterface
if (null !== $this->logger) {
$this->logger->info('Matched route "{route}".', [
'route' => isset($parameters['_route']) ? $parameters['_route'] : 'n/a',
'route' => $parameters['_route'] ?? 'n/a',
'route_parameters' => $parameters,
'request_uri' => $request->getUri(),
'method' => $request->getMethod(),

View File

@ -71,12 +71,12 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
$uri = $this->generateSignedFragmentUri($uri, $request);
}
$alt = isset($options['alt']) ? $options['alt'] : null;
$alt = $options['alt'] ?? null;
if ($alt instanceof ControllerReference) {
$alt = $this->generateSignedFragmentUri($alt, $request);
}
$tag = $this->surrogate->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : '');
$tag = $this->surrogate->renderIncludeTag($uri, $alt, $options['ignore_errors'] ?? false, $options['comment'] ?? '');
return new Response($tag);
}

View File

@ -73,7 +73,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
$uri = str_replace('&', '&amp;', $uri);
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
$template = $options['default'] ?? $this->globalDefaultTemplate;
if (null !== $this->twig && $template && $this->twig->getLoader()->exists($template)) {
$content = $this->twig->render($template);
} else {

View File

@ -97,7 +97,7 @@ class Esi extends AbstractSurrogate
$chunks[$i] = sprintf('<?php echo $this->surrogate->handle($this, %s, %s, %s) ?>'."\n",
var_export($options['src'], true),
var_export(isset($options['alt']) ? $options['alt'] : '', true),
var_export($options['alt'] ?? '', true),
isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false'
);
++$i;

View File

@ -277,8 +277,8 @@ class Store implements StoreInterface
foreach (preg_split('/[\s,]+/', $vary) as $header) {
$key = str_replace('_', '-', strtolower($header));
$v1 = isset($env1[$key]) ? $env1[$key] : null;
$v2 = isset($env2[$key]) ? $env2[$key] : null;
$v1 = $env1[$key] ?? null;
$v2 = $env2[$key] ?? null;
if ($v1 !== $v2) {
return false;
}

View File

@ -43,7 +43,7 @@ class Logger extends AbstractLogger
$minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) {
switch ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {
case -1: $minLevel = LogLevel::ERROR; break;
case 1: $minLevel = LogLevel::NOTICE; break;
case 2: $minLevel = LogLevel::INFO; break;

View File

@ -99,12 +99,12 @@ class UriSigner
$url['query'] = http_build_query($params, '', '&');
$scheme = isset($url['scheme']) ? $url['scheme'].'://' : '';
$host = isset($url['host']) ? $url['host'] : '';
$host = $url['host'] ?? '';
$port = isset($url['port']) ? ':'.$url['port'] : '';
$user = isset($url['user']) ? $url['user'] : '';
$user = $url['user'] ?? '';
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
$pass = ($user || $pass) ? "$pass@" : '';
$path = isset($url['path']) ? $url['path'] : '';
$path = $url['path'] ?? '';
$query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : '';
$fragment = isset($url['fragment']) ? '#'.$url['fragment'] : '';

View File

@ -114,7 +114,7 @@ abstract class Collator
self::SORT_STRING => \SORT_STRING,
];
$plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR;
$plainSortFlag = $intlToPlainFlagMap[$sortFlag] ?? self::SORT_REGULAR;
return asort($array, $plainSortFlag);
}

View File

@ -298,15 +298,15 @@ class FullTransformer
private function getDefaultValueForOptions(array $options): array
{
return [
'year' => isset($options['year']) ? $options['year'] : 1970,
'month' => isset($options['month']) ? $options['month'] : 1,
'day' => isset($options['day']) ? $options['day'] : 1,
'hour' => isset($options['hour']) ? $options['hour'] : 0,
'hourInstance' => isset($options['hourInstance']) ? $options['hourInstance'] : null,
'minute' => isset($options['minute']) ? $options['minute'] : 0,
'second' => isset($options['second']) ? $options['second'] : 0,
'marker' => isset($options['marker']) ? $options['marker'] : null,
'timezone' => isset($options['timezone']) ? $options['timezone'] : null,
'year' => $options['year'] ?? 1970,
'month' => $options['month'] ?? 1,
'day' => $options['day'] ?? 1,
'hour' => $options['hour'] ?? 0,
'hourInstance' => $options['hourInstance'] ?? null,
'minute' => $options['minute'] ?? 0,
'second' => $options['second'] ?? 0,
'marker' => $options['marker'] ?? null,
'timezone' => $options['timezone'] ?? null,
];
}
}

View File

@ -394,7 +394,7 @@ abstract class NumberFormatter
*/
public function getAttribute(int $attr)
{
return isset($this->attributes[$attr]) ? $this->attributes[$attr] : null;
return $this->attributes[$attr] ?? null;
}
/**

View File

@ -101,7 +101,7 @@ class Collection implements CollectionInterface
{
$this->toArray();
return isset($this->entries[$offset]) ? $this->entries[$offset] : null;
return $this->entries[$offset] ?? null;
}
public function offsetSet($offset, $value)

View File

@ -59,7 +59,7 @@ class Entry
*/
public function getAttribute(string $name)
{
return isset($this->attributes[$name]) ? $this->attributes[$name] : null;
return $this->attributes[$name] ?? null;
}
/**

View File

@ -754,7 +754,7 @@ class Process implements \IteratorAggregate
return null;
}
return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
return self::$exitCodes[$exitcode] ?? 'Unknown error';
}
/**

View File

@ -113,9 +113,9 @@ class YamlFileLoader extends FileLoader
*/
protected function parseRoute(RouteCollection $collection, string $name, array $config, string $path)
{
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
$options = isset($config['options']) ? $config['options'] : [];
$defaults = $config['defaults'] ?? [];
$requirements = $config['requirements'] ?? [];
$options = $config['options'] ?? [];
foreach ($requirements as $placeholder => $requirement) {
if (\is_int($placeholder)) {
@ -161,15 +161,15 @@ class YamlFileLoader extends FileLoader
*/
protected function parseImport(RouteCollection $collection, array $config, string $path, string $file)
{
$type = isset($config['type']) ? $config['type'] : null;
$prefix = isset($config['prefix']) ? $config['prefix'] : '';
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
$options = isset($config['options']) ? $config['options'] : [];
$host = isset($config['host']) ? $config['host'] : null;
$condition = isset($config['condition']) ? $config['condition'] : null;
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
$methods = isset($config['methods']) ? $config['methods'] : null;
$type = $config['type'] ?? null;
$prefix = $config['prefix'] ?? '';
$defaults = $config['defaults'] ?? [];
$requirements = $config['requirements'] ?? [];
$options = $config['options'] ?? [];
$host = $config['host'] ?? null;
$condition = $config['condition'] ?? null;
$schemes = $config['schemes'] ?? null;
$methods = $config['methods'] ?? null;
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true;
$namePrefix = $config['name_prefix'] ?? null;
$exclude = $config['exclude'] ?? null;

Some files were not shown because too many files have changed in this diff Show More