Skip to content

Commit

Permalink
Replace some @phpstan-param/return
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Oct 9, 2024
1 parent f7a3b2e commit 56fe112
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 55 deletions.
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public function setClassMetadataFactoryName(string $cmfName): void
$this->attributes['classMetadataFactoryName'] = $cmfName;
}

/** @phpstan-return class-string<ClassMetadataFactoryInterface> */
/** @return class-string<ClassMetadataFactoryInterface> */
public function getClassMetadataFactoryName(): string
{
if (! isset($this->attributes['classMetadataFactoryName'])) {
Expand Down Expand Up @@ -480,7 +480,7 @@ public function addFilter(string $name, string $className, array $parameters = [
];
}

/** @phpstan-return class-string|null */
/** @return class-string|null */
public function getFilterClassName(string $name): ?string
{
return isset($this->attributes['filters'][$name])
Expand Down Expand Up @@ -512,7 +512,7 @@ public function setDefaultDocumentRepositoryClassName(string $className): void
$this->attributes['defaultDocumentRepositoryClassName'] = $className;
}

/** @phpstan-return class-string<ObjectRepository<object>> */
/** @return class-string<ObjectRepository<object>> */
public function getDefaultDocumentRepositoryClassName(): string
{
return $this->attributes['defaultDocumentRepositoryClassName'] ?? DocumentRepository::class;
Expand All @@ -534,7 +534,7 @@ public function setDefaultGridFSRepositoryClassName(string $className): void
$this->attributes['defaultGridFSRepositoryClassName'] = $className;
}

/** @phpstan-return class-string<GridFSRepository<object>> */
/** @return class-string<GridFSRepository<object>> */
public function getDefaultGridFSRepositoryClassName(): string
{
return $this->attributes['defaultGridFSRepositoryClassName'] ?? DefaultGridFSRepository::class;
Expand Down
20 changes: 8 additions & 12 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,9 @@ public function getClassNameResolver(): ClassNameResolver
/**
* Returns the metadata for a class.
*
* @param string $className The class name.
* @param class-string<T> $className
* @param class-string<T> $className The class name.
*
* @phpstan-return ClassMetadata<T>
* @return ClassMetadata<T>
*
* @template T of object
*/
Expand Down Expand Up @@ -551,11 +550,9 @@ public function unlock(object $document): void
/**
* Gets the repository for a document class.
*
* @param string $className The name of the Document.
* @param class-string<T> $className
* @param class-string<T> $className The name of the Document.
*
* @return DocumentRepository|GridFSRepository|ViewRepository The repository.
* @phpstan-return DocumentRepository<T>|GridFSRepository<T>|ViewRepository<T>
* @return DocumentRepository<T>|GridFSRepository<T>|ViewRepository<T> The repository.
*
* @template T of object
*/
Expand Down Expand Up @@ -592,7 +589,7 @@ public function flush(array $options = [])
* @param mixed $identifier
* @param class-string<T> $documentName
*
* @phpstan-return T|(T&GhostObjectInterface<T>)
* @return T|(T&GhostObjectInterface<T>)
*
* @template T of object
*/
Expand Down Expand Up @@ -662,7 +659,7 @@ public function getPartialReference(string $documentName, $identifier): object
* @param int $lockVersion
* @param class-string<T> $className

Check failure on line 660 in lib/Doctrine/ODM/MongoDB/DocumentManager.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Superfluous parameter comment
*
* @phpstan-return T|null
* @return T|null
*
* @template T of object
*/
Expand Down Expand Up @@ -803,8 +800,7 @@ public function createReference(object $document, array $referenceMapping)
* @param ClassMetadata<object> $class Metadata of reference document class.
* @phpstan-param FieldMapping $referenceMapping
*
* @return array with next structure [{discriminator field} => {discriminator value}]
* @phpstan-return array<string, class-string>
* @return array<string, class-string> with next structure [{discriminator field} => {discriminator value}]
*
* @throws MappingException When discriminator map is present and reference class in not registered in it.
*/
Expand Down Expand Up @@ -890,7 +886,7 @@ public function getFilterCollection(): FilterCollection
* @param FieldMapping $mapping
* @param array<string, mixed>|null $data
*
* @phpstan-return class-string
* @return class-string
*/
public function getClassNameForAssociation(array $mapping, $data): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getFoundMetadata(): ?ClassMetadata
/**
* Retrieve class name for which a failed metadata fetch attempt was executed
*
* @phpstan-return class-string
* @return class-string
*/
public function getClassName(): string
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Iterator/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
*/
interface Iterator extends \Iterator
{
/** @phpstan-return array<mixed, TValue> */
/** @return array<mixed, TValue> */
public function toArray(): array;
}
13 changes: 5 additions & 8 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1315,10 +1315,7 @@ public function isSharded(): bool
return $this->shardKey !== [];
}

/**
* @return array|object|null
* @phpstan-return array<string, mixed>|object|null
*/
/** @return array<string, mixed>|object|null */
public function getValidator()
{
return $this->validator;
Expand Down Expand Up @@ -1438,7 +1435,7 @@ public function getReflectionProperty(string $name): ReflectionProperty
return $this->reflFields[$name];
}

/** @phpstan-return class-string<T> */
/** @return class-string<T> */
public function getName(): string
{
return $this->name;
Expand Down Expand Up @@ -1928,7 +1925,7 @@ public function getFieldMapping(string $fieldName): array
/**
* Gets mappings of fields holding embedded document(s).
*
* @phpstan-return array<string, AssociationFieldMapping>
* @return array<string, AssociationFieldMapping>
*/
public function getEmbeddedFieldsMappings(): array
{
Expand Down Expand Up @@ -2192,7 +2189,7 @@ public function getTypeOfField($fieldName): ?string
/**
* @param string $assocName
*
* @phpstan-return class-string|null
* @return class-string|null
*/
public function getAssociationTargetClass($assocName): ?string
{
Expand All @@ -2206,7 +2203,7 @@ public function getAssociationTargetClass($assocName): ?string
/**
* Retrieve the collectionClass associated with an association
*
* @phpstan-return class-string
* @return class-string
*/
public function getAssociationCollectionClass(string $assocName): string
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ private function setShardKey(ClassMetadata $class, SimpleXMLElement $xmlShardkey
*
* list($readPreference, $tags) = $this->transformReadPreference($xml->{read-preference});
*
* @phpstan-return array{string, array<int, array<string, string>>|null}
* @return array{string, array<int, array<string, string>>|null}
*/
private function transformReadPreference(SimpleXMLElement $xmlReadPreference): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ interface PersistentCollectionFactory
/**
* Creates specified persistent collection to work with given collection class.
*
* @param BaseCollection<array-key, object>|null $coll
* @phpstan-param FieldMapping $mapping
* @phpstan-param BaseCollection<array-key, object>|null $coll
*
* @phpstan-return PersistentCollectionInterface<array-key, object>
* @return PersistentCollectionInterface<array-key, object>
*/
public function create(DocumentManager $dm, array $mapping, ?BaseCollection $coll = null): PersistentCollectionInterface;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,11 @@ public function refresh(object $document): void
*
* @param array<string, mixed>|scalar|ObjectId|null $criteria Query criteria
* @param array<string, int|string|array<string, string>>|null $sort
* @param T|null $document
* @phpstan-param SortShape|null $sort
* @phpstan-param Hints $hints
* @phpstan-param T|null $document
*
* @phpstan-return T|null
* @return T|null
*
* @throws LockException
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Proxy/Factory/ProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function generateProxyClasses(array $classes): int;
* @param mixed $identifier
* @phpstan-param ClassMetadata<T> $metadata
*
* @phpstan-return T&GhostObjectInterface<T>
* @return T&GhostObjectInterface<T>
*
* @template T of object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(DocumentManager $documentManager)
* @param mixed $identifier
* @phpstan-param ClassMetadata<T> $metadata
*
* @phpstan-return T&GhostObjectInterface<T>
* @return T&GhostObjectInterface<T>
*
* @template T of object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private function getDocumentBucket(): Bucket
}

/**
* @phpstan-return array{
* @return array{
* _id?: mixed,
* chunkSizeBytes?: int,
* metadata?: object
Expand Down
12 changes: 6 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function clear(): void
*
* @param mixed $id Identifier.
*
* @phpstan-return T|null
* @return T|null
*
* @throws MappingException
* @throws LockException
Expand Down Expand Up @@ -185,14 +185,14 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $
* @param array<string, mixed> $criteria
*
* @return object|null The object.
* @phpstan-return T|null
* @return T|null

Check failure on line 188 in lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Only 1 @return tag is allowed in a function comment
*/
public function findOneBy(array $criteria, ?array $sort = null): ?object
{
return $this->getDocumentPersister()->load($criteria, null, [], 0, $sort);
}

/** @phpstan-return class-string<T> */
/** @return class-string<T> */
public function getDocumentName(): string
{
return $this->documentName;
Expand All @@ -203,13 +203,13 @@ public function getDocumentManager(): DocumentManager
return $this->dm;
}

/** @phpstan-return ClassMetadata<T> */
/** @return ClassMetadata<T> */
public function getClassMetadata(): ClassMetadata
{
return $this->class;
}

/** @phpstan-return class-string<T> */
/** @return class-string<T> */
public function getClassName(): string
{
return $this->getDocumentName();
Expand Down Expand Up @@ -251,7 +251,7 @@ public function matching(Criteria $criteria): ArrayCollection
return new ArrayCollection($iterator->toArray());
}

/** @phpstan-return DocumentPersister<T> */
/** @return DocumentPersister<T> */
protected function getDocumentPersister(): DocumentPersister
{
return $this->uow->getDocumentPersister($this->documentName);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Repository/RepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface RepositoryFactory
*
* @param class-string<T> $documentName
*
* @phpstan-return ObjectRepository<T>
* @return ObjectRepository<T>
*
* @template T of object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function addResolveTargetDocument(string $originalDocument, string $newDo
$this->resolveTargetDocuments[$this->getRealClassName($originalDocument)] = $mapping;
}

/** @phpstan-return class-string */
/** @return class-string */
private function getRealClassName(string $className): string
{
return ltrim($className, '\\');
Expand Down
25 changes: 12 additions & 13 deletions lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -2626,8 +2626,7 @@ public function getVisitedCollections(object $document): array
*
* @internal
*
* @return PersistentCollectionInterface[]
* @phpstan-return array<string, PersistentCollectionInterface<array-key, object>>
* @return array<string, PersistentCollectionInterface<array-key, object>>
*/
public function getScheduledCollections(object $document): array
{
Expand Down Expand Up @@ -2726,12 +2725,12 @@ public function getOwningDocument(object $document): object
/**
* Creates a document. Used for reconstitution of documents during hydration.
*
* @param array<string, mixed> $data
* @param class-string<T> $className
* @phpstan-param T|null $document
* @phpstan-param Hints $hints
* @param array<string, mixed> $data
* @param T|null $document
* @phpstan-param Hints $hints
*
* @phpstan-return T
* @return T
*
* @template T of object
*/
Expand Down Expand Up @@ -2837,7 +2836,7 @@ public function loadCollection(PersistentCollectionInterface $collection): void
*
* @internal
*
* @phpstan-return array<class-string, array<string, object>>
* @return array<class-string, array<string, object>>
*/
public function getIdentityMap(): array
{
Expand Down Expand Up @@ -2991,7 +2990,7 @@ public function propertyChanged($sender, $propertyName, $oldValue, $newValue)
/**
* Gets the currently scheduled document insertions in this UnitOfWork.
*
* @phpstan-return array<string, object>
* @return array<string, object>
*/
public function getScheduledDocumentInsertions(): array
{
Expand All @@ -3001,7 +3000,7 @@ public function getScheduledDocumentInsertions(): array
/**
* Gets the currently scheduled document upserts in this UnitOfWork.
*
* @phpstan-return array<string, object>
* @return array<string, object>
*/
public function getScheduledDocumentUpserts(): array
{
Expand All @@ -3011,7 +3010,7 @@ public function getScheduledDocumentUpserts(): array
/**
* Gets the currently scheduled document updates in this UnitOfWork.
*
* @phpstan-return array<string, object>
* @return array<string, object>
*/
public function getScheduledDocumentUpdates(): array
{
Expand All @@ -3021,7 +3020,7 @@ public function getScheduledDocumentUpdates(): array
/**
* Gets the currently scheduled document deletions in this UnitOfWork.
*
* @phpstan-return array<string, object>
* @return array<string, object>
*/
public function getScheduledDocumentDeletions(): array
{
Expand All @@ -3033,7 +3032,7 @@ public function getScheduledDocumentDeletions(): array
*
* @internal
*
* @phpstan-return array<string, PersistentCollectionInterface<array-key, object>>
* @return array<string, PersistentCollectionInterface<array-key, object>>
*/
public function getScheduledCollectionDeletions(): array
{
Expand All @@ -3045,7 +3044,7 @@ public function getScheduledCollectionDeletions(): array
*
* @internal
*
* @phpstan-return array<string, PersistentCollectionInterface<array-key, object>>
* @return array<string, PersistentCollectionInterface<array-key, object>>
*/
public function getScheduledCollectionUpdates(): array
{
Expand Down

0 comments on commit 56fe112

Please sign in to comment.