Skip to content

Commit

Permalink
Fixed misuses of array_push()
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmayer committed Sep 25, 2016
1 parent 9dfa350 commit e37b560
Show file tree
Hide file tree
Showing 32 changed files with 67 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ protected function batchCopy($value, $pks, $contexts)
{
if (!in_array($childId, $pks))
{
array_push($pks, $childId);
$pks[] = $childId;
}
}

Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_installer/models/updatesites.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function rebuild()
{
foreach (glob($clientPath . '/' . $extensionGroupFolderName . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath)
{
array_push($pathsToSearch, $extensionFolderPath);
$pathsToSearch[] = $extensionFolderPath;
}
}

Expand All @@ -265,7 +265,7 @@ public function rebuild()
{
foreach (glob($pluginGroupFolderPath . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath)
{
array_push($pathsToSearch, $extensionFolderPath);
$pathsToSearch[] = $extensionFolderPath;
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions administrator/components/com_joomlaupdate/restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ function decode($str)
}
}

array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$stk[] = array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false);

$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
Expand Down Expand Up @@ -802,12 +802,12 @@ function decode($str)
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
$stk[] = array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false);
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");

if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
$arr[] = $this->decode($slice);

} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
Expand Down Expand Up @@ -842,7 +842,7 @@ function decode($str)

} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
$stk[] = array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c});
//print("Found start of string at {$c}\n");

} elseif (($chrs{$c} == $top['delim']) &&
Expand All @@ -857,7 +857,7 @@ function decode($str)
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
$stk[] = array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false);
//print("Found start of array at {$c}\n");

} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
Expand All @@ -868,7 +868,7 @@ function decode($str)
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
$stk[] = array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false);
//print("Found start of object at {$c}\n");

} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
Expand All @@ -879,7 +879,7 @@ function decode($str)
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$stk[] = array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false);
$c++;
//print("Found start of comment at {$c}\n");

Expand Down Expand Up @@ -1036,7 +1036,7 @@ public function setError($error)
array_shift($this->_errors);
}
}
array_push($this->_errors, $error);
$this->_errors[] = $error;
}

/**
Expand Down Expand Up @@ -1080,7 +1080,7 @@ public function setWarning($warning)
}
}

array_push($this->_warnings, $warning);
$this->_warnings[] = $warning;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_menus/models/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ protected function batchCopy($value, $pks, $contexts)
{
if (!in_array($childId, $pks))
{
array_push($pks, $childId);
$pks[] = $childId;
}
}

Expand Down
4 changes: 2 additions & 2 deletions administrator/includes/subtoolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class JSubMenuHelper
public static function addEntry($name, $link = '', $active = false)
{
JLog::add('JSubMenuHelper::addEntry() is deprecated. Use JHtmlSidebar::addEntry() instead.', JLog::WARNING, 'deprecated');
array_push(self::$entries, array($name, $link, $active));
self::$entries[] = array($name, $link, $active);
}

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ public static function getEntries()
public static function addFilter($label, $name, $options, $noDefault = false)
{
JLog::add('JSubMenuHelper::addFilter() is deprecated. Use JHtmlSidebar::addFilter() instead.', JLog::WARNING, 'deprecated');
array_push(self::$filters, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault));
self::$filters[] = array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
if ($item->user_count > 0)
{
array_push($groupsWithUsers, $i);
$groupsWithUsers[] = $i;
}
}
JFactory::getDocument()->addScriptDeclaration('
Expand Down
4 changes: 2 additions & 2 deletions layouts/joomla/modal/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@

if (!isset($params['animation']) || $params['animation'])
{
array_push($modalClasses, 'fade');
$modalClasses[] = 'fade';
}

$modalWidth = isset($params['modalWidth']) ? round((int) $params['modalWidth'], -1) : '';

if ($modalWidth && $modalWidth > 0 && $modalWidth <= 100)
{
array_push($modalClasses, 'jviewport-width' . $modalWidth);
$modalClasses[] = 'jviewport-width' . $modalWidth;
}

$modalAttributes = array(
Expand Down
4 changes: 2 additions & 2 deletions libraries/cms/component/router/viewconfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ public function setNestable($isNestable = true)
*/
public function addLayout($layout)
{
array_push($this->layouts, $layout);
$this->layouts = array_unique($this->layouts);
$this->layouts[] = $layout;
$this->layouts = array_unique($this->layouts);

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/cms/html/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ public static function linkoptions($all = false, $unassigned = false)
// First pass - collect children
foreach ($mitems as $v)
{
$pt = $v->parent_id;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$pt = $v->parent_id;
$list = @$children[$pt] ? $children[$pt] : array();
$list[] = $v;
$children[$pt] = $list;
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/cms/html/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function render()
*/
public static function addEntry($name, $link = '', $active = false)
{
array_push(static::$entries, array($name, $link, $active));
static::$entries[] = array($name, $link, $active);
}

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ public static function getEntries()
*/
public static function addFilter($label, $name, $options, $noDefault = false)
{
array_push(static::$filters, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault));
static::$filters[] = array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions libraries/cms/installer/adapter/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ protected function populateFilesAndFolderList()
// Check if folder exists, if not then add to the array for folder creation
if (!JFolder::exists($folderName))
{
array_push($this->folderList, $folderName);
$this->folderList[] = $folderName;
}
}

Expand Down Expand Up @@ -584,12 +584,12 @@ protected function populateFilesAndFolderList()

if ($eFileName->getName() == 'folder')
{
$folderName = $targetFolder . '/' . $eFileName;
array_push($this->folderList, $folderName);
$path['type'] = 'folder';
$folderName = $targetFolder . '/' . $eFileName;
$this->folderList[] = $folderName;
$path['type'] = 'folder';
}

array_push($this->fileList, $path);
$this->fileList[] = $path;
}
}
else
Expand All @@ -601,7 +601,7 @@ protected function populateFilesAndFolderList()
$path['src'] = $sourceFolder . '/' . $file;
$path['dest'] = $targetFolder . '/' . $file;

