diff --git a/composer.lock b/composer.lock index 3151d0c17..d08a958c7 100644 --- a/composer.lock +++ b/composer.lock @@ -193,28 +193,28 @@ }, { "name": "jean85/pretty-package-versions", - "version": "2.0.6", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4" + "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4", - "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", + "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", "shasum": "" }, "require": { - "composer-runtime-api": "^2.0.0", - "php": "^7.1|^8.0" + "composer-runtime-api": "^2.1.0", + "php": "^7.4|^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^7.5|^8.5|^9.4", - "vimeo/psalm": "^4.3" + "phpunit/phpunit": "^7.5|^8.5|^9.6", + "vimeo/psalm": "^4.3 || ^5.0" }, "type": "library", "extra": { @@ -246,9 +246,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.6" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0" }, - "time": "2024-03-08T09:58:59+00:00" + "time": "2024-11-18T16:19:46+00:00" }, { "name": "mongodb/mongodb", @@ -2097,16 +2097,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.12", + "version": "0.33.14", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "bfb7812df9e489b3cba7d5504a49ce578c71af1f" + "reference": "45a5a2db3602fa054096f378482c7da9936f5850" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/bfb7812df9e489b3cba7d5504a49ce578c71af1f", - "reference": "bfb7812df9e489b3cba7d5504a49ce578c71af1f", + "url": "https://api.github.com/repos/utopia-php/http/zipball/45a5a2db3602fa054096f378482c7da9936f5850", + "reference": "45a5a2db3602fa054096f378482c7da9936f5850", "shasum": "" }, "require": { @@ -2138,9 +2138,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.12" + "source": "https://github.com/utopia-php/http/tree/0.33.14" }, - "time": "2024-11-13T12:45:45+00:00" + "time": "2024-11-20T12:39:10+00:00" }, { "name": "utopia-php/mongo", @@ -2389,16 +2389,16 @@ }, { "name": "laravel/pint", - "version": "v1.18.1", + "version": "v1.18.2", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9" + "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/35c00c05ec43e6b46d295efc0f4386ceb30d50d9", - "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9", + "url": "https://api.github.com/repos/laravel/pint/zipball/f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64", + "reference": "f55daaf7eb6c2f49ddf6702fb42e3091c64d8a64", "shasum": "" }, "require": { @@ -2451,7 +2451,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-09-24T17:22:50+00:00" + "time": "2024-11-20T09:33:46+00:00" }, { "name": "myclabs/deep-copy", @@ -2723,16 +2723,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.10", + "version": "1.12.11", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "fc463b5d0fe906dcf19689be692c65c50406a071" + "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc463b5d0fe906dcf19689be692c65c50406a071", - "reference": "fc463b5d0fe906dcf19689be692c65c50406a071", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", + "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", "shasum": "" }, "require": { @@ -2777,7 +2777,7 @@ "type": "github" } ], - "time": "2024-11-11T15:37:09+00:00" + "time": "2024-11-17T14:08:01+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4348,7 +4348,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -4356,6 +4356,6 @@ "ext-mbstring": "*", "php": ">=8.3" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/src/Database/Adapter.php b/src/Database/Adapter.php index ae6627f97..f5748e460 100644 --- a/src/Database/Adapter.php +++ b/src/Database/Adapter.php @@ -481,7 +481,7 @@ abstract public function createAttribute(string $collection, string $id, string * * @return bool */ - abstract public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, string $newKey = null): bool; + abstract public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, ?string $newKey = null): bool; /** * Delete Attribute diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index 50672a113..e0e514fcc 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -394,7 +394,7 @@ public function createAttribute(string $collection, string $id, string $type, in * @throws Exception * @throws PDOException */ - public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, string $newKey = null): bool + public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, ?string $newKey = null): bool { $name = $this->filter($collection); $id = $this->filter($id); diff --git a/src/Database/Adapter/Mongo.php b/src/Database/Adapter/Mongo.php index c259ead09..4a54c473b 100644 --- a/src/Database/Adapter/Mongo.php +++ b/src/Database/Adapter/Mongo.php @@ -122,7 +122,7 @@ public function create(string $name): bool * @return bool * @throws Exception */ - public function exists(string $database, string $collection = null): bool + public function exists(string $database, ?string $collection = null): bool { if (!\is_null($collection)) { $collection = $this->getNamespace() . "_" . $collection; @@ -1007,7 +1007,7 @@ public function deleteDocuments(string $collection, array $ids): int * * @return bool */ - public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, string $newKey = null): bool + public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, ?string $newKey = null): bool { if (!empty($newKey) && $newKey !== $id) { return $this->renameAttribute($collection, $id, $newKey); diff --git a/src/Database/Adapter/Postgres.php b/src/Database/Adapter/Postgres.php index d47478c12..c679a9414 100644 --- a/src/Database/Adapter/Postgres.php +++ b/src/Database/Adapter/Postgres.php @@ -478,12 +478,12 @@ public function renameAttribute(string $collection, string $old, string $new): b * @param int $size * @param bool $signed * @param bool $array - * @param string $newKey + * @param string|null $newKey * @return bool * @throws Exception * @throws PDOException */ - public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, string $newKey = null): bool + public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, ?string $newKey = null): bool { $name = $this->filter($collection); $id = $this->filter($id); diff --git a/src/Database/Adapter/SQLite.php b/src/Database/Adapter/SQLite.php index 005b58564..a52ce1332 100644 --- a/src/Database/Adapter/SQLite.php +++ b/src/Database/Adapter/SQLite.php @@ -332,12 +332,12 @@ public function analyzeCollection(string $collection): bool * @param int $size * @param bool $signed * @param bool $array - * @param string $newKey + * @param string|null $newKey * @return bool * @throws Exception * @throws PDOException */ - public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, string $newKey = null): bool + public function updateAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, ?string $newKey = null): bool { if (!empty($newKey) && $newKey !== $id) { return $this->renameAttribute($collection, $id, $newKey); diff --git a/src/Database/Database.php b/src/Database/Database.php index d4e2dc151..976806271 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -477,7 +477,7 @@ public function before(string $event, string $name, callable $callback): static * @param array|null $listeners List of listeners to silence; if null, all listeners will be silenced * @return T */ - public function silent(callable $callback, array $listeners = null): mixed + public function silent(callable $callback, ?array $listeners = null): mixed { $previous = $this->silentListeners; @@ -1143,14 +1143,14 @@ public function delete(?string $database = null): bool * @param string $id * @param array $attributes * @param array $indexes - * @param array $permissions + * @param array|null $permissions * @param bool $documentSecurity * @return Document * @throws DatabaseException * @throws DuplicateException * @throws LimitException */ - public function createCollection(string $id, array $attributes = [], array $indexes = [], array $permissions = null, bool $documentSecurity = true): Document + public function createCollection(string $id, array $attributes = [], array $indexes = [], ?array $permissions = null, bool $documentSecurity = true): Document { $permissions ??= [ Permission::create(Role::any()), @@ -1437,7 +1437,7 @@ public function deleteCollection(string $id): bool * @throws StructureException * @throws Exception */ - public function createAttribute(string $collection, string $id, string $type, int $size, bool $required, mixed $default = null, bool $signed = true, bool $array = false, string $format = null, array $formatOptions = [], array $filters = []): bool + public function createAttribute(string $collection, string $id, string $type, int $size, bool $required, mixed $default = null, bool $signed = true, bool $array = false, ?string $format = null, array $formatOptions = [], array $filters = []): bool { $collection = $this->silent(fn () => $this->getCollection($collection)); @@ -1802,7 +1802,7 @@ public function updateAttributeDefault(string $collection, string $id, mixed $de * @return Document * @throws Exception */ - public function updateAttribute(string $collection, string $id, string $type = null, int $size = null, bool $required = null, mixed $default = null, bool $signed = null, bool $array = null, string $format = null, ?array $formatOptions = null, ?array $filters = null, ?string $newKey = null): Document + public function updateAttribute(string $collection, string $id, ?string $type = null, ?int $size = null, ?bool $required = null, mixed $default = null, ?bool $signed = null, ?bool $array = null, ?string $format = null, ?array $formatOptions = null, ?array $filters = null, ?string $newKey = null): Document { return $this->updateAttributeMeta($collection, $id, function ($attribute, $collectionDoc, $attributeIndex) use ($collection, $id, $type, $size, $required, $default, $signed, $array, $format, $formatOptions, $filters, $newKey) { $altering = !\is_null($type) @@ -3425,13 +3425,9 @@ public function createDocuments(string $collection, array $documents, int $batch } $documents[$key] = $this->decode($collection, $document); + $this->trigger(self::EVENT_DOCUMENT_CREATE, $documents[$key]); } - $this->trigger(self::EVENT_DOCUMENTS_CREATE, new Document([ - '$collection' => $collection->getId(), - 'modified' => array_map(fn ($document) => $document->getId(), $documents) - ])); - return $documents; } diff --git a/src/Database/Exception.php b/src/Database/Exception.php index 94099c6ae..d86e94c2b 100644 --- a/src/Database/Exception.php +++ b/src/Database/Exception.php @@ -6,7 +6,7 @@ class Exception extends \Exception { - public function __construct(string $message, int|string $code = 0, Throwable $previous = null) + public function __construct(string $message, int|string $code = 0, ?Throwable $previous = null) { if (\is_string($code)) { if (\is_numeric($code)) { diff --git a/src/Database/Mirror.php b/src/Database/Mirror.php index f21b97f43..92cdae23c 100644 --- a/src/Database/Mirror.php +++ b/src/Database/Mirror.php @@ -169,7 +169,7 @@ protected function trigger(string $event, mixed $args = null): void $this->source->trigger($event, $args); } - public function silent(callable $callback, array $listeners = null): mixed + public function silent(callable $callback, ?array $listeners = null): mixed { return $this->source->silent($callback, $listeners); } @@ -194,7 +194,7 @@ public function delete(?string $database = null): bool return $this->delegate(__FUNCTION__, \func_get_args()); } - public function createCollection(string $id, array $attributes = [], array $indexes = [], array $permissions = null, bool $documentSecurity = true): Document + public function createCollection(string $id, array $attributes = [], array $indexes = [], ?array $permissions = null, bool $documentSecurity = true): Document { $result = $this->source->createCollection( $id, @@ -292,7 +292,7 @@ public function deleteCollection(string $id): bool return $result; } - public function createAttribute(string $collection, string $id, string $type, int $size, bool $required, $default = null, bool $signed = true, bool $array = false, string $format = null, array $formatOptions = [], array $filters = []): bool + public function createAttribute(string $collection, string $id, string $type, int $size, bool $required, $default = null, bool $signed = true, bool $array = false, ?string $format = null, array $formatOptions = [], array $filters = []): bool { $result = $this->source->createAttribute( $collection, @@ -356,7 +356,7 @@ public function createAttribute(string $collection, string $id, string $type, in return $result; } - public function updateAttribute(string $collection, string $id, string $type = null, int $size = null, bool $required = null, mixed $default = null, bool $signed = null, bool $array = null, string $format = null, ?array $formatOptions = null, ?array $filters = null, ?string $newKey = null): Document + public function updateAttribute(string $collection, string $id, ?string $type = null, ?int $size = null, ?bool $required = null, mixed $default = null, ?bool $signed = null, ?bool $array = null, ?string $format = null, ?array $formatOptions = null, ?array $filters = null, ?string $newKey = null): Document { $document = $this->source->updateAttribute( $collection, diff --git a/tests/e2e/Adapter/Base.php b/tests/e2e/Adapter/Base.php index ea18ea2a7..5a141718e 100644 --- a/tests/e2e/Adapter/Base.php +++ b/tests/e2e/Adapter/Base.php @@ -17036,7 +17036,8 @@ public function testEvents(): void Database::EVENT_DOCUMENT_SUM, Database::EVENT_DOCUMENT_INCREASE, Database::EVENT_DOCUMENT_DECREASE, - Database::EVENT_DOCUMENTS_CREATE, + Database::EVENT_DOCUMENT_CREATE, + Database::EVENT_DOCUMENT_CREATE, Database::EVENT_DOCUMENT_UPDATE, Database::EVENT_DOCUMENT_UPDATE, Database::EVENT_DOCUMENT_UPDATE,