Skip to content

Commit b337726

Browse files
authored
Merge pull request #374 from greg0ire/fix-types
Make types compatible with ORM/ODM drivers
2 parents 53c572a + bce9a5e commit b337726

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/Persistence/Mapping/Driver/FileDriver.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
* classes on demand. This requires the user to adhere to the convention of 1 mapping
2222
* file per class and the file names of the mapping files must correspond to the full
2323
* class name, including namespace, with the namespace delimiters '\', replaced by dots '.'.
24+
*
25+
* @template T
2426
*/
2527
abstract class FileDriver implements MappingDriver
2628
{
2729
/** @var FileLocator */
2830
protected $locator;
2931

3032
/**
31-
* @var ClassMetadata[]|null
32-
* @psalm-var array<class-string, ClassMetadata<object>>|null
33+
* @var mixed[]|null
34+
* @psalm-var array<class-string, T>|null
3335
*/
3436
protected $classCache;
3537

@@ -78,8 +80,7 @@ public function getGlobalBasename()
7880
*
7981
* @psalm-param class-string $className
8082
*
81-
* @return ClassMetadata The element of schema meta data.
82-
* @psalm-return ClassMetadata<object>
83+
* @return T The element of schema meta data.
8384
*
8485
* @throws MappingException
8586
*/
@@ -154,8 +155,8 @@ public function getAllClassNames()
154155
*
155156
* @param string $file The mapping file to load.
156157
*
157-
* @return ClassMetadata[]
158-
* @psalm-return array<class-string, ClassMetadata<object>>
158+
* @return mixed[]
159+
* @psalm-return array<class-string, T>
159160
*/
160161
abstract protected function loadMappingFile(string $file);
161162

src/Persistence/Mapping/Driver/PHPDriver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/**
1010
* The PHPDriver includes php files which just populate ClassMetadataInfo
1111
* instances with plain PHP code.
12+
*
13+
* @template-extends FileDriver<ClassMetadata<object>>
1214
*/
1315
class PHPDriver extends FileDriver
1416
{

tests/Persistence/Mapping/FileDriverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ private function createTestFileDriver($locator, ?string $fileExtension = null):
197197
}
198198
}
199199

200+
/** @template-extends FileDriver<TestClassMetadata<object>> */
200201
class TestFileDriver extends FileDriver
201202
{
202203
/** @var ClassMetadata<object> */

tests/Persistence/Mapping/Fixtures/TestClassMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use ReflectionClass;
1010

1111
/**
12-
* @template T of object
12+
* @template-covariant T of object
1313
* @template-implements ClassMetadata<T>
1414
*/
1515
final class TestClassMetadata implements ClassMetadata

0 commit comments

Comments
 (0)