Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Database/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Adapter/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Adapter/SQLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 6 additions & 10 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public function before(string $event, string $name, callable $callback): static
* @param array<string>|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;

Expand Down Expand Up @@ -1143,14 +1143,14 @@ public function delete(?string $database = null): bool
* @param string $id
* @param array<Document> $attributes
* @param array<Document> $indexes
* @param array<string> $permissions
* @param array<string>|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()),
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Database/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 4 additions & 4 deletions src/Database/Mirror.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading