Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 150af6c

Browse files
committed
Merge branch 'feature/php-short-array-syntax' into develop
2 parents c01369f + 8a464ff commit 150af6c

File tree

122 files changed

+2247
-2246
lines changed

Some content is hidden

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

122 files changed

+2247
-2246
lines changed

.php_cs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $config->fixers(
3232
'object_operator',
3333
'php_closing_tag',
3434
'remove_lines_between_uses',
35+
'short_array_syntax',
3536
'short_tag',
3637
'standardize_not_equal',
3738
'trailing_spaces',

src/Application.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ class Application implements
6363
*
6464
* @var array
6565
*/
66-
protected $defaultListeners = array(
66+
protected $defaultListeners = [
6767
'RouteListener',
6868
'DispatchListener',
6969
'HttpMethodListener',
7070
'ViewManager',
7171
'SendResponseListener',
72-
);
72+
];
7373

7474
/**
7575
* MVC event token
@@ -134,7 +134,7 @@ public function getConfig()
134134
* @param array $listeners List of listeners to attach.
135135
* @return Application
136136
*/
137-
public function bootstrap(array $listeners = array())
137+
public function bootstrap(array $listeners = [])
138138
{
139139
$serviceManager = $this->serviceManager;
140140
$events = $this->events;
@@ -206,10 +206,10 @@ public function getMvcEvent()
206206
*/
207207
public function setEventManager(EventManagerInterface $eventManager)
208208
{
209-
$eventManager->setIdentifiers(array(
209+
$eventManager->setIdentifiers([
210210
__CLASS__,
211211
get_class($this),
212-
));
212+
]);
213213
$this->events = $eventManager;
214214
return $this;
215215
}
@@ -245,16 +245,16 @@ public function getEventManager()
245245
* @param array $configuration
246246
* @return Application
247247
*/
248-
public static function init($configuration = array())
248+
public static function init($configuration = [])
249249
{
250-
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
250+
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : [];
251251
$serviceManager = new ServiceManager(new Service\ServiceManagerConfig($smConfig));
252252
$serviceManager->setService('ApplicationConfig', $configuration);
253253
$serviceManager->get('ModuleManager')->loadModules();
254254

255-
$listenersFromAppConfig = isset($configuration['listeners']) ? $configuration['listeners'] : array();
255+
$listenersFromAppConfig = isset($configuration['listeners']) ? $configuration['listeners'] : [];
256256
$config = $serviceManager->get('Config');
257-
$listenersFromConfigService = isset($config['listeners']) ? $config['listeners'] : array();
257+
$listenersFromConfigService = isset($config['listeners']) ? $config['listeners'] : [];
258258

259259
$listeners = array_unique(array_merge($listenersFromConfigService, $listenersFromAppConfig));
260260

src/Controller/AbstractActionController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ abstract class AbstractActionController extends AbstractController
3131
*/
3232
public function indexAction()
3333
{
34-
return new ViewModel(array(
34+
return new ViewModel([
3535
'content' => 'Placeholder page'
36-
));
36+
]);
3737
}
3838

3939
/**
@@ -94,7 +94,7 @@ public function onDispatch(MvcEvent $e)
9494
*/
9595
protected function createHttpNotFoundModel(HttpResponse $response)
9696
{
97-
return $this->__call('createHttpNotFoundModel', array($response));
97+
return $this->__call('createHttpNotFoundModel', [$response]);
9898
}
9999

100100
/**
@@ -105,6 +105,6 @@ protected function createHttpNotFoundModel(HttpResponse $response)
105105
*/
106106
protected function createConsoleNotFoundModel($response)
107107
{
108-
return $this->__call('createConsoleNotFoundModel', array($response));
108+
return $this->__call('createConsoleNotFoundModel', [$response]);
109109
}
110110
}

src/Controller/AbstractController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ public function setEventManager(EventManagerInterface $events)
164164

165165
$nsPos = strpos($className, '\\') ?: 0;
166166
$events->setIdentifiers(array_merge(
167-
array(
167+
[
168168
__CLASS__,
169169
$className,
170170
substr($className, 0, $nsPos)
171-
),
171+
],
172172
array_values(class_implements($className)),
173173
(array) $this->eventIdentifier
174174
));
@@ -320,7 +320,7 @@ public function __call($method, $params)
320320
protected function attachDefaultListeners()
321321
{
322322
$events = $this->getEventManager();
323-
$events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'onDispatch'));
323+
$events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'onDispatch']);
324324
}
325325

