Skip to content

Commit 3b9d663

Browse files
authored
Replace array() with [] (#5509)
Replace the outdated `array()` spelling with the more modern `[]`. This is applied throughout the whole project, also including phpdocs, tests, view scripts and core modules.
1 parent eb942c8 commit 3b9d663

325 files changed

Lines changed: 2729 additions & 2727 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

application/clicommands/AutocompleteCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function completeAction()
5555
$search_word = $bare_params[$cword];
5656
if ($search_word === '--') {
5757
// TODO: Unfinished, completion missing
58-
return $this->suggest(array('--verbose', '--help', '--debug'));
58+
return $this->suggest(['--verbose', '--help', '--debug']);
5959
}
6060

6161
$search = $params->shift();
@@ -68,7 +68,7 @@ public function completeAction()
6868
if ($found) {
6969
// Do not return suggestions if we are already on the next word:
7070
if ($bare_params[$cword] === $search) {
71-
return $this->suggest(array($found));
71+
return $this->suggest([$found]);
7272
}
7373
} else {
7474
return $this->suggest($loader->getLastSuggestions());
@@ -90,7 +90,7 @@ public function completeAction()
9090
if ($command) {
9191
// Do not return suggestions if we are already on the next word:
9292
if ($bare_params[$cword] === $search) {
93-
return $this->suggest(array($command));
93+
return $this->suggest([$command]);
9494
}
9595
$obj = $loader->getModuleCommandInstance(
9696
$module,
@@ -112,7 +112,7 @@ public function completeAction()
112112
);
113113
if ($action) {
114114
if ($bare_params[$cword] === $search) {
115-
return $this->suggest(array($action));
115+
return $this->suggest([$action]);
116116
}
117117
} else {
118118
return $this->suggest($loader->getLastSuggestions());

application/clicommands/ModuleCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function init()
4040
public function listAction()
4141
{
4242
if ($type = $this->params->shift()) {
43-
if (! in_array($type, array('enabled', 'installed'))) {
43+
if (! in_array($type, ['enabled', 'installed'])) {
4444
return $this->showUsage();
4545
}
4646
} else {

application/controllers/AboutController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public function indexAction()
1919
$this->view->title = $this->translate('About');
2020
$this->view->tabs = $this->getTabs()->add(
2121
'about',
22-
array(
22+
[
2323
'label' => $this->translate('About'),
2424
'title' => $this->translate('About Icinga Web 2'),
2525
'url' => 'about'
26-
)
26+
]
2727
)->activate('about');
2828
}
2929
}

application/controllers/AccountController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ class AccountController extends Controller
2525
public function init()
2626
{
2727
$this->getTabs()
28-
->add('account', array(
28+
->add('account', [
2929
'title' => $this->translate('Update your account'),
3030
'label' => $this->translate('My Account'),
3131
'url' => 'account'
32-
))
33-
->add('navigation', array(
32+
])
33+
->add('navigation', [
3434
'title' => $this->translate('List and configure your own navigation items'),
3535
'label' => $this->translate('Navigation'),
3636
'url' => 'navigation'
37-
))
37+
])
3838
->add(
3939
'devices',
40-
array(
40+
[
4141
'title' => $this->translate('List of devices you are logged in'),
4242
'label' => $this->translate('My Devices'),
4343
'url' => 'my-devices'
44-
)
44+
]
4545
);
4646
}
4747

@@ -72,9 +72,9 @@ public function indexAction()
7272
$form = new PreferenceForm();
7373
$form->setPreferences($user->getPreferences());
7474
if (isset($config->config_resource)) {
75-
$form->setStore(PreferencesStore::create(new ConfigObject(array(
76-
'resource' => $config->config_resource
77-
)), $user));
75+
$form->setStore(PreferencesStore::create(new ConfigObject([
76+
'resource' => $config->config_resource
77+
]), $user));
7878
}
7979
$form->handleRequest();
8080

application/controllers/AnnouncementsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public function indexAction()
2828
{
2929
$this->getTabs()->add(
3030
'announcements',
31-
array(
31+
[
3232
'active' => true,
3333
'label' => $this->translate('Announcements'),
3434
'title' => $this->translate('List All Announcements'),
3535
'url' => Url::fromPath('announcements')
36-
)
36+
]
3737
);
3838

3939
$announcements = (new AnnouncementIniRepository())

application/controllers/ConfigController.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@ public function createApplicationTabs()
3838
{
3939
$tabs = $this->getTabs();
4040
if ($this->hasPermission('config/general')) {
41-
$tabs->add('general', array(
41+
$tabs->add('general', [
4242
'title' => $this->translate('Adjust the general configuration of Icinga Web 2'),
4343
'label' => $this->translate('General'),
4444
'url' => 'config/general',
4545
'baseTarget' => '_main'
46-
));
46+
]);
4747
}
4848
if ($this->hasPermission('config/resources')) {
49-
$tabs->add('resource', array(
49+
$tabs->add('resource', [
5050
'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'),
5151
'label' => $this->translate('Resources'),
5252
'url' => 'config/resource',
5353
'baseTarget' => '_main'
54-
));
54+
]);
5555
}
5656
if ($this->hasPermission('config/access-control/users')
5757
|| $this->hasPermission('config/access-control/groups')
5858
) {
59-
$tabs->add('authentication', array(
59+
$tabs->add('authentication', [
6060
'title' => $this->translate('Configure the user and group backends'),
6161
'label' => $this->translate('Access Control Backends'),
6262
'url' => 'config/userbackend',
6363
'baseTarget' => '_main'
64-
));
64+
]);
6565
}
6666

6767
return $tabs;
@@ -125,11 +125,11 @@ public function modulesAction()
125125
// Overwrite tabs created in init
126126
// @TODO(el): This seems not natural to me. Module configuration should have its own controller.
127127
$this->view->tabs = Widget::create('tabs')
128-
->add('modules', array(
128+
->add('modules', [
129129
'label' => $this->translate('Modules'),
130130
'title' => $this->translate('List intalled modules'),
131131
'url' => 'config/modules'
132-
))
132+
])
133133
->activate('modules');
134134
$this->view->modules = Icinga::app()->getModuleManager()->select()
135135
->from('modules')
@@ -418,10 +418,10 @@ public function resourceAction()
418418
public function createresourceAction()
419419
{
420420
$this->assertPermission('config/resources');
421-
$this->getTabs()->add('resources/new', array(
421+
$this->getTabs()->add('resources/new', [
422422
'label' => $this->translate('New Resource'),
423423
'url' => Url::fromRequest()
424-
))->activate('resources/new');
424+
])->activate('resources/new');
425425
$form = new ResourceConfigForm();
426426
$form->addDescription($this->translate('Resources are entities that provide data to Icinga Web 2.'));
427427
$form->setIniConfig(Config::app('resources'));
@@ -439,10 +439,10 @@ public function createresourceAction()
439439
public function editresourceAction()
440440
{
441441
$this->assertPermission('config/resources');
442-
$this->getTabs()->add('resources/update', array(
442+
$this->getTabs()->add('resources/update', [
443443
'label' => $this->translate('Update Resource'),
444444
'url' => Url::fromRequest()
445-
))->activate('resources/update');
445+
])->activate('resources/update');
446446
$form = new ResourceConfigForm();
447447
$form->setIniConfig(Config::app('resources'));
448448
$form->setRedirectUrl('config/resource');
@@ -459,11 +459,11 @@ public function editresourceAction()
459459
public function removeresourceAction()
460460
{
461461
$this->assertPermission('config/resources');
462-
$this->getTabs()->add('resources/remove', array(
462+
$this->getTabs()->add('resources/remove', [
463463
'label' => $this->translate('Remove Resource'),
464464
'url' => Url::fromRequest()
465-
))->activate('resources/remove');
466-
$form = new ConfirmRemovalForm(array(
465+
])->activate('resources/remove');
466+
$form = new ConfirmRemovalForm([
467467
'onSuccess' => function ($form) {
468468
$configForm = new ResourceConfigForm();
469469
$configForm->setIniConfig(Config::app('resources'));
@@ -482,7 +482,7 @@ public function removeresourceAction()
482482
return false;
483483
}
484484
}
485-
));
485+
]);
486486
$form->setRedirectUrl('config/resource');
487487
$form->handleRequest();
488488

application/controllers/DashboardController.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ public function init()
4040
public function newDashletAction()
4141
{
4242
$form = new DashletForm();
43-
$this->getTabs()->add('new-dashlet', array(
43+
$this->getTabs()->add('new-dashlet', [
4444
'active' => true,
4545
'label' => $this->translate('New Dashlet'),
4646
'url' => Url::fromRequest()
47-
));
47+
]);
4848
$dashboard = $this->dashboard;
4949
$form->setDashboard($dashboard);
5050
if ($this->_request->getParam('url')) {
@@ -84,11 +84,11 @@ public function newDashletAction()
8484

8585
public function updateDashletAction()
8686
{
87-
$this->getTabs()->add('update-dashlet', array(
87+
$this->getTabs()->add('update-dashlet', [
8888
'active' => true,
8989
'label' => $this->translate('Update Dashlet'),
9090
'url' => Url::fromRequest()
91-
));
91+
]);
9292
$dashboard = $this->dashboard;
9393
$form = new DashletForm();
9494
$form->setDashboard($dashboard);
@@ -149,11 +149,11 @@ public function updateDashletAction()
149149
public function removeDashletAction()
150150
{
151151
$form = new ConfirmRemovalForm();
152-
$this->getTabs()->add('remove-dashlet', array(
152+
$this->getTabs()->add('remove-dashlet', [
153153
'active' => true,
154154
'label' => $this->translate('Remove Dashlet'),
155155
'url' => Url::fromRequest()
156-
));
156+
]);
157157
$dashboard = $this->dashboard;
158158
if (! $this->_request->getParam('pane')) {
159159
throw new Zend_Controller_Action_Exception(
@@ -205,23 +205,23 @@ public function renamePaneAction()
205205
$form->addElement(
206206
'text',
207207
'name',
208-
array(
208+
[
209209
'required' => true,
210210
'label' => $this->translate('Name')
211-
)
211+
]
212212
);
213213
$form->addElement(
214214
'text',
215215
'title',
216-
array(
216+
[
217217
'required' => true,
218218
'label' => $this->translate('Title')
219-
)
219+
]
220220
);
221-
$form->setDefaults(array(
221+
$form->setDefaults([
222222
'name' => $paneName,
223223
'title' => $this->dashboard->getPane($paneName)->getTitle()
224-
));
224+
]);
225225
$form->setOnSuccess(function ($form) use ($paneName) {
226226
$newName = $form->getValue('name');
227227
$newTitle = $form->getValue('title');
@@ -241,10 +241,10 @@ public function renamePaneAction()
241241
$this->view->form = $form;
242242
$this->getTabs()->add(
243243
'update-pane',
244-
array(
244+
[
245245
'title' => $this->translate('Update Pane'),
246246
'url' => $this->getRequest()->getUrl()
247-
)
247+
]
248248
)->activate('update-pane');
249249
}
250250

@@ -306,11 +306,11 @@ function ($pane) {
306306
);
307307
if (empty($panes)) {
308308
$this->view->title = 'Dashboard';
309-
$this->getTabs()->add('dashboard', array(
309+
$this->getTabs()->add('dashboard', [
310310
'active' => true,
311311
'title' => $this->translate('Dashboard'),
312312
'url' => Url::fromRequest()
313-
));
313+
]);
314314
} else {
315315
if ($this->_getParam('pane')) {
316316
$pane = $this->_getParam('pane');

application/controllers/ErrorController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function errorAction()
6565
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
6666
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
6767
$this->getResponse()->setHttpResponseCode(404);
68-
$this->view->messages = array($this->translate('Page not found.'));
68+
$this->view->messages = [$this->translate('Page not found.')];
6969
if ($isAuthenticated) {
7070
if ($modules->hasInstalled($moduleName) && ! $modules->hasEnabled($moduleName)) {
7171
$this->view->messages[0] .= ' ' . sprintf(
@@ -136,10 +136,10 @@ public function errorAction()
136136
}
137137
}
138138

139-
$this->view->messages = array();
139+
$this->view->messages = [];
140140

141141
if ($this->getInvokeArg('displayExceptions')) {
142-
$this->view->stackTraces = array();
142+
$this->view->stackTraces = [];
143143

144144
do {
145145
$this->view->messages[] = $exception->getMessage();
@@ -168,11 +168,11 @@ public function errorAction()
168168
$this->view->hideControls = true;
169169
} else {
170170
$this->view->hideControls = false;
171-
$this->getTabs()->add('error', array(
171+
$this->getTabs()->add('error', [
172172
'active' => true,
173173
'label' => $this->translate('Error'),
174174
'url' => Url::fromRequest()
175-
));
175+
]);
176176
}
177177
}
178178
}

0 commit comments

Comments
 (0)