diff --git a/composer.json b/composer.json
index 364315ddba..b7fce1ecf5 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,7 @@
"symfony/var-dumper": "^3.4|^4.1"
},
"require-dev": {
- "doctrine/coding-standard": "^5.0",
+ "doctrine/coding-standard": "^6.0",
"jmikola/geojson": "^1.0",
"phpstan/phpstan": "^0.10.3",
"phpunit/phpunit": "^8.2"
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
index d96b268d96..f178acf3a8 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
@@ -323,7 +323,9 @@ public static function convertExpression($expression)
return array_map(static function ($expression) {
return static::convertExpression($expression);
}, $expression);
- } elseif ($expression instanceof self) {
+ }
+
+ if ($expression instanceof self) {
return $expression->getExpression();
}
@@ -1545,7 +1547,6 @@ public function zip($inputs, ?bool $useLongestLength = null, $defaults = null) :
return $this->operator('$zip', $args);
}
-
/**
* @param mixed|self $expression
*
@@ -1555,9 +1556,13 @@ private function ensureArray($expression)
{
if (is_string($expression) && substr($expression, 0, 1) === '$') {
return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));
- } elseif (is_array($expression)) {
+ }
+
+ if (is_array($expression)) {
return array_map([$this, 'ensureArray'], $expression);
- } elseif ($expression instanceof self) {
+ }
+
+ if ($expression instanceof self) {
return $expression->getExpression();
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php
index e7a77d95b5..ca7984ca51 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php
@@ -85,7 +85,9 @@ private function convertExpression($expression)
{
if (is_array($expression)) {
return array_map([$this, 'convertExpression'], $expression);
- } elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
+ }
+
+ if (is_string($expression) && substr($expression, 0, 1) === '$') {
return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php
index 6cd1c011dc..bc9c403575 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php
@@ -31,6 +31,7 @@ class Bucket extends AbstractBucket
public function boundaries(...$boundaries) : self
{
$this->boundaries = $boundaries;
+
return $this;
}
@@ -44,6 +45,7 @@ public function boundaries(...$boundaries) : self
public function defaultBucket($default) : self
{
$this->default = $default;
+
return $this;
}
@@ -59,6 +61,7 @@ public function output() : Bucket\BucketOutput
}
assert($this->output instanceof Bucket\BucketOutput);
+
return $this->output;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php
index d2cf7ab55c..c4cd19f133 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php
@@ -25,6 +25,7 @@ public function __construct(Builder $builder, Stage\BucketAuto $bucket)
public function groupBy($expression) : Stage\BucketAuto
{
assert($this->bucket instanceof Stage\BucketAuto);
+
return $this->bucket->groupBy($expression);
}
@@ -34,6 +35,7 @@ public function groupBy($expression) : Stage\BucketAuto
public function buckets(int $buckets) : Stage\BucketAuto
{
assert($this->bucket instanceof Stage\BucketAuto);
+
return $this->bucket->buckets($buckets);
}
@@ -45,6 +47,7 @@ public function buckets(int $buckets) : Stage\BucketAuto
public function granularity(string $granularity) : Stage\BucketAuto
{
assert($this->bucket instanceof Stage\BucketAuto);
+
return $this->bucket->granularity($granularity);
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketOutput.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketOutput.php
index fea638c1dd..a3f3a46af4 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketOutput.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketOutput.php
@@ -30,6 +30,7 @@ public function __construct(Builder $builder, Stage\Bucket $bucket)
public function groupBy($expression)
{
assert($this->bucket instanceof Stage\Bucket);
+
return $this->bucket->groupBy($expression);
}
@@ -49,6 +50,7 @@ public function groupBy($expression)
public function boundaries(...$boundaries)
{
assert($this->bucket instanceof Stage\Bucket);
+
return $this->bucket->boundaries(...$boundaries);
}
@@ -64,6 +66,7 @@ public function boundaries(...$boundaries)
public function defaultBucket($default)
{
assert($this->bucket instanceof Stage\Bucket);
+
return $this->bucket->defaultBucket($default);
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php
index 723c76cbcf..ba03e48beb 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php
@@ -24,6 +24,7 @@ class BucketAuto extends AbstractBucket
public function buckets(int $buckets) : self
{
$this->buckets = $buckets;
+
return $this;
}
@@ -35,6 +36,7 @@ public function buckets(int $buckets) : self
public function granularity(string $granularity) : self
{
$this->granularity = $granularity;
+
return $this;
}
@@ -50,6 +52,7 @@ public function output() : Bucket\BucketAutoOutput
}
assert($this->output instanceof Bucket\BucketAutoOutput);
+
return $this->output;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php
index c59192d8c2..2563ef53c5 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php
@@ -39,6 +39,7 @@ public function getExpression() : array
public function field(string $field) : self
{
$this->field = $field;
+
return $this;
}
@@ -62,6 +63,7 @@ public function pipeline($builder) : self
}
$this->pipelines[$this->field] = $builder;
+
return $this;
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
index 8b450e3ada..8884dd0c00 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
@@ -93,12 +93,14 @@ public function connectFromField(string $connectFromField) : self
// No targetClass mapping - simply use field name as is
if (! $this->targetClass) {
$this->connectFromField = $connectFromField;
+
return $this;
}
// connectFromField doesn't have to be a reference - in this case, just convert the field name
if (! $this->targetClass->hasReference($connectFromField)) {
$this->connectFromField = $this->convertTargetFieldName($connectFromField);
+
return $this;
}
@@ -109,6 +111,7 @@ public function connectFromField(string $connectFromField) : self
}
$this->connectFromField = $this->getReferencedFieldName($connectFromField, $referenceMapping);
+
return $this;
}
@@ -119,6 +122,7 @@ public function connectFromField(string $connectFromField) : self
public function connectToField(string $connectToField) : self
{
$this->connectToField = $this->convertTargetFieldName($connectToField);
+
return $this;
}
@@ -159,6 +163,7 @@ public function from(string $from) : self
$this->targetClass = $this->dm->getClassMetadata($from);
} catch (BaseMappingException $e) {
$this->from = $from;
+
return $this;
}
@@ -167,6 +172,7 @@ public function from(string $from) : self
}
$this->from = $this->targetClass->getCollection();
+
return $this;
}
@@ -274,7 +280,9 @@ private function convertExpression($expression)
{
if (is_array($expression)) {
return array_map([$this, 'convertExpression'], $expression);
- } elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
+ }
+
+ if (is_string($expression) && substr($expression, 0, 1) === '$') {
return '$' . $this->getDocumentPersister($this->class)->prepareFieldName(substr($expression, 1));
}
@@ -317,8 +325,6 @@ private function getReferencedFieldName(string $fieldName, array $mapping) : str
case ClassMetadata::REFERENCE_STORE_AS_ID:
case ClassMetadata::REFERENCE_STORE_AS_REF:
return ClassMetadata::getReferenceFieldName($mapping['storeAs'], $mapping['name']);
- break;
-
default:
throw MappingException::cannotLookupDbRefReference($this->class->name, $fieldName);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php
index 7853aca00f..9eac5bf4f9 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php
@@ -83,6 +83,7 @@ public function from(string $from) : self
$this->targetClass = $this->dm->getClassMetadata($from);
} catch (BaseMappingException $e) {
$this->from = $from;
+
return $this;
}
@@ -91,6 +92,7 @@ public function from(string $from) : self
}
$this->from = $this->targetClass->getCollection();
+
return $this;
}
@@ -120,6 +122,7 @@ public function getExpression() : array
public function localField(string $localField) : self
{
$this->localField = $this->prepareFieldName($localField, $this->class);
+
return $this;
}
@@ -134,6 +137,7 @@ public function localField(string $localField) : self
public function foreignField(string $foreignField) : self
{
$this->foreignField = $this->prepareFieldName($foreignField, $this->targetClass);
+
return $this;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php
index 774b81ab2f..20f96746ec 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php
@@ -46,10 +46,12 @@ public function out(string $collection) : Stage\Out
$class = $this->dm->getClassMetadata($collection);
} catch (BaseMappingException $e) {
$this->collection = $collection;
+
return $this;
}
$this->fromDocument($class);
+
return $this;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php
index 5287864265..d130d48dec 100644
--- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php
+++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php
@@ -49,7 +49,9 @@ private function convertExpression($expression)
{
if (is_array($expression)) {
return array_map([$this, 'convertExpression'], $expression);
- } elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
+ }
+
+ if (is_string($expression) && substr($expression, 0, 1) === '$') {
return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));
}
diff --git a/lib/Doctrine/ODM/MongoDB/Configuration.php b/lib/Doctrine/ODM/MongoDB/Configuration.php
index 3b86fb6da6..1218a6a4a9 100644
--- a/lib/Doctrine/ODM/MongoDB/Configuration.php
+++ b/lib/Doctrine/ODM/MongoDB/Configuration.php
@@ -339,6 +339,7 @@ public function getClassMetadataFactoryName() : string
if (! isset($this->attributes['classMetadataFactoryName'])) {
$this->attributes['classMetadataFactoryName'] = ClassMetadataFactory::class;
}
+
return $this->attributes['classMetadataFactoryName'];
}
@@ -435,6 +436,7 @@ public function getPersistentCollectionFactory() : PersistentCollectionFactory
if (! isset($this->attributes['persistentCollectionFactory'])) {
$this->attributes['persistentCollectionFactory'] = new DefaultPersistentCollectionFactory();
}
+
return $this->attributes['persistentCollectionFactory'];
}
@@ -459,6 +461,7 @@ public function getPersistentCollectionGenerator() : PersistentCollectionGenerat
$this->getPersistentCollectionNamespace()
);
}
+
return $this->attributes['persistentCollectionGenerator'];
}
diff --git a/lib/Doctrine/ODM/MongoDB/DocumentManager.php b/lib/Doctrine/ODM/MongoDB/DocumentManager.php
index 60e8964461..d31c515e29 100644
--- a/lib/Doctrine/ODM/MongoDB/DocumentManager.php
+++ b/lib/Doctrine/ODM/MongoDB/DocumentManager.php
@@ -510,6 +510,7 @@ public function merge($document)
throw new InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
+
return $this->unitOfWork->merge($document);
}
@@ -678,6 +679,7 @@ public function contains($document)
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
}
+
return $this->unitOfWork->isScheduledForInsert($document) ||
$this->unitOfWork->isInIdentityMap($document) &&
! $this->unitOfWork->isScheduledForDelete($document);
@@ -718,8 +720,6 @@ public function createReference(object $document, array $referenceMapping)
}
return $class->getDatabaseIdentifierValue($id);
- break;
-
case ClassMetadata::REFERENCE_STORE_AS_REF:
$reference = ['id' => $class->getDatabaseIdentifierValue($id)];
break;
diff --git a/lib/Doctrine/ODM/MongoDB/Event/LifecycleEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/LifecycleEventArgs.php
index 713474e43f..8879044dda 100644
--- a/lib/Doctrine/ODM/MongoDB/Event/LifecycleEventArgs.php
+++ b/lib/Doctrine/ODM/MongoDB/Event/LifecycleEventArgs.php
@@ -23,6 +23,7 @@ public function getDocumentManager() : DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);
+
return $dm;
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Event/LoadClassMetadataEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/LoadClassMetadataEventArgs.php
index 31f9a31e1e..f4e6cd232f 100644
--- a/lib/Doctrine/ODM/MongoDB/Event/LoadClassMetadataEventArgs.php
+++ b/lib/Doctrine/ODM/MongoDB/Event/LoadClassMetadataEventArgs.php
@@ -17,6 +17,7 @@ public function getDocumentManager() : DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);
+
return $dm;
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Event/ManagerEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/ManagerEventArgs.php
index 4fccda235e..e834e53b91 100644
--- a/lib/Doctrine/ODM/MongoDB/Event/ManagerEventArgs.php
+++ b/lib/Doctrine/ODM/MongoDB/Event/ManagerEventArgs.php
@@ -17,6 +17,7 @@ public function getDocumentManager() : DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);
+
return $dm;
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php
index 17ca55bced..71cacb8b98 100644
--- a/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php
+++ b/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php
@@ -17,6 +17,7 @@ public function getDocumentManager() : DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);
+
return $dm;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php b/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
index f9de08ee75..518d2a9f8c 100644
--- a/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
+++ b/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
@@ -152,6 +152,7 @@ public function getHydratorFor(string $className) : HydratorInterface
}
}
$this->hydrators[$className] = new $fqn($this->dm, $this->unitOfWork, $class);
+
return $this->hydrators[$className];
}
diff --git a/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php b/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php
index 276ee51ea3..b46ce17148 100644
--- a/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php
+++ b/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php
@@ -69,6 +69,7 @@ public function isValid(string $uuid) : bool
public function generate(DocumentManager $dm, object $document)
{
$uuid = $this->generateV4();
+
return $this->generateV5($uuid, $this->salt ?: php_uname('n'));
}
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
index c96c1246fc..b4933eb1cf 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
@@ -865,6 +865,7 @@ public function addIndex(array $keys, array $options = []) : void
return -1;
}
}
+
return $value;
}, $keys),
'options' => $options,
@@ -884,7 +885,7 @@ public function getIndexes() : array
*/
public function hasIndexes() : bool
{
- return $this->indexes ? true : false;
+ return $this->indexes !== [];
}
/**
@@ -911,7 +912,7 @@ public function setShardKey(array $keys, array $options = []) : void
throw MappingException::noMultiKeyShardKeys($this->getName(), $field);
}
- if ($this->fieldMappings[$field]['strategy'] !== static::STORAGE_STRATEGY_SET) {
+ if ($this->fieldMappings[$field]['strategy'] !== self::STORAGE_STRATEGY_SET) {
throw MappingException::onlySetStrategyAllowedInShardKey($this->getName(), $field);
}
}
@@ -931,6 +932,7 @@ public function setShardKey(array $keys, array $options = []) : void
return -1;
}
}
+
return $value;
}, $keys),
'options' => $options,
@@ -947,7 +949,7 @@ public function getShardKey() : array
*/
public function isSharded() : bool
{
- return $this->shardKey ? true : false;
+ return $this->shardKey !== [];
}
/**
@@ -1161,7 +1163,7 @@ public function setCollectionMax(int $max) : void
*/
public function isMappedToCollection() : bool
{
- return $this->collection ? true : false;
+ return $this->collection !== '' && $this->collection !== null;
}
/**
@@ -1389,6 +1391,7 @@ public function setIdGenerator(AbstractIdGenerator $generator) : void
public function getPHPIdentifierValue($id)
{
$idType = $this->fieldMappings[$this->identifier]['type'];
+
return Type::getType($idType)->convertToPHPValue($id);
}
@@ -1402,6 +1405,7 @@ public function getPHPIdentifierValue($id)
public function getDatabaseIdentifierValue($id)
{
$idType = $this->fieldMappings[$this->identifier]['type'];
+
return Type::getType($idType)->convertToDatabaseValue($id);
}
@@ -1490,6 +1494,7 @@ public function getFieldMapping(string $fieldName) : array
if (! isset($this->fieldMappings[$fieldName])) {
throw MappingException::mappingNotFound($this->name, $fieldName);
}
+
return $this->fieldMappings[$fieldName];
}
@@ -1529,6 +1534,7 @@ public function getFieldMappingByDbFieldName(string $dbFieldName) : array
public function isNullable(string $fieldName) : bool
{
$mapping = $this->getFieldMapping($fieldName);
+
return isset($mapping['nullable']) && $mapping['nullable'] === true;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
index 9820b8bdca..13a64f2354 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
@@ -134,6 +134,7 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio
protected function isEntity(ClassMetadataInterface $class) : bool
{
assert($class instanceof ClassMetadata);
+
return ! $class->isMappedSuperclass && ! $class->isEmbeddedDocument && ! $class->isQueryResultDocument;
}
@@ -322,7 +323,6 @@ private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $pare
}
}
-
/**
* Adds inherited association mappings to the subclass mapping.
*
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
index 45169fb464..7247db0fda 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
@@ -37,6 +37,7 @@ public function isTransient($className)
return false;
}
}
+
return true;
}
@@ -280,6 +281,7 @@ public static function create($paths = [], ?Reader $reader = null) : AnnotationD
if ($reader === null) {
$reader = new AnnotationReader();
}
+
return new self($reader, $paths);
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
index 949d228ea9..9faea9a5b0 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
@@ -561,6 +561,7 @@ private function transformReadPreference(SimpleXMLElement $xmlReadPreference) :
$tags[] = $set;
}
}
+
return [(string) $xmlReadPreference['mode'], $tags];
}
diff --git a/lib/Doctrine/ODM/MongoDB/MongoDBException.php b/lib/Doctrine/ODM/MongoDB/MongoDBException.php
index 0f9f8661b5..6a815ae2b6 100644
--- a/lib/Doctrine/ODM/MongoDB/MongoDBException.php
+++ b/lib/Doctrine/ODM/MongoDB/MongoDBException.php
@@ -82,6 +82,7 @@ public static function invalidValueForType(string $type, $expected, $got) : self
} else {
$gotType = 'scalar';
}
+
return new self(sprintf('%s type requires value of type %s, %s given', $type, $expected, $gotType));
}
diff --git a/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php b/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php
index 7a8a3eeb33..d57f45c429 100644
--- a/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php
+++ b/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php
@@ -341,6 +341,7 @@ private function formatType(
) {
$name = '?' . $name;
}
+
return $name;
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php b/lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php
index d83098478d..2af8961217 100644
--- a/lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php
+++ b/lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php
@@ -192,6 +192,7 @@ public function isDirty()
// if initialized let's check with last known snapshot
return $this->coll->toArray() !== $this->snapshot;
}
+
return false;
}
@@ -226,7 +227,7 @@ public function takeSnapshot()
public function clearSnapshot()
{
$this->snapshot = [];
- $this->isDirty = $this->coll->count() ? true : false;
+ $this->isDirty = $this->coll->count() !== 0;
}
/** {@inheritdoc} */
@@ -253,8 +254,10 @@ public function getDeletedDocuments()
$compare = static function ($a, $b) {
$compareA = is_object($a) ? spl_object_hash($a) : $a;
$compareb = is_object($b) ? spl_object_hash($b) : $b;
+
return $compareA === $compareb ? 0 : ($compareA > $compareb ? 1 : -1);
};
+
return array_values(array_udiff(
$this->snapshot,
$this->coll->toArray(),
@@ -280,8 +283,10 @@ public function getInsertedDocuments()
$compare = static function ($a, $b) {
$compareA = is_object($a) ? spl_object_hash($a) : $a;
$compareb = is_object($b) ? spl_object_hash($b) : $b;
+
return $compareA === $compareb ? 0 : ($compareA > $compareb ? 1 : -1);
};
+
return array_values(array_udiff(
$this->coll->toArray(),
$this->snapshot,
@@ -335,6 +340,7 @@ public function isInitialized()
public function first()
{
$this->initialize();
+
return $this->coll->first();
}
@@ -342,6 +348,7 @@ public function first()
public function last()
{
$this->initialize();
+
return $this->coll->last();
}
@@ -376,6 +383,7 @@ public function removeElement($element)
public function containsKey($key)
{
$this->initialize();
+
return $this->coll->containsKey($key);
}
@@ -385,6 +393,7 @@ public function containsKey($key)
public function contains($element)
{
$this->initialize();
+
return $this->coll->contains($element);
}
@@ -394,6 +403,7 @@ public function contains($element)
public function exists(Closure $p)
{
$this->initialize();
+
return $this->coll->exists($p);
}
@@ -403,6 +413,7 @@ public function exists(Closure $p)
public function indexOf($element)
{
$this->initialize();
+
return $this->coll->indexOf($element);
}
@@ -412,6 +423,7 @@ public function indexOf($element)
public function get($key)
{
$this->initialize();
+
return $this->coll->get($key);
}
@@ -421,6 +433,7 @@ public function get($key)
public function getKeys()
{
$this->initialize();
+
return $this->coll->getKeys();
}
@@ -430,6 +443,7 @@ public function getKeys()
public function getValues()
{
$this->initialize();
+
return $this->coll->getValues();
}
@@ -474,6 +488,7 @@ public function isEmpty()
public function getIterator()
{
$this->initialize();
+
return $this->coll->getIterator();
}
@@ -483,6 +498,7 @@ public function getIterator()
public function map(Closure $func)
{
$this->initialize();
+
return $this->coll->map($func);
}
@@ -492,6 +508,7 @@ public function map(Closure $func)
public function filter(Closure $p)
{
$this->initialize();
+
return $this->coll->filter($p);
}
@@ -501,6 +518,7 @@ public function filter(Closure $p)
public function forAll(Closure $p)
{
$this->initialize();
+
return $this->coll->forAll($p);
}
@@ -510,6 +528,7 @@ public function forAll(Closure $p)
public function partition(Closure $p)
{
$this->initialize();
+
return $this->coll->partition($p);
}
@@ -519,6 +538,7 @@ public function partition(Closure $p)
public function toArray()
{
$this->initialize();
+
return $this->coll->toArray();
}
@@ -562,6 +582,7 @@ public function clear()
public function slice($offset, $length = null)
{
$this->initialize();
+
return $this->coll->slice($offset, $length);
}
@@ -585,6 +606,7 @@ public function __sleep()
public function offsetExists($offset)
{
$this->initialize();
+
return $this->coll->offsetExists($offset);
}
@@ -594,6 +616,7 @@ public function offsetExists($offset)
public function offsetGet($offset)
{
$this->initialize();
+
return $this->coll->offsetGet($offset);
}
@@ -763,11 +786,7 @@ private function isOrphanRemovalEnabled()
return true;
}
- if (isset($this->mapping['reference']) && $this->mapping['isOwningSide'] && $this->mapping['orphanRemoval']) {
- return true;
- }
-
- return false;
+ return isset($this->mapping['reference']) && $this->mapping['isOwningSide'] && $this->mapping['orphanRemoval'];
}
/**
diff --git a/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php b/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
index 6b1eca0c5d..e554e59e43 100644
--- a/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
+++ b/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
@@ -423,6 +423,7 @@ private function getPathAndParent(PersistentCollectionInterface $coll) : array
if ($propertyPath) {
$path = $propertyPath . '.' . $path;
}
+
return [$path, $parent];
}
diff --git a/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php b/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
index f2c0b05c52..d0b2b58149 100644
--- a/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
+++ b/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
@@ -331,6 +331,7 @@ private function executeUpsert(object $document, array $options) : void
try {
assert($this->collection instanceof Collection);
$this->collection->updateOne($criteria, $data, $options);
+
return;
} catch (WriteException $e) {
if (empty($retry) || strpos($e->getMessage(), 'Mod on _id not allowed') === false) {
@@ -399,7 +400,9 @@ public function update(object $document, array $options = []) : void
if (($this->class->isVersioned || $this->class->isLockable) && $result->getModifiedCount() !== 1) {
throw LockException::lockFailed($document);
- } elseif ($this->class->isVersioned) {
+ }
+
+ if ($this->class->isVersioned) {
$this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion);
}
}
@@ -524,6 +527,7 @@ public function loadAll(array $criteria = [], ?array $sort = null, ?int $limit =
assert($this->collection instanceof Collection);
$baseCursor = $this->collection->find($criteria, $options);
+
return $this->wrapCursor($baseCursor);
}
@@ -580,6 +584,7 @@ public function exists(object $document) : bool
{
$id = $this->class->getIdentifierObject($document);
assert($this->collection instanceof Collection);
+
return (bool) $this->collection->findOne(['_id' => $id], ['_id']);
}
@@ -877,7 +882,6 @@ private function getSortDirection($sort)
switch (strtolower((string) $sort)) {
case 'desc':
return -1;
-
case 'asc':
return 1;
}
@@ -1382,6 +1386,7 @@ private function getQueryForDocument(object $document) : array
$id = $this->class->getDatabaseIdentifierValue($id);
$shardKeyQueryPart = $this->getShardKeyQuery($document);
+
return array_merge(['_id' => $id], $shardKeyQueryPart);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php b/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php
index 61a52aaf0b..47ec3f2e2b 100644
--- a/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php
+++ b/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php
@@ -220,6 +220,7 @@ public function prepareUpdateData($document)
}
// @ReferenceMany is handled by CollectionPersister
}
+
return $updateData;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/Builder.php b/lib/Doctrine/ODM/MongoDB/Query/Builder.php
index bfe060ab70..4f7fb94ce7 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/Builder.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/Builder.php
@@ -139,6 +139,7 @@ public function __clone()
public function addAnd($expression, ...$expressions) : self
{
$this->expr->addAnd(...func_get_args());
+
return $this;
}
@@ -156,6 +157,7 @@ public function addAnd($expression, ...$expressions) : self
public function addNor($expression, ...$expressions) : self
{
$this->expr->addNor(...func_get_args());
+
return $this;
}
@@ -173,6 +175,7 @@ public function addNor($expression, ...$expressions) : self
public function addOr($expression, ...$expressions) : self
{
$this->expr->addOr(...func_get_args());
+
return $this;
}
@@ -196,6 +199,7 @@ public function addOr($expression, ...$expressions) : self
public function addToSet($valueOrExpression) : self
{
$this->expr->addToSet($valueOrExpression);
+
return $this;
}
@@ -208,6 +212,7 @@ public function addToSet($valueOrExpression) : self
public function all(array $values) : self
{
$this->expr->all($values);
+
return $this;
}
@@ -222,6 +227,7 @@ public function all(array $values) : self
public function bitAnd(int $value) : self
{
$this->expr->bitAnd($value);
+
return $this;
}
@@ -234,6 +240,7 @@ public function bitAnd(int $value) : self
public function bitOr(int $value) : self
{
$this->expr->bitOr($value);
+
return $this;
}
@@ -249,6 +256,7 @@ public function bitOr(int $value) : self
public function bitsAllClear($value) : self
{
$this->expr->bitsAllClear($value);
+
return $this;
}
@@ -264,6 +272,7 @@ public function bitsAllClear($value) : self
public function bitsAllSet($value) : self
{
$this->expr->bitsAllSet($value);
+
return $this;
}
@@ -279,6 +288,7 @@ public function bitsAllSet($value) : self
public function bitsAnyClear($value) : self
{
$this->expr->bitsAnyClear($value);
+
return $this;
}
@@ -294,6 +304,7 @@ public function bitsAnyClear($value) : self
public function bitsAnySet($value) : self
{
$this->expr->bitsAnySet($value);
+
return $this;
}
@@ -306,6 +317,7 @@ public function bitsAnySet($value) : self
public function bitXor(int $value) : self
{
$this->expr->bitXor($value);
+
return $this;
}
@@ -323,6 +335,7 @@ public function bitXor(int $value) : self
public function caseSensitive(bool $caseSensitive) : self
{
$this->expr->caseSensitive($caseSensitive);
+
return $this;
}
@@ -335,6 +348,7 @@ public function caseSensitive(bool $caseSensitive) : self
public function comment(string $comment) : self
{
$this->expr->comment($comment);
+
return $this;
}
@@ -344,6 +358,7 @@ public function comment(string $comment) : self
public function count() : self
{
$this->query['type'] = Query::TYPE_COUNT;
+
return $this;
}
@@ -356,6 +371,7 @@ public function count() : self
public function currentDate(string $type = 'date') : self
{
$this->expr->currentDate($type);
+
return $this;
}
@@ -387,6 +403,7 @@ public function debug(?string $name = null)
public function diacriticSensitive(bool $diacriticSensitive) : self
{
$this->expr->diacriticSensitive($diacriticSensitive);
+
return $this;
}
@@ -399,6 +416,7 @@ public function distinct(string $field) : self
{
$this->query['type'] = Query::TYPE_DISTINCT;
$this->query['distinct'] = $field;
+
return $this;
}
@@ -415,6 +433,7 @@ public function distinct(string $field) : self
public function elemMatch($expression) : self
{
$this->expr->elemMatch($expression);
+
return $this;
}
@@ -428,6 +447,7 @@ public function elemMatch($expression) : self
public function equals($value) : self
{
$this->expr->equals($value);
+
return $this;
}
@@ -463,6 +483,7 @@ public function exclude($fieldName = null) : self
public function exists(bool $bool) : self
{
$this->expr->exists($bool);
+
return $this;
}
@@ -529,6 +550,7 @@ public function findAndUpdate(?string $documentName = null) : self
public function geoIntersects($geometry) : self
{
$this->expr->geoIntersects($geometry);
+
return $this;
}
@@ -546,6 +568,7 @@ public function geoIntersects($geometry) : self
public function geoWithin($geometry) : self
{
$this->expr->geoWithin($geometry);
+
return $this;
}
@@ -564,6 +587,7 @@ public function geoWithin($geometry) : self
public function geoWithinBox(float $x1, float $y1, float $x2, float $y2) : self
{
$this->expr->geoWithinBox($x1, $y1, $x2, $y2);
+
return $this;
}
@@ -579,6 +603,7 @@ public function geoWithinBox(float $x1, float $y1, float $x2, float $y2) : self
public function geoWithinCenter(float $x, float $y, float $radius) : self
{
$this->expr->geoWithinCenter($x, $y, $radius);
+
return $this;
}
@@ -593,6 +618,7 @@ public function geoWithinCenter(float $x, float $y, float $radius) : self
public function geoWithinCenterSphere(float $x, float $y, float $radius) : self
{
$this->expr->geoWithinCenterSphere($x, $y, $radius);
+
return $this;
}
@@ -618,6 +644,7 @@ public function geoWithinCenterSphere(float $x, float $y, float $radius) : self
public function geoWithinPolygon($point1, $point2, $point3, ...$points) : self
{
$this->expr->geoWithinPolygon(...func_get_args());
+
return $this;
}
@@ -719,6 +746,7 @@ public function getType() : int
public function gt($value) : self
{
$this->expr->gt($value);
+
return $this;
}
@@ -733,6 +761,7 @@ public function gt($value) : self
public function gte($value) : self
{
$this->expr->gte($value);
+
return $this;
}
@@ -744,12 +773,14 @@ public function gte($value) : self
public function hint($index) : self
{
$this->query['hint'] = $index;
+
return $this;
}
public function hydrate(bool $bool = true) : self
{
$this->hydrate = $bool;
+
return $this;
}
@@ -759,6 +790,7 @@ public function hydrate(bool $bool = true) : self
public function immortal(bool $bool = true) : self
{
$this->query['immortal'] = $bool;
+
return $this;
}
@@ -771,6 +803,7 @@ public function immortal(bool $bool = true) : self
public function in(array $values) : self
{
$this->expr->in($values);
+
return $this;
}
@@ -787,12 +820,14 @@ public function in(array $values) : self
public function inc($value) : self
{
$this->expr->inc($value);
+
return $this;
}
public function includesReferenceTo(object $document) : self
{
$this->expr->includesReferenceTo($document);
+
return $this;
}
@@ -815,6 +850,7 @@ public function insert(?string $documentName = null) : self
public function language(string $language) : self
{
$this->expr->language($language);
+
return $this;
}
@@ -828,6 +864,7 @@ public function language(string $language) : self
public function limit(int $limit) : self
{
$this->query['limit'] = $limit;
+
return $this;
}
@@ -842,6 +879,7 @@ public function limit(int $limit) : self
public function lt($value) : self
{
$this->expr->lt($value);
+
return $this;
}
@@ -856,6 +894,7 @@ public function lt($value) : self
public function lte($value) : self
{
$this->expr->lte($value);
+
return $this;
}
@@ -870,6 +909,7 @@ public function lte($value) : self
public function max($value) : self
{
$this->expr->max($value);
+
return $this;
}
@@ -879,6 +919,7 @@ public function max($value) : self
public function maxTimeMS(int $ms) : self
{
$this->query['maxTimeMS'] = $ms;
+
return $this;
}
@@ -893,6 +934,7 @@ public function maxTimeMS(int $ms) : self
public function min($value) : self
{
$this->expr->min($value);
+
return $this;
}
@@ -908,6 +950,7 @@ public function min($value) : self
public function mod($divisor, $remainder = 0) : self
{
$this->expr->mod($divisor, $remainder);
+
return $this;
}
@@ -924,6 +967,7 @@ public function mod($divisor, $remainder = 0) : self
public function mul($value) : self
{
$this->expr->mul($value);
+
return $this;
}
@@ -943,6 +987,7 @@ public function mul($value) : self
public function near($x, $y = null) : self
{
$this->expr->near($x, $y);
+
return $this;
}
@@ -962,6 +1007,7 @@ public function near($x, $y = null) : self
public function nearSphere($x, $y = null) : self
{
$this->expr->nearSphere($x, $y);
+
return $this;
}
@@ -978,6 +1024,7 @@ public function nearSphere($x, $y = null) : self
public function not($expression) : self
{
$this->expr->not($expression);
+
return $this;
}
@@ -992,6 +1039,7 @@ public function not($expression) : self
public function notEqual($value) : self
{
$this->expr->notEqual($value);
+
return $this;
}
@@ -1006,6 +1054,7 @@ public function notEqual($value) : self
public function notIn(array $values) : self
{
$this->expr->notIn($values);
+
return $this;
}
@@ -1018,6 +1067,7 @@ public function notIn(array $values) : self
public function popFirst() : self
{
$this->expr->popFirst();
+
return $this;
}
@@ -1030,6 +1080,7 @@ public function popFirst() : self
public function popLast() : self
{
$this->expr->popLast();
+
return $this;
}
@@ -1064,6 +1115,7 @@ public function prime($primer = true) : self
}
$this->primers[$this->currentField] = $primer;
+
return $this;
}
@@ -1079,6 +1131,7 @@ public function prime($primer = true) : self
public function pull($valueOrExpression) : self
{
$this->expr->pull($valueOrExpression);
+
return $this;
}
@@ -1092,6 +1145,7 @@ public function pull($valueOrExpression) : self
public function pullAll(array $values) : self
{
$this->expr->pullAll($values);
+
return $this;
}
@@ -1117,6 +1171,7 @@ public function pullAll(array $values) : self
public function push($valueOrExpression) : self
{
$this->expr->push($valueOrExpression);
+
return $this;
}
@@ -1134,24 +1189,28 @@ public function push($valueOrExpression) : self
public function range($start, $end) : self
{
$this->expr->range($start, $end);
+
return $this;
}
public function readOnly(bool $bool = true) : self
{
$this->readOnly = $bool;
+
return $this;
}
public function references(object $document) : self
{
$this->expr->references($document);
+
return $this;
}
public function refresh(bool $bool = true) : self
{
$this->refresh = $bool;
+
return $this;
}
@@ -1172,6 +1231,7 @@ public function remove(?string $documentName = null) : self
public function rename(string $name) : self
{
$this->expr->rename($name);
+
return $this;
}
@@ -1217,6 +1277,7 @@ public function selectElemMatch(string $fieldName, $expression) : self
$expression = $expression->getQuery();
}
$this->query['select'][$fieldName] = ['$elemMatch' => $expression];
+
return $this;
}
@@ -1228,6 +1289,7 @@ public function selectElemMatch(string $fieldName, $expression) : self
public function selectMeta(string $fieldName, string $metaDataKeyword) : self
{
$this->query['select'][$fieldName] = ['$meta' => $metaDataKeyword];
+
return $this;
}
@@ -1247,6 +1309,7 @@ public function selectSlice(string $fieldName, int $countOrSkip, ?int $limit = n
$slice = [$slice, $limit];
}
$this->query['select'][$fieldName] = ['$slice' => $slice];
+
return $this;
}
@@ -1265,6 +1328,7 @@ public function selectSlice(string $fieldName, int $countOrSkip, ?int $limit = n
public function set($value, bool $atomic = true) : self
{
$this->expr->set($value, $atomic && $this->query['type'] !== Query::TYPE_INSERT);
+
return $this;
}
@@ -1276,6 +1340,7 @@ public function set($value, bool $atomic = true) : self
public function setNewObj(array $newObj) : self
{
$this->expr->setNewObj($newObj);
+
return $this;
}
@@ -1296,6 +1361,7 @@ public function setNewObj(array $newObj) : self
public function setOnInsert($value) : self
{
$this->expr->setOnInsert($value);
+
return $this;
}
@@ -1309,6 +1375,7 @@ public function setOnInsert($value) : self
public function setReadPreference(ReadPreference $readPreference) : self
{
$this->query['readPreference'] = $readPreference;
+
return $this;
}
@@ -1320,6 +1387,7 @@ public function setReadPreference(ReadPreference $readPreference) : self
public function setQueryArray(array $query) : self
{
$this->expr->setQuery($query);
+
return $this;
}
@@ -1332,6 +1400,7 @@ public function setQueryArray(array $query) : self
public function size(int $size) : self
{
$this->expr->size($size);
+
return $this;
}
@@ -1346,6 +1415,7 @@ public function size(int $size) : self
public function skip(int $skip) : self
{
$this->query['skip'] = $skip;
+
return $this;
}
@@ -1355,6 +1425,7 @@ public function skip(int $skip) : self
public function snapshot(bool $bool = true) : self
{
$this->query['snapshot'] = $bool;
+
return $this;
}
@@ -1421,6 +1492,7 @@ public function sortMeta(string $fieldName, string $metaDataKeyword) : self
public function text(string $search) : self
{
$this->expr->text($search);
+
return $this;
}
@@ -1435,6 +1507,7 @@ public function text(string $search) : self
public function type($type) : self
{
$this->expr->type($type);
+
return $this;
}
@@ -1449,6 +1522,7 @@ public function type($type) : self
public function unsetField() : self
{
$this->expr->unsetField();
+
return $this;
}
@@ -1476,6 +1550,7 @@ public function updateMany(?string $documentName = null) : self
public function upsert(bool $bool = true) : self
{
$this->query['upsert'] = $bool;
+
return $this;
}
@@ -1490,6 +1565,7 @@ public function upsert(bool $bool = true) : self
public function where($javascript) : self
{
$this->expr->where($javascript);
+
return $this;
}
@@ -1513,6 +1589,7 @@ private function getDiscriminatorValues($classNames) : array
if (count($collections) > 1) {
throw new InvalidArgumentException('Documents involved are not all mapped to the same database collection.');
}
+
return $discriminatorValues;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/CriteriaMerger.php b/lib/Doctrine/ODM/MongoDB/Query/CriteriaMerger.php
index 9b575158ee..1eda003495 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/CriteriaMerger.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/CriteriaMerger.php
@@ -31,10 +31,8 @@ public function merge(...$criterias) : array
switch (count($nonEmptyCriterias)) {
case 0:
return [];
-
case 1:
return $nonEmptyCriterias[0];
-
default:
return ['$and' => $nonEmptyCriterias];
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/Expr.php b/lib/Doctrine/ODM/MongoDB/Query/Expr.php
index 48ddfd7bfb..92effd32a9 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/Expr.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/Expr.php
@@ -180,6 +180,7 @@ public function addToSet($valueOrExpression) : self
$this->requiresCurrentField();
$this->newObj['$addToSet'][$this->currentField] = $valueOrExpression;
+
return $this;
}
@@ -203,6 +204,7 @@ protected function bit(string $operator, int $value) : self
{
$this->requiresCurrentField();
$this->newObj['$bit'][$this->currentField][$operator] = $value;
+
return $this;
}
@@ -240,6 +242,7 @@ public function bitOr(int $value) : self
public function bitsAllClear($value) : self
{
$this->requiresCurrentField();
+
return $this->operator('$bitsAllClear', $value);
}
@@ -255,6 +258,7 @@ public function bitsAllClear($value) : self
public function bitsAllSet($value) : self
{
$this->requiresCurrentField();
+
return $this->operator('$bitsAllSet', $value);
}
@@ -270,6 +274,7 @@ public function bitsAllSet($value) : self
public function bitsAnyClear($value) : self
{
$this->requiresCurrentField();
+
return $this->operator('$bitsAnyClear', $value);
}
@@ -285,6 +290,7 @@ public function bitsAnyClear($value) : self
public function bitsAnySet($value) : self
{
$this->requiresCurrentField();
+
return $this->operator('$bitsAnySet', $value);
}
@@ -335,6 +341,7 @@ public function caseSensitive(bool $caseSensitive) : self
public function comment(string $comment) : self
{
$this->query['$comment'] = $comment;
+
return $this;
}
@@ -354,6 +361,7 @@ public function currentDate(string $type = 'date') : self
$this->requiresCurrentField();
$this->newObj['$currentDate'][$this->currentField]['$type'] = $type;
+
return $this;
}
@@ -422,6 +430,7 @@ public function equals($value) : self
} else {
$this->query = $value;
}
+
return $this;
}
@@ -444,6 +453,7 @@ public function exists(bool $bool) : self
public function field(string $field) : self
{
$this->currentField = $field;
+
return $this;
}
@@ -644,6 +654,7 @@ public function inc($value) : self
{
$this->requiresCurrentField();
$this->newObj['$inc'][$this->currentField] = $value;
+
return $this;
}
@@ -661,9 +672,8 @@ public function includesReferenceTo(object $document) : self
switch ($storeAs) {
case ClassMetadata::REFERENCE_STORE_AS_ID:
$this->query[$mapping['name']] = $reference;
- return $this;
- break;
+ return $this;
case ClassMetadata::REFERENCE_STORE_AS_REF:
$keys = ['id' => true];
break;
@@ -751,6 +761,7 @@ public function max($value) : self
{
$this->requiresCurrentField();
$this->newObj['$max'][$this->currentField] = $value;
+
return $this;
}
@@ -766,6 +777,7 @@ public function min($value) : self
{
$this->requiresCurrentField();
$this->newObj['$min'][$this->currentField] = $value;
+
return $this;
}
@@ -797,6 +809,7 @@ public function mul($value) : self
{
$this->requiresCurrentField();
$this->newObj['$mul'][$this->currentField] = $value;
+
return $this;
}
@@ -906,6 +919,7 @@ public function operator(string $operator, $value) : self
} else {
$this->query[$operator] = $value;
}
+
return $this;
}
@@ -919,6 +933,7 @@ public function popFirst() : self
{
$this->requiresCurrentField();
$this->newObj['$pop'][$this->currentField] = -1;
+
return $this;
}
@@ -932,6 +947,7 @@ public function popLast() : self
{
$this->requiresCurrentField();
$this->newObj['$pop'][$this->currentField] = 1;
+
return $this;
}
@@ -965,6 +981,7 @@ public function pull($valueOrExpression) : self
$this->requiresCurrentField();
$this->newObj['$pull'][$this->currentField] = $valueOrExpression;
+
return $this;
}
@@ -979,6 +996,7 @@ public function pullAll(array $values) : self
{
$this->requiresCurrentField();
$this->newObj['$pullAll'][$this->currentField] = $values;
+
return $this;
}
@@ -1012,6 +1030,7 @@ public function push($valueOrExpression) : self
$this->requiresCurrentField();
$this->newObj['$push'][$this->currentField] = $valueOrExpression;
+
return $this;
}
@@ -1045,9 +1064,8 @@ public function references(object $document) : self
switch ($storeAs) {
case ClassMetadata::REFERENCE_STORE_AS_ID:
$this->query[$mapping['name']] = $reference;
- return $this;
- break;
+ return $this;
case ClassMetadata::REFERENCE_STORE_AS_REF:
$keys = ['id' => true];
break;
@@ -1086,6 +1104,7 @@ public function rename(string $name) : self
{
$this->requiresCurrentField();
$this->newObj['$rename'][$this->currentField] = $name;
+
return $this;
}
@@ -1108,11 +1127,13 @@ public function set($value, bool $atomic = true) : self
if ($atomic) {
$this->newObj['$set'][$this->currentField] = $value;
+
return $this;
}
if (strpos($this->currentField, '.') === false) {
$this->newObj[$this->currentField] = $value;
+
return $this;
}
@@ -1142,6 +1163,7 @@ public function setClassMetadata(ClassMetadata $class) : void
public function setNewObj(array $newObj) : self
{
$this->newObj = $newObj;
+
return $this;
}
@@ -1175,6 +1197,7 @@ public function setOnInsert($value) : self
public function setQuery(array $query) : self
{
$this->query = $query;
+
return $this;
}
@@ -1238,6 +1261,7 @@ public function sort($fieldName, $order = null) : self
public function text(string $search) : self
{
$this->query['$text'] = ['$search' => $search];
+
return $this;
}
@@ -1266,6 +1290,7 @@ public function unsetField() : self
{
$this->requiresCurrentField();
$this->newObj['$unset'][$this->currentField] = 1;
+
return $this;
}
@@ -1280,6 +1305,7 @@ public function unsetField() : self
public function where($javascript) : self
{
$this->query['$where'] = $javascript;
+
return $this;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/Filter/BsonFilter.php b/lib/Doctrine/ODM/MongoDB/Query/Filter/BsonFilter.php
index bf83888496..62094cd968 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/Filter/BsonFilter.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/Filter/BsonFilter.php
@@ -39,6 +39,7 @@ final public function __construct(DocumentManager $dm)
final public function setParameter(string $name, $value) : self
{
$this->parameters[$name] = $value;
+
return $this;
}
@@ -56,6 +57,7 @@ final public function getParameter(string $name)
if (! array_key_exists($name, $this->parameters)) {
throw new InvalidArgumentException("Filter parameter '" . $name . "' is not set.");
}
+
return $this->parameters[$name];
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php b/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php
index 5572fd2545..ff86ef34b5 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php
@@ -114,6 +114,7 @@ public function getFilter(string $name) : BsonFilter
if (! $this->isEnabled($name)) {
throw new InvalidArgumentException("Filter '" . $name . "' is not enabled.");
}
+
return $this->enabledFilters[$name];
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/Query.php b/lib/Doctrine/ODM/MongoDB/Query/Query.php
index 17243cb528..626ee62dac 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/Query.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/Query.php
@@ -273,6 +273,7 @@ public function getSingleResult()
{
$clonedQuery = clone $this;
$clonedQuery->query['limit'] = 1;
+
return $clonedQuery->getIterator()->current() ?: null;
}
@@ -415,7 +416,6 @@ private function runQuery()
);
return $this->makeIterator($cursor);
-
case self::TYPE_FIND_AND_UPDATE:
$queryOptions = $this->getQueryOptions('select', 'sort', 'upsert');
$queryOptions = $this->renameQueryOptions($queryOptions, ['select' => 'projection']);
@@ -428,7 +428,6 @@ private function runQuery()
$this->query['newObj'],
array_merge($options, $queryOptions)
);
-
case self::TYPE_FIND_AND_REMOVE:
$queryOptions = $this->getQueryOptions('select', 'sort');
$queryOptions = $this->renameQueryOptions($queryOptions, ['select' => 'projection']);
@@ -437,10 +436,8 @@ private function runQuery()
$this->query['query'],
array_merge($options, $queryOptions)
);
-
case self::TYPE_INSERT:
return $this->collection->insertOne($this->query['newObj'], $options);
-
case self::TYPE_UPDATE:
$multiple = $this->query['multiple'] ?? false;
@@ -467,10 +464,8 @@ private function runQuery()
$this->query['newObj'],
array_merge($options, $this->getQueryOptions('upsert'))
);
-
case self::TYPE_REMOVE:
return $this->collection->deleteMany($this->query['query'], $options);
-
case self::TYPE_DISTINCT:
$collection = $this->collection;
$query = $this->query;
@@ -480,7 +475,6 @@ private function runQuery()
$query['query'],
array_merge($options, $this->getQueryOptions('readPreference'))
);
-
case self::TYPE_COUNT:
$collection = $this->collection;
$query = $this->query;
@@ -489,7 +483,6 @@ private function runQuery()
$query['query'],
array_merge($options, $this->getQueryOptions('hint', 'limit', 'skip', 'readPreference'))
);
-
default:
throw new InvalidArgumentException('Invalid query type: ' . $this->query['type']);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php b/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php
index 0b72cb185b..ee4f8cbd0d 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php
@@ -75,14 +75,12 @@ public function walkComparison(Comparison $comparison) : Expr
return $this->builder->expr()
->field($comparison->getField())
->{$method}($this->walkValue($comparison->getValue()));
-
case Comparison::CONTAINS:
$value = $this->walkValue($comparison->getValue());
return $this->builder->expr()
->field($comparison->getField())
->equals(new Regex($value, ''));
-
default:
throw new RuntimeException('Unknown comparison operator: ' . $comparison->getOperator());
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php b/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php
index 6cacbdceb3..c0bcf741f4 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php
@@ -86,7 +86,6 @@ public function __construct(DocumentManager $dm, UnitOfWork $uow)
};
}
-
/**
* Prime references within a mapped field of one or more documents.
*
diff --git a/lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php b/lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php
index 684b35d48b..18627ec43f 100644
--- a/lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php
+++ b/lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php
@@ -45,8 +45,7 @@ class DocumentRepository implements ObjectRepository, Selectable
protected $class;
/**
- * Initializes this instance with the specified document manager, unit of work and
- * class metadata.
+ * Initializes this instance with the specified document manager, unit of work and class metadata.
*
* @param DocumentManager $dm The DocumentManager to use.
* @param UnitOfWork $uow The UnitOfWork to use.
@@ -220,6 +219,7 @@ public function matching(Criteria $criteria) : ArrayCollection
// @TODO: wrap around a specialized Collection for efficient count on large collections
$iterator = $queryBuilder->getQuery()->execute();
assert($iterator instanceof Iterator);
+
return new ArrayCollection($iterator->toArray());
}
diff --git a/lib/Doctrine/ODM/MongoDB/SchemaManager.php b/lib/Doctrine/ODM/MongoDB/SchemaManager.php
index 756a9ed2e4..cfa6375517 100644
--- a/lib/Doctrine/ODM/MongoDB/SchemaManager.php
+++ b/lib/Doctrine/ODM/MongoDB/SchemaManager.php
@@ -138,6 +138,7 @@ public function updateDocumentIndexes(string $documentName, ?int $maxTimeMs = nu
public function getDocumentIndexes(string $documentName) : array
{
$visited = [];
+
return $this->doGetDocumentIndexes($documentName, $visited);
}
@@ -436,7 +437,7 @@ private function isEquivalentIndexKeys(IndexInfo $mongoIndex, array $documentInd
/* Avoid a strict equality check here. The numeric type returned by
* MongoDB may differ from the document index without implying that the
* indexes themselves are inequivalent. */
- // phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator
+ // phpcs:disable SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator
return $mongoIndexKeys == $documentIndexKeys;
}
@@ -546,7 +547,7 @@ private function isEquivalentTextIndexWeights(IndexInfo $mongoIndex, array $docu
/* Avoid a strict equality check here. The numeric type returned by
* MongoDB may differ from the document index without implying that the
* indexes themselves are inequivalent. */
- // phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator
+ // phpcs:disable SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator
return $mongoIndexWeights == $documentIndexWeights;
}
@@ -693,6 +694,7 @@ private function collectionIsSharded(string $documentName) : bool
}
$stats = $database->command(['collstats' => $class->getCollection()])->toArray()[0];
+
return (bool) ($stats['sharded'] ?? false);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateHydratorsCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateHydratorsCommand.php
index b906f5362e..5ba0cea682 100644
--- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateHydratorsCommand.php
+++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateHydratorsCommand.php
@@ -82,7 +82,9 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
throw new InvalidArgumentException(
sprintf("Hydrators destination directory '%s' does not exist.", $destPath)
);
- } elseif (! is_writable($destPath)) {
+ }
+
+ if (! is_writable($destPath)) {
throw new InvalidArgumentException(
sprintf("Hydrators destination directory '%s' does not have write permissions.", $destPath)
);
diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GeneratePersistentCollectionsCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GeneratePersistentCollectionsCommand.php
index 3d73c4f61d..f0a0154ca1 100644
--- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GeneratePersistentCollectionsCommand.php
+++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GeneratePersistentCollectionsCommand.php
@@ -82,7 +82,9 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
throw new InvalidArgumentException(
sprintf("Persistent collections destination directory '%s' does not exist.", $destPath)
);
- } elseif (! is_writable($destPath)) {
+ }
+
+ if (! is_writable($destPath)) {
throw new InvalidArgumentException(
sprintf("Persistent collections destination directory '%s' does not have write permissions.", $destPath)
);
diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php
index 9739e80ea4..8e11a5a4a2 100644
--- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php
+++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommand.php
@@ -84,7 +84,9 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
throw new InvalidArgumentException(
sprintf("Proxies destination directory '%s' does not exist.", $destPath)
);
- } elseif (! is_writable($destPath)) {
+ }
+
+ if (! is_writable($destPath)) {
throw new InvalidArgumentException(
sprintf("Proxies destination directory '%s' does not have write permissions.", $destPath)
);
diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php
index 74db3904bd..64fd1f1f1d 100644
--- a/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php
+++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php
@@ -29,6 +29,7 @@ class MetadataFilter extends FilterIterator implements Countable
public static function filter(array $metadatas, $filter) : array
{
$metadatas = new MetadataFilter(new ArrayIterator($metadatas), $filter);
+
return iterator_to_array($metadatas);
}
@@ -58,6 +59,7 @@ public function accept() : bool
return true;
}
}
+
return false;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/CollectionType.php b/lib/Doctrine/ODM/MongoDB/Types/CollectionType.php
index f320f43149..cc589151c1 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/CollectionType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/CollectionType.php
@@ -18,6 +18,7 @@ public function convertToDatabaseValue($value)
if ($value !== null && ! is_array($value)) {
throw MongoDBException::invalidValueForType('Collection', ['array', 'null'], $value);
}
+
return $value !== null ? array_values($value) : null;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/DateType.php b/lib/Doctrine/ODM/MongoDB/Types/DateType.php
index 4654353ccb..1692062df1 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/DateType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/DateType.php
@@ -41,7 +41,9 @@ public static function getDateTime($value) : DateTimeInterface
if ($value instanceof DateTimeInterface) {
return $value;
- } elseif ($value instanceof UTCDateTime) {
+ }
+
+ if ($value instanceof UTCDateTime) {
$datetime = $value->toDateTime();
$datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
} elseif (is_numeric($value)) {
diff --git a/lib/Doctrine/ODM/MongoDB/Types/HashType.php b/lib/Doctrine/ODM/MongoDB/Types/HashType.php
index c76ff2f0c4..f82074ddf3 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/HashType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/HashType.php
@@ -17,6 +17,7 @@ public function convertToDatabaseValue($value)
if ($value !== null && ! is_array($value)) {
throw MongoDBException::invalidValueForType('Hash', ['array', 'null'], $value);
}
+
return $value !== null ? (object) $value : null;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/IdType.php b/lib/Doctrine/ODM/MongoDB/Types/IdType.php
index f0601f4f01..5db5ca11f9 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/IdType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/IdType.php
@@ -24,6 +24,7 @@ public function convertToDatabaseValue($value)
$value = new ObjectId();
}
}
+
return $value;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/KeyType.php b/lib/Doctrine/ODM/MongoDB/Types/KeyType.php
index 88a6a5dc82..b98b3c880d 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/KeyType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/KeyType.php
@@ -17,6 +17,7 @@ public function convertToDatabaseValue($value)
if ($value === null) {
return null;
}
+
return $value ? new MaxKey() : new MinKey();
}
@@ -25,6 +26,7 @@ public function convertToPHPValue($value)
if ($value === null) {
return null;
}
+
return $value instanceof MaxKey ? 1 : 0;
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/ObjectIdType.php b/lib/Doctrine/ODM/MongoDB/Types/ObjectIdType.php
index c3460a4c9a..784126ff11 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/ObjectIdType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/ObjectIdType.php
@@ -19,6 +19,7 @@ public function convertToDatabaseValue($value)
if (! $value instanceof ObjectId) {
$value = new ObjectId($value);
}
+
return $value;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/TimestampType.php b/lib/Doctrine/ODM/MongoDB/Types/TimestampType.php
index 659810704e..0c7bda046d 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/TimestampType.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/TimestampType.php
@@ -30,6 +30,7 @@ public function convertToPHPValue($value)
private function extractSeconds(Timestamp $timestamp) : int
{
$parts = explode(':', substr((string) $timestamp, 1, -1));
+
return (int) $parts[1];
}
}
diff --git a/lib/Doctrine/ODM/MongoDB/Types/Type.php b/lib/Doctrine/ODM/MongoDB/Types/Type.php
index ca826afa41..6a1714e25c 100644
--- a/lib/Doctrine/ODM/MongoDB/Types/Type.php
+++ b/lib/Doctrine/ODM/MongoDB/Types/Type.php
@@ -140,6 +140,7 @@ public static function getType(string $type) : Type
$className = self::$typesMap[$type];
self::$typeObjects[$type] = new $className();
}
+
return self::$typeObjects[$type];
}
@@ -167,6 +168,7 @@ public static function getTypeFromPHPVariable($variable) : ?Type
return self::getType('int');
}
}
+
return null;
}
@@ -176,6 +178,7 @@ public static function convertPHPToDatabaseValue($value)
if ($type !== null) {
return $type->convertToDatabaseValue($value);
}
+
return $value;
}
diff --git a/lib/Doctrine/ODM/MongoDB/UnitOfWork.php b/lib/Doctrine/ODM/MongoDB/UnitOfWork.php
index d11d86167f..86f48d1602 100644
--- a/lib/Doctrine/ODM/MongoDB/UnitOfWork.php
+++ b/lib/Doctrine/ODM/MongoDB/UnitOfWork.php
@@ -283,6 +283,7 @@ public function getPersistenceBuilder() : PersistenceBuilder
if (! $this->persistenceBuilder) {
$this->persistenceBuilder = new PersistenceBuilder($this->dm, $this);
}
+
return $this->persistenceBuilder;
}
@@ -322,6 +323,7 @@ public function getDocumentPersister(string $documentName) : Persisters\Document
$pb = $this->getPersistenceBuilder();
$this->persisters[$documentName] = new Persisters\DocumentPersister($pb, $this->dm, $this, $this->hydratorFactory, $class);
}
+
return $this->persisters[$documentName];
}
@@ -334,6 +336,7 @@ public function getCollectionPersister() : CollectionPersister
$pb = $this->getPersistenceBuilder();
$this->collectionPersister = new Persisters\CollectionPersister($this->dm, $pb, $this);
}
+
return $this->collectionPersister;
}
@@ -469,6 +472,7 @@ private function getClassesForCommitAction(array $documents, bool $includeEmbedd
$divided[$class->name][1][$oid] = $d;
}
}
+
return $divided;
}
@@ -563,6 +567,7 @@ public function getDocumentActualData(object $document) : array
$actualData[$name] = $value;
}
}
+
return $actualData;
}
@@ -1266,6 +1271,7 @@ public function isScheduledForUpdate(object $document) : bool
public function isScheduledForSynchronization(object $document) : bool
{
$class = $this->dm->getClassMetadata(get_class($document));
+
return isset($this->scheduledForSynchronization[$class->name][spl_object_hash($document)]);
}
@@ -1283,6 +1289,7 @@ public function scheduleForDelete(object $document) : void
$this->removeFromIdentityMap($document);
}
unset($this->documentInsertions[$oid]);
+
return; // document has not been persisted yet, so nothing more to do.
}
@@ -1320,6 +1327,7 @@ public function isScheduledForDelete(object $document) : bool
public function isDocumentScheduled(object $document) : bool
{
$oid = spl_object_hash($document);
+
return isset($this->documentInsertions[$oid]) ||
isset($this->documentUpserts[$oid]) ||
isset($this->documentUpdates[$oid]) ||
@@ -1436,6 +1444,7 @@ public function removeFromIdentityMap(object $document) : bool
if (isset($this->identityMap[$class->name][$id])) {
unset($this->identityMap[$class->name][$id]);
$this->documentStates[$oid] = self::STATE_DETACHED;
+
return true;
}
@@ -2008,6 +2017,7 @@ private function cascadeDetach(object $document, array &$visited) : void
}
}
}
+
/**
* Cascades a merge operation to associated documents.
*/
@@ -2258,8 +2268,10 @@ private function fixPersistentCollectionOwnership(PersistentCollectionInterface
// @todo following line should be superfluous once collections are stored in change sets
$this->setOriginalDocumentProperty(spl_object_hash($document), $propName, $newValue);
}
+
return $newValue;
}
+
return $coll;
}
@@ -2540,6 +2552,7 @@ public function getOrCreateDocument(string $className, array $data, array &$hint
if (! empty($hints[Query::HINT_READ_ONLY])) {
$document = $class->newInstance();
$this->hydratorFactory->hydrate($document, $data, $hints);
+
return $document;
}
@@ -2685,6 +2698,7 @@ public function size() : int
foreach ($this->identityMap as $documentSet) {
$count += count($documentSet);
}
+
return $count;
}
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 7e33ba2141..aa10e4eece 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -31,6 +31,7 @@
+
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php
index acafeded90..7458395013 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/AggregationOperatorsProviderTrait.php
@@ -616,7 +616,9 @@ protected function resolveArgs($args) : array
{
if (is_array($args)) {
return $args;
- } elseif ($args instanceof Closure) {
+ }
+
+ if ($args instanceof Closure) {
return $args($this->createExpr());
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php
index cebc90c418..6fbdab95ef 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleCallbacksTest.php
@@ -20,6 +20,7 @@ private function createUser($name = 'jon', $fullName = 'Jonathan H. Wage')
$user->profile->name = $fullName;
$this->dm->persist($user);
$this->dm->flush();
+
return $user;
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php
index 7432db6f05..78b6a63709 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/LifecycleListenersTest.php
@@ -31,6 +31,7 @@ private function getDocumentManager()
Events::postRemove,
];
$evm->addEventListener($events, $this->listener);
+
return $this->dm;
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php
index 941f393394..9526c6cbbc 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CollectionPersisterTest.php
@@ -118,7 +118,6 @@ public function testDeleteNestedEmbedManyAndNestedParent() : void
$this->assertFalse(isset($check['categories']), 'Test that the nested categories field was deleted');
}
-
public function testDeleteRows() : void
{
$user = $this->getTestUser('jwage');
@@ -226,6 +225,7 @@ private function getTestUser(string $username) : CollectionPersisterUser
$this->dm->persist($user);
$this->dm->flush();
+
return $user;
}
@@ -233,6 +233,7 @@ private function getCollectionPersister() : CollectionPersister
{
$uow = $this->dm->getUnitOfWork();
$pb = new PersistenceBuilder($this->dm, $uow);
+
return new CollectionPersister($this->dm, $pb, $uow);
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EcommerceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EcommerceTest.php
index 7d594a8a91..fcdf022ce7 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EcommerceTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EcommerceTest.php
@@ -90,6 +90,7 @@ protected function getProduct()
->getQuery()
->execute();
$products->valid() ?: $products->next();
+
return $products->current();
}
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FilterTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FilterTest.php
index 7b1765dc5e..2f2bf3a1ae 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FilterTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FilterTest.php
@@ -104,6 +104,7 @@ protected function getUsernamesWithFind()
}
sort($usernames);
+
return $usernames;
}
@@ -129,6 +130,7 @@ protected function getUsernamesWithFindBy()
$usernames[] = $user->getUsername();
}
sort($usernames);
+
return $usernames;
}
@@ -174,6 +176,7 @@ protected function getUsernamesWithFindAll()
$usernames[] = $user->getUsername();
}
sort($usernames);
+
return $usernames;
}
@@ -203,6 +206,7 @@ protected function getGroupsByReference()
}
}
sort($groupnames);
+
return $groupnames;
}
@@ -265,6 +269,7 @@ protected function getUsernamesWithDocumentManager()
}
sort($usernames);
+
return $usernames;
}
@@ -292,6 +297,7 @@ protected function getUsernamesWithQuery()
$usernames[] = $user->getUsername();
}
sort($usernames);
+
return $usernames;
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php
index c31740fb12..11de6d914a 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php
@@ -903,6 +903,7 @@ class ParentAssociationTestA
public $name;
/** @ODM\EmbedOne */
public $child;
+
public function __construct($name)
{
$this->name = $name;
@@ -916,6 +917,7 @@ class ParentAssociationTestB
public $name;
/** @ODM\EmbedMany */
public $children = [];
+
public function __construct($name)
{
$this->name = $name;
@@ -927,6 +929,7 @@ class ParentAssociationTestC
{
/** @ODM\Field(type="string") */
public $name;
+
public function __construct($name)
{
$this->name = $name;
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php
index 86b2afb7dd..3a6012d397 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Iterator/CachingIteratorTest.php
@@ -108,7 +108,6 @@ public function testToArrayAfterPartialIteration()
$this->assertSame([1, 2, 3], $iterator->toArray());
}
-
private function getTraversable($items)
{
foreach ($items as $item) {
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php
index 58266973d4..08a3fc6a72 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php
@@ -58,7 +58,8 @@ public function testMemoryUsage()
private function formatMemory($size)
{
- $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
+ $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
+
return round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php
index 6ecf3ba727..db8699ceff 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedDocumentsTest.php
@@ -180,6 +180,7 @@ public function getChild($name)
return $child;
}
}
+
return null;
}
@@ -189,6 +190,7 @@ public function addChild($child)
$child = new Hierarchy($child);
}
$this->children[] = $child;
+
return $child;
}
@@ -233,6 +235,7 @@ public function getChild($name)
return $child;
}
}
+
return null;
}
@@ -242,6 +245,7 @@ public function addChild($child)
$child = new ChildCategory($child);
}
$this->children[] = $child;
+
return $child;
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php
index 369bdd9648..f5236514a0 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1017Test.php
@@ -35,6 +35,7 @@ public function testSPLObjectHashCollisionOnReplacingEmbeddedDoc()
$this->uow->getDocumentState($owner->embedded),
'A newly created object should be treated as NEW by UOW'
);
+
return;
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php
index 110bc89705..ceea9a72e3 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH453Test.php
@@ -182,18 +182,22 @@ public function testReferenceMany()
$colPush->forAll(static function ($k, $v) use ($dm) {
$dm->persist($v);
+
return true;
});
$colSet->forAll(static function ($k, $v) use ($dm) {
$dm->persist($v);
+
return true;
});
$colSetArray->forAll(static function ($k, $v) use ($dm) {
$dm->persist($v);
+
return true;
});
$colAddToSet->forAll(static function ($k, $v) use ($dm) {
$dm->persist($v);
+
return true;
});
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php
index ad5e9342dc..9adcf2f913 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH921Test.php
@@ -74,22 +74,27 @@ public function __construct()
{
$this->posts = new ArrayCollection();
}
+
public function getId()
{
return $this->id;
}
+
public function getName()
{
return $this->name;
}
+
public function setName($name)
{
$this->name = $name;
}
+
public function addPost(GH921Post $post)
{
$this->posts[] = $post;
}
+
public function getPosts()
{
return $this->posts;
@@ -109,10 +114,12 @@ public function getId()
{
return $this->id;
}
+
public function getName()
{
return $this->name;
}
+
public function setName($name)
{
$this->name = $name;
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php
index 8f5d99a88b..e9cf3acf3d 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM45Test.php
@@ -37,10 +37,12 @@ public function getId()
{
return $this->id;
}
+
public function getB()
{
return $this->b;
}
+
public function setB($b)
{
$this->b = $b;
@@ -57,6 +59,7 @@ public function setVal($val)
{
$this->val = $val;
}
+
public function getVal()
{
return $this->val;
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php
index 23e804ebd2..308443ce73 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM47Test.php
@@ -37,6 +37,7 @@ public function renameC($c)
{
$this->b = $c;
}
+
public function getId()
{
return $this->id;
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php
index ff26ed6ba0..16594735ca 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM83Test.php
@@ -20,6 +20,7 @@ private function getDocumentManager()
Events::postUpdate,
];
$evm->addEventListener($events, $this->listener);
+
return $this->dm;
}
@@ -55,6 +56,7 @@ public function testDocumentWithEmbeddedDocumentNotUpdated()
class MODM83EventListener
{
public $called = [];
+
public function __call($method, $args)
{
$document = $args[0]->getDocument();
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php
index 1615b35b72..50fd517a82 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM90Test.php
@@ -20,6 +20,7 @@ private function getDocumentManager()
Events::postUpdate,
];
$evm->addEventListener($events, $this->listener);
+
return $this->dm;
}
@@ -71,6 +72,7 @@ public function testDiscriminatorFieldValuePresentIfRealProperty()
class MODM90EventListener
{
public $called = [];
+
public function __call($method, $args)
{
$document = $args[0]->getDocument();
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php
index 8f4b1b5c13..401507196f 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM91Test.php
@@ -20,6 +20,7 @@ private function getDocumentManager()
Events::postUpdate,
];
$evm->addEventListener($events, $this->listener);
+
return $this->dm;
}
@@ -47,6 +48,7 @@ public function testDocumentWithEmbeddedDocumentNotUpdated()
class MODM91EventListener
{
public $called = [];
+
public function __call($method, $args)
{
$document = $args[0]->getDocument();
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AnnotationDriverTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AnnotationDriverTest.php
index 873cba419e..6f37ef1db3 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AnnotationDriverTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AnnotationDriverTest.php
@@ -233,12 +233,14 @@ protected function _loadDriverForCMSDocuments()
{
$annotationDriver = $this->_loadDriver();
$annotationDriver->addPaths([__DIR__ . '/../../../../../Documents']);
+
return $annotationDriver;
}
protected function _loadDriver()
{
$reader = new AnnotationReader();
+
return new AnnotationDriver($reader);
}
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php
index b324e2885a..1b8b8078e0 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ShardKeyInheritanceMappingTest.php
@@ -21,7 +21,6 @@ public function setUp() : void
$this->factory->setConfiguration($this->dm->getConfiguration());
}
-
public function testShardKeyFromMappedSuperclass()
{
$class = $this->factory->getMetadataFor(ShardedSubclass::class);
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTest.php
index 66f71eb0ca..0fb44a22e1 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTest.php
@@ -86,5 +86,6 @@ protected function tearDown() : void
}
abstract protected function getFileExtension();
+
abstract protected function getDriver(array $paths = []);
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php
index b092715295..ca8f641cd5 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php
@@ -59,7 +59,8 @@ public function testMemoryUsage()
private function formatMemory($size)
{
- $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
+ $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
+
return round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
}
diff --git a/tests/Documents/BaseEmployee.php b/tests/Documents/BaseEmployee.php
index 80b953000c..19f01a5689 100644
--- a/tests/Documents/BaseEmployee.php
+++ b/tests/Documents/BaseEmployee.php
@@ -41,6 +41,7 @@ public function getId()
public function setId($val)
{
$this->id = $val;
+
return $this;
}
@@ -52,6 +53,7 @@ public function getChanges()
public function incrementChanges($num)
{
$this->changes += $num;
+
return $this;
}
@@ -63,6 +65,7 @@ public function getNotes()
public function addNote($note)
{
$this->notes[] = $note;
+
return $this;
}
@@ -74,6 +77,7 @@ public function getName()
public function setName($val)
{
$this->name = $val;
+
return $this;
}
@@ -85,6 +89,7 @@ public function getSalary()
public function setSalary($val)
{
$this->salary = $val;
+
return $this;
}
@@ -96,6 +101,7 @@ public function getStarted()
public function setStarted($val)
{
$this->started = $val;
+
return $this;
}
@@ -107,6 +113,7 @@ public function getLeft()
public function setLeft($val)
{
$this->left = $val;
+
return $this;
}
@@ -118,6 +125,7 @@ public function getAddress()
public function setAddress($val)
{
$this->address = $val;
+
return $this;
}
}
diff --git a/tests/Documents/CmsUser.php b/tests/Documents/CmsUser.php
index fa077f6a7f..7b87cd089a 100644
--- a/tests/Documents/CmsUser.php
+++ b/tests/Documents/CmsUser.php
@@ -100,8 +100,10 @@ public function removePhonenumber($index)
$ph = $this->phonenumbers[$index];
unset($this->phonenumbers[$index]);
$ph->user = null;
+
return true;
}
+
return false;
}
diff --git a/tests/Documents/Ecommerce/ConfigurableProduct.php b/tests/Documents/Ecommerce/ConfigurableProduct.php
index dd04504992..ed7f725a54 100644
--- a/tests/Documents/Ecommerce/ConfigurableProduct.php
+++ b/tests/Documents/Ecommerce/ConfigurableProduct.php
@@ -50,6 +50,7 @@ public function setName($name)
throw new InvalidArgumentException('Product name cannot be empty');
}
$this->name = $name;
+
return $this;
}
@@ -96,6 +97,7 @@ public function removeOption($name)
$index = array_search($option, $this->options);
}
unset($this->options[$index]);
+
return $this;
}
@@ -111,6 +113,7 @@ public function selectOption($name)
throw new InvalidArgumentException('specified option: ' . $name . ' doesn\'t exist');
}
$this->selectedOption = $option;
+
return $this;
}
@@ -121,6 +124,7 @@ protected function _findOption($name)
return $option;
}
}
+
return null;
}
diff --git a/tests/Documents/Ecommerce/Option.php b/tests/Documents/Ecommerce/Option.php
index e8f7ef7083..59cbc337a0 100644
--- a/tests/Documents/Ecommerce/Option.php
+++ b/tests/Documents/Ecommerce/Option.php
@@ -69,6 +69,7 @@ public function getPrice($object = false)
if ($object === true) {
return $this->money;
}
+
return $this->money->getAmount();
}
diff --git a/tests/Documents/Ecommerce/StockItem.php b/tests/Documents/Ecommerce/StockItem.php
index 3bde510a85..c98236f6b9 100644
--- a/tests/Documents/Ecommerce/StockItem.php
+++ b/tests/Documents/Ecommerce/StockItem.php
@@ -46,6 +46,7 @@ public function __construct($name = null, $cost = null, $inventory = null)
public function setName($name)
{
$this->name = (string) $name;
+
return $this;
}
@@ -67,6 +68,7 @@ public function getCost()
public function setInventory($inventory)
{
$this->inventory = (int) $inventory;
+
return $this;
}
diff --git a/tests/Documents/Employee.php b/tests/Documents/Employee.php
index b64650ec97..4c78b7c711 100644
--- a/tests/Documents/Employee.php
+++ b/tests/Documents/Employee.php
@@ -20,6 +20,7 @@ public function getManager()
public function setManager($val)
{
$this->manager = $val;
+
return $this;
}
}
diff --git a/tests/Documents/Functional/VirtualHost.php b/tests/Documents/Functional/VirtualHost.php
index ddf2667bee..e62e64a7e0 100644
--- a/tests/Documents/Functional/VirtualHost.php
+++ b/tests/Documents/Functional/VirtualHost.php
@@ -28,6 +28,7 @@ public function getVHostDirective()
if (! $this->vhostDirective) {
$this->vhostDirective = new VirtualHostDirective('VirtualHost', '*:80');
}
+
return $this->vhostDirective;
}
diff --git a/tests/Documents/Functional/VirtualHostDirective.php b/tests/Documents/Functional/VirtualHostDirective.php
index e0635d4827..026eb75d41 100644
--- a/tests/Documents/Functional/VirtualHostDirective.php
+++ b/tests/Documents/Functional/VirtualHostDirective.php
@@ -20,7 +20,6 @@ class VirtualHostDirective
/** @ODM\EmbedMany(targetDocument=Documents\Functional\VirtualHostDirective::class) */
protected $directives;
-
public function __construct($name = '', $value = '')
{
$this->name = $name;
@@ -71,6 +70,7 @@ public function getDirectives()
if (! $this->directives) {
$this->directives = new ArrayCollection([]);
}
+
return $this->directives;
}
@@ -100,10 +100,10 @@ public function hasDirective($name)
return $d;
}
}
+
return null;
}
-
public function getDirective($name)
{
return $this->hasDirective($name);
diff --git a/tests/Documents/User.php b/tests/Documents/User.php
index cd1a49399e..32c204981b 100644
--- a/tests/Documents/User.php
+++ b/tests/Documents/User.php
@@ -262,9 +262,11 @@ public function removeGroup($name)
foreach ($this->groups as $key => $group) {
if ($group->getName() === $name) {
unset($this->groups[$key]);
+
return true;
}
}
+
return false;
}
@@ -361,9 +363,11 @@ public function removePost($id)
foreach ($this->posts as $key => $post) {
if ($post->getId() === $id) {
unset($this->posts[$key]);
+
return true;
}
}
+
return false;
}