diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 194066994d..f308d30e2d 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -23,9 +23,9 @@ use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Conflict as ConflictException; use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Exception\Limit as LimitException; +use Utopia\Database\Exception\Query as QueryException; use Utopia\Database\Exception\Restricted as RestrictedException; use Utopia\Database\Exception\Structure as StructureException; -use Utopia\Database\Exception\Query as QueryException; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/app/init2.php b/app/init2.php index feeef6a423..9e179427ec 100644 --- a/app/init2.php +++ b/app/init2.php @@ -2,10 +2,6 @@ require_once __DIR__ . '/../vendor/autoload.php'; -use PHPMailer\PHPMailer\PHPMailer; -use Utopia\Cache\Adapter\Redis as CacheRedis; -use Utopia\Cache\Adapter\Sharding; -use Utopia\VCS\Adapter\Git\GitHub; use Ahc\Jwt\JWT; use Ahc\Jwt\JWTException; use Appwrite\Auth\Auth; @@ -28,10 +24,13 @@ use Appwrite\Network\Validator\Origin; use Appwrite\URL\URL; use Appwrite\Utopia\Queue\Connections; use MaxMind\Db\Reader; +use PHPMailer\PHPMailer\PHPMailer; use Swoole\Database\PDOConfig; use Swoole\Database\PDOPool; use Swoole\Database\RedisConfig; use Swoole\Database\RedisPool; +use Utopia\Cache\Adapter\Redis as CacheRedis; +use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; @@ -65,6 +64,7 @@ use Utopia\Storage\Device\S3; use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Storage; use Utopia\System\System; +use Utopia\VCS\Adapter\Git\GitHub; require_once __DIR__ . '/init/constants.php'; require_once __DIR__ . '/init/config.php'; @@ -206,20 +206,20 @@ $global->set( 'pools', (function () { $fallbackForDB = 'db_main=' . URL::unparse([ - 'scheme' => 'mariadb', - 'host' => System::getEnv('_APP_DB_HOST', 'mariadb'), - 'port' => System::getEnv('_APP_DB_PORT', '3306'), - 'user' => System::getEnv('_APP_DB_USER', ''), - 'pass' => System::getEnv('_APP_DB_PASS', ''), - 'path' => System::getEnv('_APP_DB_SCHEMA', ''), - ]); + 'scheme' => 'mariadb', + 'host' => System::getEnv('_APP_DB_HOST', 'mariadb'), + 'port' => System::getEnv('_APP_DB_PORT', '3306'), + 'user' => System::getEnv('_APP_DB_USER', ''), + 'pass' => System::getEnv('_APP_DB_PASS', ''), + 'path' => System::getEnv('_APP_DB_SCHEMA', ''), + ]); $fallbackForRedis = 'redis_main=' . URL::unparse([ - 'scheme' => 'redis', - 'host' => System::getEnv('_APP_REDIS_HOST', 'redis'), - 'port' => System::getEnv('_APP_REDIS_PORT', '6379'), - 'user' => System::getEnv('_APP_REDIS_USER', ''), - 'pass' => System::getEnv('_APP_REDIS_PASS', ''), - ]); + 'scheme' => 'redis', + 'host' => System::getEnv('_APP_REDIS_HOST', 'redis'), + 'port' => System::getEnv('_APP_REDIS_PORT', '6379'), + 'user' => System::getEnv('_APP_REDIS_USER', ''), + 'pass' => System::getEnv('_APP_REDIS_PASS', ''), + ]); $connections = [ 'console' => [ @@ -430,7 +430,7 @@ $queueForCertificates = new Dependency(); $plan ->setName('plan') - ->setCallback(fn() => []); + ->setCallback(fn () => []); $mode ->setName('mode') @@ -639,7 +639,7 @@ $project return $console; } - $project = $authorization->skip(fn() => $dbForConsole->getDocument('projects', $projectId)); + $project = $authorization->skip(fn () => $dbForConsole->getDocument('projects', $projectId)); return $project; }); @@ -802,11 +802,11 @@ $connections $locale ->setName('locale') - ->setCallback(fn() => new Locale(System::getEnv('_APP_LOCALE', 'en'))); + ->setCallback(fn () => new Locale(System::getEnv('_APP_LOCALE', 'en'))); $localeCodes ->setName('localeCodes') - ->setCallback(fn() => array_map(fn($locale) => $locale['code'], Config::getParam('locale-codes', []))); + ->setCallback(fn () => array_map(fn ($locale) => $locale['code'], Config::getParam('locale-codes', []))); $queue ->setName('queue') @@ -958,10 +958,10 @@ $clients * + Filter for duplicated entries */ $clientsConsole = \array_map( - fn($node) => $node['hostname'], + fn ($node) => $node['hostname'], \array_filter( $console->getAttribute('platforms', []), - fn($node) => (isset($node['type']) && ($node['type'] === Origin::CLIENT_TYPE_WEB) && isset($node['hostname']) && !empty($node['hostname'])) + fn ($node) => (isset($node['type']) && ($node['type'] === Origin::CLIENT_TYPE_WEB) && isset($node['hostname']) && !empty($node['hostname'])) ) ); @@ -969,10 +969,10 @@ $clients \array_merge( $clientsConsole, \array_map( - fn($node) => $node['hostname'], + fn ($node) => $node['hostname'], \array_filter( $project->getAttribute('platforms', []), - fn($node) => (isset($node['type']) && ($node['type'] === Origin::CLIENT_TYPE_WEB || $node['type'] === Origin::CLIENT_TYPE_FLUTTER_WEB) && isset($node['hostname']) && !empty($node['hostname'])) + fn ($node) => (isset($node['type']) && ($node['type'] === Origin::CLIENT_TYPE_WEB || $node['type'] === Origin::CLIENT_TYPE_FLUTTER_WEB) && isset($node['hostname']) && !empty($node['hostname'])) ) ) ) @@ -1121,7 +1121,7 @@ $promiseAdapter $schemaVariable ->setName('schemaVariable') - ->setCallback(fn()=> new Schema()); + ->setCallback(fn () => new Schema()); $schema ->setName('schema') @@ -1142,7 +1142,7 @@ $schema }; $attributes = function (int $limit, int $offset) use ($dbForProject, $authorization) { - $attrs = $authorization->skip(fn() => $dbForProject->find('attributes', [ + $attrs = $authorization->skip(fn () => $dbForProject->find('attributes', [ Query::limit($limit), Query::offset($offset), ])); diff --git a/src/Appwrite/GraphQL/Resolvers.php b/src/Appwrite/GraphQL/Resolvers.php index 79f36eb3ea..871b3f7f4d 100644 --- a/src/Appwrite/GraphQL/Resolvers.php +++ b/src/Appwrite/GraphQL/Resolvers.php @@ -8,9 +8,9 @@ use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Utopia\DI\Container; use Utopia\Exception; -use Utopia\Http\Response as UtopiaHttpResponse; -use Utopia\Http\Request as UtopiaHttpRequest; use Utopia\Http\Http; +use Utopia\Http\Request as UtopiaHttpRequest; +use Utopia\Http\Response as UtopiaHttpResponse; use Utopia\Http\Route; use Utopia\System\System; @@ -31,7 +31,7 @@ class Resolvers Container $container, ): callable { $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $route, $args, $context, $container, $info, $request, $response, $resolver) { $path = $route->getPath(); foreach ($args as $key => $value) { @@ -97,8 +97,8 @@ class Resolvers UtopiaHttpResponse $response, Container $container, ): callable { - $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + $resolver = $this; + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('GET'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -128,8 +128,8 @@ class Resolvers UtopiaHttpResponse $response, Container $container, ): callable { - $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + $resolver = $this; + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $params, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('GET'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -164,8 +164,8 @@ class Resolvers UtopiaHttpResponse $response, Container $container, ): callable { - $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + $resolver = $this; + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $params, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('POST'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -196,8 +196,8 @@ class Resolvers UtopiaHttpResponse $response, Container $container, ): callable { - $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + $resolver = $this; + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $params, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('PATCH'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -226,8 +226,8 @@ class Resolvers UtopiaHttpResponse $response, Container $container, ): callable { - $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + $resolver = $this; + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('DELETE'); $request->setURI($url($databaseId, $collectionId, $args)); diff --git a/src/Appwrite/GraphQL/Schema.php b/src/Appwrite/GraphQL/Schema.php index bf5354f891..073213e4ae 100644 --- a/src/Appwrite/GraphQL/Schema.php +++ b/src/Appwrite/GraphQL/Schema.php @@ -3,17 +3,17 @@ namespace Appwrite\GraphQL; use Appwrite\GraphQL\Types\Mapper; +use Appwrite\Utopia\Response; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; use GraphQL\Type\Schema as GQLSchema; -use Appwrite\Utopia\Response; use Utopia\DI\Container; -use Utopia\Http\Response as UtopiaHttpResponse; -use Utopia\Http\Adapter\Swoole\Response as UtopiaSwooleResponse; use Utopia\Exception; +use Utopia\Http\Adapter\Swoole\Response as UtopiaSwooleResponse; use Utopia\Http\Http; -use Utopia\Http\Route; use Utopia\Http\Request; +use Utopia\Http\Response as UtopiaHttpResponse; +use Utopia\Http\Route; class Schema { @@ -51,23 +51,23 @@ class Schema $container, $complexity ); -// $collections = $this->collections( -// $http, -// $complexity, -// $request, -// $response, -// $attributes, -// $urls, -// $params, -// ); + // $collections = $this->collections( + // $http, + // $complexity, + // $request, + // $response, + // $attributes, + // $urls, + // $params, + // ); $queries = \array_merge_recursive( $api['query'], - //$collections['query'] + //$collections['query'] ); $mutations = \array_merge_recursive( $api['mutation'], - //$collections['mutation'] + //$collections['mutation'] ); \ksort($queries); @@ -241,7 +241,7 @@ class Schema 'args' => \array_merge( Mapper::args('id'), \array_map( - fn($attr) => $attr['type'] = Type::getNullableType($attr['type']), + fn ($attr) => $attr['type'] = Type::getNullableType($attr['type']), $attributes ) ), diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index cf4ce79340..a15c6aa475 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -225,7 +225,7 @@ class Mapper array $injections ): Type { $validator = \is_callable($validator) - ? \call_user_func_array($validator, array_map(fn($injection) => $container->get($injection), $injections)) + ? \call_user_func_array($validator, array_map(fn ($injection) => $container->get($injection), $injections)) : $validator; $isNullable = $validator instanceof Nullable;