Skip to content

Commit ffe1acf

Browse files
janschoenherrjoomdonationQuyTon
authored
[5.4] Remove pointless boolean expressions (joomla#44885)
* [5.3] Remove pointless boolean expressions Co-authored-by: Tuan Pham Ngoc <[email protected]> Co-authored-by: Quy Ton <[email protected]>
1 parent 0203709 commit ffe1acf

File tree

61 files changed

+93
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+93
-100
lines changed

administrator/components/com_associations/src/Model/AssociationsModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ protected function getListQuery()
328328
}
329329

330330
// If component item type supports access level, select the access level also.
331-
if (\array_key_exists('acl', $support) && $support['acl'] == true && !empty($fields['access'])) {
331+
if (\array_key_exists('acl', $support) && $support['acl'] && !empty($fields['access'])) {
332332
$query->select($db->quoteName($fields['access'], 'access'));
333333

334334
// Join over the access levels.

administrator/components/com_categories/src/Model/CategoriesModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public function getItems()
455455
{
456456
$items = parent::getItems();
457457

458-
if ($items != false) {
458+
if ($items) {
459459
$extension = $this->getState('filter.extension');
460460

461461
$this->countItems($items, $extension);

administrator/components/com_config/src/Model/ApplicationModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,11 @@ public function save($data)
585585
}
586586

587587
// Give a warning if the cache-folder can not be opened
588-
if ($data['caching'] > 0 && $data['cache_handler'] == 'file' && @opendir($path) == false) {
588+
if ($data['caching'] > 0 && $data['cache_handler'] == 'file' && @opendir($path) === false) {
589589
$error = true;
590590

591591
// If a custom path is in use, try using the system default instead of disabling cache
592-
if ($path !== JPATH_CACHE && @opendir(JPATH_CACHE) != false) {
592+
if ($path !== JPATH_CACHE && @opendir(JPATH_CACHE) !== false) {
593593
try {
594594
Log::add(
595595
Text::sprintf('COM_CONFIG_ERROR_CUSTOM_CACHE_PATH_NOTWRITABLE_USING_DEFAULT', $path, JPATH_CACHE),

administrator/components/com_content/src/Model/ArticleModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ public function save($data)
708708
$check = $input->post->get('jform', [], 'array');
709709

710710
foreach ($data['urls'] as $i => $url) {
711-
if ($url != false && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
711+
if (trim($url) !== '' && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
712712
if (preg_match('~^#[a-zA-Z]{1}[a-zA-Z0-9-_:.]*$~', $check['urls'][$i]) == 1) {
713713
$data['urls'][$i] = $check['urls'][$i];
714714
} else {

administrator/components/com_finder/src/Service/HTML/Query.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public static function explained(IndexerQuery $query)
4141

4242
// Process the required tokens.
4343
foreach ($query->included as $token) {
44-
if ($token->required && (!isset($token->derived) || $token->derived == false)) {
44+
if ($token->required && (!isset($token->derived) || !$token->derived)) {
4545
$parts[] = '<span class="query-required">' . Text::sprintf('COM_FINDER_QUERY_TOKEN_REQUIRED', $token->term) . '</span>';
4646
}
4747
}
4848

4949
// Process the optional tokens.
5050
foreach ($query->included as $token) {
51-
if (!$token->required && (!isset($token->derived) || $token->derived == false)) {
51+
if (!$token->required && (!isset($token->derived) || !$token->derived)) {
5252
$parts[] = '<span class="query-optional">' . Text::sprintf('COM_FINDER_QUERY_TOKEN_OPTIONAL', $token->term) . '</span>';
5353
}
5454
}

administrator/components/com_installer/src/Model/UpdateModel.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,13 +533,6 @@ public function getForm($data = [], $loadData = true)
533533
Form::addFieldPath(JPATH_COMPONENT . '/models/fields');
534534
$form = Form::getInstance('com_installer.update', 'update', ['load_data' => $loadData]);
535535

536-
// Check for an error.
537-
if ($form == false) {
538-
$this->setError($form->getMessage());
539-
540-
return false;
541-
}
542-
543536
// Check the session for previously entered form data.
544537
$data = $this->loadFormData();
545538

administrator/components/com_menus/src/Field/MenuItemByTypeField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
149149
{
150150
$result = parent::setup($element, $value, $group);
151151

152-
if ($result == true) {
152+
if ($result) {
153153
$menuType = (string) $this->element['menu_type'];
154154

155155
if (!$menuType) {

administrator/components/com_menus/src/Model/ItemModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
11461146
// If an XML file was found in the component, load it first.
11471147
// We need to qualify the full path to avoid collisions with component file names.
11481148

1149-
if ($form->loadFile($formFile, true, '/metadata') == false) {
1149+
if (!$form->loadFile($formFile, true, '/metadata')) {
11501150
throw new \Exception(Text::_('JERROR_LOADFILE_FAILED'));
11511151
}
11521152

administrator/components/com_redirect/src/Model/LinkModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getForm($data = [], $loadData = true)
7272
}
7373

7474
// Modify the form based on access controls.
75-
if ($this->canEditState((object) $data) != true) {
75+
if (!$this->canEditState((object)$data)) {
7676
// Disable fields for display.
7777
$form->setFieldAttribute('published', 'disabled', 'true');
7878

@@ -83,7 +83,7 @@ public function getForm($data = [], $loadData = true)
8383

8484
// If in advanced mode then we make sure the new URL field is not compulsory and the header
8585
// field compulsory in case people select non-3xx redirects
86-
if (ComponentHelper::getParams('com_redirect')->get('mode', 0) == true) {
86+
if (ComponentHelper::getParams('com_redirect')->get('mode', 0)) {
8787
$form->setFieldAttribute('new_url', 'required', 'false');
8888
$form->setFieldAttribute('header', 'required', 'true');
8989
}

administrator/components/com_redirect/src/Table/LinkTable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ public function check()
7474
}
7575

7676
// Check for valid name if not in advanced mode.
77-
if (empty($this->new_url) && ComponentHelper::getParams('com_redirect')->get('mode', 0) == false) {
77+
if (empty($this->new_url) && !ComponentHelper::getParams('com_redirect')->get('mode', 0)) {
7878
$this->setError(Text::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));
7979

8080
return false;
8181
}
8282

83-
if (empty($this->new_url) && ComponentHelper::getParams('com_redirect')->get('mode', 0) == true) {
83+
if (empty($this->new_url) && ComponentHelper::getParams('com_redirect')->get('mode', 0)) {
8484
// Else if an empty URL and in redirect mode only throw the same error if the code is a 3xx status code
8585
if ($this->header < 400 && $this->header >= 300) {
8686
$this->setError(Text::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));

0 commit comments

Comments
 (0)