Apply lint rules to Phabricator

Summary: Mostly applies a new call spacing rule; also a few things that have slipped through via pull requests and such

Test Plan: `find src/ -type f -name '*.php' | xargs -n16 arc lint --output summary --apply-patches`

Reviewers: chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D5002
This commit is contained in:
epriestley
2013-02-19 13:33:10 -08:00
parent 63f35ee94f
commit a22bea2a74
128 changed files with 341 additions and 662 deletions

View File

@@ -193,8 +193,7 @@ final class PhabricatorOAuthServer {
// check if the scope includes "offline_access", which makes the
// token valid despite being expired
if (isset(
$token_scope[PhabricatorOAuthServerScope::SCOPE_OFFLINE_ACCESS]
)) {
$token_scope[PhabricatorOAuthServerScope::SCOPE_OFFLINE_ACCESS])) {
$valid = true;
}
}

View File

@@ -29,8 +29,7 @@ final class PhabricatorOAuthServerScope {
$name = $scope,
$value = 1,
$label = self::getCheckboxLabel($scope),
$checked = isset($current_scopes[$scope])
);
$checked = isset($current_scopes[$scope]));
}
$checkboxes->setLabel('Scope');

View File

@@ -18,8 +18,7 @@ final class PhabricatorOAuthServerTestCase
$this->assertEqual(
$expected,
$result,
"Validation of redirect URI '{$input}'"
);
"Validation of redirect URI '{$input}'");
}
}
@@ -41,8 +40,7 @@ final class PhabricatorOAuthServerTestCase
$expected,
$server->validateSecondaryRedirectURI($uri, $primary_uri),
"Validation of redirect URI '{$input}' ".
"relative to '{$primary_uri}'"
);
"relative to '{$primary_uri}'");
}
$primary_uri = new PhutilURI('http://www.google.com/?auth');
@@ -60,8 +58,7 @@ final class PhabricatorOAuthServerTestCase
$expected,
$server->validateSecondaryRedirectURI($uri, $primary_uri),
"Validation of secondary redirect URI '{$input}' ".
"relative to '{$primary_uri}'"
);
"relative to '{$primary_uri}'");
}
}

View File

@@ -29,8 +29,7 @@ extends PhabricatorAuthController {
if (!$client_phid) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter client_id not specified.'
);
'Required parameter client_id not specified.');
return $response;
}
$server->setUser($current_user);
@@ -43,8 +42,7 @@ extends PhabricatorAuthController {
if (!$client) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Client with id '.$client_phid.' not found.'
);
'Client with id '.$client_phid.' not found.');
return $response;
}
$server->setClient($client);
@@ -58,8 +56,7 @@ extends PhabricatorAuthController {
'The specified redirect URI is invalid. The redirect URI '.
'must be a fully-qualified domain with no fragments and '.
'must have the same domain and at least the same query '.
'parameters as the redirect URI the client registered.'
);
'parameters as the redirect URI the client registered.');
return $response;
}
$uri = $redirect_uri;
@@ -73,8 +70,7 @@ extends PhabricatorAuthController {
if (empty($response_type)) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter response_type not specified.'
);
'Required parameter response_type not specified.');
return $response;
}
if ($response_type != 'code') {
@@ -82,16 +78,14 @@ extends PhabricatorAuthController {
$response->setErrorDescription(
'The authorization server does not support obtaining an '.
'authorization code using the specified response_type. '.
'You must specify the response_type as "code".'
);
'You must specify the response_type as "code".');
return $response;
}
if ($scope) {
if (!PhabricatorOAuthServerScope::validateScopesList($scope)) {
$response->setError('invalid_scope');
$response->setErrorDescription(
'The requested scope is invalid, unknown, or malformed.'
);
'The requested scope is invalid, unknown, or malformed.');
return $response;
}
$scope = PhabricatorOAuthServerScope::scopesListToDict($scope);
@@ -136,8 +130,7 @@ extends PhabricatorAuthController {
$response->setError('server_error');
$response->setErrorDescription(
'The authorization server encountered an unexpected condition '.
'which prevented it from fulfilling the request. '
);
'which prevented it from fulfilling the request. ');
return $response;
}
@@ -162,8 +155,7 @@ extends PhabricatorAuthController {
if (!PhabricatorOAuthServerScope::validateScopesDict($desired_scopes)) {
$response->setError('invalid_scope');
$response->setErrorDescription(
'The requested scope is invalid, unknown, or malformed.'
);
'The requested scope is invalid, unknown, or malformed.');
return $response;
}
} else {
@@ -185,16 +177,13 @@ extends PhabricatorAuthController {
->setUser($current_user)
->appendChild(
id(new AphrontFormStaticControl())
->setValue($description)
)
->setValue($description))
->appendChild(
PhabricatorOAuthServerScope::getCheckboxControl($desired_scopes)
)
PhabricatorOAuthServerScope::getCheckboxControl($desired_scopes))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Authorize')
->addCancelButton($cancel_uri)
);
->addCancelButton($cancel_uri));
$panel->appendChild($form);

