From c94a583871a6e7a5faed1e7ed4580640e56bcb79 Mon Sep 17 00:00:00 2001
From: Toni Peric <me@toni.hr>
Date: Mon, 30 Dec 2024 15:19:56 +0100
Subject: [PATCH] Add doctrine/persistence v4 support

---
 composer.json                                 |  2 +-
 .../Proxy/LazyLoadableObjectClassMetadata.php | 32 +++++++++----------
 ...jectWithNullableTypehintsClassMetadata.php | 32 +++++++++----------
 ...WithPHP81IntersectionTypeClassMetadata.php | 32 +++++++++----------
 ...2UnionAndIntersectionTypeClassMetadata.php | 32 +++++++++----------
 ...leObjectWithPHP8UnionTypeClassMetadata.php | 32 +++++++++----------
 ...zyLoadableObjectWithTraitClassMetadata.php | 32 +++++++++----------
 ...ObjectWithTypedPropertiesClassMetadata.php | 32 +++++++++----------
 ...adableObjectWithTypehintsClassMetadata.php | 32 +++++++++----------
 ...azyLoadableObjectWithVoidClassMetadata.php | 32 +++++++++----------
 10 files changed, 145 insertions(+), 145 deletions(-)

diff --git a/composer.json b/composer.json
index ff64cc17f..73ff5d2b0 100644
--- a/composer.json
+++ b/composer.json
@@ -19,7 +19,7 @@
     ],
     "require": {
         "php": "^7.1 || ^8.0",
-        "doctrine/persistence": "^2.0 || ^3.0"
+        "doctrine/persistence": "^2.0 || ^3.0 || ^4.0"
     },
     "require-dev": {
         "doctrine/collections": "^1",
diff --git a/tests/Common/Proxy/LazyLoadableObjectClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectClassMetadata.php
index 8ac2ab8ed..56294678f 100644
--- a/tests/Common/Proxy/LazyLoadableObjectClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectClassMetadata.php
@@ -38,7 +38,7 @@ class LazyLoadableObjectClassMetadata implements ClassMetadata
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -46,7 +46,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -54,7 +54,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObject');
@@ -66,7 +66,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -74,7 +74,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -82,7 +82,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return isset($this->associations[$fieldName]);
     }
@@ -90,7 +90,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -98,7 +98,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -106,7 +106,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -114,7 +114,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -122,7 +122,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return array_keys($this->associations);
     }
@@ -130,7 +130,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -138,7 +138,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -146,7 +146,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -154,7 +154,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -162,7 +162,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithNullableTypehintsClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithNullableTypehintsClassMetadata.php
index 5c92079c8..8058016b8 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithNullableTypehintsClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithNullableTypehintsClassMetadata.php
@@ -30,7 +30,7 @@ class LazyLoadableObjectWithNullableTypehintsClassMetadata implements ClassMetad
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -38,7 +38,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -46,7 +46,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithNullableTypehints');
@@ -58,7 +58,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -66,7 +66,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -74,7 +74,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -82,7 +82,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -90,7 +90,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -98,7 +98,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -106,7 +106,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -114,7 +114,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -122,7 +122,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -130,7 +130,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -138,7 +138,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -146,7 +146,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -154,7 +154,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithPHP81IntersectionTypeClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithPHP81IntersectionTypeClassMetadata.php
index 54ab55f04..1a66f2655 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithPHP81IntersectionTypeClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithPHP81IntersectionTypeClassMetadata.php
@@ -25,7 +25,7 @@ class LazyLoadableObjectWithPHP81IntersectionTypeClassMetadata implements ClassM
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -33,7 +33,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -41,7 +41,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithPHP81IntersectionType');
@@ -53,7 +53,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -61,7 +61,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -69,7 +69,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -77,7 +77,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -85,7 +85,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -93,7 +93,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -101,7 +101,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -109,7 +109,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -117,7 +117,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -125,7 +125,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -133,7 +133,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -141,7 +141,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -149,7 +149,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithPHP82UnionAndIntersectionTypeClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithPHP82UnionAndIntersectionTypeClassMetadata.php
index 6f9b4e4b1..1e6045455 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithPHP82UnionAndIntersectionTypeClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithPHP82UnionAndIntersectionTypeClassMetadata.php
@@ -25,7 +25,7 @@ class LazyLoadableObjectWithPHP82UnionAndIntersectionTypeClassMetadata implement
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -33,7 +33,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -41,7 +41,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithPHP82UnionAndIntersectionType');
@@ -53,7 +53,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -61,7 +61,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -69,7 +69,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -77,7 +77,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -85,7 +85,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -93,7 +93,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -101,7 +101,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -109,7 +109,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -117,7 +117,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -125,7 +125,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -133,7 +133,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -141,7 +141,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -149,7 +149,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithPHP8UnionTypeClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithPHP8UnionTypeClassMetadata.php
index 5e1b8a14a..f19373ff5 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithPHP8UnionTypeClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithPHP8UnionTypeClassMetadata.php
@@ -25,7 +25,7 @@ class LazyLoadableObjectWithPHP8UnionTypeClassMetadata implements ClassMetadata
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -33,7 +33,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -41,7 +41,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithPHP8UnionType');
@@ -53,7 +53,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -61,7 +61,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -69,7 +69,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -77,7 +77,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -85,7 +85,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -93,7 +93,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -101,7 +101,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -109,7 +109,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -117,7 +117,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -125,7 +125,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -133,7 +133,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -141,7 +141,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -149,7 +149,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithTraitClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithTraitClassMetadata.php
index 24dd07b72..7b1a9a4b7 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithTraitClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithTraitClassMetadata.php
@@ -24,7 +24,7 @@ class LazyLoadableObjectWithTraitClassMetadata implements ClassMetadata
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -32,7 +32,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -40,7 +40,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithTrait');
@@ -52,7 +52,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -60,7 +60,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -68,7 +68,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -76,7 +76,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -84,7 +84,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -92,7 +92,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -100,7 +100,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -108,7 +108,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -116,7 +116,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -124,7 +124,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -132,7 +132,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -140,7 +140,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -148,7 +148,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithTypedPropertiesClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithTypedPropertiesClassMetadata.php
index 7ea187913..16de6bd0f 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithTypedPropertiesClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithTypedPropertiesClassMetadata.php
@@ -38,7 +38,7 @@ class LazyLoadableObjectWithTypedPropertiesClassMetadata implements ClassMetadat
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -46,7 +46,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -54,7 +54,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithTypedProperties');
@@ -66,7 +66,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -74,7 +74,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -82,7 +82,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return isset($this->associations[$fieldName]);
     }
