Skip to content
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
033aa88
Fixed callable call in loop termination condition
frankmayer Sep 25, 2016
a650515
Fixed non-optimal regular expression
frankmayer Sep 25, 2016
a33ad89
Shortened syntax for applied operations
frankmayer Sep 25, 2016
4173a7f
Don't use strlen() to check if string is empty.
frankmayer Sep 25, 2016
186f975
Reverted preg changes. Look into those later again.
frankmayer Sep 25, 2016
19eb362
Replaced call_user_func_array() with call_user_func()
frankmayer Sep 25, 2016
f9cb3fe
Merge unset() calls
frankmayer Sep 25, 2016
d30d1d7
Replaced old intval() call with modern typecasting
frankmayer Sep 25, 2016
0d1f128
Optimize away substr() as index-based access
frankmayer Sep 25, 2016
321c813
Merge branch 'Performance_2' into Performance_1
frankmayer Sep 25, 2016
d30fe28
Replace some cases of substr() with strpos()
frankmayer Sep 25, 2016
5dfd4e9
Replace some stristr() with stripos()
frankmayer Sep 25, 2016
4c1cfdd
Replace is_null() with null === ...
frankmayer Sep 25, 2016
271d02a
Removed unnecessary ternary operators
frankmayer Sep 25, 2016
c500e83
Fix for Juri...
frankmayer Sep 25, 2016
44d234d
Revert some changes for ... PHP5.3 compatibility
frankmayer Sep 25, 2016
6fb499b
Make travis happy ....
frankmayer Sep 25, 2016
5ada9b9
Make codesniffer happy...
frankmayer Sep 25, 2016
c2fd895
DYC!
frankmayer Sep 25, 2016
de1a93e
Optimize non-optimal if conditions.
frankmayer Sep 25, 2016
2aa353b
codsniffer...
frankmayer Sep 25, 2016
307cd94
Inline one-time use variables
frankmayer Sep 25, 2016
062ef22
Codesniffer...
frankmayer Sep 25, 2016
1bc9d8f
Flipped comparisons
frankmayer Sep 28, 2016
7d287f0
Flipped comparisons
frankmayer Sep 28, 2016
53d4854
Fix removal of ternary operator. Forgot inversion.
frankmayer Sep 28, 2016
5f6d634
More flipping of comparisons ;)
frankmayer Sep 28, 2016
2e2df19
Removed another unnecessary set of ternary operators.
frankmayer Sep 28, 2016
6b3e0fb
Codesniffer...
frankmayer Sep 28, 2016
171f66b
Type-safe comparisons on strings
frankmayer Oct 4, 2016
a730ca0
More type-safe comparisons
frankmayer Oct 4, 2016
1ff621a
Changes that occurred during PR discussion
frankmayer Oct 4, 2016
ba6ac8a
Merge branch 'staging' into Performance_1
frankmayer Dec 12, 2016
c67b374
Remove some unnecessary parentheses
frankmayer Dec 12, 2016
7e02da0
Removed empty if-group and reversed condition
frankmayer Dec 12, 2016
a924e5c
Merge branch 'staging' into Performance_1
frankmayer Dec 15, 2016
e0b11c7
Merge branch 'staging' into Performance_1
frankmayer May 29, 2017
22fc1c4
Merge branch 'staging' into Performance_1
frankmayer Jun 13, 2017
4b30c17
Corrections on errors during merge (Conflict resolving)
frankmayer Jun 13, 2017
e3f8617
Missed one.
frankmayer Jun 13, 2017
7d7b3cd
Remove a parenthesis
frankmayer Jun 13, 2017
42a6146
Changes according to reviewer's comment
frankmayer Jun 13, 2017
cb5ee93
Revert change because of failure
frankmayer Jun 13, 2017
bb10022
Changes according to reviewer's comment
frankmayer Jun 13, 2017
c4157d9
reversed change, though according to the method's doc that value shou…
frankmayer Jun 13, 2017
ec2c21a
Hopefully fixed...
frankmayer Jun 13, 2017
c0d3b44
Hopefully fixed...
frankmayer Jun 13, 2017
3619945
Re-apply some changes
frankmayer Jun 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/cms/application/administrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public static function purgeMessages()
$config = $db->loadObject();

// Check if auto_purge value set
if (is_object($config) and $config->cfg_name === 'auto_purge')
if (is_object($config) && $config->cfg_name === 'auto_purge')
{
$purge = $config->cfg_value;
}
Expand Down
10 changes: 5 additions & 5 deletions libraries/cms/application/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public function __construct(JInput $input = null, Registry $config = null, JAppl
}

// Enable sessions by default.
if (is_null($this->config->get('session')))
if ($this->config->get('session') === null)
{
$this->config->set('session', true);
}

// Set the session default name.
if (is_null($this->config->get('session_name')))
if ($this->config->get('session_name') === null)
{
$this->config->set('session_name', $this->getName());
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public function checkSession()
public function enqueueMessage($msg, $type = 'message')
{
// Don't add empty messages.
if (!strlen(trim($msg)))
if (trim($msg) === '')
{
return;
}
Expand Down Expand Up @@ -595,7 +595,7 @@ public function getUserState($key, $default = null)
$session = JFactory::getSession();
$registry = $session->get('registry');

if (!is_null($registry))
if ($registry !== null)
{
return $registry->get($key, $default);
}
Expand Down Expand Up @@ -1170,7 +1170,7 @@ public function setUserState($key, $value)
$session = JFactory::getSession();
$registry = $session->get('registry');

if (!is_null($registry))
if ($registry !== null)
{
return $registry->set($key, $value);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/application/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function getClientInfo($id = null, $byName = false)
}

// If no client id has been passed return the whole array
if (is_null($id))
if ($id === null)
{
return self::$_clients;
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/cms/application/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ protected function initialiseApp($options = array())
}
}

if ($this->getLanguageFilter() && empty($options['language']))
if (empty($options['language']) && $this->getLanguageFilter())
{
// Detect cookie language
$lang = $this->input->cookie->get(md5($this->get('secret') . 'language'), null, 'string');
Expand All @@ -646,7 +646,7 @@ protected function initialiseApp($options = array())
}
}

