Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
TASK: short array syntax (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi authored Mar 16, 2018
1 parent dd9156e commit 336a5d4
Show file tree
Hide file tree
Showing 121 changed files with 1,936 additions and 1,807 deletions.
24 changes: 12 additions & 12 deletions core/floaters.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
}

$allSkins = glob(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'skins' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
$skins = array();
$skins = [];
foreach ($allSkins as $skin) {
$name = basename($skin);
$skins[$name] = $name;
}

$languages = array();
$languages = [];
foreach (Kimai_Translation_Service::getAvailableLanguages() as $lang) {
$languages[$lang] = $lang;
}
Expand All @@ -79,9 +79,9 @@
$view->assign('user', $kga['user']);
$view->assign('rate', $database->get_rate($kga['user']['userID'], null, null));

$defaults = array(
$defaults = [
'table_time_format' => $kga->getTableTimeFormat()
);
];
$prefs = $database->user_get_preferences_by_prefix('ui.');
$view->assign('prefs', array_merge($defaults, $prefs));

Expand All @@ -92,7 +92,7 @@
* Display the dialog to add or edit a customer.
*/
case 'add_edit_customer':
$oldGroups = array();
$oldGroups = [];
if ($id) {
$oldGroups = $database->customer_get_groupIDs($id);
}
Expand Down Expand Up @@ -135,7 +135,7 @@

// A new customer is assigned to the group of the current user by default.
if (!$id) {
$view->assign('selectedGroups', array());
$view->assign('selectedGroups', []);
foreach ($kga['user']['groups'] as $group) {
$membershipRoleID = $database->user_get_membership_role($kga['user']['userID'], $group);
if ($database->membership_role_allows($membershipRoleID, 'core-user-add')) {
Expand All @@ -157,7 +157,7 @@
* Display the dialog to add or edit a project.
*/
case 'add_edit_project':
$oldGroups = array();
$oldGroups = [];
if ($id) {
$oldGroups = $database->project_get_groupIDs($id);
}
Expand Down Expand Up @@ -200,13 +200,13 @@
}

if (!isset($view->id)) {
$view->assign('selectedActivities', array());
$view->assign('selectedActivities', []);
$view->assign('internal', false);
}

// Set defaults for a new project.
if (!$id) {
$view->assign('selectedGroups', array());
$view->assign('selectedGroups', []);
foreach ($kga['user']['groups'] as $group) {
$membershipRoleID = $database->user_get_membership_role($kga['user']['userID'], $group);
if ($database->membership_role_allows($membershipRoleID, 'core-project-add')) {
Expand All @@ -225,7 +225,7 @@
* Display the dialog to add or edit an activity.
*/
case 'add_edit_activity':
$oldGroups = array();
$oldGroups = [];
if ($id) {
$oldGroups = $database->activity_get_groupIDs($id);
}
Expand All @@ -234,7 +234,7 @@
die();
}

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

if ($id) {
$data = $database->activity_get_data($id);
Expand Down Expand Up @@ -271,7 +271,7 @@

// Set defaults for a new project.
if (!$id) {
$selectedGroups = array();
$selectedGroups = [];
foreach ($kga['user']['groups'] as $group) {
$membershipRoleID = $database->user_get_membership_role($kga['user']['userID'], $group);
if ($database->membership_role_allows($membershipRoleID, 'core-activity-add')) {
Expand Down
18 changes: 9 additions & 9 deletions core/kimai.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
// ===============================================
// = get time for the probably running stopwatch =
// ===============================================
$current_timer = array();
$current_timer = [];
if (isset($kga['customer'])) {
$current_timer['all'] = 0;
$current_timer['hour'] = 0;
Expand Down Expand Up @@ -85,7 +85,7 @@
$view->assign('dp_today', $dp_today);

if (isset($kga['customer'])) {
$view->assign('total', Kimai_Format::formatDuration($database->get_duration($in, $out, null, array($kga['customer']['customerID']))));
$view->assign('total', Kimai_Format::formatDuration($database->get_duration($in, $out, null, [$kga['customer']['customerID']])));
} else {
$view->assign('total', Kimai_Format::formatDuration($database->get_duration($in, $out, $kga['user']['userID'])));
}
Expand Down Expand Up @@ -182,9 +182,9 @@
$view->assign('lang_checkGlobalRoleName', $kga['lang']['checkGlobalRoleName']);
$view->assign('lang_checkMembershipRoleName', $kga['lang']['checkMembershipRoleName']);

$customerData = array('customerID'=>false, 'name'=>'');
$projectData = array('projectID'=>false, 'name'=>'');
$activityData = array('activityID'=>false, 'name'=>'');
$customerData = ['customerID'=>false, 'name'=>''];
$projectData = ['projectID'=>false, 'name'=>''];
$activityData = ['activityID'=>false, 'name'=>''];

if (!isset($kga['customer'])) {
//$lastTimeSheetRecord = $database->timeSheet_get_data(false);
Expand Down Expand Up @@ -222,13 +222,13 @@
// = display customer table =
// ========================
if (isset($kga['customer'])) {
$view->assign('customers', array(
array(
$view->assign('customers', [
[
'customerID' => $kga['customer']['customerID'],
'name' => $kga['customer']['name'],
'visible' => $kga['customer']['visible']
)
));
]
]);
} else {
$view->assign('customers', $database->get_customers($kga['user']['groups']));
}
Expand Down
46 changes: 23 additions & 23 deletions core/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
return;
}

$data = array();
$data = [];
if (isset($_REQUEST['project'])) {
$data['lastProject'] = $_REQUEST['project'];
}
Expand Down Expand Up @@ -94,7 +94,7 @@
$preferences['table_time_format'] = $_REQUEST['table_time_format'];

$database->user_set_preferences($preferences, 'ui.');
$database->user_set_preferences(array('timezone' => $_REQUEST['timezone']));
$database->user_set_preferences(['timezone' => $_REQUEST['timezone']]);

$rate = str_replace($kga['conf']['decimalSeparator'], '.', $_REQUEST['rate']);
if (is_numeric($rate)) {
Expand Down Expand Up @@ -148,19 +148,19 @@

$IDs = explode('|', $axValue);
$newID = $database->startRecorder($IDs[0], $IDs[1], $id);
echo json_encode(array(
echo json_encode([
'id' => $newID
));
]);
break;

/**
* Stop the running recording.
*/
case 'stopRecord':
$database->stopRecorder($id);
echo json_encode(array(
echo json_encode([
'id' => $id
));
]);
break;

/**
Expand All @@ -184,7 +184,7 @@
*/
case 'reload_customers':
if (isset($kga['customer'])) {
$view->assign('customers', array($database->customer_get_data($kga['customer']['customerID'])));
$view->assign('customers', [$database->customer_get_data($kga['customer']['customerID'])]);
} else {
$view->assign('customers', $database->get_customers($kga['user']['groups']));
}
Expand Down Expand Up @@ -264,13 +264,13 @@
$data['password'] = '';
}

$oldGroups = array();
$oldGroups = [];
if ($id) {
$oldGroups = $database->customer_get_groupIDs($id);
}

// validate data
$errorMessages = array();
$errorMessages = [];

if ($database->user_name2id($data['name']) !== false) {
$errorMessages['name'] = $kga['lang']['errorMessages']['userWithSameName'];
Expand Down Expand Up @@ -298,9 +298,9 @@
}

header('Content-Type: application/json;charset=utf-8');
echo json_encode(array(
echo json_encode([
'errors' => $errorMessages
));
]);

break;

Expand All @@ -321,13 +321,13 @@
$data['myRate'] = getRequestDecimal($_REQUEST['myRate']);
$data['fixedRate'] = getRequestDecimal($_REQUEST['fixedRate']);

$oldGroups = array();
$oldGroups = [];
if ($id) {
$oldGroups = $database->project_get_groupIDs($id);
}

// validate data
$errorMessages = array();
$errorMessages = [];

if (count($_REQUEST['projectGroups']) == 0) {
$errorMessages['projectGroups'] = $kga['lang']['atLeastOneGroup'];
Expand Down Expand Up @@ -361,8 +361,8 @@
continue;
}

$data = array();
foreach (array('budget', 'effort', 'approved') as $key) {
$data = [];
foreach (['budget', 'effort', 'approved'] as $key) {
$value = getRequestDecimal($_REQUEST[$key][$index]);
if ($value !== null) {
$data[$key] = max(0, $value);
Expand All @@ -382,14 +382,14 @@
$database->remove_fixed_rate($id, $item);
}
} else {
$database->assignProjectToActivitiesForGroup($id, array(), $kga['user']['groups']);
$database->assignProjectToActivitiesForGroup($id, [], $kga['user']['groups']);
}
}

header('Content-Type: application/json;charset=utf-8');
echo json_encode(array(
echo json_encode([
'errors' => $errorMessages
));
]);
break;

/**
Expand All @@ -405,13 +405,13 @@
$data['fixedRate'] = getRequestDecimal($_REQUEST['fixedRate']);
$activityGroups = $_REQUEST['activityGroups'];

$oldGroups = array();
$oldGroups = [];
if ($id) {
$oldGroups = $database->activity_get_groupIDs($id);
}

// validate data
$errorMessages = array();
$errorMessages = [];

if (count($_REQUEST['activityGroups']) == 0) {
$errorMessages['activityGroups'] = $kga['lang']['atLeastOneGroup'];
Expand Down Expand Up @@ -445,7 +445,7 @@
}
}
} else {
$database->assignActivityToProjectsForGroup($id, array(), $kga['user']['groups']);
$database->assignActivityToProjectsForGroup($id, [], $kga['user']['groups']);
}

// set the activity group and activity project mappings
Expand All @@ -455,9 +455,9 @@
}

header('Content-Type: application/json;charset=utf-8');
echo json_encode(array(
echo json_encode([
'errors' => $errorMessages
));
]);
break;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion core/soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// TODO check what works better, with or without?
//$soapOpts = array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8'/*, 'uri' => $wsdlUrl*/);
$soapOpts = array();
$soapOpts = [];

if (isset($_GET['wsdl']) || isset($_GET['WSDL'])) {
$autodiscover = new Zend_Soap_AutoDiscover();
Expand Down
4 changes: 2 additions & 2 deletions extensions/ext_debug/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
$view->assign('delete_logfile', $kga['delete_logfile']);
$view->assign(
'kga_sections',
array(
[
'all' => '',
'plain' => 'plain',
'lang' => 'translations',
'user' => 'user',
'conf' => 'config',
)
]
);
$view->assign('limitText', sprintf($view->translate('debug:lines'), $kga['logfile_lines']));

Expand Down
10 changes: 5 additions & 5 deletions extensions/ext_debug/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@
case "reloadKGA":

$output = $kga;
$filter = array(
$filter = [
'server_hostname' => "xxx",
'server_database' => "xxx",
'server_username' => "xxx",
'server_password' => "xxx",
'password_salt' => "xxx",
'user' => array(
'user' => [
'secure' => "xxx",
'userID' => "xxx",
'pw' => "xxx",
'password' => "xxx",
'apikey' => "xxx"
),
);
],
];

switch ($axValue) {
case 'plain':
Expand All @@ -120,7 +120,7 @@

case 'lang':
$output = $kga['lang'];
$filter = array();
$filter = [];
break;

case 'user':
Expand Down
6 changes: 3 additions & 3 deletions extensions/ki_adminpanel/floaters.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@

$userDetails['rate'] = $database->get_rate($userDetails['userID'], NULL, NULL);

$view->assign('globalRoles', array());
$view->assign('globalRoles', []);
foreach ($database->global_roles() as $role) {
$view->globalRoles[$role['globalRoleID']] = $role['name'];
}

$view->assign('memberships', array());
$view->assign('memberships', []);
foreach ($database->getGroupMemberships($id) as $groupId) {
$view->memberships[$groupId] = $database->user_get_membership_role($id, $groupId);
}
Expand All @@ -62,7 +62,7 @@ function ($group) {
));
}

$view->assign('membershipRoles', array());
$view->assign('membershipRoles', []);
foreach ($database->membership_roles() as $role) {
$view->membershipRoles[$role['membershipRoleID']] = $role['name'];
}
Expand Down
Loading

0 comments on commit 336a5d4

Please sign in to comment.