Skip to content

Commit 22f5460

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: CS: Apply ternary_to_null_coalescing fixer
2 parents a1f6218 + fe1eccf commit 22f5460

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

AcceptHeaderItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function hasAttribute(string $name)
146146
*/
147147
public function getAttribute(string $name, $default = null)
148148
{
149-
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
149+
return $this->attributes[$name] ?? $default;
150150
}
151151

152152
/**

File/UploadedFile.php

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

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

283283
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
284284
}

Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ public static function getMimeTypes(string $format)
13221322
static::initializeFormats();
13231323
}
13241324

1325-
return isset(static::$formats[$format]) ? static::$formats[$format] : [];
1325+
return static::$formats[$format] ?? [];
13261326
}
13271327

13281328
/**
@@ -1645,7 +1645,7 @@ public function getPreferredLanguage(array $locales = null)
16451645
$preferredLanguages = $this->getLanguages();
16461646

16471647
if (empty($locales)) {
1648-
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null;
1648+
return $preferredLanguages[0] ?? null;
16491649
}
16501650

16511651
if (!$preferredLanguages) {
@@ -1665,7 +1665,7 @@ public function getPreferredLanguage(array $locales = null)
16651665

16661666
$preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
16671667

1668-
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
1668+
return $preferredLanguages[0] ?? $locales[0];
16691669
}
16701670

16711671
/**

Response.php

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

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

475475
return $this;
476476
}

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)