if ($this->getDetectBrowser() && empty($options['language']))
if (empty($options['language']) && $this->getDetectBrowser())
{
// Detect browser language
$lang = JLanguageHelper::detectLanguage();
Expand Down Expand Up @@ -748,7 +748,7 @@ protected function render()
$template = $this->getTemplate(true);
$file = $this->input->get('tmpl', 'index');

if (!$this->get('offline') && $file === 'offline')
if ($file === 'offline' && !$this->get('offline'))
{
$this->set('themeFile', 'index.php');
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/cms/captcha/captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function initialise($id)
public function display($name, $id, $class = '')
{
// Check if captcha is already loaded.
if (is_null($this->_captcha))
if ($this->_captcha === null)
{
return;
}
Expand Down Expand Up @@ -188,7 +188,7 @@ public function display($name, $id, $class = '')
public function checkAnswer($code)
{
// Check if captcha is already loaded
if (is_null(($this->_captcha)))
if ($this->_captcha === null)
{
return;
}
Expand Down
7 changes: 1 addition & 6 deletions libraries/cms/component/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,7 @@ public static function filterText($text)
$whiteListTags = array_unique($whiteListTags);
$whiteListAttributes = array_unique($whiteListAttributes);

// Unfiltered assumes first priority.
if ($unfiltered)
{
// Dont apply filtering.
}
else
if (!$unfiltered)
{
// Custom blacklist precedes Default blacklist
if ($customList)
Expand Down
10 changes: 5 additions & 5 deletions libraries/cms/editor/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function detach($observer)
public function initialise()
{
// Check if editor is already loaded
if (is_null(($this->_editor)))
if ($this->_editor === null)
{
return;
}
Expand All @@ -261,7 +261,7 @@ public function initialise()

$document = JFactory::getDocument();

if (method_exists($document, 'addCustomTag') && !empty($return))
if (!empty($return) && method_exists($document, 'addCustomTag'))
{
$document->addCustomTag($return);
}
Expand Down Expand Up @@ -293,7 +293,7 @@ public function display($name, $html, $width, $height, $col, $row, $buttons = tr
$this->_loadEditor($params);

// Check whether editor is already loaded
if (is_null(($this->_editor)))
if ($this->_editor === null)
{
JFactory::getApplication()->enqueueMessage(JText::_('JLIB_NO_EDITOR_PLUGIN_PUBLISHED'), 'error');

Expand Down Expand Up @@ -349,7 +349,7 @@ public function save($editor)
$this->_loadEditor();

// Check whether editor is already loaded
if (is_null(($this->_editor)))
if ($this->_editor === null)
{
return;
}
Expand Down Expand Up @@ -517,7 +517,7 @@ public function getButtons($editor, $buttons = true)
protected function _loadEditor($config = array())
{
// Check whether editor is already loaded
if (!is_null(($this->_editor)))
if ($this->_editor !== null)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/field/captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null)

if (strpos($this->class, 'required') === false)
{
$this->class = $this->class . ' required';
$this->class .= ' required';
}
}

Expand Down
12 changes: 6 additions & 6 deletions libraries/cms/form/field/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ public function __set($name, $value)
case 'buttons':
$value = (string) $value;

if ($value === 'true' || $value === 'yes' || $value == '1')
if ($value === 'true' || $value === 'yes' || $value === '1')
{
$this->buttons = true;
}
elseif ($value === 'false' || $value === 'no' || $value == '0')
elseif ($value === 'false' || $value === 'no' || $value === '0')
{
$this->buttons = false;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result == true)
if ($result === true)
{
$this->height = $this->element['height'] ? (string) $this->element['height'] : '500';
$this->width = $this->element['width'] ? (string) $this->element['width'] : '100%';
Expand All @@ -210,11 +210,11 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
$hide = (string) $this->element['hide'];
$editorType = (string) $this->element['editor'];

if ($buttons === 'true' || $buttons === 'yes' || $buttons == '1')
if ($buttons === 'true' || $buttons === 'yes' || $buttons === '1')
{
$this->buttons = true;
}
elseif ($buttons === 'false' || $buttons === 'no' || $buttons == '0')
elseif ($buttons === 'false' || $buttons === 'no' || $buttons === '0')
{
$this->buttons = false;
}
Expand Down Expand Up @@ -296,7 +296,7 @@ protected function getEditor()
}

// Create the JEditor instance based on the given editor.
if (is_null($editor))
if ($editor === null)
{
$editor = JFactory::getConfig()->get('editor');
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/field/menuitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result == true)
if ($result === true)
{
$this->menuType = (string) $this->element['menu_type'];
$this->clientId = (int) $this->element['client_id'];
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/field/moduleposition.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result == true)
if ($result === true)
{
// Get the client id.
$clientId = $this->element['client_id'];
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/field/ordering.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result == true)
if ($result === true)
{
$this->contentType = (string) $this->element['content_type'];
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/field/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected function prepareOptionsNested(&$options)
*/
public function isNested()
{
if (is_null($this->isNested))
if ($this->isNested === null)
{
// If mode="nested" || ( mode not set & config = nested )
if (isset($this->element['mode']) && $this->element['mode'] === 'nested'
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/field/templatestyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result == true)
if ($result === true)
{
// Get the clientName template.
$this->clientName = $this->element['client'] ? (string) $this->element['client'] : 'site';
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/form/rule/notequals.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test(SimpleXMLElement $element, $value, $group = null, Registry
throw new UnexpectedValueException(sprintf('$field empty in %s::test', get_class($this)));
}

if (is_null($input))
if ($input === null)
{
throw new InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this)));
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/help/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function createUrl($ref, $useComponent = false, $override = null,
$local = false;
$app = JFactory::getApplication();

if (is_null($component))
if ($component === null)
{
$component = JApplicationHelper::getComponentName();
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/helper/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function _getActions($categoryId = 0, $id = 0, $assetName = '')
public static function getActions($component = '', $section = '', $id = 0)
{
// Check for deprecated arguments order
if (is_int($component) || is_null($component))
if (is_int($component) || $component === null)
{
$result = self::_getActions($component, $section, $id);

Expand Down
9 changes: 4 additions & 5 deletions libraries/cms/helper/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function canUpload($file, $component = 'com_media')
foreach ($html_tags as $tag)
{
// A tag is '<tagname ', so we need to add < and a space or '<tagname>'
if (stristr($xss_check, '<' . $tag . ' ') || stristr($xss_check, '<' . $tag . '>'))
if (stripos($xss_check, '<' . $tag . ' ') !== false || stripos($xss_check, '<' . $tag . '>') !== false)
{
$app->enqueueMessage(JText::_('JLIB_MEDIA_ERROR_WARNIEXSS'), 'error');

Expand Down Expand Up @@ -360,15 +360,14 @@ public function countFiles($dir)
{
$d = dir($dir);

while (false !== ($entry = $d->read()))
while (($entry = $d->read()) !== false)
{
if (substr($entry, 0, 1) !== '.' && is_file($dir . DIRECTORY_SEPARATOR . $entry)
&& strpos($entry, '.html') === false && strpos($entry, '.php') === false)
if ($entry[0] !== '.' && strpos($entry, '.html') === false && strpos($entry, '.php') === false && is_file($dir . DIRECTORY_SEPARATOR . $entry))
{
$total_file++;
}

if (substr($entry, 0, 1) !== '.' && is_dir($dir . DIRECTORY_SEPARATOR . $entry))
if ($entry[0] !== '.' && is_dir($dir . DIRECTORY_SEPARATOR . $entry))
{
$total_dir++;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/cms/helper/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function findItem($needles = array())
$language = isset($needles['language']) ? $needles['language'] : '*';

// $this->extension may not be set if coming from a static method, check it
if (is_null($this->extension))
if ($this->extension === null)
{
$this->extension = $app->input->getCmd('option');
}
Expand Down Expand Up @@ -180,7 +180,7 @@ protected function findItem($needles = array())
* $language != * can override existing entries
* $language == * cannot override existing entries
*/
if (!isset(static::$lookup[$language][$view][$item->query['id']]) || $item->language !== '*')
if ($item->language !== '*' || !isset(static::$lookup[$language][$view][$item->query['id']]))
{
static::$lookup[$language][$view][$item->query['id']] = $item->id;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/helper/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function createTagsFromField($tags)
foreach ($tags as $key => $tag)
{
// User is not allowed to create tags, so don't create.
if (strpos($tag, '#new#') !== false && !$canCreate)
if (!$canCreate && strpos($tag, '#new#') !== false)
{
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/cms/helper/usergroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function count()
*/
public static function getInstance()
{
if (null === static::$instance)
if (static::$instance === null)
{
// Only here to avoid code style issues...
$groups = array();
Expand Down Expand Up @@ -165,7 +165,7 @@ public function getAll()
*/
public function has($id)
{
return (array_key_exists($id, $this->groups) && false !== $this->groups[$id]);
return (array_key_exists($id, $this->groups) && $this->groups[$id] !== false);
}

/**
Expand All @@ -189,7 +189,7 @@ private function isSingleton()
*/
public function total()
{
if (null === $this->total)
if ($this->total === null)
{
$db = JFactory::getDbo();

Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/html/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public static function assetgrouplist($name, $selected, $attribs = null, $config
$name,
array(
'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count),
'list.attr' => is_null($attribs) ? 'class="inputbox" size="3"' : $attribs,
'list.attr' => $attribs === null ? 'class="inputbox" size="3"' : $attribs,
'list.select' => (int) $selected,
)
);
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/html/behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public static function keepalive()
static::core();
static::polyfill('event', 'lt IE 9');

// Add keepalive script options.
// Add keepalive script options.
JFactory::getDocument()->addScriptOptions('system.keepalive', array('interval' => $refreshTime * 1000, 'uri' => JRoute::_($uri)));

// Add script.
Expand Down
Loading