326326
/**
@@ -331,7 +331,7 @@ protected function attachDefaultListeners()
331331
*/
332332
public static function getMethodFromAction($action)
333333
{
334-
$method = str_replace(array('.', '-', '_'), ' ', $action);
334+
$method = str_replace(['.', '-', '_'], ' ', $action);
335335
$method = ucwords($method);
336336
$method = str_replace(' ', '', $method);
337337
$method = lcfirst($method);

src/Controller/AbstractRestfulController.php

+29-29
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ abstract class AbstractRestfulController extends AbstractController
3030
/**
3131
* @var array
3232
*/
33-
protected $contentTypes = array(
34-
self::CONTENT_TYPE_JSON => array(
33+
protected $contentTypes = [
34+
self::CONTENT_TYPE_JSON => [
3535
'application/hal+json',
3636
'application/json'
37-
)
38-
);
37+
]
38+
];
3939

4040
/**
4141
* Name of request or query parameter containing identifier
@@ -54,7 +54,7 @@ abstract class AbstractRestfulController extends AbstractController
5454
*
5555
* @var array
5656
*/
57-
protected $customHttpMethodsMap = array();
57+
protected $customHttpMethodsMap = [];
5858

5959
/**
6060
* Set the route match/query parameter name containing the identifier
@@ -88,9 +88,9 @@ public function create($data)
8888
{
8989
$this->response->setStatusCode(405);
9090

91-
return array(
91+
return [
9292
'content' => 'Method Not Allowed'
93-
);
93+
];
9494
}
9595

9696
/**
@@ -103,9 +103,9 @@ public function delete($id)
103103
{
104104
$this->response->setStatusCode(405);
105105

106-
return array(
106+
return [
107107
'content' => 'Method Not Allowed'
108-
);
108+
];
109109
}
110110

111111
/**
@@ -120,9 +120,9 @@ public function deleteList($data)
120120
{
121121
$this->response->setStatusCode(405);
122122

123-
return array(
123+
return [
124124
'content' => 'Method Not Allowed'
125-
);
125+
];
126126
}
127127

128128
/**
@@ -135,9 +135,9 @@ public function get($id)
135135
{
136136
$this->response->setStatusCode(405);
137137

138-
return array(
138+
return [
139139
'content' => 'Method Not Allowed'
140-
);
140+
];
141141
}
142142

143143
/**
@@ -149,9 +149,9 @@ public function getList()
149149
{
150150
$this->response->setStatusCode(405);
151151

152-
return array(
152+
return [
153153
'content' => 'Method Not Allowed'
154-
);
154+
];
155155
}
156156

157157
/**
@@ -167,9 +167,9 @@ public function head($id = null)
167167
{
168168
$this->response->setStatusCode(405);
169169

170-
return array(
170+
return [
171171
'content' => 'Method Not Allowed'
172-
);
172+
];
173173
}
174174

175175
/**
@@ -187,9 +187,9 @@ public function options()
187187
{
188188
$this->response->setStatusCode(405);
189189

190-
return array(
190+
return [
191191
'content' => 'Method Not Allowed'
192-
);
192+
];
193193
}
194194

195195
/**
@@ -206,9 +206,9 @@ public function patch($id, $data)
206206
{
207207
$this->response->setStatusCode(405);
208208

209-
return array(
209+
return [
210210
'content' => 'Method Not Allowed'
211-
);
211+
];
212212
}
213213

214214
/**
@@ -224,9 +224,9 @@ public function replaceList($data)
224224
{
225225
$this->response->setStatusCode(405);
226226

227-
return array(
227+
return [
228228
'content' => 'Method Not Allowed'
229-
);
229+
];
230230
}
231231

232232
/**
@@ -242,9 +242,9 @@ public function patchList($data)
242242
{
243243
$this->response->setStatusCode(405);
244244

245-
return array(
245+
return [
246246
'content' => 'Method Not Allowed'
247-
);
247+
];
248248
}
249249

250250
/**
@@ -258,9 +258,9 @@ public function update($id, $data)
258258
{
259259
$this->response->setStatusCode(405);
260260

261-
return array(
261+
return [
262262
'content' => 'Method Not Allowed'
263-
);
263+
];
264264
}
265265

266266
/**
@@ -272,9 +272,9 @@ public function notFoundAction()
272272
{
273273
$this->response->setStatusCode(404);
274274

275-
return array(
275+
return [
276276
'content' => 'Page not found'
277-
);
277+
];
278278
}
279279

280280
/**

src/Controller/ControllerManager.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(ConfigInterface $configuration = null)
4444
{
4545
parent::__construct($configuration);
4646
// Pushing to bottom of stack to ensure this is done last
47-
$this->addInitializer(array($this, 'injectControllerDependencies'), false);
47+
$this->addInitializer([$this, 'injectControllerDependencies'], false);
4848
}
4949

5050
/**
@@ -132,7 +132,7 @@ public function has($name, $checkAbstractFactories = true, $usePeeringServiceMan
132132
* @param bool $usePeeringServiceManagers
133133
* @return mixed
134134
*/
135-
public function get($name, $options = array(), $usePeeringServiceManagers = false)
135+
public function get($name, $options = [], $usePeeringServiceManagers = false)
136136
{
137137
return parent::get($name, $options, $usePeeringServiceManagers);
138138
}

src/Controller/Plugin/CreateHttpNotFoundModel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function __invoke(Response $response)
2525
{
2626
$response->setStatusCode(404);
2727

28-
return new ViewModel(array('content' => 'Page not found'));
28+
return new ViewModel(['content' => 'Page not found']);
2929
}
3030
}