View File

@@ -22,29 +22,25 @@ extends PhabricatorAuthController {
if ($grant_type != 'authorization_code') {
$response->setError('unsupported_grant_type');
$response->setErrorDescription(
'Only grant_type authorization_code is supported.'
);
'Only grant_type authorization_code is supported.');
return $response;
}
if (!$code) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter code missing.'
);
'Required parameter code missing.');
return $response;
}
if (!$client_phid) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter client_id missing.'
);
'Required parameter client_id missing.');
return $response;
}
if (!$client_secret) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter client_secret missing.'
);
'Required parameter client_secret missing.');
return $response;
}
// one giant try / catch around all the exciting database stuff so we
@@ -56,8 +52,7 @@ extends PhabricatorAuthController {
if (!$auth_code) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Authorization code '.$code.' not found.'
);
'Authorization code '.$code.' not found.');
return $response;
}
@@ -72,16 +67,14 @@ extends PhabricatorAuthController {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Redirect uri in request must exactly match redirect uri '.
'from authorization code.'
);
'from authorization code.');
return $response;
}
} else if ($redirect_uri) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Redirect uri in request and no redirect uri in authorization '.
'code. The two must exactly match.'
);
'code. The two must exactly match.');
return $response;
}
@@ -91,8 +84,7 @@ extends PhabricatorAuthController {
if (!$client) {
$response->setError('invalid_client');
$response->setErrorDescription(
'Client with client_id '.$client_phid.' not found.'
);
'Client with client_id '.$client_phid.' not found.');
return $response;
}
$server->setClient($client);
@@ -103,8 +95,7 @@ extends PhabricatorAuthController {
if (!$user) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'User with phid '.$user_phid.' not found.'
);
'User with phid '.$user_phid.' not found.');
return $response;
}
$server->setUser($user);
@@ -117,8 +108,7 @@ extends PhabricatorAuthController {
if (!$is_good_code) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Invalid authorization code '.$code.'.'
);
'Invalid authorization code '.$code.'.');
return $response;
}
@@ -136,8 +126,7 @@ extends PhabricatorAuthController {
$response->setError('server_error');
$response->setErrorDescription(
'The authorization server encountered an unexpected condition '.
'which prevented it from fulfilling the request.'
);
'which prevented it from fulfilling the request.');
return $response;
}
}

View File

@@ -88,8 +88,7 @@ extends PhabricatorOAuthClientBaseController {
'Redirect URI must be a fully qualified domain name '.
'with no fragments. See '.
'http://tools.ietf.org/html/draft-ietf-oauth-v2-23#section-3.1.2 '.
'for more information on the correct format.'
);
'for more information on the correct format.');
$bad_redirect = true;
} else {
$client->save();
@@ -124,20 +123,17 @@ extends PhabricatorOAuthClientBaseController {
id(new AphrontFormTextControl())
->setLabel('Name')
->setName('name')
->setValue($client->getName())
);
->setValue($client->getName()));
if ($this->isClientEdit()) {
$form
->appendChild(
id(new AphrontFormTextControl())
->setLabel('ID')
->setValue($phid)
)
->setValue($phid))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Secret')
->setValue($client->getSecret())
);
->setValue($client->getSecret()));
}
$form
->appendChild(
@@ -145,8 +141,7 @@ extends PhabricatorOAuthClientBaseController {
->setLabel('Redirect URI')
->setName('redirect_uri')
->setValue($client->getRedirectURI())
->setError($bad_redirect)
);
->setError($bad_redirect));
if ($this->isClientEdit()) {
$created = phabricator_datetime($client->getDateCreated(),
$current_user);
@@ -156,27 +151,23 @@ extends PhabricatorOAuthClientBaseController {
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Created')
->setValue($created)
)
->setValue($created))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Last Updated')
->setValue($updated)
);
->setValue($updated));
}
$form
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($submit_button)
);
->setValue($submit_button));
$panel->appendChild($form);
return $this->buildStandardPageResponse(
array($error,
$panel
),
array('title' => $title)
);
array('title' => $title));
}
}

View File

@@ -36,8 +36,7 @@ extends PhabricatorOAuthClientBaseController {
array(
'href' => $client->getViewURI(),
),
$client->getName()
),
$client->getName()),
$client->getPHID(),
$client->getSecret(),
phutil_tag(
@@ -45,16 +44,14 @@ extends PhabricatorOAuthClientBaseController {
array(
'href' => $client->getRedirectURI(),
),
$client->getRedirectURI()
),
$client->getRedirectURI()),
phutil_tag(
'a',
array(
'class' => 'small button grey',
'href' => $client->getEditURI(),
),
'Edit'
),
'Edit'),
);
$rows[] = $row;
@@ -72,8 +69,7 @@ extends PhabricatorOAuthClientBaseController {
$this->getNoticeView(),
$panel->appendChild($pager)
),
array('title' => $title)
);
array('title' => $title));
}
private function buildClientList($rows, $rowc, $title) {
@@ -97,8 +93,7 @@ extends PhabricatorOAuthClientBaseController {
));
if (empty($rows)) {
$table->setNoDataString(
'You have not created any clients for this OAuthServer.'
);
'You have not created any clients for this OAuthServer.');
}
$panel = new AphrontPanelView();

