Skip to content

Commit 8e048f8

Browse files
authored
Merge pull request #2462 from malarzm/fix-failing-jobs
Fix failing CI checks
2 parents 89a5bfd + 36827e4 commit 8e048f8

File tree

9 files changed

+46
-21
lines changed

9 files changed

+46
-21
lines changed

lib/Doctrine/ODM/MongoDB/DocumentManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,15 @@ public function getReference(string $documentName, $identifier): object
621621
/** @psalm-var ClassMetadata<T> $class */
622622
$class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\'));
623623
assert($class instanceof ClassMetadata);
624+
/** @psalm-var T|false $document */
624625
$document = $this->unitOfWork->tryGetById($identifier, $class);
625626

626627
// Check identity map first, if its already in there just return it.
627-
if ($document) {
628+
if ($document !== false) {
628629
return $document;
629630
}
630631

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

@@ -689,6 +691,7 @@ public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion =
689691
{
690692
$repository = $this->getRepository($className);
691693
if ($repository instanceof DocumentRepository) {
694+
/** @psalm-var DocumentRepository<T> $repository */
692695
return $repository->find($id, $lockMode, $lockVersion);
693696
}
694697

lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ public function mapField(array $mapping): array
22472247
break;
22482248
default:
22492249
if (! empty($this->generatorOptions['type'])) {
2250-
$mapping['type'] = $this->generatorOptions['type'];
2250+
$mapping['type'] = (string) $this->generatorOptions['type'];
22512251
} elseif (empty($mapping['type'])) {
22522252
$mapping['type'] = $this->generatorType === self::GENERATOR_TYPE_INCREMENT ? Type::INT : Type::CUSTOMID;
22532253
}

lib/Doctrine/ODM/MongoDB/Mapping/Driver/CompatibilityAnnotationDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99

1010
use function class_exists;
1111

12-
if (class_exists(PersistenceAnnotationDriver::class)) {
12+
if (! class_exists(PersistenceAnnotationDriver::class)) {
1313
/**
1414
* @internal This class will be removed in ODM 3.0.
1515
*/
16-
abstract class CompatibilityAnnotationDriver extends PersistenceAnnotationDriver
16+
abstract class CompatibilityAnnotationDriver implements MappingDriver
1717
{
1818
}
1919
} else {
2020
/**
2121
* @internal This class will be removed in ODM 3.0.
2222
*/
23-
abstract class CompatibilityAnnotationDriver implements MappingDriver
23+
abstract class CompatibilityAnnotationDriver extends PersistenceAnnotationDriver
2424
{
2525
}
2626
}

lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ static function (): bool {
8888
* @param DocumentPersister<TDocument> $documentPersister
8989
*
9090
* @psalm-return Closure(
91-
* TDocument&GhostObjectInterface<TDocument>,
92-
* string,
93-
* array<string, mixed>,
91+
* TDocument&GhostObjectInterface<TDocument>=,
92+
* string=,
93+
* array<string, mixed>=,
9494
* ?Closure=,
95-
* array<string, mixed>
95+
* array<string, mixed>=
9696
* ) : bool
9797
*
9898
* @template TDocument of object
@@ -103,10 +103,8 @@ private function createInitializer(
103103
): Closure {
104104
return function (
105105
GhostObjectInterface $ghostObject,
106-
string $method,
107-
// we don't care
108-
array $parameters,
109-
// we don't care
106+
string $method, // we don't care
107+
array $parameters, // we don't care
110108
&$initializer,
111109
array $properties // we currently do not use this
112110
) use (

lib/Doctrine/ODM/MongoDB/UnitOfWork.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ public function getDocumentPersister(string $documentName): Persisters\DocumentP
367367
$this->persisters[$documentName] = new Persisters\DocumentPersister($pb, $this->dm, $this, $this->hydratorFactory, $class);
368368
}
369369

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

phpstan-baseline.neon

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ parameters:
145145

146146
# When iterating over SimpleXMLElement, we cannot know the key values
147147
-
148-
message: "#^Parameter \\#2 \\$mapping of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\Driver\\\\XmlDriver\\:\\:addFieldMapping\\(\\) expects array\\{type\\?\\: string, fieldName\\?\\: string, name\\?\\: string, strategy\\?\\: string, association\\?\\: int, id\\?\\: bool, isOwningSide\\?\\: bool, collectionClass\\?\\: class\\-string, \\.\\.\\.\\}, array\\<int\\|string, non\\-empty\\-array\\<int, string\\>\\|bool\\|string\\> given\\.$#"
149-
count: 1
148+
message: "#^Parameter \\#2 \\$mapping of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\Driver\\\\XmlDriver\\:\\:addFieldMapping\\(\\) expects array#"
149+
count: 2
150150
path: lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
151151

152152
# This is handled by a try-catch block
@@ -163,6 +163,17 @@ parameters:
163163
count: 1
164164
path: lib/Doctrine/ODM/MongoDB/PersistentCollection.php
165165

166+
# complains about types for arguments we do not use/care
167+
-
168+
message: "#^Method Doctrine\\\\ODM\\\\MongoDB\\\\Proxy\\\\Factory\\\\StaticProxyFactory\\:\\:createInitializer\\(\\) should return Closure\\(ProxyManager\\\\Proxy\\\\GhostObjectInterface\\<TDocument of object\\>&TDocument of object\\=, string\\=, array\\<string, mixed\\>\\=, Closure\\|null\\=, array\\<string, mixed\\>\\=\\)\\: bool but returns Closure\\(ProxyManager\\\\Proxy\\\\GhostObjectInterface, string, array, mixed, array\\)\\: true\\.$#"
169+
count: 1
170+
path: lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php
171+
172+
-
173+
message: "#^Parameter \\#1 \\$initializer of method ProxyManager\\\\Proxy\\\\GhostObjectInterface\\<object\\>\\:\\:setProxyInitializer\\(\\) expects \\(Closure\\(ProxyManager\\\\Proxy\\\\GhostObjectInterface\\<object\\>\\=, string\\=, array\\<string, mixed\\>\\=, Closure\\|null\\=, array\\<string, mixed\\>\\=\\)\\: bool\\)\\|null, Closure\\(ProxyManager\\\\Proxy\\\\GhostObjectInterface, string, array, mixed, array\\)\\: true given\\.$#"
174+
count: 1
175+
path: lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
176+
166177
# compatibility layer for doctrine/persistence ^2.4 || ^3.0
167178
-
168179
message: "#.*#"
@@ -220,3 +231,14 @@ parameters:
220231
message: "#.+mapField\\(\\) expects.+enumType\\: 'Documents81#"
221232
count: 2
222233
path: tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php
234+
235+
# it loads an empty class ReflectionEnum of ReflectionEnumPolyfill.php file from laminas/laminas-code, see https://github.com/phpstan/phpstan/issues/7290
236+
-
237+
message: "#^Call to an undefined method ReflectionEnum\\:\\:isBacked\\(\\)\\.$#"
238+
count: 1
239+
path: lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
240+
241+
-
242+
message: "#^Call to an undefined method ReflectionEnum\\:\\:getBackingType\\(\\)\\.$#"
243+
count: 1
244+
path: lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php

tests/Doctrine/ODM/MongoDB/Tests/Repository/DefaultGridFSRepositoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private function getRepository(string $className = File::class): GridFSRepositor
268268

269269
assert($repository instanceof GridFSRepository);
270270

271+
/** @psalm-var GridFSRepository<T> */
271272
return $repository;
272273
}
273274

tests/Documents81/Suit.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
enum Suit: string
88
{
9-
case Hearts = 'H';
9+
case Hearts = 'H';
1010
case Diamonds = 'D';
11-
case Clubs = 'C';
12-
case Spades = 'S';
11+
case Clubs = 'C';
12+
case Spades = 'S';
1313
}

tests/Documents81/SuitInt.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
enum SuitInt: int
88
{
9-
case Hearts = 1;
9+
case Hearts = 1;
1010
case Diamonds = 2;
11-
case Clubs = 3;
12-
case Spades = 4;
11+
case Clubs = 3;
12+
case Spades = 4;
1313
}

0 commit comments

Comments
 (0)