Skip to content

Commit

Permalink
Simplify code using no_unneeded_control_parentheses rule (#44981)
Browse files Browse the repository at this point in the history
Co-authored-by: Harald Leithner <[email protected]>
  • Loading branch information
joomdonation and HLeithner authored Feb 26, 2025
1 parent 40daa53 commit 26d8886
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
'native_function_invocation' => ['include' => ['@compiler_optimized']],
// Adds null to type declarations when parameter have a default null value
'nullable_type_declaration_for_default_null_value' => true,
// Removes unneeded parentheses around control statements
'no_unneeded_control_parentheses' => true,
// Using isset($var) && multiple times should be done in one call.
'combine_consecutive_issets' => true,
// Calling unset on multiple items should be done in one call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public static function canCheckinItem($extensionName, $typeName, $itemId)

$userId = Factory::getUser()->id;

return ($item->{$checkedOutFieldName} == $userId || $item->{$checkedOutFieldName} == 0);
return $item->{$checkedOutFieldName} == $userId || $item->{$checkedOutFieldName} == 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function allowAdd($data = [])
{
$user = $this->app->getIdentity();

return ($user->authorise('core.create', $this->extension) || \count($user->getAuthorisedCategories($this->extension, 'core.create')));
return $user->authorise('core.create', $this->extension) || \count($user->getAuthorisedCategories($this->extension, 'core.create'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getContexts(): array
*/
protected function getTableNameForSection(?string $section = null)
{
return ($section === 'category' ? 'categories' : 'contact_details');
return $section === 'category' ? 'categories' : 'contact_details';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function loadChangelog()

$output = $model->loadChangelog($eid, $source);

echo (new JsonResponse($output));
echo new JsonResponse($output);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ public function checkNewName()
->bind(':name', $name);
$db->setQuery($query);

return ($db->loadResult() == 0);
return $db->loadResult() == 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GroupController extends FormController
*/
protected function allowSave($data, $key = 'id')
{
return ($this->app->getIdentity()->authorise('core.admin', $this->option) && parent::allowSave($data, $key));
return $this->app->getIdentity()->authorise('core.admin', $this->option) && parent::allowSave($data, $key);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LevelController extends FormController
*/
protected function allowSave($data, $key = 'id')
{
return ($this->app->getIdentity()->authorise('core.admin', $this->option) && parent::allowSave($data, $key));
return $this->app->getIdentity()->authorise('core.admin', $this->option) && parent::allowSave($data, $key);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ protected function allowEdit($data = [], $key = 'id')

// Fallback on edit.own.
if ($user->authorise('core.edit.own', $this->option . '.category.' . $categoryId)) {
return ($record->created_by === $user->id);
return $record->created_by === $user->id;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/helpers/icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ public static function print_screen($article, $params, $attribs = [], $legacy =
*/
private static function getIcon()
{
return (new \Joomla\Component\Content\Administrator\Service\HTML\Icon(Joomla\CMS\Factory::getApplication()));
return new \Joomla\Component\Content\Administrator\Service\HTML\Icon(Joomla\CMS\Factory::getApplication());
}
}
2 changes: 1 addition & 1 deletion components/com_finder/src/Model/SearchModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ protected function populateState($ordering = null, $direction = null)
$this->setState('list.ordering', 'l.sale_price');
break;

case ($order === 'relevance' && !empty($this->includedTerms)):
case $order === 'relevance' && !empty($this->includedTerms):
$this->setState('list.ordering', 'm.weight');
break;

Expand Down
2 changes: 1 addition & 1 deletion components/com_finder/src/View/Search/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected function getLayoutFile($layout = null)
$filetofind = $this->_createFileName('template', ['name' => $file]);
$exists = Path::find($this->_path['template'], $filetofind);

return ($exists ? $layout : 'result');
return $exists ? $layout : 'result';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Client/FtpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function connect($host = '127.0.0.1', $port = 21)
*/
public function isConnected()
{
return ($this->_conn);
return $this->_conn;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Console/SetConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function getOptions()
*/
public function getInitialConfigurationOptions(): Registry
{
return (new Registry(new \JConfig()));
return new Registry(new \JConfig());
}


Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Helper/UserGroupsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getAll()
*/
public function has($id)
{
return (\array_key_exists($id, $this->groups) && $this->groups[$id] !== false);
return \array_key_exists($id, $this->groups) && $this->groups[$id] !== false;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ public function getOrientation()
private static function getOrientationString(int $width, int $height): string
{
switch (true) {
case ($width > $height):
case $width > $height:
return self::ORIENTATION_LANDSCAPE;

case ($width < $height):
case $width < $height:
return self::ORIENTATION_PORTRAIT;

default:
Expand Down

0 comments on commit 26d8886

Please sign in to comment.