Skip to content

Commit b35e5bf

Browse files
4.1.0 (#705)
* 4.1.0 * Fix static analysis
1 parent 85cde37 commit b35e5bf

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [4.1.0](https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/compare/4.0.1...4.1.0) - 2021-12-04
6+
### Added
7+
- [[#699](https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/pull/699)] Added support for Symfony 6 ([@jordisala1991](https://github.com/jordisala1991))
8+
59
## [4.0.1](https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/compare/4.0.0...4.0.1) - 2021-10-01
610
### Fixed
711
- [[#680](https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/pull/680)] Fixed not forcing to set `field_name` in `DatagridMapper` fields with type defined ([@franmomu](https://github.com/franmomu))

src/Datagrid/ProxyQuery.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public function __clone()
6868
}
6969

7070
/**
71-
* @psalm-suppress TooManyTemplateParams until release of doctrine/mongodb-odm 2.3
72-
*
7371
* @return Iterator<object>
7472
*/
7573
public function execute()

src/FieldDescription/FieldDescriptionFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function create(string $class, string $name, array $options = []): FieldD
4949
* @phpstan-param class-string $baseClass
5050
*
5151
* @phpstan-return array{
52-
* ClassMetadata,
52+
* ClassMetadata<object>,
5353
* string,
5454
* mixed[]
5555
* }
@@ -72,7 +72,9 @@ private function getParentMetadataForProperty(string $baseClass, string $propert
7272
}
7373

7474
/**
75-
* @param class-string $class
75+
* @phpstan-template T of object
76+
* @phpstan-param class-string<T> $class
77+
* @phpstan-return ClassMetadata<T>
7678
*/
7779
private function getMetadata(string $class): ClassMetadata
7880
{

src/Model/ModelManager.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,41 @@ public function delete(object $object): void
7171
$documentManager->flush();
7272
}
7373

74+
/**
75+
* @param int|string $id
76+
*
77+
* @phpstan-param class-string<T> $class
78+
* @phpstan-return T|null
79+
*/
7480
public function find(string $class, $id): ?object
7581
{
7682
$documentManager = $this->getDocumentManager($class);
7783

7884
return $documentManager->getRepository($class)->find($id);
7985
}
8086

87+
/**
88+
* @phpstan-param class-string<T> $class
89+
* @phpstan-return array<T>
90+
*/
8191
public function findBy(string $class, array $criteria = []): array
8292
{
8393
return $this->getDocumentManager($class)->getRepository($class)->findBy($criteria);
8494
}
8595

96+
/**
97+
* @phpstan-param class-string<T> $class
98+
* @phpstan-return T|null
99+
*/
86100
public function findOneBy(string $class, array $criteria = []): ?object
87101
{
88102
return $this->getDocumentManager($class)->getRepository($class)->findOneBy($criteria);
89103
}
90104

91105
/**
92-
* @param object|string $class
106+
* NEXT_MAJOR: Change visibility to private.
107+
*
108+
* @param object|class-string<T> $class
93109
*
94110
* @throw \RuntimeException
95111
*/
@@ -122,9 +138,6 @@ public function supportsQuery(object $query): bool
122138
return $query instanceof ProxyQuery || $query instanceof Builder;
123139
}
124140

125-
/**
126-
* @psalm-suppress TooManyTemplateParams until release of doctrine/mongodb-odm 2.3
127-
*/
128141
public function executeQuery(object $query)
129142
{
130143
if ($query instanceof Builder) {
@@ -231,6 +244,9 @@ public function reverseTransform(object $object, array $array = []): void
231244
}
232245
}
233246

247+
/**
248+
* @param MongoDBClassMetadata<T> $metadata
249+
*/
234250
private function getFieldName(MongoDBClassMetadata $metadata, string $name): string
235251
{
236252
if (\array_key_exists($name, $metadata->fieldMappings)) {
@@ -244,6 +260,11 @@ private function getFieldName(MongoDBClassMetadata $metadata, string $name): str
244260
return $name;
245261
}
246262

263+
/**
264+
* @param class-string<T> $class
265+
*
266+
* @return MongoDBClassMetadata<T>
267+
*/
247268
private function getMetadata(string $class): MongoDBClassMetadata
248269
{
249270
return $this->getDocumentManager($class)->getClassMetadata($class);

tests/App/AppKernel.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
use Symfony\Component\DependencyInjection\ContainerBuilder;
3131
use Symfony\Component\HttpKernel\Kernel;
3232
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
33-
use Symfony\Component\Routing\RouteCollectionBuilder;
3433

3534
/**
3635
* @psalm-suppress PropertyNotSetInConstructor
@@ -79,11 +78,9 @@ public function getProjectDir(): string
7978
}
8079

8180
/**
82-
* TODO: Use RoutingConfigurator when dropping support of symfony < 5.1.
81+
* TODO: Add typehint when dropping support of symfony < 5.1.
8382
*
84-
* @param RoutingConfigurator|RouteCollectionBuilder $routes
85-
*
86-
* @psalm-suppress DeprecatedClass
83+
* @param RoutingConfigurator $routes
8784
*/
8885
protected function configureRoutes($routes): void
8986
{

tests/ClassMetadataAnnotationTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
trait ClassMetadataAnnotationTrait
2121
{
2222
/**
23-
* @phpstan-param class-string $class
23+
* @phpstan-template T of object
24+
* @phpstan-param class-string<T> $class
25+
* @phpstan-return ClassMetadata<T>
2426
*/
2527
protected function getMetadataForDocumentWithAnnotations(string $class): ClassMetadata
2628
{

0 commit comments

Comments
 (0)