Skip to content

Commit

Permalink
Fix Psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
malarzm committed Sep 20, 2022
1 parent a53f3ac commit 36827e4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,15 @@ public function getReference(string $documentName, $identifier): object
/** @psalm-var ClassMetadata<T> $class */
$class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\'));
assert($class instanceof ClassMetadata);
/** @psalm-var T|false $document */
$document = $this->unitOfWork->tryGetById($identifier, $class);

// Check identity map first, if its already in there just return it.
if ($document) {
if ($document !== false) {
return $document;
}

/** @psalm-var T&GhostObjectInterface<T> $document */
$document = $this->proxyFactory->getProxy($class, $identifier);
$this->unitOfWork->registerManaged($document, $identifier, []);

Expand Down Expand Up @@ -689,6 +691,7 @@ public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion =
{
$repository = $this->getRepository($className);
if ($repository instanceof DocumentRepository) {
/** @psalm-var DocumentRepository<T> $repository */
return $repository->find($id, $lockMode, $lockVersion);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ public function mapField(array $mapping): array
break;
default:
if (! empty($this->generatorOptions['type'])) {
$mapping['type'] = $this->generatorOptions['type'];
$mapping['type'] = (string) $this->generatorOptions['type'];
} elseif (empty($mapping['type'])) {
$mapping['type'] = $this->generatorType === self::GENERATOR_TYPE_INCREMENT ? Type::INT : Type::CUSTOMID;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ public function getDocumentPersister(string $documentName): Persisters\DocumentP
$this->persisters[$documentName] = new Persisters\DocumentPersister($pb, $this->dm, $this, $this->hydratorFactory, $class);
}

/** @psalm-var Persisters\DocumentPersister<T> */
return $this->persisters[$documentName];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ private function getRepository(string $className = File::class): GridFSRepositor

assert($repository instanceof GridFSRepository);

/** @psalm-var GridFSRepository<T> */
return $repository;
}

Expand Down

0 comments on commit 36827e4

Please sign in to comment.