Skip to content

Commit

Permalink
Merge pull request #2239 from doctrine/cherry-pick-2234
Browse files Browse the repository at this point in the history
Assert array value is an instance of the key
  • Loading branch information
malarzm authored Nov 3, 2020
2 parents f3f1d1d + a1be178 commit 1409465
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\ODM\MongoDB\Events;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractIndex;
use Doctrine\ODM\MongoDB\Mapping\Annotations\ShardKey;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Mapping\MappingException;
use Doctrine\Persistence\Mapping\Driver\AnnotationDriver as AbstractAnnotationDriver;
Expand Down Expand Up @@ -204,8 +205,9 @@ public function loadMetadataForClass($className, \Doctrine\Persistence\Mapping\C
}

// Set shard key after all fields to ensure we mapped all its keys
if (isset($classAnnotations['Doctrine\ODM\MongoDB\Mapping\Annotations\ShardKey'])) {
$this->setShardKey($class, $classAnnotations['Doctrine\ODM\MongoDB\Mapping\Annotations\ShardKey']);
if (isset($classAnnotations[ShardKey::class])) {
assert($classAnnotations[ShardKey::class] instanceof ShardKey);
$this->setShardKey($class, $classAnnotations[ShardKey::class]);
}

/** @var ReflectionMethod $method */
Expand Down

0 comments on commit 1409465

Please sign in to comment.