Skip to content

Commit

Permalink
Remove unnecessary parentheses in site components (#13190)
Browse files Browse the repository at this point in the history
* Remove unnecessary parentheses in site/components

* Insert space, wrongfully removed

* Re-added a pair, for readability as @andrepereiradasilva suggested not to have it ungrouped for readability

* Removed some whitespace, as noted in @shur's comment
  • Loading branch information
frankmayer authored and rdeutz committed Dec 14, 2016
1 parent c27c856 commit 78c7599
Show file tree
Hide file tree
Showing 32 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion components/com_banners/models/banners.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function getListQuery()
$query->where($categoryEquals);
}
}
elseif ((is_array($categoryId)) && (count($categoryId) > 0))
elseif (is_array($categoryId) && (count($categoryId) > 0))
{
$categoryId = ArrayHelper::toInteger($categoryId);
$categoryId = implode(',', $categoryId);
Expand Down
4 changes: 2 additions & 2 deletions components/com_config/model/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ protected function cleanCache($group = null, $client_id = 0)
$dispatcher = JEventDispatcher::getInstance();

$options = array(
'defaultgroup' => ($group) ? $group : (isset($this->option) ? $this->option : JFactory::getApplication()->input->get('option')),
'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'));
'defaultgroup' => $group ? $group : (isset($this->option) ? $this->option : JFactory::getApplication()->input->get('option')),
'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'));

$cache = JCache::getInstance('callback', $options);
$cache->clean();
Expand Down
8 changes: 4 additions & 4 deletions components/com_contact/helpers/legacyrouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function build(&$query, &$segments)
$menuItem = $this->router->menu->getItem($query['Itemid']);
}

$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
$mView = empty($menuItem->query['view']) ? null : $menuItem->query['view'];
$mId = empty($menuItem->query['id']) ? null : $menuItem->query['id'];

if (isset($query['view']))
{
Expand All @@ -86,7 +86,7 @@ public function build(&$query, &$segments)
}

// Are we dealing with a contact that is attached to a menu item?
if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id']))
if (isset($view) && ($mView == $view) and isset($query['id']) and ($mId == (int) $query['id']))
{
unset($query['view'], $query['catid'], $query['id']);

Expand Down Expand Up @@ -221,7 +221,7 @@ public function parse(&$segments, &$vars)

$contactCategory = JCategories::getInstance('Contact')->get($id);

$categories = ($contactCategory) ? $contactCategory->getChildren() : array();
$categories = $contactCategory ? $contactCategory->getChildren() : array();
$vars['catid'] = $id;
$vars['id'] = $id;
$found = 0;
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/models/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function getItem($pk = null)
}

