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

Commit 0963c58

Browse files
committed
Merge branch 'feature/php-short-array-syntax'
2 parents 5a0aebc + fa4c8a9 commit 0963c58

24 files changed

+149
-148
lines changed

.php_cs

Lines changed: 1 addition & 0 deletions
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/Adapter/Callback.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public function authenticate()
5353
try {
5454
$identity = call_user_func($callback, $this->getIdentity(), $this->getCredential());
5555
} catch (Exception $e) {
56-
return new Result(Result::FAILURE_UNCATEGORIZED, null, array($e->getMessage()));
56+
return new Result(Result::FAILURE_UNCATEGORIZED, null, [$e->getMessage()]);
5757
}
5858

5959
if (! $identity) {
60-
return new Result(Result::FAILURE, null, array('Authentication failure'));
60+
return new Result(Result::FAILURE, null, ['Authentication failure']);
6161
}
6262

63-
return new Result(Result::SUCCESS, $identity, array('Authentication success'));
63+
return new Result(Result::SUCCESS, $identity, ['Authentication success']);
6464
}
6565

6666
/**

src/Adapter/DbTable/AbstractAdapter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ protected function authenticateSetup()
294294
throw new Exception\RuntimeException($exception);
295295
}
296296

297-
$this->authenticateResultInfo = array(
297+
$this->authenticateResultInfo = [
298298
'code' => AuthenticationResult::FAILURE,
299299
'identity' => $this->identity,
300-
'messages' => array()
301-
);
300+
'messages' => []
301+
];
302302

303303
return true;
304304
}
@@ -317,7 +317,7 @@ protected function authenticateQuerySelect(Sql\Select $dbSelect)
317317
$statement = $sql->prepareStatementForSqlObject($dbSelect);
318318
try {
319319
$result = $statement->execute();
320-
$resultIdentities = array();
320+
$resultIdentities = [];
321321
// iterate result, most cross platform way
322322
foreach ($result as $row) {
323323
// ZF-6428 - account for db engines that by default return uppercase column names

src/Adapter/DbTable/CallbackCheckAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function authenticateCreateSelect()
7979
// get select
8080
$dbSelect = clone $this->getDbSelect();
8181
$dbSelect->from($this->tableName)
82-
->columns(array(Sql\Select::SQL_STAR))
82+
->columns([Sql\Select::SQL_STAR])
8383
->where(new SqlOp($this->identityColumn, '=', $this->identity));
8484

8585
return $dbSelect;

src/Adapter/DbTable/CredentialTreatmentAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ protected function authenticateCreateSelect()
8585

8686
$credentialExpression = new SqlExpr(
8787
'(CASE WHEN ?' . ' = ' . $this->credentialTreatment . ' THEN 1 ELSE 0 END) AS ?',
88-
array($this->credentialColumn, $this->credential, 'zend_auth_credential_match'),
89-
array(SqlExpr::TYPE_IDENTIFIER, SqlExpr::TYPE_VALUE, SqlExpr::TYPE_IDENTIFIER)
88+
[$this->credentialColumn, $this->credential, 'zend_auth_credential_match'],
89+
[SqlExpr::TYPE_IDENTIFIER, SqlExpr::TYPE_VALUE, SqlExpr::TYPE_IDENTIFIER]
9090
);
9191

9292
// get select
9393
$dbSelect = clone $this->getDbSelect();
9494
$dbSelect->from($this->tableName)
95-
->columns(array('*', $credentialExpression))
95+
->columns(['*', $credentialExpression])
9696
->where(new SqlOp($this->identityColumn, '=', $this->identity));
9797

9898
return $dbSelect;

src/Adapter/Digest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function setPassword($password)
147147
*/
148148
public function authenticate()
149149
{
150-
$optionsRequired = array('filename', 'realm', 'identity', 'credential');
150+
$optionsRequired = ['filename', 'realm', 'identity', 'credential'];
151151
foreach ($optionsRequired as $optionRequired) {
152152
if (null === $this->$optionRequired) {
153153
throw new Exception\RuntimeException("Option '$optionRequired' must be set before authentication");
@@ -164,14 +164,14 @@ public function authenticate()
164164
$id = "$this->identity:$this->realm";
165165
$idLength = strlen($id);
166166

167-
$result = array(
167+
$result = [
168168
'code' => AuthenticationResult::FAILURE,
169-
'identity' => array(
169+
'identity' => [
170170
'realm' => $this->realm,
171171
'username' => $this->identity,
172-
),
173-
'messages' => array()
174-
);
172+
],
173+
'messages' => []
174+
];
175175

176176
while (($line = fgets($fileHandle)) !== false) {
177177
$line = trim($line);

src/Adapter/Http.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Http implements AdapterInterface
5959
*
6060
* @var array
6161
*/
62-
protected $supportedSchemes = array('basic', 'digest');
62+
protected $supportedSchemes = ['basic', 'digest'];
6363

6464
/**
6565
* List of schemes this class will accept from the client
@@ -102,7 +102,7 @@ class Http implements AdapterInterface
102102
*
103103
* @var array
104104
*/
105-
protected $supportedAlgos = array('MD5');
105+
protected $supportedAlgos = ['MD5'];
106106

107107
/**
108108
* The actual algorithm to use. Defaults to MD5
@@ -117,7 +117,7 @@ class Http implements AdapterInterface
117117
*
118118
* @var array
119119
*/
120-
protected $supportedQops = array('auth');
120+
protected $supportedQops = ['auth'];
121121

122122
/**
123123
* Whether or not to do Proxy Authentication instead of origin server
@@ -346,8 +346,8 @@ public function authenticate()
346346
$this->response->setStatusCode(400);
347347
return new Authentication\Result(
348348
Authentication\Result::FAILURE_UNCATEGORIZED,
349-
array(),
350-
array('Client requested an incorrect or unsupported authentication scheme')
349+
[],
350+
['Client requested an incorrect or unsupported authentication scheme']
351351
);
352352
}
353353

@@ -418,8 +418,8 @@ public function challengeClient()
418418
}
419419
return new Authentication\Result(
420420
Authentication\Result::FAILURE_CREDENTIAL_INVALID,
421-
array(),
422-
array('Invalid or absent credentials; challenging client')
421+
[],
422+
['Invalid or absent credentials; challenging client']
423423
);
424424
}
425425

@@ -503,7 +503,7 @@ protected function _basicAuth($header)
503503
&& !is_array($result)
504504
&& CryptUtils::compareStrings($result, $creds[1])
505505
) {
506-
$identity = array('username' => $creds[0], 'realm' => $this->realm);
506+
$identity = ['username' => $creds[0], 'realm' => $this->realm];
507507
return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
508508
} elseif (is_array($result)) {
509509
return new Authentication\Result(Authentication\Result::SUCCESS, $result);
@@ -533,8 +533,8 @@ protected function _digestAuth($header)
533533
$this->response->setStatusCode(400);
534534
return new Authentication\Result(
535535
Authentication\Result::FAILURE_UNCATEGORIZED,
536-
array(),
537-
array('Invalid Authorization header format')
536+
[],
537+
['Invalid Authorization header format']
538538
);
539539
}
540540

@@ -594,7 +594,7 @@ protected function _digestAuth($header)
594594
// If our digest matches the client's let them in, otherwise return
595595
// a 401 code and exit to prevent access to the protected resource.
596596
if (CryptUtils::compareStrings($digest, $data['response'])) {
597-
$identity = array('username' => $data['username'], 'realm' => $data['realm']);
597+
$identity = ['username' => $data['username'], 'realm' => $data['realm']];
598598
return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
599599
}
600600

@@ -658,7 +658,7 @@ protected function _calcOpaque()
658658
protected function _parseDigestAuth($header)
659659
{
660660
$temp = null;
661-
$data = array();
661+
$data = [];
662662

663663
// See ZF-1052. Detect invalid usernames instead of just returning a
664664
// 400 code.

src/Adapter/Http/ApacheResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function resolve($username, $realm, $password = null)
148148
fclose($fp);
149149

150150
if (!isset($matchedHash)) {
151-
return new AuthResult(AuthResult::FAILURE_IDENTITY_NOT_FOUND, null, array('Username not found in provided htpasswd file'));
151+
return new AuthResult(AuthResult::FAILURE_IDENTITY_NOT_FOUND, null, ['Username not found in provided htpasswd file']);
152152
}
153153

154154
// Plaintext password
@@ -166,6 +166,6 @@ public function resolve($username, $realm, $password = null)
166166
return new AuthResult(AuthResult::SUCCESS, $username);
167167
}
168168

169-
return new AuthResult(AuthResult::FAILURE_CREDENTIAL_INVALID, null, array('Passwords did not match.'));
169+
return new AuthResult(AuthResult::FAILURE_CREDENTIAL_INVALID, null, ['Passwords did not match.']);
170170
}
171171
}

src/Adapter/Ldap.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Ldap extends AbstractAdapter
4444
* @param string $identity The username of the account being authenticated
4545
* @param string $credential The password of the account being authenticated
4646
*/
47-
public function __construct(array $options = array(), $identity = null, $credential = null)
47+
public function __construct(array $options = [], $identity = null, $credential = null)
4848
{
4949
$this->setOptions($options);
5050
if ($identity !== null) {
@@ -74,7 +74,7 @@ public function getOptions()
7474
*/
7575
public function setOptions($options)
7676
{
77-
$this->options = is_array($options) ? $options : array();
77+
$this->options = is_array($options) ? $options : [];
7878
if (array_key_exists('identity', $this->options)) {
7979
$this->options['username'] = $this->options['identity'];
8080
}
@@ -152,7 +152,7 @@ public function setLdap(ZendLdap\Ldap $ldap)
152152
{
153153
$this->ldap = $ldap;
154154

155-
$this->setOptions(array($ldap->getOptions()));
155+
$this->setOptions([$ldap->getOptions()]);
156156

157157
return $this;
158158
}
@@ -182,7 +182,7 @@ protected function getAuthorityName()
182182
*/
183183
public function authenticate()
184184
{
185-
$messages = array();
185+
$messages = [];
186186
$messages[0] = ''; // reserved
187187
$messages[1] = ''; // reserved
188188

@@ -207,7 +207,7 @@ public function authenticate()
207207

208208
$code = AuthenticationResult::FAILURE;
209209
$messages[0] = "Authority not found: $username";
210-
$failedAuthorities = array();
210+
$failedAuthorities = [];
211211

212212
/* Iterate through each server and try to authenticate the supplied
213213
* credentials against it.
@@ -326,15 +326,15 @@ public function authenticate()
326326
*/
327327
protected function prepareOptions(ZendLdap\Ldap $ldap, array $options)
328328
{
329-
$adapterOptions = array(
329+
$adapterOptions = [
330330
'group' => null,
331331
'groupDn' => $ldap->getBaseDn(),
332332
'groupScope' => ZendLdap\Ldap::SEARCH_SCOPE_SUB,
333333
'groupAttr' => 'cn',
334334
'groupFilter' => 'objectClass=groupOfUniqueNames',
335335
'memberAttr' => 'uniqueMember',
336336
'memberIsDn' => true
337-
);
337+
];
338338
foreach ($adapterOptions as $key => $value) {
339339
if (array_key_exists($key, $options)) {
340340
$value = $options[$key];
@@ -344,11 +344,11 @@ protected function prepareOptions(ZendLdap\Ldap $ldap, array $options)
344344
$value = (int) $value;
345345
if (in_array(
346346
$value,
347-
array(
347+
[
348348
ZendLdap\Ldap::SEARCH_SCOPE_BASE,
349349
ZendLdap\Ldap::SEARCH_SCOPE_ONE,
350350
ZendLdap\Ldap::SEARCH_SCOPE_SUB,
351-
),
351+
],
352352
true
353353
)) {
354354
$adapterOptions[$key] = $value;
@@ -416,7 +416,7 @@ protected function checkGroupMembership(ZendLdap\Ldap $ldap, $canonicalName, $dn
416416
* @param array $omitAttribs
417417
* @return stdClass|bool
418418
*/
419-
public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array())
419+
public function getAccountObject(array $returnAttribs = [], array $omitAttribs = [])
420420
{
421421
if (!$this->authenticatedDn) {
422422
return false;

src/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Result
7171
* @param mixed $identity
7272
* @param array $messages
7373
*/
74-
public function __construct($code, $identity, array $messages = array())
74+
public function __construct($code, $identity, array $messages = [])
7575
{
7676
$this->code = (int) $code;
7777
$this->identity = $identity;

0 commit comments

Comments
 (0)