array_push($this->fileList, $path);
$this->fileList[] = $path;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/cms/toolbar/toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public static function getInstance($name = 'toolbar')
public function appendButton()
{
// Push button onto the end of the toolbar array.
$btn = func_get_args();
array_push($this->_bar, $btn);
$btn = func_get_args();
$this->_bar[] = $btn;

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/fof/database/driver/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ public function __sleep()
// Do not serialize properties that are PDO
if ($property->isStatic() == false && !($this->{$property->name} instanceof PDO))
{
array_push($serializedProperties, $property->name);
$serializedProperties[] = $property->name;
}
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/fof/hal/render/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function render($options = array())

foreach ($links as $link)
{
array_push($serialiseThis->_links->$rel, $this->_getLink($link));
$serialiseThis->_links->$rel[] = $this->_getLink($link);
}
}
}
Expand All @@ -102,8 +102,8 @@ public function render($options = array())

foreach ($embeddeddocs as $embedded)
{
$renderer = new FOFHalRenderJson($embedded);
array_push($serialiseThis->_embedded->$rel, $renderer->render($options));
$renderer = new FOFHalRenderJson($embedded);
$serialiseThis->_embedded->$rel[] = $renderer->render($options);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/fof/utils/object/object.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ public function setProperties($properties)
*/
public function setError($error)
{
array_push($this->_errors, $error);
$this->_errors[] = $error;
}
}
2 changes: 1 addition & 1 deletion libraries/joomla/application/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public function prependBody($content)
*/
public function appendBody($content)
{
array_push($this->response->body, (string) $content);
$this->response->body[] = (string) $content;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ public function __sleep()
// Do not serialize properties that are PDO
if ($property->isStatic() == false && !($this->{$property->name} instanceof PDO))
{
array_push($serializedProperties, $property->name);
$serializedProperties[] = $property->name;
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/query/sqlsrv.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function group($columns)

foreach ($tmpCols as $name => $tmpColType)
{
array_push($cols, $alias . "." . $name);
$cols[] = $alias . "." . $name;
}
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/form/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,8 @@ public function validate($data, $group = null)
// Check for an error.
if ($valid instanceof Exception)
{
array_push($this->errors, $valid);
$return = false;
$this->errors[] = $valid;
$return = false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/object/object.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,6 @@ public function setProperties($properties)
*/
public function setError($error)
{
array_push($this->_errors, $error);
$this->_errors[] = $error;
}
}
4 changes: 2 additions & 2 deletions libraries/joomla/updater/adapters/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ protected function _getParent()
*/
public function _startElement($parser, $name, $attrs = array())
{
array_push($this->stack, $name);
$tag = $this->_getStackLocation();
$this->stack[] = $name;
$tag = $this->_getStackLocation();

// Reset the data
if (isset($this->$tag))
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/updater/adapters/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class JUpdaterExtension extends JUpdateAdapter
*/
protected function _startElement($parser, $name, $attrs = array())
{
array_push($this->stack, $name);
$tag = $this->_getStackLocation();
$this->stack[] = $name;
$tag = $this->_getStackLocation();

// Reset the data
if (isset($this->$tag))
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/updater/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ protected function _getLastTag()
*/
public function _startElement($parser, $name, $attrs = array())
{
array_push($this->stack, $name);
$tag = $this->_getStackLocation();
$this->stack[] = $name;
$tag = $this->_getStackLocation();

// Reset the data
if (isset($this->$tag))
Expand Down
4 changes: 2 additions & 2 deletions libraries/legacy/controller/legacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,8 @@ protected function holdEditId($context, $id)
// Add the id to the list if non-zero.
if (!empty($id))
{
array_push($values, (int) $id);
$values = array_unique($values);
$values[] = (int) $id;
$values = array_unique($values);
$app->setUserState($context . '.id', $values);

if (defined('JDEBUG') && JDEBUG)
Expand Down
2 changes: 1 addition & 1 deletion libraries/legacy/exception/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,6 @@ public function setError($error)
{
JLog::add('JException::setErrors is deprecated.', JLog::WARNING, 'deprecated');

array_push($this->_errors, $error);
$this->_errors[] = $error;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public function prependBody($content)
*/
public function appendBody($content)
{
array_push($this->response->body, (string) $content);
$this->response->body[] = (string) $content;

return $this;
}
Expand Down

0 comments on commit e37b560

Please sign in to comment.