@@ -90,7 +90,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -98,7 +98,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -106,7 +106,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -114,7 +114,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -122,7 +122,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return array_keys($this->associations);
     }
@@ -130,7 +130,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -138,7 +138,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -146,7 +146,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -154,7 +154,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -162,7 +162,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithTypehintsClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithTypehintsClassMetadata.php
index 93c12db77..d577cbd78 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithTypehintsClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithTypehintsClassMetadata.php
@@ -40,7 +40,7 @@ class LazyLoadableObjectWithTypehintsClassMetadata implements ClassMetadata
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -48,7 +48,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return array_keys($this->identifier);
     }
@@ -56,7 +56,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithTypehints');
@@ -68,7 +68,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return isset($this->identifier[$fieldName]);
     }
@@ -76,7 +76,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return isset($this->fields[$fieldName]);
     }
@@ -84,7 +84,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -92,7 +92,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -100,7 +100,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -108,7 +108,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return array_keys($this->fields);
     }
@@ -116,7 +116,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -124,7 +124,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -132,7 +132,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'string';
     }
@@ -140,7 +140,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -148,7 +148,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -156,7 +156,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -164,7 +164,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }
diff --git a/tests/Common/Proxy/LazyLoadableObjectWithVoidClassMetadata.php b/tests/Common/Proxy/LazyLoadableObjectWithVoidClassMetadata.php
index f37c47a3f..a70ffdeae 100644
--- a/tests/Common/Proxy/LazyLoadableObjectWithVoidClassMetadata.php
+++ b/tests/Common/Proxy/LazyLoadableObjectWithVoidClassMetadata.php
@@ -17,7 +17,7 @@ class LazyLoadableObjectWithVoidClassMetadata implements ClassMetadata
     /**
      * {@inheritDoc}
      */
-    public function getName()
+    public function getName(): string
     {
         return $this->getReflectionClass()->getName();
     }
@@ -25,7 +25,7 @@ public function getName()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifier()
+    public function getIdentifier(): array
     {
         return [];
     }
@@ -33,7 +33,7 @@ public function getIdentifier()
     /**
      * {@inheritDoc}
      */
-    public function getReflectionClass()
+    public function getReflectionClass(): ReflectionClass
     {
         if ($this->reflectionClass === null) {
             $this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithVoid');
@@ -45,7 +45,7 @@ public function getReflectionClass()
     /**
      * {@inheritDoc}
      */
-    public function isIdentifier($fieldName)
+    public function isIdentifier($fieldName): bool
     {
         return false;
     }
@@ -53,7 +53,7 @@ public function isIdentifier($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasField($fieldName)
+    public function hasField($fieldName): bool
     {
         return false;
     }
@@ -61,7 +61,7 @@ public function hasField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function hasAssociation($fieldName)
+    public function hasAssociation($fieldName): bool
     {
         return false;
     }
@@ -69,7 +69,7 @@ public function hasAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isSingleValuedAssociation($fieldName)
+    public function isSingleValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -77,7 +77,7 @@ public function isSingleValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function isCollectionValuedAssociation($fieldName)
+    public function isCollectionValuedAssociation($fieldName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -85,7 +85,7 @@ public function isCollectionValuedAssociation($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getFieldNames()
+    public function getFieldNames(): array
     {
         return [];
     }
@@ -93,7 +93,7 @@ public function getFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierFieldNames()
+    public function getIdentifierFieldNames(): array
     {
         return $this->getIdentifier();
     }
@@ -101,7 +101,7 @@ public function getIdentifierFieldNames()
     /**
      * {@inheritDoc}
      */
-    public function getAssociationNames()
+    public function getAssociationNames(): array
     {
         return [];
     }
@@ -109,7 +109,7 @@ public function getAssociationNames()
     /**
      * {@inheritDoc}
      */
-    public function getTypeOfField($fieldName)
+    public function getTypeOfField($fieldName): ?string
     {
         return 'integer';
     }
@@ -117,7 +117,7 @@ public function getTypeOfField($fieldName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationTargetClass($assocName)
+    public function getAssociationTargetClass($assocName): ?string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -125,7 +125,7 @@ public function getAssociationTargetClass($assocName)
     /**
      * {@inheritDoc}
      */
-    public function isAssociationInverseSide($assocName)
+    public function isAssociationInverseSide($assocName): bool
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -133,7 +133,7 @@ public function isAssociationInverseSide($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getAssociationMappedByTargetField($assocName)
+    public function getAssociationMappedByTargetField($assocName): string
     {
         throw new BadMethodCallException('not implemented');
     }
@@ -141,7 +141,7 @@ public function getAssociationMappedByTargetField($assocName)
     /**
      * {@inheritDoc}
      */
-    public function getIdentifierValues($object)
+    public function getIdentifierValues($object): array
     {
         throw new BadMethodCallException('not implemented');
     }