Skip to content

Commit

Permalink
Merge pull request #2527 from doctrine/2.5.x-merge-up-into-2.6.x_TYQB…
Browse files Browse the repository at this point in the history
…MVqZ

Merge release 2.5.1 into 2.6.x
  • Loading branch information
alcaeus authored Apr 11, 2023
2 parents 3091159 + 1004bb3 commit c100aec
Show file tree
Hide file tree
Showing 261 changed files with 676 additions and 674 deletions.
24 changes: 18 additions & 6 deletions .doctrine-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,34 @@
"docsSlug": "doctrine-mongodb-odm",
"versions": [
{
"name": "2.4",
"branchName": "2.4.x",
"name": "2.6",
"branchName": "2.6.x",
"slug": "latest",
"upcoming": true
},
{
"name": "2.3",
"branchName": "2.3.x",
"slug": "2.3",
"name": "2.5",
"branchName": "2.5.x",
"slug": "2.5",
"current": true,
"aliases": [
"current",
"stable",
"2.3.x"
"2.5.x"
]
},
{
"name": "2.4",
"branchName": "2.4.x",
"slug": "2.4",
"maintained": false
},
{
"name": "2.3",
"branchName": "2.3.x",
"slug": "2.3",
"maintained": false
},
{
"name": "2.2",
"branchName": "2.2.x",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ phpunit.xml
composer.lock
vendor/
.phpcs-cache
.phpunit.cache
.phpunit.result.cache
phpcs.xml
psalm.xml
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"doctrine/coding-standard": "^11.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0@dev",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan": "^1.10.11",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5.5",
"phpunit/phpunit": "^9.5.5 || ^10.0.15",
"squizlabs/php_codesniffer": "^3.5",
"symfony/cache": "^4.4 || ^5.0 || ^6.0",
"vimeo/psalm": "^5.7.7"
"vimeo/psalm": "^5.9.0"
},
"suggest": {
"ext-bcmath": "Decimal128 type support"
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @internal
*
* @psalm-import-type PipelineExpression from Builder
* @psalm-type StageExpression = non-empty-array<non-empty-string, mixed>|object
* @psalm-type StageExpression = array<non-empty-string, mixed>
*/
abstract class Stage
{
Expand All @@ -31,6 +31,7 @@ public function __construct(Builder $builder)
* Assembles the aggregation stage
*
* @return array<string, mixed>
* @psalm-return StageExpression
*/
abstract public function getExpression(): array;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private function getDocumentPersister(): DocumentPersister
return $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name);
}

/** @return array|string */
/** @return array<string, mixed>|string */
protected function getReplaceExpression()
{
return $this->expression !== null ? $this->convertExpression($this->expression) : $this->expr->getExpression();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public function returnStoredSource(bool $returnStoredSource): Search
return $this->search->returnStoredSource($returnStoredSource);
}

/** @return array<string, object> */
/**
* @return array<string, object>
* @psalm-return non-empty-array<non-empty-string, object>
*/
final public function getExpression(): array
{
return [$this->getOperatorName() => $this->getOperatorParams()];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ private function hasQueryOperators($value): bool
/**
* Returns the list of discriminator values for the given ClassMetadata
*
* @psalm-return list<class-string>
* @psalm-return list<class-string|null>
*/
private function getClassDiscriminatorValues(ClassMetadata $metadata): array
{
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,8 @@ public function clear(?string $documentName = null): void
$this->embeddedDocumentsRegistry =
$this->orphanRemovals =
$this->hasScheduledCollections = [];

$event = new Event\OnClearEventArgs($this->dm);
} else {
$visited = [];
foreach ($this->identityMap as $className => $documents) {
Expand All @@ -2406,9 +2408,11 @@ public function clear(?string $documentName = null): void
$this->doDetach($document, $visited);
}
}

$event = new Event\OnClearEventArgs($this->dm, $documentName);
}

$this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->dm, $documentName));
$this->evm->dispatchEvent(Events::onClear, $event);
}

/**
Expand Down
78 changes: 49 additions & 29 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
parameters:
ignoreErrors:
-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$applyFilters$#"
message: "#^Circular definition detected in type alias PipelineExpression\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
message: "#^PHPDoc tag @param references unknown parameter\\: \\$applyFilters$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
path: lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\AbstractReplace\\:\\:getReplaceExpression\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractReplace.php
path: lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Bucket\\\\AbstractOutput\\:\\:avg\\(\\) has parameter \\$expressions with no type specified\\.$#"
Expand Down Expand Up @@ -51,19 +51,19 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/AbstractOutput.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Densify\\:\\:getExpression\\(\\) has invalid return type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\DensifyStageExpression\\.$#"
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Densify\\:\\:getExpression\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Densify.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Densify\\:\\:getExpression\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^PHPDoc tag @return with type mixed is not subtype of native type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Densify.php

-
message: "#^PHPDoc tag @return with type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\DensifyStageExpression is incompatible with native type array\\.$#"
message: "#^Circular definition detected in type alias FacetStageExpression\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Densify.php
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php

-
message: "#^Return type \\(static\\(Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\GeoNear\\)\\) of method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\GeoNear\\:\\:limit\\(\\) should be compatible with return type \\(Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Limit\\) of method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\:\\:limit\\(\\)$#"
Expand All @@ -76,7 +76,7 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Lookup\\:\\:getExpression\\(\\) has invalid return type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\LookupStageExpression\\.$#"
message: "#^Circular definition detected in type alias PipelineParamType\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php

Expand All @@ -86,7 +86,7 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php

-
message: "#^PHPDoc tag @return with type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\LookupStageExpression is incompatible with native type array\\.$#"
message: "#^PHPDoc tag @return with type mixed is not subtype of native type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php

Expand All @@ -96,7 +96,12 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Merge\\:\\:getExpression\\(\\) has invalid return type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\MergeStageExpression\\.$#"
message: "#^Circular definition detected in type alias WhenMatchedParamType\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Merge.php

-
message: "#^Circular definition detected in type alias WhenMatchedType\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Merge.php

Expand All @@ -106,7 +111,17 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Merge.php

-
message: "#^PHPDoc tag @return with type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\MergeStageExpression is incompatible with native type array\\.$#"
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Merge\\:\\:whenMatched\\(\\) has parameter \\$whenMatched with no value type specified in iterable type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Merge.php

-
message: "#^PHPDoc tag @return with type mixed is not subtype of native type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Merge.php

-
message: "#^Property Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Merge\\:\\:\\$whenMatched type has no value type specified in iterable type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Merge.php

Expand All @@ -125,11 +140,21 @@ parameters:
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Search\\:\\:getExpression\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Search\\:\\:near\\(\\) has parameter \\$origin with no value type specified in iterable type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search.php

-
message: "#^PHPDoc tag @return with type mixed is not subtype of native type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\Search\\\\Compound\\:\\:geoShape\\(\\) has parameter \\$geometry with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -445,11 +470,6 @@ parameters:
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Search/SupportsNearOperator.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\UnionWith\\:\\:getExpression\\(\\) has invalid return type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\UnionWithStageExpression\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/UnionWith.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\UnionWith\\:\\:getExpression\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -461,7 +481,7 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/UnionWith.php

-
message: "#^PHPDoc tag @return with type Doctrine\\\\ODM\\\\MongoDB\\\\Aggregation\\\\Stage\\\\UnionWithStageExpression is incompatible with native type array\\.$#"
message: "#^PHPDoc tag @return with type mixed is not subtype of native type array\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Aggregation/Stage/UnionWith.php

Expand Down Expand Up @@ -506,7 +526,7 @@ parameters:
path: lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php

-
message: "#^Parameter \\#2 \\$options of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\<object\\>\\:\\:addIndex\\(\\) expects array\\{background\\?\\: bool, bits\\?\\: int, default_language\\?\\: string, expireAfterSeconds\\?\\: int, language_override\\?\\: string, min\\?\\: float, max\\?\\: float, name\\?\\: string, \\.\\.\\.\\}, array\\<string, non\\-empty\\-array\\<string, array\\<int\\|string, mixed\\>\\|bool\\|float\\|int\\|string\\|null\\>\\|bool\\|float\\|int\\|string\\|null\\> given\\.$#"
message: "#^Parameter \\#2 \\$options of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\<object\\>\\:\\:addIndex\\(\\) expects array\\{background\\?\\: bool, bits\\?\\: int, default_language\\?\\: string, expireAfterSeconds\\?\\: int, language_override\\?\\: string, min\\?\\: float, max\\?\\: float, name\\?\\: string, \\.\\.\\.\\}, array\\<string, non\\-empty\\-array\\<string, array\\<int\\<0, max\\>\\|string, mixed\\>\\|bool\\|float\\|int\\|string\\|null\\>\\|bool\\|float\\|int\\|string\\|null\\> given\\.$#"
count: 1
path: lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php

Expand Down Expand Up @@ -683,32 +703,32 @@ parameters:
-
message: "#^Constant DOCTRINE_MONGODB_DATABASE not found\\.$#"
count: 5
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

-
message: "#^Constant DOCTRINE_MONGODB_SERVER not found\\.$#"
count: 1
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\BaseTest\\:\\:assertArraySubset\\(\\) has parameter \\$array with no value type specified in iterable type array\\.$#"
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\BaseTestCase\\:\\:assertArraySubset\\(\\) has parameter \\$array with no value type specified in iterable type array\\.$#"
count: 1
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

-
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\BaseTest\\:\\:assertArraySubset\\(\\) has parameter \\$subset with no value type specified in iterable type array\\.$#"
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\BaseTestCase\\:\\:assertArraySubset\\(\\) has parameter \\$subset with no value type specified in iterable type array\\.$#"
count: 1
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

-
message: "#^Used constant DOCTRINE_MONGODB_DATABASE not found\\.$#"
count: 1
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

-
message: "#^Used constant DOCTRINE_MONGODB_SERVER not found\\.$#"
count: 1
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

-
message: "#^Parameter \\#2 \\$referenceMapping of method Doctrine\\\\ODM\\\\MongoDB\\\\DocumentManager\\:\\:createReference\\(\\) expects array\\{type\\: string, fieldName\\: string, name\\: string, isCascadeRemove\\: bool, isCascadePersist\\: bool, isCascadeRefresh\\: bool, isCascadeMerge\\: bool, isCascadeDetach\\: bool, \\.\\.\\.\\}, array\\{storeAs\\: 'dbRef'\\} given\\.$#"
Expand Down Expand Up @@ -863,7 +883,7 @@ parameters:
-
message: "#^Property Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\Mapping\\\\AnnotationDriverTestSuper\\:\\:\\$private is unused\\.$#"
count: 1
path: tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTest.php
path: tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php

-
message: "#^Property Doctrine\\\\ODM\\\\MongoDB\\\\Tests\\\\Mapping\\\\DocumentSubClass2\\:\\:\\$id is unused\\.$#"
Expand Down
23 changes: 10 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticProperties="false"
colors="false"
failOnRisky="true"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Doctrine ODM MongoDB Test Suite">
<directory>./tests/Doctrine/</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">./lib/Doctrine/ODM/MongoDB</directory>
Expand All @@ -25,13 +24,11 @@
<file>./lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Match.php</file>
</exclude>
</coverage>

<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>

<php>
<ini name="error_reporting" value="-1"/>
<const name="DOCTRINE_MONGODB_SERVER" value="mongodb://localhost:27017" />
Expand Down
Loading

0 comments on commit c100aec

Please sign in to comment.