Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to doctrine/coding-standard 9 #2309

Merged
merged 1 commit into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"require-dev": {
"ext-bcmath": "*",
"doctrine/coding-standard": "^8.2",
"doctrine/coding-standard": "^9.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0",
"phpstan/phpstan": "^0.12.32",
Expand Down
9 changes: 4 additions & 5 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,12 @@ public function unlock(object $document): void
* Gets the repository for a document class.
*
* @param string $documentName The name of the Document.
* @psalm-param class-string<T> $documentName
*
* @return ObjectRepository The repository.
* @psalm-return ObjectRepository<T>
*
* @template T of object
* @psalm-param class-string<T> $documentName
*
* @psalm-return ObjectRepository<T>
*/
public function getRepository($documentName)
{
Expand Down Expand Up @@ -661,11 +660,11 @@ public function getPartialReference(string $documentName, $identifier): object
* @param mixed $id
* @param int $lockMode
* @param int $lockVersion
*
* @template T of object
* @psalm-param class-string<T> $className
*
* @psalm-return T|null
*
* @template T of object
*/
public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion = null): ?object
{
Expand Down
11 changes: 4 additions & 7 deletions lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,14 @@ public function refresh(object $document): void
* be used to match an _id value.
*
* @param mixed $criteria Query criteria
* @psalm-param T|null $document
*
* @psalm-return T|null
*
* @throws LockException
*
* @todo Check identity map? loadById method? Try to guess whether
* $criteria is the id?
*
* @psalm-param T|null $document
*
* @psalm-return T|null
*/
public function load($criteria, ?object $document = null, array $hints = [], int $lockMode = 0, ?array $sort = null): ?object
{
Expand Down Expand Up @@ -630,11 +629,9 @@ public function unlock(object $document): void
* @param array $result The query result.
* @param object|null $document The document object to fill, if any.
* @param array $hints Hints for document creation.
*
* @return object The filled and managed document object.
*
* @psalm-param T|null $document
*
* @return object The filled and managed document object.
* @psalm-return T
*/
private function createDocument(array $result, ?object $document = null, array $hints = []): object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public function getRealClass(string $class): string
}

/**
* @psalm-template RealClassName of object
* @psalm-param class-string<RealClassName>|class-string<ProxyInterface<RealClassName>> $className
*
* @psalm-return class-string<RealClassName>
*
* @psalm-template RealClassName of object
*/
public function resolveClassName(string $className): string
{
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class DocumentRepository implements ObjectRepository, Selectable
* @param DocumentManager $dm The DocumentManager to use.
* @param UnitOfWork $uow The UnitOfWork to use.
* @param ClassMetadata $classMetadata The class metadata.
*
* @psalm-param ClassMetadata<T> $classMetadata The class metadata.
*/
public function __construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $classMetadata)
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Repository/RepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ interface RepositoryFactory
/**
* Gets the repository for a document class.
*
* @template T of object
* @psalm-param class-string<T> $documentName
*
* @psalm-return ObjectRepository<T>
*
* @template T of object
*/
public function getRepository(DocumentManager $documentManager, string $documentName): ObjectRepository;
}
8 changes: 6 additions & 2 deletions lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,11 @@ public function getParentAssociation(object $document): ?array
/**
* Get the document persister instance for the given document name
*
* @template T of object
* @psalm-param class-string<T> $documentName
*
* @psalm-return Persisters\DocumentPersister<T>
*
* @template T of object
*/
public function getDocumentPersister(string $documentName): Persisters\DocumentPersister
{
Expand Down Expand Up @@ -2621,10 +2623,12 @@ public function getClassNameForAssociation(array $mapping, $data): string
/**
* Creates a document. Used for reconstitution of documents during hydration.
*
* @template T of object
* @psalm-param class-string<T> $className
* @psalm-param T|null $document
*
* @psalm-return T
*
* @template T of object
*/
public function getOrCreateDocument(string $className, array $data, array &$hints = [], ?object $document = null): object
{
Expand Down
16 changes: 0 additions & 16 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,6 @@
<exclude-pattern>lib/Doctrine/ODM/MongoDB/Events.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements">
<properties>
<property name="alwaysUsedPropertiesAnnotations" type="array" value="
@ODM\Id,
@ODM\Field,
@ODM\EmbedOne,
@ODM\EmbedMany,
@ODM\ReferenceOne,
@ODM\ReferenceMany
"/>
</properties>
<exclude-pattern>tests/Doctrine/ODM/MongoDB/Tests/Mapping/BasicInheritanceMappingTest.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataFactoryTest.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataLoadEventTest.php</exclude-pattern>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
Expand Down