Use Short Array notation

This commit is contained in:
Nicolas Le Goff
2013-11-18 15:54:39 +01:00
parent 739866a2b4
commit 678f741660
67 changed files with 1295 additions and 1295 deletions

View File

@@ -79,7 +79,7 @@ class API_OAuth2_Account
WHERE api_account_id = :api_account_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':api_account_id' => $this->id));
$stmt->execute([':api_account_id' => $this->id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -141,10 +141,10 @@ class API_OAuth2_Account
$sql = 'UPDATE api_accounts SET revoked = :revoked
WHERE api_account_id = :account_id';
$params = array(
$params = [
':revoked' => ($boolean ? '1' : '0')
, 'account_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -209,7 +209,7 @@ class API_OAuth2_Account
$sql = 'DELETE FROM api_accounts WHERE api_account_id = :account_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array('account_id' => $this->id));
$stmt->execute(['account_id' => $this->id]);
$stmt->closeCursor();
return;
@@ -222,13 +222,13 @@ class API_OAuth2_Account
VALUES (null, :usr_id, :revoked, :api_version, :application_id, :created)';
$datetime = new Datetime();
$params = array(
$params = [
':usr_id' => $user->getId()
, ':application_id' => $application->get_id()
, ':api_version' => API_OAuth2_Adapter::API_VERSION
, ':revoked' => 0
, ':created' => $datetime->format("Y-m-d H:i:s")
);
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -244,10 +244,10 @@ class API_OAuth2_Account
$sql = 'SELECT api_account_id FROM api_accounts
WHERE usr_id = :usr_id AND application_id = :application_id';
$params = array(
$params = [
":usr_id" => $user->getId(),
":application_id" => $application->get_id()
);
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);

View File

@@ -138,7 +138,7 @@ class API_OAuth2_Application
WHERE application_id = :application_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':application_id' => $this->id));
$stmt->execute([':application_id' => $this->id]);
if (0 === $stmt->rowCount()) {
throw new NotFoundHttpException(sprintf('Application with id %d not found', $this->id));
@@ -206,7 +206,7 @@ class API_OAuth2_Application
*/
public function set_type($type)
{
if ( ! in_array($type, array(self::DESKTOP_TYPE, self::WEB_TYPE)))
if ( ! in_array($type, [self::DESKTOP_TYPE, self::WEB_TYPE]))
throw new Exception_InvalidArgument();
$this->type = $type;
@@ -217,10 +217,10 @@ class API_OAuth2_Application
$sql = 'UPDATE api_applications SET type = :type, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':type' => $this->type
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -250,10 +250,10 @@ class API_OAuth2_Application
$sql = 'UPDATE api_applications SET name = :name, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':name' => $this->name
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -284,10 +284,10 @@ class API_OAuth2_Application
SET description = :description, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':description' => $this->description
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -318,10 +318,10 @@ class API_OAuth2_Application
SET website = :website, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':website' => $this->website
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -352,10 +352,10 @@ class API_OAuth2_Application
SET activated = :activated, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':activated' => $this->activated
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -386,10 +386,10 @@ class API_OAuth2_Application
SET grant_password = :grant_password, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':grant_password' => $this->grant_password
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -438,10 +438,10 @@ class API_OAuth2_Application
SET client_id = :client_id, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':client_id' => $this->client_id
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -472,10 +472,10 @@ class API_OAuth2_Application
SET client_secret = :client_secret, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':client_secret' => $this->client_secret
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -505,10 +505,10 @@ class API_OAuth2_Application
SET redirect_uri = :redirect_uri, last_modified = NOW()
WHERE application_id = :application_id';
$params = array(
$params = [
':redirect_uri' => $this->redirect_uri
, ':application_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -527,10 +527,10 @@ class API_OAuth2_Application
$sql = 'SELECT api_account_id FROM api_accounts
WHERE usr_id = :usr_id AND application_id = :id';
$params = array(
$params = [
':usr_id' => $user->getId()
, ':id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -557,7 +557,7 @@ class API_OAuth2_Application
WHERE application_id = :application_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':application_id' => $this->get_id()));
$stmt->execute([':application_id' => $this->get_id()]);
$stmt->closeCursor();
return;
@@ -573,11 +573,11 @@ class API_OAuth2_Application
WHERE application_id = :application_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':application_id' => $this->get_id()));
$stmt->execute([':application_id' => $this->get_id()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$accounts = array();
$accounts = [];
foreach ($rs as $row) {
$accounts[] = new API_OAuth2_Account($this->app, $row['api_account_id']);
@@ -609,7 +609,7 @@ class API_OAuth2_Application
$client_secret = API_OAuth2_Token::generate_token();
$client_token = API_OAuth2_Token::generate_token();
$params = array(
$params = [
':usr_id' => $user ? $user->getId() : null,
':name' => $name,
':client_id' => $client_token,
@@ -617,7 +617,7 @@ class API_OAuth2_Application
':nonce' => $nonce,
':activated' => 1,
':grant_password' => 0
);
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -646,7 +646,7 @@ class API_OAuth2_Application
WHERE client_id = :client_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':client_id' => $client_id));
$stmt->execute([':client_id' => $client_id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -663,11 +663,11 @@ class API_OAuth2_Application
WHERE a.creator = :usr_id AND a.application_id = b.application_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $user->getId()));
$stmt->execute([':usr_id' => $user->getId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$apps = array();
$apps = [];
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
@@ -682,11 +682,11 @@ class API_OAuth2_Application
WHERE usr_id = :usr_id AND c.application_id = a.application_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $user->getId()));
$stmt->execute([':usr_id' => $user->getId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$apps = array();
$apps = [];
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
@@ -703,11 +703,11 @@ class API_OAuth2_Application
AND revoked = 0';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $user->getId()));
$stmt->execute([':usr_id' => $user->getId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$apps = array();
$apps = [];
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}