diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index b7fc8c0..1ea7fec 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -94,7 +94,7 @@ jobs: mongodb-version: - "6.0" - "7.0" - - "8.0" + - "9.0" env: MONGODB_URI: 'mongodb://localhost:27017' diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d71d325..2f9e3f0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -72,18 +72,6 @@ parameters: count: 1 path: src/Repository/MongoDBRepository.php - - - message: '#^Parameter \#1 \$documents of method MongoDB\\Collection\:\:insertMany\(\) expects list\, array\\> given\.$#' - identifier: argument.type - count: 1 - path: src/Repository/MongoDBRepository.php - - - - message: '#^Parameter \#1 \$operations of method MongoDB\\Collection\:\:bulkWrite\(\) expects list\, non\-empty\-array\, array\{''\$set''\: array\\}\}\}\> given\.$#' - identifier: argument.type - count: 1 - path: src/Repository/MongoDBRepository.php - - message: '#^Parameter \#2 \$data of method Patchlevel\\ODM\\Hydrator\\DocumentHydrator\:\:hydrate\(\) expects array\, array\|object given\.$#' identifier: argument.type @@ -114,18 +102,6 @@ parameters: count: 1 path: src/Repository/RangoRepository.php - - - message: '#^Parameter \#1 \$documents of method Patchlevel\\Rango\\Collection\\>\:\:insertMany\(\) expects list\\>, array\\> given\.$#' - identifier: argument.type - count: 1 - path: src/Repository/RangoRepository.php - - - - message: '#^Parameter \#1 \$operations of method Patchlevel\\Rango\\Collection\\>\:\:bulkWrite\(\) expects list\\>\>\>, non\-empty\-array\, array\{''\$set''\: array\\}\}\}\> given\.$#' - identifier: argument.type - count: 1 - path: src/Repository/RangoRepository.php - - message: '#^Property Patchlevel\\ODM\\Repository\\RangoRepository\:\:\$collection with generic class Patchlevel\\Rango\\Collection does not specify its types\: TDocument$#' identifier: missingType.generics diff --git a/src/Metadata/DocumentMetadata.php b/src/Metadata/DocumentMetadata.php index bef9ff8..03be4c5 100644 --- a/src/Metadata/DocumentMetadata.php +++ b/src/Metadata/DocumentMetadata.php @@ -122,6 +122,7 @@ public function discriminatorFilter(): array return [$this->discriminatorField => ['$in' => $this->discriminatorValues]]; } + /** @throws UnknownPropertyPath */ public function propertyPathToFieldPath(string $propertyPath): string { return $this->propertyPathToFieldPathWithChildren($propertyPath, $this->fields)[0]; @@ -131,6 +132,8 @@ public function propertyPathToFieldPath(string $propertyPath): string * @param array $filter * * @return array + * + * @throws UnknownPropertyPath */ public function mapFilterToFieldPaths(array $filter): array { @@ -210,6 +213,8 @@ private function propertyPathToFieldPathWithChildren(string $propertyPath, array * @param array $orderBy * * @return array + * + * @throws UnknownPropertyPath */ public function mapSortingToFieldPaths(array $orderBy): array { diff --git a/src/Repository/MongoDBRepository.php b/src/Repository/MongoDBRepository.php index 4c9b03e..f6bc0e4 100644 --- a/src/Repository/MongoDBRepository.php +++ b/src/Repository/MongoDBRepository.php @@ -12,6 +12,7 @@ use Patchlevel\ODM\Metadata\DocumentMetadata; use function array_map; +use function array_values; use function count; use function in_array; use function iterator_to_array; @@ -40,6 +41,8 @@ public function __construct( /** @param list ...$objects */ public function insert(object ...$objects): void { + $objects = array_values($objects); + try { if (count($objects) === 1) { $object = $objects[0]; @@ -73,6 +76,8 @@ public function update(object ...$objects): void return; } + $objects = array_values($objects); + if (count($objects) === 1) { $update = $this->prepareUpdate($objects[0]); diff --git a/src/Repository/RangoRepository.php b/src/Repository/RangoRepository.php index 233ef7d..79018b8 100644 --- a/src/Repository/RangoRepository.php +++ b/src/Repository/RangoRepository.php @@ -12,6 +12,7 @@ use Patchlevel\Rango\Exception\QueryException; use function array_map; +use function array_values; use function count; use function in_array; use function str_ends_with; @@ -39,6 +40,8 @@ public function __construct( /** @param list ...$objects */ public function insert(object ...$objects): void { + $objects = array_values($objects); + try { if (count($objects) === 1) { $object = $objects[0]; @@ -78,6 +81,8 @@ public function update(object ...$objects): void return; } + $objects = array_values($objects); + if (count($objects) === 1) { $update = $this->prepareUpdate($objects[0]);