Skip to content

Commit 1c16df5

Browse files
committed
Make signatures forward-comaptible with doctrine/persistence 4.x
These changes are the first of migration toward doctrine/persistence 4.0. Most of the signatures that could've been made compatible have been made compatible. There are some other, which require more in-depth knowledge of repository to adjust / rework.
1 parent d956cd8 commit 1c16df5

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\ODM\PHPCR\ChildrenCollection;
88
use Doctrine\ODM\PHPCR\Configuration;
99
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
10+
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata as PhpcrClassMetadata;
1011
use Doctrine\ODM\PHPCR\Proxy\ProxyFactory;
1112
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
1213
use Doctrine\ODM\PHPCR\Query\Query;
@@ -38,6 +39,12 @@ public function __construct(DocumentManagerInterface $wrapped)
3839
$this->wrapped = $wrapped;
3940
}
4041

42+
/** @noinspection SenselessMethodDuplicationInspection - return type is made more specific to match {@see DocumentManagerInterface::getClassMetadata()} */
43+
public function getClassMetadata(string $className): PhpcrClassMetadata
44+
{
45+
return $this->wrapped->getClassMetadata($className);
46+
}
47+
4148
public function setTranslationStrategy(string $key, TranslationStrategyInterface $strategy): void
4249
{
4350
$this->wrapped->setTranslationStrategy($key, $strategy);

lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@
4545
interface DocumentManagerInterface extends ObjectManager
4646
{
4747
/**
48-
* @{@inheritDoc}
49-
*
50-
* Overwritten to tighten return type. We can't tighten the return type declaration because of Doctrine\Persistence\ObjectManagerDecorator.
48+
* {@inheritdoc}
5149
*
52-
* @return PhpcrClassMetadata
50+
* Overwritten to tighten the return type.
5351
*/
54-
public function getClassMetadata(string $className);
52+
public function getClassMetadata(string $className): PhpcrClassMetadata;
5553

5654
/**
5755
* Add or replace a translation strategy.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ public function getAssociationTargetClass($fieldName): ?string
13171317
return $this->mappings[$fieldName]['targetDocument'];
13181318
}
13191319

1320-
public function getAssociationMappedByTargetField($assocName)
1320+
public function getAssociationMappedByTargetField($assocName): string
13211321
{
13221322
throw new BadMethodCallException(sprintf(
13231323
'%s not yet implemented in "%s"',
@@ -1326,7 +1326,7 @@ public function getAssociationMappedByTargetField($assocName)
13261326
));
13271327
}
13281328

1329-
public function isAssociationInverseSide($assocName)
1329+
public function isAssociationInverseSide($assocName): bool
13301330
{
13311331
throw new BadMethodCallException(sprintf(
13321332
'%s not yet implemented in "%s"',

lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(array $paths)
6363
$this->addPaths($paths);
6464
}
6565

66-
public function isTransient($className)
66+
public function isTransient($className): bool
6767
{
6868
$classAttributes = $this->reader->getClassAttributes(new \ReflectionClass($className));
6969

lib/Doctrine/ODM/PHPCR/Mapping/Driver/YamlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private function addMappingFromReference(ClassMetadata $class, string $fieldName
262262
}
263263
}
264264

265-
protected function loadMappingFile($file)
265+
protected function loadMappingFile($file): array
266266
{
267267
if (!is_file($file)) {
268268
throw new InvalidArgumentException(sprintf('File "%s" not found', $file));

0 commit comments

Comments
 (0)