From 65c08825a547757c0629dce8b43d1ffe2381ef31 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 25 Jun 2020 00:05:16 +0300 Subject: [PATCH] Updated coding standards --- src/Appwrite/Auth/OAuth2.php | 4 +-- src/Appwrite/Auth/OAuth2/Apple.php | 2 +- src/Appwrite/Auth/OAuth2/Facebook.php | 2 +- src/Appwrite/Auth/OAuth2/Gitlab.php | 2 +- src/Appwrite/Auth/OAuth2/Google.php | 2 +- src/Appwrite/Auth/OAuth2/Microsoft.php | 2 +- src/Appwrite/Auth/OAuth2/Mock.php | 2 +- src/Appwrite/Auth/OAuth2/Slack.php | 4 +-- src/Appwrite/Auth/OAuth2/Spotify.php | 7 ++-- src/Appwrite/Auth/OAuth2/Twitch.php | 7 ++-- src/Appwrite/Auth/OAuth2/Yahoo.php | 7 ++-- .../Database/Validator/Authorization.php | 4 +-- src/Appwrite/Network/Validator/CNAME.php | 2 +- src/Appwrite/Network/Validator/Origin.php | 2 +- src/Appwrite/Storage/Storage.php | 2 +- src/Appwrite/URL/URL.php | 34 +++++++++---------- 16 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2.php b/src/Appwrite/Auth/OAuth2.php index 14c6c94a4a..2882746608 100644 --- a/src/Appwrite/Auth/OAuth2.php +++ b/src/Appwrite/Auth/OAuth2.php @@ -89,12 +89,12 @@ abstract class OAuth2 /** * @param $scope - * + * * @return $this */ protected function addScope(string $scope):OAuth2 { - // Add a scope to the scopes array if it isn't already present + // Add a scope to the scopes array if it isn't already present if (!\in_array($scope, $this->scopes)) { $this->scopes[] = $scope; } diff --git a/src/Appwrite/Auth/OAuth2/Apple.php b/src/Appwrite/Auth/OAuth2/Apple.php index 097cbea936..11a0b0c694 100644 --- a/src/Appwrite/Auth/OAuth2/Apple.php +++ b/src/Appwrite/Auth/OAuth2/Apple.php @@ -19,7 +19,7 @@ class Apple extends OAuth2 * @var array */ protected $scopes = [ - "name", + "name", "email" ]; diff --git a/src/Appwrite/Auth/OAuth2/Facebook.php b/src/Appwrite/Auth/OAuth2/Facebook.php index 6a2982242b..543fbaa1d7 100644 --- a/src/Appwrite/Auth/OAuth2/Facebook.php +++ b/src/Appwrite/Auth/OAuth2/Facebook.php @@ -58,7 +58,7 @@ class Facebook extends OAuth2 'redirect_uri' => $this->callback, 'client_secret' => $this->appSecret, 'code' => $code - ]) + ]) ); $accessToken = \json_decode($accessToken, true); diff --git a/src/Appwrite/Auth/OAuth2/Gitlab.php b/src/Appwrite/Auth/OAuth2/Gitlab.php index 93f27db510..369fe0e56c 100644 --- a/src/Appwrite/Auth/OAuth2/Gitlab.php +++ b/src/Appwrite/Auth/OAuth2/Gitlab.php @@ -4,7 +4,7 @@ namespace Appwrite\Auth\OAuth2; use Appwrite\Auth\OAuth2; -// Reference Material +// Reference Material // https://docs.gitlab.com/ee/api/oauth2.html class Gitlab extends OAuth2 diff --git a/src/Appwrite/Auth/OAuth2/Google.php b/src/Appwrite/Auth/OAuth2/Google.php index 2f4a4febc0..5066809109 100644 --- a/src/Appwrite/Auth/OAuth2/Google.php +++ b/src/Appwrite/Auth/OAuth2/Google.php @@ -4,7 +4,7 @@ namespace Appwrite\Auth\OAuth2; use Appwrite\Auth\OAuth2; -// Reference Material +// Reference Material // https://developers.google.com/oauthplayground/ // https://developers.google.com/identity/protocols/OAuth2 // https://developers.google.com/identity/protocols/OAuth2WebServer diff --git a/src/Appwrite/Auth/OAuth2/Microsoft.php b/src/Appwrite/Auth/OAuth2/Microsoft.php index 8f543c7962..349446ead3 100644 --- a/src/Appwrite/Auth/OAuth2/Microsoft.php +++ b/src/Appwrite/Auth/OAuth2/Microsoft.php @@ -19,7 +19,7 @@ class Microsoft extends OAuth2 * @var array */ protected $scopes = [ - 'offline_access', + 'offline_access', 'user.read' ]; diff --git a/src/Appwrite/Auth/OAuth2/Mock.php b/src/Appwrite/Auth/OAuth2/Mock.php index e1744343fb..d7f9962937 100644 --- a/src/Appwrite/Auth/OAuth2/Mock.php +++ b/src/Appwrite/Auth/OAuth2/Mock.php @@ -134,4 +134,4 @@ class Mock extends OAuth2 return $this->user; } -} \ No newline at end of file +} diff --git a/src/Appwrite/Auth/OAuth2/Slack.php b/src/Appwrite/Auth/OAuth2/Slack.php index c5d8f7c53b..20a67456e4 100644 --- a/src/Appwrite/Auth/OAuth2/Slack.php +++ b/src/Appwrite/Auth/OAuth2/Slack.php @@ -15,8 +15,8 @@ class Slack extends OAuth2 * @var array */ protected $scopes = [ - 'identity.avatar', - 'identity.basic', + 'identity.avatar', + 'identity.basic', 'identity.email', 'identity.team' ]; diff --git a/src/Appwrite/Auth/OAuth2/Spotify.php b/src/Appwrite/Auth/OAuth2/Spotify.php index 1bc3d51909..7962386b08 100644 --- a/src/Appwrite/Auth/OAuth2/Spotify.php +++ b/src/Appwrite/Auth/OAuth2/Spotify.php @@ -137,8 +137,11 @@ class Spotify extends OAuth2 protected function getUser(string $accessToken) { if (empty($this->user)) { - $this->user = \json_decode($this->request('GET', - $this->resourceEndpoint . "me", ['Authorization: Bearer '.\urlencode($accessToken)]), true); + $this->user = \json_decode($this->request( + 'GET', + $this->resourceEndpoint . "me", + ['Authorization: Bearer '.\urlencode($accessToken)] + ), true); } return $this->user; diff --git a/src/Appwrite/Auth/OAuth2/Twitch.php b/src/Appwrite/Auth/OAuth2/Twitch.php index 94f735b505..463bbf9175 100644 --- a/src/Appwrite/Auth/OAuth2/Twitch.php +++ b/src/Appwrite/Auth/OAuth2/Twitch.php @@ -139,8 +139,11 @@ class Twitch extends OAuth2 protected function getUser(string $accessToken) { if (empty($this->user)) { - $this->user = \json_decode($this->request('GET', - $this->resourceEndpoint, ['Authorization: Bearer '.\urlencode($accessToken)]), true)['data']['0']; + $this->user = \json_decode($this->request( + 'GET', + $this->resourceEndpoint, + ['Authorization: Bearer '.\urlencode($accessToken)] + ), true)['data']['0']; } return $this->user; diff --git a/src/Appwrite/Auth/OAuth2/Yahoo.php b/src/Appwrite/Auth/OAuth2/Yahoo.php index 41100132f8..8593c41ce8 100644 --- a/src/Appwrite/Auth/OAuth2/Yahoo.php +++ b/src/Appwrite/Auth/OAuth2/Yahoo.php @@ -153,8 +153,11 @@ class Yahoo extends OAuth2 protected function getUser(string $accessToken) { if (empty($this->user)) { - $this->user = \json_decode($this->request('GET', - $this->resourceEndpoint, ['Authorization: Bearer '.\urlencode($accessToken)]), true); + $this->user = \json_decode($this->request( + 'GET', + $this->resourceEndpoint, + ['Authorization: Bearer '.\urlencode($accessToken)] + ), true); } return $this->user; diff --git a/src/Appwrite/Database/Validator/Authorization.php b/src/Appwrite/Database/Validator/Authorization.php index fdadd05109..444f651be0 100644 --- a/src/Appwrite/Database/Validator/Authorization.php +++ b/src/Appwrite/Database/Validator/Authorization.php @@ -111,7 +111,7 @@ class Authorization extends Validator /** * Default value in case we need * to reset Authorization status - * + * * @var bool */ public static $statusDefault = true; @@ -119,7 +119,7 @@ class Authorization extends Validator /** * Change default status. * This will be used for the - * value set on the self::reset() method + * value set on the self::reset() method */ public static function setDefaultStatus($status) { diff --git a/src/Appwrite/Network/Validator/CNAME.php b/src/Appwrite/Network/Validator/CNAME.php index 708396e81c..54e4987f16 100644 --- a/src/Appwrite/Network/Validator/CNAME.php +++ b/src/Appwrite/Network/Validator/CNAME.php @@ -26,7 +26,7 @@ class CNAME extends Validator /** * Check if CNAME record target value matches selected target - * + * * @param string $domain * * @return bool diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php index eb838367e1..d1368a1c3e 100644 --- a/src/Appwrite/Network/Validator/Origin.php +++ b/src/Appwrite/Network/Validator/Origin.php @@ -92,7 +92,7 @@ class Origin extends Validator /** * Check if Origin has been whiltlisted * for access to the API - * + * * @param string $origin * * @return bool diff --git a/src/Appwrite/Storage/Storage.php b/src/Appwrite/Storage/Storage.php index 800c90b430..40c2889738 100644 --- a/src/Appwrite/Storage/Storage.php +++ b/src/Appwrite/Storage/Storage.php @@ -78,7 +78,7 @@ class Storage * * @return string */ - static public function human($bytes, $decimals = 2) + public static function human($bytes, $decimals = 2) { $units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); $step = 1024; diff --git a/src/Appwrite/URL/URL.php b/src/Appwrite/URL/URL.php index b4e55039e4..5f2b54a65e 100644 --- a/src/Appwrite/URL/URL.php +++ b/src/Appwrite/URL/URL.php @@ -6,14 +6,14 @@ class URL { /** * Parse URL - * + * * Take a URL string and split it to array parts - * + * * @param string $url - * + * * @return array */ - static public function parse(string $url):array + public static function parse(string $url):array { $default = [ 'scheme' => '', @@ -31,15 +31,15 @@ class URL /** * Un-Parse URL - * + * * Take URL parts and combine them to a valid string - * + * * @param array $url * @param array $ommit - * + * * @return string */ - static public function unparse(array $url, array $ommit = []):string + public static function unparse(array $url, array $ommit = []):string { if (isset($url['path']) && \mb_substr($url['path'], 0, 1) !== '/') { $url['path'] = '/'.$url['path']; @@ -78,14 +78,14 @@ class URL /** * Parse Query String - * + * * Convert query string to array - * + * * @param string $query - * + * * @return array */ - static public function parseQuery(string $query):array + public static function parseQuery(string $query):array { \parse_str($query, $result); @@ -94,15 +94,15 @@ class URL /** * Un-Parse Query String - * + * * Convert query string array to string - * + * * @param string $query - * + * * @return array */ - static public function unparseQuery(array $query):string + public static function unparseQuery(array $query):string { return \http_build_query($query); } -} \ No newline at end of file +}