File tree 5 files changed +37
-1
lines changed
tests/Doctrine/StaticAnalysis/Mapping
5 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 52
52
"autoload-dev" : {
53
53
"psr-4" : {
54
54
"Doctrine\\ Tests\\ " : " tests/Doctrine/Tests" ,
55
+ "Doctrine\\ StaticAnalysis\\ " : " tests/Doctrine/StaticAnalysis" ,
55
56
"Doctrine\\ Performance\\ " : " tests/Doctrine/Performance"
56
57
}
57
58
},
Original file line number Diff line number Diff line change 29
29
*/
30
30
class ClassMetadata extends ClassMetadataInfo
31
31
{
32
+ /**
33
+ * Repeating the ClassMetadataInfo constructor to infer correctly the template with PHPStan
34
+ *
35
+ * @see https://github.com/doctrine/orm/issues/8709
36
+ *
37
+ * @param string $entityName The name of the entity class the new instance is used for.
38
+ * @psalm-param class-string<T> $entityName
39
+ */
40
+ public function __construct ($ entityName , ?NamingStrategy $ namingStrategy = null )
41
+ {
42
+ parent ::__construct ($ entityName , $ namingStrategy );
43
+ }
32
44
}
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ includes:
4
4
parameters :
5
5
level : 5
6
6
paths :
7
- - %currentWorkingDirectory%/lib
7
+ - lib
8
+ - tests/Doctrine/StaticAnalysis
8
9
earlyTerminatingMethodCalls :
9
10
Doctrine\ORM\Query\Parser :
10
11
- syntaxError
Original file line number Diff line number Diff line change 9
9
>
10
10
<projectFiles >
11
11
<directory name =" lib/Doctrine/ORM" />
12
+ <directory name =" tests/Doctrine/StaticAnalysis" />
12
13
<ignoreFiles >
13
14
<directory name =" vendor" />
14
15
</ignoreFiles >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Doctrine \StaticAnalysis \Mapping ;
4
+
5
+ use Doctrine \ORM \Mapping \ClassMetadata ;
6
+
7
+ /**
8
+ * @template T of object
9
+ */
10
+ class MetadataGenerator
11
+ {
12
+ /**
13
+ * @psalm-param class-string<T> $entityName
14
+ *
15
+ * @psalm-return ClassMetadata<T>
16
+ */
17
+ public function createMetadata (string $ entityName ): ClassMetadata
18
+ {
19
+ return new ClassMetadata ($ entityName );
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments