Commit f8839bf4 authored by Côme Chilliet's avatar Côme Chilliet

🚑 fix(code) Use shorthand array syntax

issue #5955
parent 43447205
......@@ -61,17 +61,17 @@ function smarty_block_render ($params, $text)
}
/* Remove select options */
$from = array(
$from = [
"#<option.*<\/option>#is",
"/(<textarea.*>).*(<\/textarea>)/is",
"/^(.*<input.*)checked(.*>.*)$/isD"
);
];
$to = array(
$to = [
" ",
"\\1\\2",
"\\1 \\2"
);
];
return preg_replace($from, $to, $text);
}
......@@ -21,14 +21,14 @@
function smarty_function_msgPool ($params)
{
if (class_available('msgPool') && isset($params['type'])) {
$parameter = array();
$parameter = [];
foreach ($params as $para => $value) {
if (!preg_match('/^type$/i', $para)) {
$parameter[$para] = $value;
}
}
if (is_callable('msgPool::'.$params['type'])) {
echo call_user_func_array(array('msgPool',$params['type']), $parameter);
echo call_user_func_array(['msgPool',$params['type']], $parameter);
} else {
trigger_error('Unknown msgPool function '.$params['type']);
}
......
......@@ -30,7 +30,7 @@ reset_errors();
/* Logged in? Simple security check */
if (!session::global_is_set('ui')) {
logging::log('security', 'unknown', '', array(), 'Error: autocomplete.php called without session');
logging::log('security', 'unknown', '', [], 'Error: autocomplete.php called without session');
header('Location: index.php');
exit;
}
......
......@@ -31,7 +31,7 @@ reset_errors();
/* Logged in? Simple security check */
if (!session::global_is_set('ui')) {
logging::log('security', 'unknown', '', array(), 'Error: getbin.php called without session');
logging::log('security', 'unknown', '', [], 'Error: getbin.php called without session');
header('Location: index.php');
exit;
}
......
......@@ -34,7 +34,7 @@ if (session::global_is_set('config')) {
} else {
header("cache-control: no-cache");
}
IconTheme::$extensions = array('png');
IconTheme::$extensions = ['png'];
if (!isset($_GET['context']) || !isset($_GET['icon']) || !isset($_GET['size'])) {
trigger_error('Missing information in query string: '.$_SERVER['QUERY_STRING']);
exit;
......
......@@ -123,7 +123,7 @@ if (
($config->get_cfg_value('casActivated') == 'TRUE') ||
($config->get_cfg_value('httpAuthActivated') == 'TRUE') ||
($config->get_cfg_value('httpHeaderAuthActivated') == 'TRUE') ||
in_array($config->get_cfg_value('LoginMethod'), array('LoginCas', 'LoginHTTPAuth', 'LoginHTTPHeader'))) {
in_array($config->get_cfg_value('LoginMethod'), ['LoginCas', 'LoginHTTPAuth', 'LoginHTTPHeader'])) {
session::global_set('DEBUGLEVEL', 0);
}
......
......@@ -46,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
/* Logged in? Simple security check */
if (!session::global_is_set('connected')) {
logging::log('security', 'login', '', array(), 'main.php called without session - logging out');
logging::log('security', 'login', '', [], 'main.php called without session - logging out');
header('Location: index.php?message=nosession');
exit;
}
......@@ -78,7 +78,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') {
*/
if ($request_time > $max_life) {
session::destroy();
logging::log('security', 'login', '', array(), 'main.php called with expired session - logging out');
logging::log('security', 'login', '', [], 'main.php called with expired session - logging out');
header('Location: index.php?signout=1&message=expired');
exit;
}
......@@ -114,7 +114,7 @@ if ($config->get_cfg_value("handleExpiredAccounts") == "TRUE") {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account ('.$ui->uid.') is about to expire');
// The users password is about to xpire soon, display a warning message.
logging::log('security', 'fusiondirectory', '', array(), 'password for user "'.$ui->uid.'" is about to expire');
logging::log('security', 'fusiondirectory', '', [], 'password for user "'.$ui->uid.'" is about to expire');
msg_dialog::display(_('Password change'), _('Your password is about to expire, please change your password!'), INFO_DIALOG);
session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE);
} elseif ($expired == POSIX_FORCE_PASSWORD_CHANGE) {
......
......@@ -57,7 +57,7 @@ if (!function_exists("imagecreate")) {
} else {
$x_matches = FALSE;
$y_matches = FALSE;
foreach (array(7,6,5,4,3,2,1,0) as $font) {
foreach ([7,6,5,4,3,2,1,0] as $font) {
$fx = ImageFontWidth($font) * strlen("$p%");
$fy = ImageFontHeight($font);
......
......@@ -74,7 +74,7 @@
*/
function parse_scores ($str)
{
$scores = array();
$scores = [];
$parts = preg_split('/,/', $str);
foreach ($parts as $part) {
$part = trim(strtolower($part));
......@@ -109,7 +109,7 @@ function max_scores ($scores, $testvals)
function parse_gettext_lang ($str)
{
if (preg_match("/^([^_]*)(_([^_]*))?\.(.*)$/", $str, $m)) {
return array(strtolower($m[1]), strtolower($m[3]), strtolower($m[4]));
return [strtolower($m[1]), strtolower($m[3]), strtolower($m[4])];
} else {
return FALSE;
}
......@@ -157,8 +157,8 @@ function al2gt ($gettextlangs)
}
list ($lang, $country, $char) = $infos;
$lang_score = max_scores($lang_scores, array($lang,$lang.'-'.$country,'*'));
$char_score = max_scores($char_scores, array($char,'*'));
$lang_score = max_scores($lang_scores, [$lang,$lang.'-'.$country,'*']);
$char_score = max_scores($char_scores, [$char,'*']);
if ($char_score == 0) {
// exclude charsets the user refuses
continue;
......
......@@ -43,7 +43,7 @@ class Combinations implements Iterator
function current ()
{
$r = array();
$r = [];
for ($i = 0; $i < $this->size; $i++) {
$r[] = $this->input[$this->current[$i]];
}
......
......@@ -34,20 +34,20 @@ class CopyPasteHandler
/*!
* \brief This array contains all dns of the currently copied objects
*/
protected $objectList = array();
protected $objectList = [];
/*!
* \brief This array contains all remaining objects to paste
*/
protected $queue = array();
protected $queue = [];
/*!
* \brief The dn of the last edited object
*/
protected $lastdn = '';
protected $disallowed_objects = array();
protected $objects_to_fix = array();
protected $clean_objects = array();
protected $disallowed_objects = [];
protected $objects_to_fix = [];
protected $clean_objects = [];
protected $require_update = FALSE;
/*!
......@@ -74,12 +74,12 @@ class CopyPasteHandler
{
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue');
if (!in_array($action, array('cut','copy'))) {
if (!in_array($action, ['cut','copy'])) {
trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action));
return FALSE;
}
$tmp = array();
$tmp = [];
$tmp['method'] = $action;
$tmp['dn'] = $dn;
......@@ -109,8 +109,8 @@ class CopyPasteHandler
{
$this->current = FALSE;
$this->require_update = TRUE;
$this->queue = array();
$this->objectList = array();
$this->queue = [];
$this->objectList = [];
}
/*!
......@@ -138,7 +138,7 @@ class CopyPasteHandler
{
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap');
if (!isset($entry['tab_class']) && !isset($entry['type'])) {
return array();
return [];
}
$entry['object'] = objects::open($entry['dn'], $entry['type']);
......@@ -169,9 +169,9 @@ class CopyPasteHandler
* Create a list of all entries that can be pasted directly.
*/
if ($this->require_update) {
$this->clean_objects = array();
$this->objects_to_fix = array();
$this->disallowed_objects = array();
$this->clean_objects = [];
$this->objects_to_fix = [];
$this->disallowed_objects = [];
/* Put each queued object in one of the above arrays */
foreach ($this->queue as $key => $entry) {
......@@ -195,7 +195,7 @@ class CopyPasteHandler
}
}
if (count($this->disallowed_objects)) {
$dns = array();
$dns = [];
foreach ($this->disallowed_objects as $entry) {
$dns[] = $entry['dn'];
}
......
......@@ -54,7 +54,7 @@ class IconThemeDir
$this->Size = $infos['Size'];
$this->MinSize = $infos['Size'];
$this->MaxSize = $infos['Size'];
foreach (array('Type', 'MaxSize', 'MinSize', 'Threshold') as $key) {
foreach (['Type', 'MaxSize', 'MinSize', 'Threshold'] as $key) {
if (isset($infos[$key])) {
$this->$key = $infos[$key];
}
......@@ -102,7 +102,7 @@ class IconThemeDir
*/
class IconTheme
{
private $subdirs = array();
private $subdirs = [];
private $path;
private $parent;
......@@ -197,7 +197,7 @@ class IconTheme
}
static public $default_theme = 'breezy';
static public $extensions = array('png', 'xpm', 'svg');
static public $extensions = ['png', 'xpm', 'svg'];
static public $find_closest = FALSE;
/* We store themes in the session. To do otherwise, override these methods. */
......@@ -205,7 +205,7 @@ class IconTheme
static public function loadThemes ($path)
{
$themes = array();
$themes = [];
if ($dir = opendir("$path")) {
while (($file = readdir($dir)) !== FALSE) {
if (file_exists("$path/$file/index.theme") && !preg_match("/^\./", $file)) {
......@@ -244,160 +244,160 @@ class IconTheme
}
/* Fallback system */
static public $fallbacks = array(
'types/user-group' => array(
array('applications','system-users')
),
'types/resource-group' => array(
array('actions','resource-group')
),
'types/user' => array(
array('places','user-identity'),
array('status','avatar-default'),
),
'types/contact' => array(
array('mimetypes','x-office-contact'),
),
'types/certificate' => array(
array('mimetypes','stock_certificate'),
array('mimetypes','application-certificate'),
array('actions','view-certificate'),
),
'applications/user-info' => array(
array('actions','user-properties'),
array('types','contact'),
array('mimetypes','x-office-contact'),
array('types','user'),
array('places','user-identity'),
array('status','avatar-default'),
),
'applications/office-calendar' => array(
array('mimetypes','x-office-calendar'),
),
'applications/os-linux' => array(
array('applications','linux'),
),
'applications/os-windows' => array(
array('applications','windows'),
),
'applications/samba' => array(
array('applications','os-windows'),
array('applications','windows'),
),
'applications/config-language' => array(
array('applications','locale'),
array('applications','preferences-desktop-locale'),
),
'mimetypes/text-csv' => array(
array('mimetypes','x-office-spreadsheet'),
array('mimetypes','text-x-generic'),
),
'mimetypes/application-pdf' => array(
array('mimetypes','x-office-document'),
),
'actions/application-exit' => array(
array('actions','system-log-out'),
),
'actions/document-export' => array(
array('actions','document-send'),
),
'actions/download' => array(
array('actions','document-save'),
),
'actions/document-restore' => array(
array('actions','document-import'),
array('actions','document-open'),
),
'actions/document-edit' => array(
array('actions','edit'),
array('applications','text-editor'),
array('applications','accessories-text-editor'),
array('actions','document-open'),
),
'actions/snapshot' => array(
array('actions','document-save'),
),
'actions/system-reboot' => array(
array('actions','view-refresh'),
),
'actions/system-update' => array(
array('applications','system-software-update'),
),
'actions/system-reinstall' => array(
array('applications','system-installer'),
),
'actions/task-start' => array(
array('actions','media-playback-start'),
),
'actions/task-stop' => array(
array('actions','media-playback-stop'),
),
'actions/task-schedule' => array(
array('actions','chronometer'),
array('actions','smallclock'),
),
'actions/up' => array(
array('actions','go-up'),
array('actions','arrow-up'),
),
'actions/upload' => array(
array('actions','document-import'),
array('actions','up'),
),
'actions/down' => array(
array('actions','go-down'),
array('actions','arrow-down'),
),
'actions/previous' => array(
array('actions','go-previous'),
array('actions','arrow-left'),
),
'actions/next' => array(
array('actions','go-next'),
array('actions','arrow-right'),
),
'actions/submit' => array(
array('actions','go-jump'),
),
'categories/settings' => array(
array('categories','gnome-settings'),
array('categories','preferences-other'),
array('categories','preferences-system'),
),
'categories/checks' => array(
array('actions','view-task'),
array('actions','view-calendar-tasks'),
array('actions','checkbox'),
array('status','task-complete'),
),
'devices/server' => array(
array('places','server'),
array('places','network-server'),
),
'devices/media-cdrom' => array(
array('devices','media-optical'),
),
'devices/terminal' => array(
array('applications','utilities-terminal'),
),
'devices/computer-windows' => array(
array('applications','os-windows'),
array('applications','windows'),
),
'devices/template' => array(
array('actions','document-new'),
),
'status/object-locked' => array(
array('status','changes-prevent'),
),
'status/object-unlocked' => array(
array('status','changes-allow'),
),
'status/task-waiting' => array(
array('actions','task-schedule'),
),
'places/folder-network' => array(
array('places','folder-remote'),
),
);
static public $fallbacks = [
'types/user-group' => [
['applications','system-users']
],
'types/resource-group' => [
['actions','resource-group']
],
'types/user' => [
['places','user-identity'],
['status','avatar-default'],
],
'types/contact' => [
['mimetypes','x-office-contact'],
],
'types/certificate' => [
['mimetypes','stock_certificate'],
['mimetypes','application-certificate'],
['actions','view-certificate'],
],
'applications/user-info' => [
['actions','user-properties'],
['types','contact'],
['mimetypes','x-office-contact'],
['types','user'],
['places','user-identity'],
['status','avatar-default'],
],
'applications/office-calendar' => [
['mimetypes','x-office-calendar'],
],
'applications/os-linux' => [
['applications','linux'],
],
'applications/os-windows' => [
['applications','windows'],
],
'applications/samba' => [
['applications','os-windows'],
['applications','windows'],
],
'applications/config-language' => [
['applications','locale'],
['applications','preferences-desktop-locale'],
],
'mimetypes/text-csv' => [
['mimetypes','x-office-spreadsheet'],
['mimetypes','text-x-generic'],
],
'mimetypes/application-pdf' => [
['mimetypes','x-office-document'],
],
'actions/application-exit' => [
['actions','system-log-out'],
],
'actions/document-export' => [
['actions','document-send'],
],
'actions/download' => [
['actions','document-save'],
],
'actions/document-restore' => [
['actions','document-import'],
['actions','document-open'],
],
'actions/document-edit' => [
['actions','edit'],
['applications','text-editor'],
['applications','accessories-text-editor'],
['actions','document-open'],
],
'actions/snapshot' => [
['actions','document-save'],
],
'actions/system-reboot' => [
['actions','view-refresh'],
],
'actions/system-update' => [
['applications','system-software-update'],
],
'actions/system-reinstall' => [
['applications','system-installer'],
],
'actions/task-start' => [
['actions','media-playback-start'],
],
'actions/task-stop' => [
['actions','media-playback-stop'],
],
'actions/task-schedule' => [
['actions','chronometer'],
['actions','smallclock'],
],
'actions/up' => [
['actions','go-up'],
['actions','arrow-up'],
],
'actions/upload' => [
['actions','document-import'],
['actions','up'],
],
'actions/down' => [
['actions','go-down'],
['actions','arrow-down'],
],
'actions/previous' => [
['actions','go-previous'],
['actions','arrow-left'],
],
'actions/next' => [
['actions','go-next'],
['actions','arrow-right'],
],
'actions/submit' => [
['actions','go-jump'],
],
'categories/settings' => [
['categories','gnome-settings'],
['categories','preferences-other'],
['categories','preferences-system'],
],
'categories/checks' => [
['actions','view-task'],
['actions','view-calendar-tasks'],
['actions','checkbox'],
['status','task-complete'],
],
'devices/server' => [
['places','server'],
['places','network-server'],
],
'devices/media-cdrom' => [
['devices','media-optical'],
],
'devices/terminal' => [
['applications','utilities-terminal'],
],
'devices/computer-windows' => [
['applications','os-windows'],
['applications','windows'],
],
'devices/template' => [
['actions','document-new'],
],
'status/object-locked' => [
['status','changes-prevent'],
],
'status/object-unlocked' => [
['status','changes-allow'],
],
'status/task-waiting' => [
['actions','task-schedule'],
],
'places/folder-network' => [
['places','folder-remote'],
],
];
}
......@@ -118,7 +118,7 @@ class Language
$languages = static::getList();
/* Move supported languages to flat list */
$langs = array();
$langs = [];
foreach (array_keys($languages) as $lang) {
$langs[] = $lang.'.UTF-8';
}
......@@ -135,7 +135,7 @@ class Language
public static function getList ($ownLanguage = FALSE)
{
/* locales in english */
$tmp_english = array(
$tmp_english = [
'en_US' => 'English',
'af_ZA' => 'Afrikaans',
'ar_EG' => 'Arabic',
......@@ -166,12 +166,12 @@ class Language
'vi_VN' => 'Vietnamese',
'zh_TW' => 'Taiwanese',
'zh_CN' => 'Chinese',
);
];
$ret = array();
$ret = [];
if ($ownLanguage) {
/* locales in their own language */
$tmp_ownlang = array(
$tmp_ownlang = [
'en_US' => 'English',
'ar_EG' => 'عربية',
'af_ZA' => 'Afrikaans',
......@@ -202,7 +202,7 @@ class Language
'vi_VN' => 'Tiếng Việt',
'zh_TW' => 'Taiwanese',
'zh_CN' => '中文, 汉语, 漢語',
);
];
foreach ($tmp_english as $key => $name) {
$ret[$key] = _($name).' ('.$tmp_ownlang[$key].')';
......
......@@ -28,17 +28,17 @@ class SnapshotCreateDialog extends simplePlugin
static function plInfo (): array
{
return array(
return [
'plShortName' => 'SnapshotCreateDialog',
);
];
}
static function getAttributesInfo (): array
{
return array(
'main' => array(
return [
'main' => [
'name' => _('Creating an object snapshot'),
'attrs' => array(
'attrs' => [