minor #29009 SCA: simplify some ifs in favour of null coalescing operator (kalessil, vladimir.reznichenko)
This PR was merged into the 4.1 branch. Discussion ---------- SCA: simplify some ifs in favour of null coalescing operator | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Some of ifs were replaced with null coalescing operator in order to simplify control flow. Commits -------636a872389
SCA: reverted code style changesc926b1abd3
SCA: reverted code style changes300b31fa75
SCA: applied requested code style changes0180cb936f
SCA: simplify some ifs in favour of null coalescing operator
This commit is contained in:
commit
d9b4872454
@ -283,11 +283,7 @@ class SecurityExtension extends Extension
|
|||||||
$contextKey = null;
|
$contextKey = null;
|
||||||
// Context serializer listener
|
// Context serializer listener
|
||||||
if (false === $firewall['stateless']) {
|
if (false === $firewall['stateless']) {
|
||||||
$contextKey = $id;
|
$contextKey = $firewall['context'] ?? $id;
|
||||||
if (isset($firewall['context'])) {
|
|
||||||
$contextKey = $firewall['context'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$listeners[] = new Reference($this->createContextListener($container, $contextKey));
|
$listeners[] = new Reference($this->createContextListener($container, $contextKey));
|
||||||
$sessionStrategyId = 'security.authentication.session_strategy';
|
$sessionStrategyId = 'security.authentication.session_strategy';
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,11 +180,7 @@ class Table
|
|||||||
*/
|
*/
|
||||||
public function getColumnStyle($columnIndex)
|
public function getColumnStyle($columnIndex)
|
||||||
{
|
{
|
||||||
if (isset($this->columnStyles[$columnIndex])) {
|
return $this->columnStyles[$columnIndex] ?? $this->getStyle();
|
||||||
return $this->columnStyles[$columnIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->getStyle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -557,10 +557,7 @@ class Filesystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$copyOnWindows = false;
|
$copyOnWindows = $options['copy_on_windows'] ?? false;
|
||||||
if (isset($options['copy_on_windows'])) {
|
|
||||||
$copyOnWindows = $options['copy_on_windows'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $iterator) {
|
if (null === $iterator) {
|
||||||
$flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
|
$flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
|
||||||
|
@ -100,11 +100,7 @@ abstract class IntlGlobals
|
|||||||
*/
|
*/
|
||||||
public static function getErrorName($code)
|
public static function getErrorName($code)
|
||||||
{
|
{
|
||||||
if (isset(self::$errorCodes[$code])) {
|
return self::$errorCodes[$code] ?? '[BOGUS UErrorCode]';
|
||||||
return self::$errorCodes[$code];
|
|
||||||
}
|
|
||||||
|
|
||||||
return '[BOGUS UErrorCode]';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,10 +57,7 @@ class SenderLocator implements SenderLocatorInterface
|
|||||||
if ($interfaceMapping = array_intersect_key($mapping, class_implements($message))) {
|
if ($interfaceMapping = array_intersect_key($mapping, class_implements($message))) {
|
||||||
return current($interfaceMapping);
|
return current($interfaceMapping);
|
||||||
}
|
}
|
||||||
if (isset($mapping['*'])) {
|
|
||||||
return $mapping['*'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return $mapping['*'] ?? null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,10 +254,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
|||||||
});
|
});
|
||||||
|
|
||||||
// extract fragment
|
// extract fragment
|
||||||
$fragment = '';
|
$fragment = $defaults['_fragment'] ?? '';
|
||||||
if (isset($defaults['_fragment'])) {
|
|
||||||
$fragment = $defaults['_fragment'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($extra['_fragment'])) {
|
if (isset($extra['_fragment'])) {
|
||||||
$fragment = $extra['_fragment'];
|
$fragment = $extra['_fragment'];
|
||||||
|
@ -326,11 +326,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
|
|||||||
$val = $this->parseXml($subnode, $context);
|
$val = $this->parseXml($subnode, $context);
|
||||||
|
|
||||||
if ('item' === $subnode->nodeName && isset($val['@key'])) {
|
if ('item' === $subnode->nodeName && isset($val['@key'])) {
|
||||||
if (isset($val['#'])) {
|
$value[$val['@key']] = $val['#'] ?? $val;
|
||||||
$value[$val['@key']] = $val['#'];
|
|
||||||
} else {
|
|
||||||
$value[$val['@key']] = $val;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$value[$subnode->nodeName][] = $val;
|
$value[$subnode->nodeName][] = $val;
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,7 @@ class ClassDiscriminatorMapping
|
|||||||
|
|
||||||
public function getClassForType(string $type): ?string
|
public function getClassForType(string $type): ?string
|
||||||
{
|
{
|
||||||
if (isset($this->typesMapping[$type])) {
|
return $this->typesMapping[$type] ?? null;
|
||||||
return $this->typesMapping[$type];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,11 +25,7 @@ class JsonFileDumper extends FileDumper
|
|||||||
*/
|
*/
|
||||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||||
{
|
{
|
||||||
if (isset($options['json_encoding'])) {
|
$flags = $options['json_encoding'] ?? JSON_PRETTY_PRINT;
|
||||||
$flags = $options['json_encoding'];
|
|
||||||
} else {
|
|
||||||
$flags = JSON_PRETTY_PRINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_encode($messages->all($domain), $flags);
|
return json_encode($messages->all($domain), $flags);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user