Skip to content

Commit

Permalink
Changes the code base to short array syntax (#39616)
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo authored Jan 14, 2023
1 parent f6b21f2 commit 10f250f
Show file tree
Hide file tree
Showing 1,042 changed files with 6,127 additions and 6,127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function exportLogs()

$task = $this->getTask();

$pks = array();
$pks = [];

if ($task == 'exportSelectedLogs') {
// Get selected logs
Expand Down Expand Up @@ -116,7 +116,7 @@ public function exportLogs()
}

fclose($output);
$this->app->triggerEvent('onAfterLogExport', array());
$this->app->triggerEvent('onAfterLogExport', []);
$this->app->close();
} else {
$this->setMessage(Text::_('COM_ACTIONLOGS_NO_LOGS_TO_EXPORT'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getOptions()
$db->setQuery($query);
$context = $db->loadColumn();

$options = array();
$options = [];

if (\count($context) > 0) {
foreach ($context as $item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class LogsdaterangeField extends PredefinedlistField
* @var array
* @since 3.9.0
*/
protected $predefinedOptions = array(
protected $predefinedOptions = [
'today' => 'COM_ACTIONLOGS_OPTION_RANGE_TODAY',
'past_week' => 'COM_ACTIONLOGS_OPTION_RANGE_PAST_WEEK',
'past_1month' => 'COM_ACTIONLOGS_OPTION_RANGE_PAST_1MONTH',
'past_3month' => 'COM_ACTIONLOGS_OPTION_RANGE_PAST_3MONTH',
'past_6month' => 'COM_ACTIONLOGS_OPTION_RANGE_PAST_6MONTH',
'past_year' => 'COM_ACTIONLOGS_OPTION_RANGE_PAST_YEAR',
);
];

/**
* Method to instantiate the form field object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function getInput()
'link',
Route::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . $result),
Text::_('PLG_SYSTEM_ACTIONLOGS_JOOMLA_ACTIONLOG_DISABLED'),
array('class' => 'alert-link')
['class' => 'alert-link']
);

return '<div class="alert alert-info">'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ActionlogsHelper
*
* @since 3.9.7
*/
private static $characters = array('=', '+', '-', '@');
private static $characters = ['=', '+', '-', '@'];

/**
* Method to convert logs objects array to an iterable type for use with a CSV export
Expand Down Expand Up @@ -72,14 +72,14 @@ public static function getCsvData($data): Generator

static::loadTranslationFiles($extension);

yield array(
yield [
'id' => $log->id,
'message' => self::escapeCsvFormula(strip_tags(static::getHumanReadableLogMessage($log, false))),
'extension' => self::escapeCsvFormula(Text::_($extension)),
'date' => (new Date($log->log_date, new \DateTimeZone('UTC')))->format('Y-m-d H:i:s T'),
'name' => self::escapeCsvFormula($log->name),
'ip_address' => self::escapeCsvFormula($log->ip_address === 'COM_ACTIONLOGS_DISABLED' ? $disabledText : $log->ip_address)
);
];
}
}

Expand All @@ -94,7 +94,7 @@ public static function getCsvData($data): Generator
*/
public static function loadTranslationFiles($extension)
{
static $cache = array();
static $cache = [];
$extension = strtolower($extension);

if (isset($cache[$extension])) {
Expand Down Expand Up @@ -175,7 +175,7 @@ public static function getLogContentTypeParams($context)
*/
public static function getHumanReadableLogMessage($log, $generateLinks = true)
{
static $links = array();
static $links = [];

$message = Text::_($log->message_language_key);
$messageData = json_decode($log->message, true);
Expand Down Expand Up @@ -242,7 +242,7 @@ public static function getContentTypeLink($component, $contentType, $id, $urlVar

\JLoader::register($cName, $file);

if (class_exists($cName) && \is_callable(array($cName, 'getContentTypeLink'))) {
if (class_exists($cName) && \is_callable([$cName, 'getContentTypeLink'])) {
return $cName::getContentTypeLink($contentType, $id, $object);
}
}
Expand Down Expand Up @@ -273,18 +273,18 @@ public static function loadActionLogPluginsLanguage()
$query = $db->getQuery(true)
->select(
$db->quoteName(
array(
[
'folder',
'element',
'params',
'extension_id'
),
array(
],
[
'type',
'name',
'params',
'id'
)
]
)
)
->from($db->quoteName('#__extensions'))
Expand All @@ -297,7 +297,7 @@ public static function loadActionLogPluginsLanguage()
try {
$rows = $db->loadObjectList();
} catch (\RuntimeException $e) {
$rows = array();
$rows = [];
}

if (empty($rows)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function addLog($messages, $messageLanguageKey, $context, $userId = null)
$ip = 'COM_ACTIONLOGS_DISABLED';
}

$loggedMessages = array();
$loggedMessages = [];

foreach ($messages as $message) {
$logMessage = new \stdClass();
Expand Down Expand Up @@ -112,7 +112,7 @@ protected function sendNotificationEmails($messages, $username, $context)
$query = $db->getQuery(true);

$query
->select($db->quoteName(array('u.email', 'l.extensions')))
->select($db->quoteName(['u.email', 'l.extensions']))
->from($db->quoteName('#__users', 'u'))
->where($db->quoteName('u.block') . ' = 0')
->join(
Expand All @@ -125,7 +125,7 @@ protected function sendNotificationEmails($messages, $username, $context)

$users = $db->loadObjectList();

$recipients = array();
$recipients = [];

foreach ($users as $user) {
$extensions = json_decode($user->extensions, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ class ActionlogsModel extends ListModel
*
* @throws Exception
*/
public function __construct($config = array())
public function __construct($config = [])
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
$config['filter_fields'] = [
'a.id', 'id',
'a.extension', 'extension',
'a.user_id', 'user',
'a.message', 'message',
'a.log_date', 'log_date',
'a.ip_address', 'ip_address',
'dateRange',
);
];
}

parent::__construct($config);
Expand Down Expand Up @@ -217,7 +217,7 @@ private function buildDateRange($range)
break;
}

return array('dNow' => $dNow, 'dStart' => $dStart);
return ['dNow' => $dNow, 'dStart' => $dStart];
}

/**
Expand Down Expand Up @@ -347,7 +347,7 @@ public function delete(&$pks)
return false;
}

Factory::getApplication()->triggerEvent('onAfterLogPurge', array());
Factory::getApplication()->triggerEvent('onAfterLogPurge', []);

return true;
}
Expand All @@ -367,7 +367,7 @@ public function purge()
return false;
}

Factory::getApplication()->triggerEvent('onAfterLogPurge', array());
Factory::getApplication()->triggerEvent('onAfterLogPurge', []);

return true;
}
Expand All @@ -382,7 +382,7 @@ public function purge()
*
* @since 3.9.0
*/
public function getFilterForm($data = array(), $loadData = true)
public function getFilterForm($data = [], $loadData = true)
{
$form = parent::getFilterForm($data, $loadData);
$params = ComponentHelper::getParams('com_actionlogs');
Expand All @@ -392,8 +392,8 @@ public function getFilterForm($data = array(), $loadData = true)
if ($form && $ipLogging) {
/* @var \Joomla\CMS\Form\Field\ListField $field */
$field = $form->getField('fullordering', 'list');
$field->addOption(Text::_('COM_ACTIONLOGS_IP_ADDRESS_ASC'), array('value' => 'a.ip_address ASC'));
$field->addOption(Text::_('COM_ACTIONLOGS_IP_ADDRESS_DESC'), array('value' => 'a.ip_address DESC'));
$field->addOption(Text::_('COM_ACTIONLOGS_IP_ADDRESS_ASC'), ['value' => 'a.ip_address ASC']);
$field->addOption(Text::_('COM_ACTIONLOGS_IP_ADDRESS_DESC'), ['value' => 'a.ip_address DESC']);
}

return $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<form action="<?php echo Route::_('index.php?option=com_actionlogs&view=actionlogs'); ?>" method="post" name="adminForm" id="adminForm">
<div id="j-main-container" class="j-main-container">
<?php // Search tools bar ?>
<?php echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function admin_postinstall_behindproxy_condition()
function behindproxy_postinstall_action()
{
$prev = ArrayHelper::fromObject(new JConfig());
$data = array_merge($prev, array('behind_loadbalancer' => '1'));
$data = array_merge($prev, ['behind_loadbalancer' => '1']);

$config = new Registry($data);

Expand All @@ -71,7 +71,7 @@ function behindproxy_postinstall_action()
}

// Attempt to write the configuration file as a PHP class named JConfig.
$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
$configuration = $config->toString('PHP', ['class' => 'JConfig', 'closingtag' => false]);

if (!File::write($file, $configuration)) {
Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
Expand Down
20 changes: 10 additions & 10 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function update($installer)
$options['format'] = '{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}';
$options['text_file'] = 'joomla_update.php';

Log::addLogger($options, Log::INFO, array('Update', 'databasequery', 'jerror'));
Log::addLogger($options, Log::INFO, ['Update', 'databasequery', 'jerror']);

try {
Log::add(Text::_('COM_JOOMLAUPDATE_UPDATE_LOG_DELETE_FILES'), Log::INFO, 'Update');
Expand Down Expand Up @@ -539,7 +539,7 @@ protected function updateManifestCaches()

// If we have the search package around, it may not have a manifest cache entry after upgrades from 3.x, so add it to the list
if (File::exists(JPATH_ROOT . '/administrator/manifests/packages/pkg_search.xml')) {
$extensions[] = array('package', 'pkg_search', '', 0);
$extensions[] = ['package', 'pkg_search', '', 0];
}

// Attempt to refresh manifest caches
Expand Down Expand Up @@ -599,7 +599,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
'files_checked' => [],
];

$files = array(
$files = [
// From 3.10 to 4.1
'/administrator/components/com_actionlogs/actionlogs.php',
'/administrator/components/com_actionlogs/controller.php',
Expand Down Expand Up @@ -6463,9 +6463,9 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
'/media/vendor/hotkeys.js/LICENSE',
// From 4.2.1 to 4.2.2
'/administrator/cache/fido.jwt',
);
];

$folders = array(
$folders = [
// From 3.10 to 4.1
'/templates/system/images',
'/templates/system/html',
Expand Down Expand Up @@ -7837,7 +7837,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
'/media/vendor/hotkeys.js/js',
'/media/vendor/hotkeys.js',
'/libraries/vendor/symfony/string/Resources/bin',
);
];

$status['files_checked'] = $files;
$status['folders_checked'] = $folders;
Expand Down Expand Up @@ -7910,9 +7910,9 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
public function updateAssets($installer)
{
// List all components added since 4.0
$newComponents = array(
$newComponents = [
// Components to be added here
);
];

foreach ($newComponents as $component) {
/** @var \Joomla\CMS\Table\Asset $asset */
Expand Down Expand Up @@ -8562,13 +8562,13 @@ private function updateContentTypes(): void
*/
protected function fixFilenameCasing()
{
$files = array(
$files = [
// 3.10 changes
'/libraries/src/Filesystem/Support/Stringcontroller.php' => '/libraries/src/Filesystem/Support/StringController.php',
'/libraries/src/Form/Rule/SubFormRule.php' => '/libraries/src/Form/Rule/SubformRule.php',
// 4.0.0
'/media/vendor/skipto/js/skipTo.js' => '/media/vendor/skipto/js/skipto.js',
);
];

foreach ($files as $old => $expected) {
$oldRealpath = realpath(JPATH_ROOT . $old);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DisplayController extends BaseController
*
* @since 3.9
*/
public function display($cachable = false, $urlparams = array())
public function display($cachable = false, $urlparams = [])
{
$viewName = $this->input->get('view', $this->default_view);
$format = $this->input->get('format', 'html');
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_admin/src/Model/HelpModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function &getToc()

// Get Help files
$files = Folder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$');
$this->toc = array();
$this->toc = [];

foreach ($files as $file) {
$buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$data = $displayData;

// Receive overridable options
$data['options'] = !empty($data['options']) ? $data['options'] : array();
$data['options'] = !empty($data['options']) ? $data['options'] : [];

$noResultsText = '';
$hideActiveFilters = false;
Expand Down Expand Up @@ -58,7 +58,7 @@
}

// Set some basic options.
$customOptions = array(
$customOptions = [
'filtersHidden' => isset($data['options']['filtersHidden']) && $data['options']['filtersHidden'] ? $data['options']['filtersHidden'] : $hideActiveFilters,
'filterButton' => isset($data['options']['filterButton']) && $data['options']['filterButton'] ? $data['options']['filterButton'] : $showFilterButton,
'defaultLimit' => $data['options']['defaultLimit'] ?? Factory::getApplication()->get('list_limit', 20),
Expand All @@ -69,7 +69,7 @@
'showNoResults' => !empty($noResultsText),
'noResultsText' => !empty($noResultsText) ? $noResultsText : '',
'formSelector' => !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm',
);
];

// Merge custom options in the options array.
$data['options'] = array_merge($customOptions, $data['options']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function cancel($key = null)

// Only check in, if component item type allows to check out.
if (AssociationsHelper::typeSupportsCheckout($extensionName, $typeName)) {
$ids = array();
$ids = [];
$targetId = $this->input->get('target-id', '', 'string');

if ($targetId !== '') {
Expand Down
Loading

0 comments on commit 10f250f

Please sign in to comment.