Skip to content

Commit ff2d9ba

Browse files
committed
CS: Apply ternary_to_null_coalescing fixer
1 parent 5ebda66 commit ff2d9ba

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

AcceptHeaderItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function hasAttribute($name)
157157
*/
158158
public function getAttribute($name, $default = null)
159159
{
160-
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
160+
return $this->attributes[$name] ?? $default;
161161
}
162162

163163
/**

File/MimeType/MimeTypeExtensionGuesser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,6 @@ public function guess($mimeType)
821821

822822
$lcMimeType = strtolower($mimeType);
823823

824-
return isset($this->defaultExtensions[$lcMimeType]) ? $this->defaultExtensions[$lcMimeType] : null;
824+
return $this->defaultExtensions[$lcMimeType] ?? null;
825825
}
826826
}

File/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function getErrorMessage()
301301

302302
$errorCode = $this->error;
303303
$maxFilesize = \UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
304-
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';
304+
$message = $errors[$errorCode] ?? 'The file "%s" was not uploaded due to an unknown error.';
305305

306306
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
307307
}

Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ public static function getMimeTypes($format)
13011301
static::initializeFormats();
13021302
}
13031303

1304-
return isset(static::$formats[$format]) ? static::$formats[$format] : [];
1304+
return static::$formats[$format] ?? [];
13051305
}
13061306

13071307
/**
@@ -1609,7 +1609,7 @@ public function getPreferredLanguage(array $locales = null)
16091609
$preferredLanguages = $this->getLanguages();
16101610

16111611
if (empty($locales)) {
1612-
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null;
1612+
return $preferredLanguages[0] ?? null;
16131613
}
16141614

16151615
if (!$preferredLanguages) {
@@ -1629,7 +1629,7 @@ public function getPreferredLanguage(array $locales = null)
16291629

16301630
$preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
16311631

1632-
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
1632+
return $preferredLanguages[0] ?? $locales[0];
16331633
}
16341634

16351635
/**

Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public function setStatusCode(int $code, $text = null)
465465
}
466466

467467
if (null === $text) {
468-
$this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : 'unknown status';
468+
$this->statusText = self::$statusTexts[$code] ?? 'unknown status';
469469

470470
return $this;
471471
}

ServerBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getHeaders()
3838

3939
if (isset($this->parameters['PHP_AUTH_USER'])) {
4040
$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
41-
$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
41+
$headers['PHP_AUTH_PW'] = $this->parameters['PHP_AUTH_PW'] ?? '';
4242
} else {
4343
/*
4444
* php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default

Session/Storage/Handler/MemcachedSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(\Memcached $memcached, array $options = [])
5151
}
5252

5353
$this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
54-
$this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
54+
$this->prefix = $options['prefix'] ?? 'sf2s';
5555
}
5656

5757
/**

Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ public function __construct($pdoOrDsn = null, array $options = [])
185185
$this->dsn = $pdoOrDsn;
186186
}
187187

188-
$this->table = isset($options['db_table']) ? $options['db_table'] : $this->table;
189-
$this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol;
190-
$this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol;
191-
$this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol;
192-
$this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol;
193-
$this->username = isset($options['db_username']) ? $options['db_username'] : $this->username;
194-
$this->password = isset($options['db_password']) ? $options['db_password'] : $this->password;
195-
$this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions;
196-
$this->lockMode = isset($options['lock_mode']) ? $options['lock_mode'] : $this->lockMode;
188+
$this->table = $options['db_table'] ?? $this->table;
189+
$this->idCol = $options['db_id_col'] ?? $this->idCol;
190+
$this->dataCol = $options['db_data_col'] ?? $this->dataCol;
191+
$this->lifetimeCol = $options['db_lifetime_col'] ?? $this->lifetimeCol;
192+
$this->timeCol = $options['db_time_col'] ?? $this->timeCol;
193+
$this->username = $options['db_username'] ?? $this->username;
194+
$this->password = $options['db_password'] ?? $this->password;
195+
$this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
196+
$this->lockMode = $options['lock_mode'] ?? $this->lockMode;
197197
}
198198

199199
/**
@@ -479,7 +479,7 @@ private function buildDsnFromUrl(string $dsnOrUrl): string
479479
'sqlite3' => 'sqlite',
480480
];
481481

482-
$driver = isset($driverAliasMap[$params['scheme']]) ? $driverAliasMap[$params['scheme']] : $params['scheme'];
482+
$driver = $driverAliasMap[$params['scheme']] ?? $params['scheme'];
483483

484484
// Doctrine DBAL supports passing its internal pdo_* driver names directly too (allowing both dashes and underscores). This allows supporting the same here.
485485
if (0 === strpos($driver, 'pdo_') || 0 === strpos($driver, 'pdo-')) {

Session/Storage/MockArraySessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ protected function loadSession()
242242

243243
foreach ($bags as $bag) {
244244
$key = $bag->getStorageKey();
245-
$this->data[$key] = isset($this->data[$key]) ? $this->data[$key] : [];
245+
$this->data[$key] = $this->data[$key] ?? [];
246246
$bag->initialize($this->data[$key]);
247247
}
248248

0 commit comments

Comments
 (0)