Skip to content

Commit

Permalink
Merge pull request #2523 from phansys/query
Browse files Browse the repository at this point in the history
Parameter 4 in `Query::__construct()` can not use an empty array as default value
  • Loading branch information
malarzm authored Apr 5, 2023
2 parents 10530b3 + 9d12594 commit 856de18
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* skip?: int,
* snapshot?: bool,
* sort?: array<string, -1|1|SortMeta>,
* type?: Query::TYPE_*,
* type: Query::TYPE_*,
* upsert?: bool,
* }
* @psalm-import-type Hints from UnitOfWork
Expand Down Expand Up @@ -136,7 +136,7 @@ final class Query implements IteratorAggregate
* @param array<string, mixed> $options
* @param array<string, callable|true|null> $primers
*/
public function __construct(DocumentManager $dm, ClassMetadata $class, Collection $collection, array $query = [], array $options = [], bool $hydrate = true, bool $refresh = false, array $primers = [], bool $readOnly = false, bool $rewindable = true)
public function __construct(DocumentManager $dm, ClassMetadata $class, Collection $collection, array $query, array $options = [], bool $hydrate = true, bool $refresh = false, array $primers = [], bool $readOnly = false, bool $rewindable = true)
{
$primers = array_filter($primers);

Expand Down
5 changes: 0 additions & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,6 @@
<code>1</code>
</InvalidArgument>
</file>
<file src="tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php">
<InvalidArgument>
<code><![CDATA[['type' => -1]]]></code>
</InvalidArgument>
</file>
<file src="tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php">
<InternalClass>
<code>new IndexInfoIteratorIterator(new ArrayIterator($indexes))</code>
Expand Down
2 changes: 2 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ public function testReadOnly(): void
public function testConstructorShouldThrowExceptionForInvalidType(): void
{
$this->expectException(InvalidArgumentException::class);

/** @psalm-suppress InvalidArgument */
new Query($this->dm, new ClassMetadata(User::class), $this->getMockCollection(), ['type' => -1], []);
}

Expand Down

0 comments on commit 856de18

Please sign in to comment.