Skip to content

Commit d608b7d

Browse files
authored
Changes unneeded null check to ?? operator for libraries (joomla#44918)
1 parent ed3c42b commit d608b7d

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

libraries/src/Application/CMSApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ protected function initialiseApp($options = [])
829829
*/
830830
public function isHttpsForced($clientId = null)
831831
{
832-
$clientId = (int) ($clientId !== null ? $clientId : $this->getClientId());
832+
$clientId = (int) ($clientId ?? $this->getClientId());
833833
$forceSsl = (int) $this->get('force_ssl');
834834

835835
if ($clientId === 0 && $forceSsl === 2) {

libraries/src/HTML/Helpers/Access.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public static function assetgrouplist($name, $selected, $attribs = null, $config
293293
$name,
294294
[
295295
'id' => $config['id'] ?? 'assetgroups_' . (++$count),
296-
'list.attr' => $attribs === null ? 'class="inputbox" size="3"' : $attribs,
296+
'list.attr' => $attribs ?? 'class="inputbox" size="3"',
297297
'list.select' => (int) $selected,
298298
]
299299
);

libraries/src/HTML/Helpers/Bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ public static function addTab($selector, $id, $title): string
849849
{
850850
static $tabLayout = null;
851851

852-
$tabLayout = $tabLayout === null ? new FileLayout('libraries.html.bootstrap.tab.addtab') : $tabLayout;
852+
$tabLayout = $tabLayout ?? new FileLayout('libraries.html.bootstrap.tab.addtab');
853853
$active = (static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active'] == $id) ? ' active' : '';
854854

855855
return $tabLayout->render(['id' => preg_replace('/^[\.#]/', '', $id), 'active' => $active, 'title' => $title]);

libraries/src/Image/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ protected function prepareDimensions($width, $height, $scaleMethod)
10801080
protected function sanitizeHeight($height, $width)
10811081
{
10821082
// If no height was given we will assume it is a square and use the width.
1083-
$height = ($height === null) ? $width : $height;
1083+
$height = $height ?? $width;
10841084

10851085
// If we were given a percentage, calculate the integer value.
10861086
if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $height)) {
@@ -1119,7 +1119,7 @@ protected function sanitizeOffset($offset)
11191119
protected function sanitizeWidth($width, $height)
11201120
{
11211121
// If no width was given we will assume it is a square and use the height.
1122-
$width = ($width === null) ? $height : $width;
1122+
$width = $width ?? $height;
11231123

11241124
// If we were given a percentage, calculate the integer value.
11251125
if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $width)) {

libraries/src/MVC/Model/AdminModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ public function publish(&$pks, $value = 1)
11161116
*/
11171117
$publishedColumnName = $table->getColumnAlias('published');
11181118

1119-
if (property_exists($table, $publishedColumnName) && (isset($table->$publishedColumnName) ? $table->$publishedColumnName : $value) == $value) {
1119+
if (property_exists($table, $publishedColumnName) && ($table->$publishedColumnName ?? $value) == $value) {
11201120
unset($pks[$i]);
11211121
}
11221122
}
@@ -1252,7 +1252,7 @@ public function save($data)
12521252
}
12531253

12541254
$key = $table->getKeyName();
1255-
$pk = (isset($data[$key])) ? $data[$key] : (int) $this->getState($this->getName() . '.id');
1255+
$pk = $data[$key] ?? (int) $this->getState($this->getName() . '.id');
12561256
$isNew = true;
12571257

12581258
// Include the plugins for the save events.

libraries/src/Mail/Mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public function addAttachment($path, $name = '', $encoding = 'base64', $type = '
406406
}
407407

408408
foreach ($path as $key => $file) {
409-
$result = parent::addAttachment($file, isset($name[$key]) ? $name[$key] : '', $encoding, $type, $disposition);
409+
$result = parent::addAttachment($file, $name[$key] ?? '', $encoding, $type, $disposition);
410410
}
411411

412412
// Check for boolean false return if exception handling is disabled

libraries/src/Session/MetadataManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private function createSessionRecord(SessionInterface $session, User $user)
233233
$sessionId = $session->getId();
234234
$userIsGuest = $user->guest;
235235
$userId = $user->id;
236-
$username = $user->username === null ? '' : $user->username;
236+
$username = $user->username ?? '';
237237

238238
$query->bind(':session_id', $sessionId)
239239
->bind(':guest', $userIsGuest, ParameterType::INTEGER)
@@ -290,7 +290,7 @@ private function updateSessionRecord(SessionInterface $session, User $user)
290290
$sessionId = $session->getId();
291291
$userIsGuest = $user->guest;
292292
$userId = $user->id;
293-
$username = $user->username === null ? '' : $user->username;
293+
$username = $user->username ?? '';
294294

295295
$query->bind(':session_id', $sessionId)
296296
->bind(':guest', $userIsGuest, ParameterType::INTEGER)

libraries/src/Table/MenuType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function store($updateNulls = false)
197197
public function delete($pk = null)
198198
{
199199
$k = $this->_tbl_key;
200-
$pk = $pk === null ? $this->$k : $pk;
200+
$pk = $pk ?? $this->$k;
201201

202202
// If no primary key is given, return false.
203203
if ($pk !== null) {
@@ -316,6 +316,6 @@ protected function _getAssetParentId(?Table $table = null, $id = null)
316316
$assetId = $asset->id;
317317
}
318318

319-
return $assetId === null ? parent::_getAssetParentId($table, $id) : $assetId;
319+
return $assetId ?? parent::_getAssetParentId($table, $id);
320320
}
321321
}

libraries/src/Updater/Updater.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private function getUpdateObjectsForSite($updateSite, $minimumStability = self::
305305
'element' => $current_update->element,
306306
'type' => $current_update->type,
307307
'client_id' => $current_update->client_id,
308-
'folder' => isset($current_update->folder) ? $current_update->folder : '',
308+
'folder' => $current_update->folder ?? '',
309309
]
310310
);
311311

@@ -315,7 +315,7 @@ private function getUpdateObjectsForSite($updateSite, $minimumStability = self::
315315
'element' => $current_update->element,
316316
'type' => $current_update->type,
317317
'client_id' => $current_update->client_id,
318-
'folder' => isset($current_update->folder) ? $current_update->folder : '',
318+
'folder' => $current_update->folder ?? '',
319319
]
320320
);
321321

0 commit comments

Comments
 (0)