SCA: simplify some ifs in favour of null coalescing operator
This commit is contained in:
parent
76b2541468
commit
0180cb936f
@ -283,11 +283,7 @@ class SecurityExtension extends Extension
|
||||
$contextKey = null;
|
||||
// Context serializer listener
|
||||
if (false === $firewall['stateless']) {
|
||||
$contextKey = $id;
|
||||
if (isset($firewall['context'])) {
|
||||
$contextKey = $firewall['context'];
|
||||
}
|
||||
|
||||
$contextKey = $firewall['context'] ?? $id;
|
||||
$listeners[] = new Reference($this->createContextListener($container, $contextKey));
|
||||
$sessionStrategyId = 'security.authentication.session_strategy';
|
||||
} else {
|
||||
|
@ -180,11 +180,7 @@ class Table
|
||||
*/
|
||||
public function getColumnStyle($columnIndex)
|
||||
{
|
||||
if (isset($this->columnStyles[$columnIndex])) {
|
||||
return $this->columnStyles[$columnIndex];
|
||||
}
|
||||
|
||||
return $this->getStyle();
|
||||
return $this->columnStyles[$columnIndex] ?? $this->getStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,12 +54,12 @@ class Filesystem
|
||||
|
||||
if ($doCopy) {
|
||||
// https://bugs.php.net/bug.php?id=64634
|
||||
if (false === $source = @fopen($originFile, 'r')) {
|
||||
if (false === $source = @fopen($originFile, 'rb')) {
|
||||
throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
|
||||
}
|
||||
|
||||
// Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default
|
||||
if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
|
||||
if (false === $target = @fopen($targetFile, 'wb', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
|
||||
throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
|
||||
}
|
||||
|
||||
@ -557,10 +557,7 @@ class Filesystem
|
||||
}
|
||||
}
|
||||
|
||||
$copyOnWindows = false;
|
||||
if (isset($options['copy_on_windows'])) {
|
||||
$copyOnWindows = $options['copy_on_windows'];
|
||||
}
|
||||
$copyOnWindows = $options['copy_on_windows'] ?? false;
|
||||
|
||||
if (null === $iterator) {
|
||||
$flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
|
||||
@ -650,7 +647,7 @@ class Filesystem
|
||||
|
||||
// Use fopen instead of file_exists as some streams do not support stat
|
||||
// Use mode 'x+' to atomically check existence and create to avoid a TOCTOU vulnerability
|
||||
$handle = @fopen($tmpFile, 'x+');
|
||||
$handle = @fopen($tmpFile, 'x+b');
|
||||
|
||||
// If unsuccessful restart the loop
|
||||
if (false === $handle) {
|
||||
|
@ -100,11 +100,7 @@ abstract class IntlGlobals
|
||||
*/
|
||||
public static function getErrorName($code)
|
||||
{
|
||||
if (isset(self::$errorCodes[$code])) {
|
||||
return self::$errorCodes[$code];
|
||||
}
|
||||
|
||||
return '[BOGUS UErrorCode]';
|
||||
return self::$errorCodes[$code] ?? '[BOGUS UErrorCode]';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,10 +57,6 @@ class SenderLocator implements SenderLocatorInterface
|
||||
if ($interfaceMapping = array_intersect_key($mapping, class_implements($message))) {
|
||||
return current($interfaceMapping);
|
||||
}
|
||||
if (isset($mapping['*'])) {
|
||||
return $mapping['*'];
|
||||
}
|
||||
|
||||
return null;
|
||||
return $mapping['*'] ?? null;
|
||||
}
|
||||
}
|
||||
|
@ -254,10 +254,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
});
|
||||
|
||||
// extract fragment
|
||||
$fragment = '';
|
||||
if (isset($defaults['_fragment'])) {
|
||||
$fragment = $defaults['_fragment'];
|
||||
}
|
||||
$fragment = $defaults['_fragment'] ?? '';
|
||||
|
||||
if (isset($extra['_fragment'])) {
|
||||
$fragment = $extra['_fragment'];
|
||||
|
@ -326,11 +326,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
|
||||
$val = $this->parseXml($subnode, $context);
|
||||
|
||||
if ('item' === $subnode->nodeName && isset($val['@key'])) {
|
||||
if (isset($val['#'])) {
|
||||
$value[$val['@key']] = $val['#'];
|
||||
} else {
|
||||
$value[$val['@key']] = $val;
|
||||
}
|
||||
$value[$val['@key']] = $val['#'] ?? $val;
|
||||
} else {
|
||||
$value[$subnode->nodeName][] = $val;
|
||||
}
|
||||
|
@ -32,11 +32,7 @@ class ClassDiscriminatorMapping
|
||||
|
||||
public function getClassForType(string $type): ?string
|
||||
{
|
||||
if (isset($this->typesMapping[$type])) {
|
||||
return $this->typesMapping[$type];
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->typesMapping[$type] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,11 +25,7 @@ class JsonFileDumper extends FileDumper
|
||||
*/
|
||||
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
if (isset($options['json_encoding'])) {
|
||||
$flags = $options['json_encoding'];
|
||||
} else {
|
||||
$flags = JSON_PRETTY_PRINT;
|
||||
}
|
||||
$flags = $options['json_encoding'] ?? JSON_PRETTY_PRINT;
|
||||
|
||||
return json_encode($messages->all($domain), $flags);
|
||||
}
|
||||
|
Reference in New Issue
Block a user