diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7efeacbdc434a..2e5cc541915e6 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -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 diff --git a/administrator/components/com_associations/src/Helper/AssociationsHelper.php b/administrator/components/com_associations/src/Helper/AssociationsHelper.php index 67c4d0142ebd4..6f591141a919e 100644 --- a/administrator/components/com_associations/src/Helper/AssociationsHelper.php +++ b/administrator/components/com_associations/src/Helper/AssociationsHelper.php @@ -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; } /** diff --git a/administrator/components/com_categories/src/Controller/CategoryController.php b/administrator/components/com_categories/src/Controller/CategoryController.php index a3809aca8f77f..c10bc37a213b8 100644 --- a/administrator/components/com_categories/src/Controller/CategoryController.php +++ b/administrator/components/com_categories/src/Controller/CategoryController.php @@ -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')); } /** diff --git a/administrator/components/com_contact/src/Extension/ContactComponent.php b/administrator/components/com_contact/src/Extension/ContactComponent.php index 7016c7503687a..73d1ed69cde8e 100644 --- a/administrator/components/com_contact/src/Extension/ContactComponent.php +++ b/administrator/components/com_contact/src/Extension/ContactComponent.php @@ -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'; } /** diff --git a/administrator/components/com_installer/src/Controller/ManageController.php b/administrator/components/com_installer/src/Controller/ManageController.php index 27cb7b9cd4656..1cff966e77d0e 100644 --- a/administrator/components/com_installer/src/Controller/ManageController.php +++ b/administrator/components/com_installer/src/Controller/ManageController.php @@ -173,7 +173,7 @@ public function loadChangelog() $output = $model->loadChangelog($eid, $source); - echo (new JsonResponse($output)); + echo new JsonResponse($output); } /** diff --git a/administrator/components/com_templates/src/Model/TemplateModel.php b/administrator/components/com_templates/src/Model/TemplateModel.php index 4b45c793b1be7..52fafd50b8b27 100644 --- a/administrator/components/com_templates/src/Model/TemplateModel.php +++ b/administrator/components/com_templates/src/Model/TemplateModel.php @@ -701,7 +701,7 @@ public function checkNewName() ->bind(':name', $name); $db->setQuery($query); - return ($db->loadResult() == 0); + return $db->loadResult() == 0; } /** diff --git a/administrator/components/com_users/src/Controller/GroupController.php b/administrator/components/com_users/src/Controller/GroupController.php index f3e0d4cb0e5b2..e8a47efc2b232 100644 --- a/administrator/components/com_users/src/Controller/GroupController.php +++ b/administrator/components/com_users/src/Controller/GroupController.php @@ -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); } /** diff --git a/administrator/components/com_users/src/Controller/LevelController.php b/administrator/components/com_users/src/Controller/LevelController.php index f4d36c7a69fa7..a16fc20e4c7eb 100644 --- a/administrator/components/com_users/src/Controller/LevelController.php +++ b/administrator/components/com_users/src/Controller/LevelController.php @@ -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); } /** diff --git a/components/com_contact/src/Controller/ContactController.php b/components/com_contact/src/Controller/ContactController.php index 3f7b94cc8e718..e651119c26e7a 100644 --- a/components/com_contact/src/Controller/ContactController.php +++ b/components/com_contact/src/Controller/ContactController.php @@ -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; diff --git a/components/com_content/helpers/icon.php b/components/com_content/helpers/icon.php index 46d76acccbb77..9906ef941646a 100644 --- a/components/com_content/helpers/icon.php +++ b/components/com_content/helpers/icon.php @@ -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()); } } diff --git a/components/com_finder/src/Model/SearchModel.php b/components/com_finder/src/Model/SearchModel.php index 746585e01c894..959de428f23cf 100644 --- a/components/com_finder/src/Model/SearchModel.php +++ b/components/com_finder/src/Model/SearchModel.php @@ -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; diff --git a/components/com_finder/src/View/Search/HtmlView.php b/components/com_finder/src/View/Search/HtmlView.php index 9178f9deffa21..f9195cda974de 100644 --- a/components/com_finder/src/View/Search/HtmlView.php +++ b/components/com_finder/src/View/Search/HtmlView.php @@ -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'; } /** diff --git a/libraries/src/Client/FtpClient.php b/libraries/src/Client/FtpClient.php index fb94d9b95f269..28be94171e137 100644 --- a/libraries/src/Client/FtpClient.php +++ b/libraries/src/Client/FtpClient.php @@ -344,7 +344,7 @@ public function connect($host = '127.0.0.1', $port = 21) */ public function isConnected() { - return ($this->_conn); + return $this->_conn; } /** diff --git a/libraries/src/Console/SetConfigurationCommand.php b/libraries/src/Console/SetConfigurationCommand.php index b0651581f24f9..e4c86aa1370d1 100644 --- a/libraries/src/Console/SetConfigurationCommand.php +++ b/libraries/src/Console/SetConfigurationCommand.php @@ -205,7 +205,7 @@ public function getOptions() */ public function getInitialConfigurationOptions(): Registry { - return (new Registry(new \JConfig())); + return new Registry(new \JConfig()); } diff --git a/libraries/src/Helper/UserGroupsHelper.php b/libraries/src/Helper/UserGroupsHelper.php index 40a7cc98554df..13693231dc7f1 100644 --- a/libraries/src/Helper/UserGroupsHelper.php +++ b/libraries/src/Helper/UserGroupsHelper.php @@ -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; } /** diff --git a/libraries/src/Image/Image.php b/libraries/src/Image/Image.php index ae75155449c30..a00cf57bfe0dd 100644 --- a/libraries/src/Image/Image.php +++ b/libraries/src/Image/Image.php @@ -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: