Use short array declaration

This commit is contained in:
Romain Neutron
2013-11-18 11:58:12 +01:00
parent 2898b317c4
commit 56b373ee6e
723 changed files with 8350 additions and 8352 deletions

View File

@@ -88,7 +88,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();
@@ -150,10 +150,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);
@@ -218,7 +218,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;
@@ -231,13 +231,13 @@ class API_OAuth2_Account
VALUES (null, :usr_id, :revoked, :api_version, :application_id, :created)';
$datetime = new Datetime();
$params = array(
$params = [
':usr_id' => $user->get_id()
, ':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);
@@ -253,10 +253,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->get_id(),
":application_id" => $application->get_id()
);
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);

View File

@@ -55,12 +55,12 @@ class API_OAuth2_Adapter extends OAuth2
*
* @var array
*/
protected $token_type = array("bearer" => "Bearer");
protected $token_type = ["bearer" => "Bearer"];
/**
* @var array
*/
protected $authentication_scheme = array("authorization", "uri", "body");
protected $authentication_scheme = ["authorization", "uri", "body"];
/**
*
@@ -95,7 +95,7 @@ class API_OAuth2_Adapter extends OAuth2
public function __construct(Application $app)
{
parent::__construct();
$this->params = array();
$this->params = [];
$this->app = $app;
return $this;
@@ -227,7 +227,7 @@ class API_OAuth2_Adapter extends OAuth2
try {
$token = API_OAuth2_Token::load_by_oauth_token($this->app, $oauth_token);
$result = array(
$result = [
'scope' => $token->get_scope()
, 'expires' => $token->get_expires()
, 'client_id' => $token->get_account()->get_application()->get_client_id()
@@ -235,7 +235,7 @@ class API_OAuth2_Adapter extends OAuth2
, 'revoked' => ($token->get_account()->is_revoked() ? '1' : '0')
, 'usr_id' => $token->get_account()->get_user()->get_id()
, 'oauth_token' => $token->get_value()
);
];
} catch (Exception $e) {
@@ -272,10 +272,10 @@ class API_OAuth2_Adapter extends OAuth2
*/
protected function getSupportedGrantTypes()
{
return array(
return [
OAUTH2_GRANT_TYPE_AUTH_CODE,
OAUTH2_GRANT_TYPE_USER_CREDENTIALS
);
];
}
/**
@@ -286,7 +286,7 @@ class API_OAuth2_Adapter extends OAuth2
*/
protected function getSupportedScopes()
{
return array();
return [];
}
/**
@@ -300,12 +300,12 @@ class API_OAuth2_Adapter extends OAuth2
try {
$code = new API_OAuth2_AuthCode($this->app, $code);
return array(
return [
'redirect_uri' => $code->get_redirect_uri()
, 'client_id' => $code->get_account()->get_application()->get_client_id()
, 'expires' => $code->get_expires()
, 'account_id' => $code->get_account()->get_id()
);
];
} catch (Exception $e) {
}
@@ -352,11 +352,11 @@ class API_OAuth2_Adapter extends OAuth2
try {
$token = new API_OAuth2_RefreshToken($this->app, $refresh_token);
return array(
return [
'token' => $token->get_value()
, 'expires' => $token->get_expires()->format('U')
, 'client_id' => $token->get_account()->get_application()->get_client_id()
);
];
} catch (Exception $e) {
}
@@ -383,11 +383,11 @@ class API_OAuth2_Adapter extends OAuth2
public function getAuthorizationRequestParameters(Request $request)
{
$datas = array(
$datas = [
'response_type' => $request->get('response_type', false)
, 'client_id' => $request->get('client_id', false)
, 'redirect_uri' => $request->get('redirect_uri', false)
);
];
$scope = $request->get('scope', false);
$state = $request->get('state', false);
@@ -400,21 +400,21 @@ class API_OAuth2_Adapter extends OAuth2
$datas["scope"] = $scope;
}
$filters = array(
"client_id" => array(
$filters = [
"client_id" => [
"filter" => FILTER_VALIDATE_REGEXP
, "options" => array("regexp" => OAUTH2_CLIENT_ID_REGEXP)
, "options" => ["regexp" => OAUTH2_CLIENT_ID_REGEXP]
, "flags" => FILTER_REQUIRE_SCALAR
)
, "response_type" => array(
]
, "response_type" => [
"filter" => FILTER_VALIDATE_REGEXP
, "options" => array("regexp" => OAUTH2_AUTH_RESPONSE_TYPE_REGEXP)
, "options" => ["regexp" => OAUTH2_AUTH_RESPONSE_TYPE_REGEXP]
, "flags" => FILTER_REQUIRE_SCALAR
)
, "redirect_uri" => array("filter" => FILTER_SANITIZE_URL)
, "state" => array("flags" => FILTER_REQUIRE_SCALAR)
, "scope" => array("flags" => FILTER_REQUIRE_SCALAR)
);
]
, "redirect_uri" => ["filter" => FILTER_SANITIZE_URL]
, "state" => ["flags" => FILTER_REQUIRE_SCALAR]
, "scope" => ["flags" => FILTER_REQUIRE_SCALAR]
];
$input = filter_var_array($datas, $filters);
@@ -544,13 +544,13 @@ class API_OAuth2_Adapter extends OAuth2
* @param array $params
* @return string
*/
public function finishNativeClientAuthorization($is_authorized, $params = array())
public function finishNativeClientAuthorization($is_authorized, $params = [])
{
$result = array();
$params += array(
$result = [];
$params += [
'scope' => NULL,
'state' => NULL,
);
];
extract($params);
if ($state !== NULL)
@@ -632,12 +632,12 @@ class API_OAuth2_Adapter extends OAuth2
return TRUE;
}
public function finishClientAuthorization($is_authorized, $params = array())
public function finishClientAuthorization($is_authorized, $params = [])
{
$params += array(
$params += [
'scope' => NULL,
'state' => NULL,
);
];
extract($params);
if ($state !== NULL)
@@ -659,17 +659,17 @@ class API_OAuth2_Adapter extends OAuth2
*/
public function grantAccessToken()
{
$filters = array(
"grant_type" => array("filter" => FILTER_VALIDATE_REGEXP, "options" => array("regexp" => OAUTH2_GRANT_TYPE_REGEXP), "flags" => FILTER_REQUIRE_SCALAR),
"scope" => array("flags" => FILTER_REQUIRE_SCALAR),
"code" => array("flags" => FILTER_REQUIRE_SCALAR),
"redirect_uri" => array("filter" => FILTER_SANITIZE_URL),
"username" => array("flags" => FILTER_REQUIRE_SCALAR),
"password" => array("flags" => FILTER_REQUIRE_SCALAR),
"assertion_type" => array("flags" => FILTER_REQUIRE_SCALAR),
"assertion" => array("flags" => FILTER_REQUIRE_SCALAR),
"refresh_token" => array("flags" => FILTER_REQUIRE_SCALAR),
);
$filters = [
"grant_type" => ["filter" => FILTER_VALIDATE_REGEXP, "options" => ["regexp" => OAUTH2_GRANT_TYPE_REGEXP], "flags" => FILTER_REQUIRE_SCALAR],
"scope" => ["flags" => FILTER_REQUIRE_SCALAR],
"code" => ["flags" => FILTER_REQUIRE_SCALAR],
"redirect_uri" => ["filter" => FILTER_SANITIZE_URL],
"username" => ["flags" => FILTER_REQUIRE_SCALAR],
"password" => ["flags" => FILTER_REQUIRE_SCALAR],
"assertion_type" => ["flags" => FILTER_REQUIRE_SCALAR],
"assertion" => ["flags" => FILTER_REQUIRE_SCALAR],
"refresh_token" => ["flags" => FILTER_REQUIRE_SCALAR],
];
$input = filter_input_array(INPUT_POST, $filters);
@@ -773,10 +773,10 @@ class API_OAuth2_Adapter extends OAuth2
protected function createAccessToken($account_id, $scope = NULL)
{
$token = array(
$token = [
"access_token" => $this->genAccessToken(),
"scope" => $scope
);
];
if ($this->enable_expire)
$token['expires_in'] = $this->getVariable('access_token_lifetime', OAUTH2_DEFAULT_ACCESS_TOKEN_LIFETIME);
@@ -810,11 +810,11 @@ class API_OAuth2_Adapter extends OAuth2
$account = API_OAuth2_Account::load_with_user($this->app, $application, $user);
return array(
return [
'redirect_uri' => $application->get_redirect_uri()
, 'client_id' => $application->get_client_id()
, 'account_id' => $account->get_id()
);
];
} catch (AccountLockedException $e) {
return false;
} catch (RequireCaptchaException $e) {

View File

@@ -147,7 +147,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));
@@ -215,7 +215,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;
@@ -226,10 +226,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);
@@ -259,10 +259,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);
@@ -293,10 +293,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);
@@ -327,10 +327,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);
@@ -361,10 +361,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);
@@ -395,10 +395,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);
@@ -447,10 +447,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);
@@ -481,10 +481,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);
@@ -514,10 +514,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);
@@ -536,10 +536,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->get_id()
, ':id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -566,7 +566,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;
@@ -582,11 +582,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']);
@@ -618,7 +618,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->get_id() : null,
':name' => $name,
':client_id' => $client_token,
@@ -626,7 +626,7 @@ class API_OAuth2_Application
':nonce' => $nonce,
':activated' => 1,
':grant_password' => 0
);
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -655,7 +655,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();
@@ -672,11 +672,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->get_id()));
$stmt->execute([':usr_id' => $user->get_id()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$apps = array();
$apps = [];
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
@@ -691,11 +691,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->get_id()));
$stmt->execute([':usr_id' => $user->get_id()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$apps = array();
$apps = [];
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
@@ -712,11 +712,11 @@ class API_OAuth2_Application
AND revoked = 0';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $user->get_id()));
$stmt->execute([':usr_id' => $user->get_id()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$apps = array();
$apps = [];
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}

View File

@@ -40,7 +40,7 @@ class API_OAuth2_AuthCode
FROM api_oauth_codes WHERE code = :code';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':code' => $this->code));
$stmt->execute([':code' => $this->code]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -82,7 +82,7 @@ class API_OAuth2_AuthCode
$sql = 'UPDATE api_oauth_codes SET redirect_uri = :redirect_uri
WHERE code = :code';
$params = array(':redirect_uri' => $redirect_uri, ':code' => $this->code);
$params = [':redirect_uri' => $redirect_uri, ':code' => $this->code];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -112,7 +112,7 @@ class API_OAuth2_AuthCode
$sql = 'UPDATE api_oauth_codes SET scope = :scope
WHERE code = :code';
$params = array(':scope' => $scope, ':code' => $this->code);
$params = [':scope' => $scope, ':code' => $this->code];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -128,7 +128,7 @@ class API_OAuth2_AuthCode
$sql = 'DELETE FROM api_oauth_codes WHERE code = :code';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':code' => $this->code));
$stmt->execute([':code' => $this->code]);
$stmt->closeCursor();
return;
@@ -147,12 +147,12 @@ class API_OAuth2_AuthCode
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$params = array(":account_id" => $account->get_id());
$params = [":account_id" => $account->get_id()];
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$codes = array();
$codes = [];
foreach ($rs as $row) {
$codes[] = new API_OAuth2_AuthCode($app, $row['code']);
@@ -177,11 +177,11 @@ class API_OAuth2_AuthCode
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$params = array(
$params = [
":code" => $code,
":account_id" => $account->get_id(),
":expires" => $expires
);
];
$stmt->execute($params);
$stmt->closeCursor();

View File

@@ -144,8 +144,8 @@ class API_OAuth2_Form_DevAppDesktop
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$blank = array('message' => _('Cette valeur ne peut être vide'));
$url = array('message' => _('Url non valide'));
$blank = ['message' => _('Cette valeur ne peut être vide')];
$url = ['message' => _('Url non valide')];
$metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank));
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));

View File

@@ -147,8 +147,8 @@ class API_OAuth2_Form_DevAppInternet
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$blank = array('message' => _('Cette valeur ne peut être vide'));
$url = array('message' => _('Url non valide'));
$blank = ['message' => _('Cette valeur ne peut être vide')];
$url = ['message' => _('Url non valide')];
$metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank));
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));

View File

@@ -39,7 +39,7 @@ class API_OAuth2_RefreshToken
FROM api_oauth_refresh_tokens WHERE refresh_token = :token';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':token' => $this->token));
$stmt->execute([':token' => $this->token]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -88,7 +88,7 @@ class API_OAuth2_RefreshToken
WHERE refresh_token = :refresh_token';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(":refresh_token" => $this->token));
$stmt->execute([":refresh_token" => $this->token]);
$stmt->closeCursor();
return;
@@ -106,11 +106,11 @@ class API_OAuth2_RefreshToken
WHERE api_account_id = :account_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':account_id' => $account->get_id()));
$stmt->execute([':account_id' => $account->get_id()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$tokens = array();
$tokens = [];
foreach ($rs as $row) {
$tokens[] = new API_OAuth2_RefreshToken($app, $row['refresh_token']);
@@ -135,12 +135,12 @@ class API_OAuth2_RefreshToken
VALUES (:refresh_token, :account_id, :expires, :scope)';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$params = array(
$params = [
":refresh_token" => $refresh_token,
":account_id" => $account->get_id(),
":expires" => $expires,
":scope" => $scope
);
];
$stmt->execute($params);
$stmt->closeCursor();

View File

@@ -75,7 +75,7 @@ class API_OAuth2_Token
FROM api_oauth_tokens
WHERE api_account_id = :account_id';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':account_id' => $this->account->get_id()));
$stmt->execute([':account_id' => $this->account->get_id()]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ( ! $row)
@@ -110,10 +110,10 @@ class API_OAuth2_Token
$sql = 'UPDATE api_oauth_tokens SET oauth_token = :oauth_token
WHERE oauth_token = :current_token';
$params = array(
$params = [
':oauth_token' => $oauth_token
, ':current_token' => $this->token
);
];
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -143,10 +143,10 @@ class API_OAuth2_Token
$sql = 'UPDATE api_oauth_tokens SET session_id = :session_id
WHERE oauth_token = :current_token';
$params = array(
$params = [
':session_id' => $session_id
, ':current_token' => $this->token
);
];
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -176,10 +176,10 @@ class API_OAuth2_Token
$sql = 'UPDATE api_oauth_tokens SET expires = FROM_UNIXTIME(:expires)
WHERE oauth_token = :oauth_token';
$params = array(
$params = [
':expires' => $expires
, ':oauth_token' => $this->get_value()
);
];
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -204,10 +204,10 @@ class API_OAuth2_Token
$sql = 'UPDATE api_oauth_tokens SET scope = :scope
WHERE oauth_token = :oauth_token';
$params = array(
$params = [
':scope' => $scope
, ':oauth_token' => $this->get_value()
);
];
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -238,10 +238,10 @@ class API_OAuth2_Token
$new_token = self::generate_token();
$params = array(
$params = [
':new_token' => $new_token
, ':old_token' => $this->get_value()
);
];
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -261,7 +261,7 @@ class API_OAuth2_Token
$sql = 'DELETE FROM api_oauth_tokens WHERE oauth_token = :oauth_token';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':oauth_token' => $this->get_value()));
$stmt->execute([':oauth_token' => $this->get_value()]);
$stmt->closeCursor();
return;
@@ -281,7 +281,7 @@ class API_OAuth2_Token
AND a.api_account_id = b.api_account_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$params = array(":oauth_token" => $oauth_token);
$params = [":oauth_token" => $oauth_token];
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -309,12 +309,12 @@ class API_OAuth2_Token
$expires = new \DateTime('+1 hour');
$params = array(
$params = [
':token' => self::generate_token()
, ':account_id' => $account->get_id()
, ':expire' => $expires->format(DATE_ISO8601)
, ':scope' => $scope
);
];
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);

View File

@@ -108,7 +108,7 @@ class API_V1_Log
api_log_id = :log_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':log_id' => $this->id));
$stmt->execute([':log_id' => $this->id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -137,10 +137,10 @@ class API_V1_Log
SET api_account_id = :account_id
WHERE api_log_id = :log_id';
$params = array(
$params = [
':api_account_id' => $this->account_id
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -162,10 +162,10 @@ class API_V1_Log
SET api_log_date = :date
WHERE api_log_id = :log_id';
$params = array(
$params = [
':date' => $this->date->format("Y-m-d H:i:s")
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -187,10 +187,10 @@ class API_V1_Log
SET api_log_status_code = :code
WHERE api_log_id = :log_id';
$params = array(
$params = [
':code' => $this->status_code
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -207,7 +207,7 @@ class API_V1_Log
public function set_format($format)
{
if ( ! in_array($format, array('json', 'jsonp', 'yaml', 'unknow')))
if ( ! in_array($format, ['json', 'jsonp', 'yaml', 'unknow']))
throw new Exception_InvalidArgument();
$this->format = $format;
@@ -216,10 +216,10 @@ class API_V1_Log
SET api_log_format = :format
WHERE api_log_id = :log_id';
$params = array(
$params = [
':format' => $this->format
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -235,7 +235,7 @@ class API_V1_Log
public function set_ressource($ressource)
{
if ( ! in_array($format, array(self::DATABOXES_RESSOURCE, self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE)))
if ( ! in_array($format, [self::DATABOXES_RESSOURCE, self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE]))
throw new Exception_InvalidArgument();
$this->ressource = $ressource;
@@ -244,10 +244,10 @@ class API_V1_Log
SET api_log_ressource = :ressource
WHERE api_log_id = :log_id';
$params = array(
$params = [
':ressource' => $this->ressource
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -269,10 +269,10 @@ class API_V1_Log
SET api_log_general = :general
WHERE api_log_id = :log_id';
$params = array(
$params = [
':general' => $this->general
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -294,10 +294,10 @@ class API_V1_Log
SET api_log_aspect = :aspect
WHERE api_log_id = :log_id';
$params = array(
$params = [
':aspect' => $this->aspect
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -319,10 +319,10 @@ class API_V1_Log
SET api_log_action = :action
WHERE api_log_id = :log_id';
$params = array(
$params = [
':action' => $this->action
, ':log_id' => $this->id
);
];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -365,7 +365,7 @@ class API_V1_Log
:action
)';
$params = array(
$params = [
':account_id' => $account->get_id(),
':route' => $route,
':status_code' => $status_code,
@@ -374,7 +374,7 @@ class API_V1_Log
':general' => $general,
':aspect' => $aspect,
':action' => $action
);
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);

View File

@@ -28,11 +28,11 @@ class API_V1_Timer implements ServiceProviderInterface
$n++;
$name = $event->getName() . '#' . $n;
}
$app['api.timers']->add(array(
$app['api.timers']->add([
'name' => $name,
'memory' => memory_get_usage(),
'time' => microtime(true) - $app['api.timers.start'],
));
]);
};
$app['dispatcher']->addListener(KernelEvents::CONTROLLER, $callback, -999999);

File diff suppressed because it is too large Load Diff

View File

@@ -124,7 +124,7 @@ class API_V1_result
}
$accept = $this->request->getAcceptableContentTypes();
$response_types = array();
$response_types = [];
foreach ($accept as $key => $app_type) {
$response_types[strtolower($app_type)] = true;
@@ -183,8 +183,8 @@ class API_V1_result
. $this->request->getPathInfo()
);
$ret = array(
'meta' => array(
$ret = [
'meta' => [
'api_version' => $this->api_version
, 'request' => $request_uri
, 'response_time' => $this->response_time
@@ -193,9 +193,9 @@ class API_V1_result
, 'error_message' => $this->error_message
, 'error_details' => $this->error_details
, 'charset' => 'UTF-8'
)
]
, 'response' => $this->response
);
];
$this->app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent());
@@ -214,7 +214,7 @@ class API_V1_result
break;
case self::FORMAT_YAML:
if ($ret['response'] instanceof stdClass)
$ret['response'] = array();
$ret['response'] = [];
$dumper = new Symfony\Component\Yaml\Dumper();
$return_value = $dumper->dump($ret, 8);
@@ -388,7 +388,7 @@ class API_V1_result
$response = new Response(
$this->format(),
$this->get_http_code(),
array('Content-Type' => $this->get_content_type())
['Content-Type' => $this->get_content_type()]
);
$response->setCharset('UTF-8');