File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
rules-tests/CodeQuality/Rector/Property/TypedPropertyFromToManyRelationTypeRector/Fixture/ODM Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Rector \Doctrine \Tests \CodeQuality \Rector \Property \TypedPropertyFromToManyRelationTypeRector \Fixture \ODM ;
4
+
5
+ use Doctrine \Common \Collections \ArrayCollection ;
6
+ use Doctrine \Common \Collections \Collection ;
7
+ use Rector \Doctrine \Tests \CodeQuality \Rector \Property \TypedPropertyFromToManyRelationTypeRector \Source \TrainingTerm ;
8
+
9
+ final class CollectionOfSuperClass
10
+ {
11
+ /**
12
+ * @\Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedMany()
13
+ */
14
+ private ?Collection $ trainingTerms = null ;
15
+
16
+ public function __construct ()
17
+ {
18
+ }
19
+ }
20
+
21
+ ?>
22
+ -----
23
+ <?php
24
+
25
+ namespace Rector \Doctrine \Tests \CodeQuality \Rector \Property \TypedPropertyFromToManyRelationTypeRector \Fixture \ODM ;
26
+
27
+ use Doctrine \Common \Collections \ArrayCollection ;
28
+ use Doctrine \Common \Collections \Collection ;
29
+ use Rector \Doctrine \Tests \CodeQuality \Rector \Property \TypedPropertyFromToManyRelationTypeRector \Source \TrainingTerm ;
30
+
31
+ final class CollectionOfSuperClass
32
+ {
33
+ /**
34
+ * @\Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedMany()
35
+ * @var \Doctrine\Common\Collections\Collection
36
+ */
37
+ private \Doctrine \Common \Collections \Collection $ trainingTerms ;
38
+
39
+ public function __construct ()
40
+ {
41
+ }
42
+ }
43
+
44
+ ?>
Original file line number Diff line number Diff line change 7
7
use PhpParser \Node \Expr ;
8
8
use PhpParser \Node \Param ;
9
9
use PhpParser \Node \Stmt \Property ;
10
+ use PHPStan \Type \ObjectType ;
10
11
use PHPStan \Type \Type ;
11
12
use Rector \BetterPhpDocParser \PhpDoc \ArrayItemNode ;
12
13
use Rector \BetterPhpDocParser \PhpDoc \DoctrineAnnotationTagValueNode ;
@@ -65,7 +66,8 @@ private function processToManyRelation(
65
66
EntityMappingKey::TARGET_ENTITY
66
67
) ?: $ doctrineAnnotationTagValueNode ->getValue (OdmMappingKey::TARGET_DOCUMENT );
67
68
if (! $ targetEntityArrayItemNode instanceof ArrayItemNode) {
68
- return null ;
69
+ // most likely mapped superclass
70
+ return new ObjectType (DoctrineClass::COLLECTION );
69
71
}
70
72
71
73
$ targetEntityClass = $ targetEntityArrayItemNode ->value ;
You can’t perform that action at this time.
0 commit comments