Skip to content

Commit 89a8a07

Browse files
committed
Converting remaining array syntax to the short syntax.
1 parent dd9f502 commit 89a8a07

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/Controller/Component/Auth/FormAuthenticate.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
* data. Can be used by configuring AuthComponent to use it via the AuthComponent::$authenticate config.
2626
*
2727
* {{{
28-
* $this->Auth->authenticate = array(
29-
* 'Form' => array(
30-
* 'scope' => array('Users.active' => 1)
31-
* )
32-
* )
28+
* $this->Auth->authenticate = [
29+
* 'Form' => [
30+
* 'scope' => ['Users.active' => 1]
31+
* ]
32+
* ]
3333
* }}}
3434
*
3535
* When configuring FormAuthenticate you can pass in config to which fields, model and additional conditions
@@ -47,7 +47,7 @@ class FormAuthenticate extends BaseAuthenticate {
4747
* @return boolean False if the fields have not been supplied. True if they exist.
4848
*/
4949
protected function _checkFields(Request $request, array $fields) {
50-
foreach (array($fields['username'], $fields['password']) as $field) {
50+
foreach ([$fields['username'], $fields['password']] as $field) {
5151
$value = $request->data($field);
5252
if (empty($value) || !is_string($value)) {
5353
return false;

tests/TestCase/Controller/Component/Auth/FormAuthenticateTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class FormAuthenticateTest extends TestCase {
3838
*
3939
* @var array
4040
*/
41-
public $fixtures = array('core.user', 'core.auth_user');
41+
public $fixtures = ['core.user', 'core.auth_user'];
4242

4343
/**
4444
* setup
@@ -48,9 +48,9 @@ class FormAuthenticateTest extends TestCase {
4848
public function setUp() {
4949
parent::setUp();
5050
$this->Collection = $this->getMock('Cake\Controller\ComponentRegistry');
51-
$this->auth = new FormAuthenticate($this->Collection, array(
51+
$this->auth = new FormAuthenticate($this->Collection, [
5252
'userModel' => 'Users'
53-
));
53+
]);
5454
$password = Security::hash('password', 'blowfish', false);
5555
$Users = TableRegistry::get('Users');
5656
$Users->updateAll(['password' => $password], []);
@@ -63,12 +63,12 @@ public function setUp() {
6363
* @return void
6464
*/
6565
public function testConstructor() {
66-
$object = new FormAuthenticate($this->Collection, array(
66+
$object = new FormAuthenticate($this->Collection, [
6767
'userModel' => 'AuthUsers',
68-
'fields' => array('username' => 'user', 'password' => 'password')
69-
));
68+
'fields' => ['username' => 'user', 'password' => 'password']
69+
]);
7070
$this->assertEquals('AuthUsers', $object->config('userModel'));
71-
$this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->config('fields'));
71+
$this->assertEquals(['username' => 'user', 'password' => 'password'], $object->config('fields'));
7272
}
7373

7474
/**
@@ -133,13 +133,13 @@ public function testAuthenticatePasswordIsEmptyString() {
133133

134134
$this->auth = $this->getMock(
135135
'Cake\Controller\Component\Auth\FormAuthenticate',
136-
array('_checkFields'),
137-
array(
136+
['_checkFields'],
137+
[
138138
$this->Collection,
139-
array(
139+
[
140140
'userModel' => 'Users'
141-
)
142-
)
141+
]
142+
]
143143
);
144144

145145
// Simulate that check for ensuring password is not empty is missing.
@@ -196,12 +196,12 @@ public function testAuthenticateSuccess() {
196196
'password' => 'password'
197197
];
198198
$result = $this->auth->authenticate($request, $this->response);
199-
$expected = array(
199+
$expected = [
200200
'id' => 1,
201201
'username' => 'mariano',
202202
'created' => new \DateTime('2007-03-17 01:16:23'),
203203
'updated' => new \DateTime('2007-03-17 01:18:31')
204-
);
204+
];
205205
$this->assertEquals($expected, $result);
206206
}
207207

@@ -245,12 +245,12 @@ public function testPluginModel() {
245245
];
246246

247247
$result = $this->auth->authenticate($request, $this->response);
248-
$expected = array(
248+
$expected = [
249249
'id' => 1,
250250
'username' => 'gwoo',
251251
'created' => new \DateTime('2007-03-17 01:16:23'),
252252
'updated' => new \DateTime('2007-03-17 01:18:31')
253-
);
253+
];
254254
$this->assertEquals($expected, $result);
255255
Plugin::unload();
256256
}
@@ -273,8 +273,8 @@ public function testPasswordHasherSettings() {
273273
$hash = Security::hash('mypass', 'md5', true);
274274
$User = TableRegistry::get('Users');
275275
$User->updateAll(
276-
array('password' => $hash),
277-
array('username' => 'mariano')
276+
['password' => $hash],
277+
['username' => 'mariano']
278278
);
279279

280280
$request = new Request('posts/index');
@@ -284,18 +284,18 @@ public function testPasswordHasherSettings() {
284284
];
285285

286286
$result = $this->auth->authenticate($request, $this->response);
287-
$expected = array(
287+
$expected = [
288288
'id' => 1,
289289
'username' => 'mariano',
290290
'created' => new \DateTime('2007-03-17 01:16:23'),
291291
'updated' => new \DateTime('2007-03-17 01:18:31')
292-
);
292+
];
293293
$this->assertEquals($expected, $result);
294294

295-
$this->auth = new FormAuthenticate($this->Collection, array(
296-
'fields' => array('username' => 'username', 'password' => 'password'),
295+
$this->auth = new FormAuthenticate($this->Collection, [
296+
'fields' => ['username' => 'username', 'password' => 'password'],
297297
'userModel' => 'Users'
298-
));
298+
]);
299299
$this->auth->config('passwordHasher', [
300300
'className' => 'Simple',
301301
'hashType' => 'sha1'

0 commit comments

Comments
 (0)