src/Controller/Plugin/FilePostRedirectGet.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function handlePostRequest(FormInterface $form, $redirect, $redirectTo
7272

7373
// Change required flag to false for any previously uploaded files
7474
$inputFilter = $form->getInputFilter();
75-
$previousFiles = ($container->files) ?: array();
75+
$previousFiles = ($container->files) ?: [];
7676
$this->traverseInputs(
7777
$inputFilter,
7878
$previousFiles,
@@ -93,14 +93,14 @@ function ($input, $value) {
9393
$prevFileData = $this->getEmptyUploadData($inputFilter, $previousFiles);
9494
$newFileData = $this->getNonEmptyUploadData($inputFilter, $data);
9595
$postFiles = ArrayUtils::merge(
96-
$prevFileData ?: array(),
97-
$newFileData ?: array(),
96+
$prevFileData ?: [],
97+
$newFileData ?: [],
9898
true
9999
);
100100
$post = ArrayUtils::merge($postOther, $postFiles, true);
101101

102102
// Save form data in session
103-
$container->setExpirationHops(1, array('post', 'errors', 'isValid'));
103+
$container->setExpirationHops(1, ['post', 'errors', 'isValid']);
104104
$container->post = $post;
105105
$container->errors = $errors;
106106
$container->isValid = $isValid;
@@ -299,8 +299,8 @@ function ($input, $value) {
299299
protected function redirect($redirect, $redirectToUrl)
300300
{
301301
$controller = $this->getController();
302-
$params = array();
303-
$options = array();
302+
$params = [];
303+
$options = [];
304304
$reuseMatchedParams = false;
305305

306306
if (null === $redirect) {

0 commit comments

Comments
 (0)