// Check for published state if filter set.
if (((is_numeric($published)) || (is_numeric($archived))) && (($data->state != $published) && ($data->state != $archived)))
if ((is_numeric($published) || is_numeric($archived)) && (($data->state != $published) && ($data->state != $archived)))
{
return JError::raiseError(404, JText::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'));
}
Expand Down Expand Up @@ -330,7 +330,7 @@ public function storeVote($pk = 0, $rate = 0)
}
else
{
if ($userIP != ($rating->lastip))
if ($userIP != $rating->lastip)
{
$query = $db->getQuery(true);

Expand Down
2 changes: 1 addition & 1 deletion components/com_content/models/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ protected function getListQuery()
}

// Process the filter for list views with user-entered filters
if ((is_object($params)) && ($params->get('filter_field') != 'hide') && ($filter = $this->getState('list.filter')))
if (is_object($params) && ($params->get('filter_field') != 'hide') && ($filter = $this->getState('list.filter')))
{
// Clean filter variable
$filter = StringHelper::strtolower($filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</h2>
<?php if ($params->get('show_author') && !empty($item->author )) : ?>
<div class="createdby" itemprop="author" itemscope itemtype="https://schema.org/Person">
<?php $author = ($item->created_by_alias) ? $item->created_by_alias : $item->author; ?>
<?php $author = $item->created_by_alias ? $item->created_by_alias : $item->author; ?>
<?php $author = '<span itemprop="name">' . $author . '</span>'; ?>
<?php if (!empty($item->contact_link) && $params->get('link_author') == true) : ?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', $this->item->contact_link, $author, array('itemprop' => 'url'))); ?>
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/views/archive/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function display($tpl = null)

foreach ($items as $item)
{
$item->catslug = ($item->category_alias) ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = ($item->parent_alias) ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;

// No link for ROOT category
if ($item->parent_alias == 'root')
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/views/article/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@
elseif ($readmore = $attribs->alternative_readmore) :
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) :
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
echo JHtml::_('string.truncate', $this->item->title, $params->get('readmore_limit'));
endif;
elseif ($params->get('show_readmore_title', 0) == 0) :
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
else :
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
echo JHtml::_('string.truncate', $this->item->title, $params->get('readmore_limit'));
endif; ?>
</a>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
endif;

// If no label is present, take the link
$label = ($label) ? $label : $link;
$label = $label ? $label : $link;

// If no target is present, use the default
$target = $target ? $target : $params->get('target' . $id);
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/views/article/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function display($tpl = null)
$currentLink = $active->link;

// If the current view is the active item and an article view for this article, then the menu item params take priority
if (strpos($currentLink, 'view=article') && (strpos($currentLink, '&id=' . (string) $item->id)))
if (strpos($currentLink, 'view=article') && strpos($currentLink, '&id=' . (string) $item->id))
{
// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout']))
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/views/category/tmpl/blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<?php endif; ?>

<?php
$introcount = (count($this->intro_items));
$introcount = count($this->intro_items);
$counter = 0;
?>

Expand All @@ -78,7 +78,7 @@
<?php $row = $counter / $this->columns; ?>
<div class="items-row cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row-fluid clearfix">
<?php endif; ?>
<div class="span<?php echo round((12 / $this->columns)); ?>">
<div class="span<?php echo round(12 / $this->columns); ?>">
<div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if (($this->params->get('list_show_votes', 0)) && ($this->vote)) : ?>
<?php if ($this->params->get('list_show_votes', 0) && $this->vote) : ?>
<th scope="col" id="categorylist_header_votes">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_VOTES', 'rating_count', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if (($this->params->get('list_show_ratings', 0)) && ($this->vote)) : ?>
<?php if ($this->params->get('list_show_ratings', 0) && $this->vote) : ?>
<th scope="col" id="categorylist_header_ratings">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_RATINGS', 'rating', $listDirn, $listOrder); ?>
</th>
Expand Down Expand Up @@ -225,14 +225,14 @@
</span>
</td>
<?php endif; ?>
<?php if (($this->params->get('list_show_votes', 0)) && ($this->vote)) : ?>
<?php if ($this->params->get('list_show_votes', 0) && $this->vote) : ?>
<td headers="categorylist_header_votes" class="list-votes">
<span class="badge badge-success">
<?php echo JText::sprintf('COM_CONTENT_VOTES_COUNT', $article->rating_count); ?>
</span>
</td>
<?php endif; ?>
<?php if (($this->params->get('list_show_ratings', 0)) && ($this->vote)) : ?>
<?php if ($this->params->get('list_show_ratings', 0) && $this->vote) : ?>
<td headers="categorylist_header_ratings" class="list-ratings">
<span class="badge badge-warning">
<?php echo JText::sprintf('COM_CONTENT_RATINGS_COUNT', $article->rating); ?>
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/views/category/view.feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function reconcileNames($item)
$params = $app->getParams();
$item->description = '';
$obj = json_decode($item->images);
$introImage = ( isset( $obj->{'image_intro'} ) ) ? $obj->{'image_intro'} : '';
$introImage = isset($obj->{'image_intro'}) ? $obj->{'image_intro'} : '';

if (isset($introImage) && ($introImage != ''))
{
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/views/category/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function display($tpl = null)
{
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;

$item->parent_slug = ($item->parent_alias) ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;

// No link for ROOT category
if ($item->parent_alias == 'root')
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/views/featured/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
<?php endif; ?>
<?php
$introcount = (count($this->intro_items));
$introcount = count($this->intro_items);
$counter = 0;
?>
<?php if (!empty($this->intro_items)) : ?>
Expand All @@ -58,7 +58,7 @@

<div class="items-row cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row-fluid">
<?php endif; ?>
<div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> span<?php echo round((12 / $this->columns)); ?>"
<div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> span<?php echo round(12 / $this->columns); ?>"
itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<?php
$this->item = &$item;
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/views/featured/view.feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function display($tpl = null)

$description = '';
$obj = json_decode($row->images);
$introImage = ( isset( $obj->{'image_intro'} ) ) ? $obj->{'image_intro'} : '';
$introImage = isset($obj->{'image_intro'}) ? $obj->{'image_intro'} : '';

if (isset($introImage) && ($introImage != ''))
{
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/views/featured/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function display($tpl = null)
foreach ($items as &$item)
{
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$item->catslug = ($item->category_alias) ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = ($item->parent_alias) ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;

// No link for ROOT category
if ($item->parent_alias == 'root')
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/views/form/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function display($tpl = null)

if (empty($this->item->id))
{
$authorised = $user->authorise('core.create', 'com_content') || (count($user->getAuthorisedCategories('com_content', 'core.create')));
$authorised = $user->authorise('core.create', 'com_content') || count($user->getAuthorisedCategories('com_content', 'core.create'));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions components/com_finder/helpers/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function getSearchRoute($f = null, $q = null)
$item = self::getItemid($query);

// Get the base route.
$uri = clone(JUri::getInstance('index.php?option=com_finder&view=search'));
$uri = clone JUri::getInstance('index.php?option=com_finder&view=search');

// Add the pre-defined search filter if present.
if ($f !== null)
Expand Down Expand Up @@ -73,7 +73,7 @@ public static function getAdvancedRoute($f = null, $q = null)
$item = self::getItemid($query);

// Get the base route.
$uri = clone(JUri::getInstance('index.php?option=com_finder&view=advanced'));
$uri = clone JUri::getInstance('index.php?option=com_finder&view=advanced');

// Add the pre-defined search filter if present.
if ($q !== null)
Expand Down
14 changes: 7 additions & 7 deletions components/com_finder/models/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected function getListQuery()
// Use the cached data if possible.
if ($this->retrieve($store, false))
{
return clone($this->retrieve($store, false));
return clone $this->retrieve($store, false);
}

// Set variables
Expand Down Expand Up @@ -307,7 +307,7 @@ protected function getListQuery()
$this->store($store, $query, false);

// Return a copy of the query object.
return clone($this->retrieve($store, false));
return clone $this->retrieve($store, false);
}

/**
Expand Down Expand Up @@ -343,7 +343,7 @@ protected function getResultsTotal()
if (empty($this->includedTerms))
{
// Adjust the query to join on the appropriate mapping table.
$query = clone($base);
$query = clone $base;
$query->clear('select')
->select('COUNT(DISTINCT l.link_id)');

Expand Down Expand Up @@ -416,7 +416,7 @@ protected function getResultsTotal()
else
{
// Adjust the query to join on the appropriate mapping table.
$query = clone($base);
$query = clone $base;
$query->join('INNER', '#__finder_links_terms' . $suffix . ' AS m ON m.link_id = l.link_id')
->where('m.term_id IN (' . implode(',', $ids) . ')');

Expand Down Expand Up @@ -527,7 +527,7 @@ protected function getResultsTotal()
$suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1);

// Adjust the query to join on the appropriate mapping table.
$query = clone($base);
$query = clone $base;
$query->join('INNER', '#__finder_links_terms' . $suffix . ' AS m ON m.link_id = l.link_id')
->where('m.term_id IN (' . implode(',', $required) . ')');

Expand Down Expand Up @@ -695,7 +695,7 @@ protected function getResultsData()
else
{
// Adjust the query to join on the appropriate mapping table.
$query = clone($base);
$query = clone $base;
$query->join('INNER', $this->_db->quoteName('#__finder_links_terms' . $suffix) . ' AS m ON m.link_id = l.link_id')
->where('m.term_id IN (' . implode(',', $ids) . ')');

Expand Down Expand Up @@ -848,7 +848,7 @@ protected function getResultsData()
$suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1);

// Adjust the query to join on the appropriate mapping table.
$query = clone($base);
$query = clone $base;
$query->join('INNER', $this->_db->quoteName('#__finder_links_terms' . $suffix) . ' AS m ON m.link_id = l.link_id')
->where('m.term_id IN (' . implode(',', $required) . ')');

Expand Down
6 changes: 3 additions & 3 deletions components/com_newsfeeds/helpers/legacyrouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function build(&$query, &$segments)
$menuItem = $this->router->menu->getItem($query['Itemid']);
}

$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
$mView = empty($menuItem->query['view']) ? null : $menuItem->query['view'];
$mId = empty($menuItem->query['id']) ? null : $menuItem->query['id'];

if (isset($query['view']))
{
Expand All @@ -86,7 +86,7 @@ public function build(&$query, &$segments)
}

// Are we dealing with an newsfeed that is attached to a menu item?
if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id']))
if (isset($query['view']) && ($mView == $query['view']) and isset($query['id']) and ($mId == (int) $query['id']))
{
unset($query['view'], $query['catid'], $query['id']);

Expand Down
2 changes: 1 addition & 1 deletion components/com_newsfeeds/models/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function &getItem($pk = null)

// Check for published state if filter set.

if (((is_numeric($published)) || (is_numeric($archived))) && (($data->published != $published) && ($data->published != $archived)))
if ((is_numeric($published) || is_numeric($archived)) && (($data->published != $published) && ($data->published != $archived)))
{
JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
}
Expand Down
4 changes: 2 additions & 2 deletions components/com_newsfeeds/views/newsfeed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<!-- Show Images from Component -->
<?php if (isset($images->image_first) and !empty($images->image_first)) : ?>
<?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
<?php $imgfloat = empty($images->float_first) ? $this->params->get('float_first') : $images->float_first; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?>"> <img
<?php if ($images->image_first_caption) :
echo 'class="caption"' . ' title="' . htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8') . '"';
Expand All @@ -75,7 +75,7 @@
<?php endif; ?>

<?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
<?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
<?php $imgfloat = empty($images->float_second) ? $this->params->get('float_second') : $images->float_second; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?> item-image"> <img
<?php if ($images->image_second_caption) :
echo 'class="caption"' . ' title="' . htmlspecialchars($images->image_second_caption) . '"';
Expand Down
4 changes: 2 additions & 2 deletions components/com_newsfeeds/views/newsfeed/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function display($tpl = null)
$currentLink = $active->link;

// If the current view is the active item and an newsfeed view for this feed, then the menu item params take priority
if (strpos($currentLink, 'view=newsfeed') && (strpos($currentLink, '&id=' . (string) $item->id)))
if (strpos($currentLink, 'view=newsfeed') && strpos($currentLink, '&id=' . (string) $item->id))
{
// $item->params are the newsfeed params, $temp are the menu item params
// Merge so that the menu item params take priority
Expand Down Expand Up @@ -139,7 +139,7 @@ public function display($tpl = null)
// Check the access to the newsfeed
$levels = $user->getAuthorisedViewLevels();

if (!in_array($item->access, $levels) or ((in_array($item->access, $levels) and (!in_array($item->category_access, $levels)))))
if (!in_array($item->access, $levels) or (in_array($item->access, $levels) and (!in_array($item->category_access, $levels))))
{
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->setHeader('status', 403, true);
Expand Down

0 comments on commit 78c7599

Please sign in to comment.