View File

@@ -33,8 +33,7 @@ extends PhabricatorOAuthClientBaseController {
$message = 'No client found with id '.$phid.'.';
return $this->buildStandardPageResponse(
$this->buildErrorView($message),
array('title' => $title)
);
array('title' => $title));
}
$panel = new AphrontPanelView();
@@ -45,27 +44,23 @@ extends PhabricatorOAuthClientBaseController {
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Name')
->setValue($client->getName())
)
->setValue($client->getName()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('ID')
->setValue($phid)
);
->setValue($phid));
if ($current_user->getPHID() == $client->getCreatorPHID()) {
$form
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Secret')
->setValue($client->getSecret())
);
->setValue($client->getSecret()));
}
$form
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Redirect URI')
->setValue($client->getRedirectURI())
);
->setValue($client->getRedirectURI()));
$created = phabricator_datetime($client->getDateCreated(),
$current_user);
$updated = phabricator_datetime($client->getDateModified(),
@@ -74,13 +69,11 @@ extends PhabricatorOAuthClientBaseController {
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Created')
->setValue($created)
)
->setValue($created))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Last Updated')
->setValue($updated)
);
->setValue($updated));
$panel->appendChild($form);
$admin_panel = null;
if ($client->getCreatorPHID() == $current_user->getPHID()) {
@@ -100,8 +93,7 @@ extends PhabricatorOAuthClientBaseController {
->setAction('/oauthserver/test/')
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Create Scopeless Test Authorization')
);
->setValue('Create Scopeless Test Authorization'));
$admin_panel = id(new AphrontPanelView())
->setHeader('Admin Tools')
->appendChild($create_authorization_form);
@@ -112,7 +104,6 @@ extends PhabricatorOAuthClientBaseController {
$panel,
$admin_panel
),
array('title' => $title)
);
array('title' => $title));
}
}

View File

@@ -66,33 +66,26 @@ extends PhabricatorOAuthClientAuthorizationBaseController {
array(
'href' => $client->getViewURI(),
),
$client->getName()))
)
$client->getName())))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Created')
->setValue($created)
)
->setValue($created))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Last Updated')
->setValue($updated)
)
->setValue($updated))
->appendChild(
PhabricatorOAuthServerScope::getCheckboxControl(
$authorization->getScope()
)
)
$authorization->getScope()))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save OAuth Client Authorization')
->addCancelButton('/oauthserver/clientauthorization/')
);
->addCancelButton('/oauthserver/clientauthorization/'));
$panel->appendChild($form);
return $this->buildStandardPageResponse(
$panel,
array('title' => $title)
);
array('title' => $title));
}
}

View File

@@ -47,39 +47,33 @@ extends PhabricatorOAuthClientAuthorizationBaseController {
$updated = phabricator_datetime($authorization->getDateModified(),
$current_user);
$scope_doc_href = PhabricatorEnv::getDoclink(
'article/Using_the_Phabricator_OAuth_Server.html#scopes'
);
'article/Using_the_Phabricator_OAuth_Server.html#scopes');
$row = array(
phutil_tag(
'a',
array(
'href' => $client->getViewURI(),
),
$client->getName()
),
$client->getName()),
phutil_tag(
'a',
array(
'href' => $scope_doc_href,
),
$authorization->getScopeString()
),
$authorization->getScopeString()),
phabricator_datetime(
$authorization->getDateCreated(),
$current_user
),
$current_user),
phabricator_datetime(
$authorization->getDateModified(),
$current_user
),
$current_user),
phutil_tag(
'a',
array(
'class' => 'small button grey',
'href' => $authorization->getEditURI(),
),
'Edit'
),
'Edit'),
);
$rows[] = $row;
@@ -97,8 +91,7 @@ extends PhabricatorOAuthClientAuthorizationBaseController {
$this->getNoticeView(),
$panel->appendChild($pager),
),
array('title' => $title)
);
array('title' => $title));
}
private function buildClientAuthorizationList($rows, $rowc, $title) {
@@ -122,8 +115,7 @@ extends PhabricatorOAuthClientAuthorizationBaseController {
));
if (empty($rows)) {
$table->setNoDataString(
'You have not authorized any clients for this OAuthServer.'
);
'You have not authorized any clients for this OAuthServer.');
}
$panel = new AphrontPanelView();