From 4df8803c75d35e7c7e049805bc6f4e213e5b9b77 Mon Sep 17 00:00:00 2001 From: Srijit Date: Wed, 6 Oct 2021 17:14:03 +0530 Subject: [PATCH] fix: Fix PSR issue in database library --- src/Appwrite/Database/Adapter/MySQL.php | 11 +++++----- src/Appwrite/Database/Adapter/Redis.php | 2 +- src/Appwrite/Database/Database.php | 22 +++++++++---------- .../Database/Validator/Authorization.php | 4 ++-- .../Database/Validator/Collection.php | 2 +- src/Appwrite/Database/Validator/Structure.php | 4 ++-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/Appwrite/Database/Adapter/MySQL.php b/src/Appwrite/Database/Adapter/MySQL.php index fc3370c778..945a2c852e 100644 --- a/src/Appwrite/Database/Adapter/MySQL.php +++ b/src/Appwrite/Database/Adapter/MySQL.php @@ -569,7 +569,7 @@ class MySQL extends Adapter //$path = implode('.', $path); - if(array_key_exists($key, $filterTypes) && $filterTypes[$key] === 'numeric') { + if (array_key_exists($key, $filterTypes) && $filterTypes[$key] === 'numeric') { $value = (float) $value; } else { $value = $this->getPDO()->quote($value, PDO::PARAM_STR); @@ -607,7 +607,7 @@ class MySQL extends Adapter } // Sorting - if(!empty($options['orderField'])) { + if (!empty($options['orderField'])) { $orderPath = \explode('.', $options['orderField']); $len = \count($orderPath); $orderKey = 'order_b'; @@ -634,9 +634,8 @@ class MySQL extends Adapter $prev = 'd'; } } - } - } - else { + } + } else { $orderSelect = 'a.uid AS sort_ff'; } @@ -984,4 +983,4 @@ class MySQL extends Adapter { return $this->redis; } -} \ No newline at end of file +} diff --git a/src/Appwrite/Database/Adapter/Redis.php b/src/Appwrite/Database/Adapter/Redis.php index 68946b0469..eb2c185281 100644 --- a/src/Appwrite/Database/Adapter/Redis.php +++ b/src/Appwrite/Database/Adapter/Redis.php @@ -297,4 +297,4 @@ class Redis extends Adapter return parent::setNamespace($namespace); } -} \ No newline at end of file +} diff --git a/src/Appwrite/Database/Database.php b/src/Appwrite/Database/Database.php index 43f7403795..a1e5e52fb2 100644 --- a/src/Appwrite/Database/Database.php +++ b/src/Appwrite/Database/Database.php @@ -59,12 +59,12 @@ class Database /** * @var array */ - static protected $filters = []; + protected static $filters = []; /** * @var bool */ - static protected $statusFilters = true; + protected static $statusFilters = true; /** * @var array @@ -462,7 +462,7 @@ class Database * * @return void */ - static public function addFilter(string $name, callable $encode, callable $decode): void + public static function addFilter(string $name, callable $encode, callable $decode): void { self::$filters[$name] = [ 'encode' => $encode, @@ -496,7 +496,7 @@ class Database return $document; } - $collection = $this->getDocument($document->getCollection(), true , false); + $collection = $this->getDocument($document->getCollection(), true, false); $rules = $collection->getAttribute('rules', []); foreach ($rules as $key => $rule) { @@ -508,7 +508,7 @@ class Database if (($value !== null)) { if ($type === self::SYSTEM_VAR_TYPE_DOCUMENT) { - if($array) { + if ($array) { $list = []; foreach ($value as $child) { $list[] = $this->encode($child); @@ -536,7 +536,7 @@ class Database return $document; } - $collection = $this->getDocument($document->getCollection(), true , false); + $collection = $this->getDocument($document->getCollection(), true, false); $rules = $collection->getAttribute('rules', []); foreach ($rules as $key => $rule) { @@ -548,7 +548,7 @@ class Database if (($value !== null)) { if ($type === self::SYSTEM_VAR_TYPE_DOCUMENT) { - if($array) { + if ($array) { $list = []; foreach ($value as $child) { $list[] = $this->decode($child); @@ -572,11 +572,11 @@ class Database /** * Encode Attribute - * + * * @param string $name * @param mixed $value */ - static protected function encodeAttribute(string $name, $value) + protected static function encodeAttribute(string $name, $value) { if (!isset(self::$filters[$name])) { return $value; @@ -594,11 +594,11 @@ class Database /** * Decode Attribute - * + * * @param string $name * @param mixed $value */ - static protected function decodeAttribute(string $name, $value) + protected static function decodeAttribute(string $name, $value) { if (!isset(self::$filters[$name])) { return $value; diff --git a/src/Appwrite/Database/Validator/Authorization.php b/src/Appwrite/Database/Validator/Authorization.php index 1ae2554001..4a7f82b392 100644 --- a/src/Appwrite/Database/Validator/Authorization.php +++ b/src/Appwrite/Database/Validator/Authorization.php @@ -10,7 +10,7 @@ class Authorization extends Validator /** * @var array */ - static $roles = ['*' => true]; + public static $roles = ['*' => true]; /** * @var Document @@ -125,7 +125,7 @@ class Authorization extends Validator /** * @param string $role - * + * * @return bool */ public static function isRole(string $role): bool diff --git a/src/Appwrite/Database/Validator/Collection.php b/src/Appwrite/Database/Validator/Collection.php index 4941a777e5..45faa2801d 100644 --- a/src/Appwrite/Database/Validator/Collection.php +++ b/src/Appwrite/Database/Validator/Collection.php @@ -34,7 +34,7 @@ class Collection extends Structure * Is valid. * * Returns true if valid or false if not. - * + * * @param mixed $document * * @return bool diff --git a/src/Appwrite/Database/Validator/Structure.php b/src/Appwrite/Database/Validator/Structure.php index 58a4eeadd2..7f33074766 100644 --- a/src/Appwrite/Database/Validator/Structure.php +++ b/src/Appwrite/Database/Validator/Structure.php @@ -277,9 +277,9 @@ class Structure extends Validator /** * Get Collection - * + * * Get Collection by unique ID - * + * * @return Document */ protected function getCollection($id): Document