File tree Expand file tree Collapse file tree
rules-tests/CodeQuality/Rector/Class_/TypeNullableEntityFromDocblockRector/Fixture
rules/CodeQuality/Rector/Class_ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Doctrine \Tests \CodeQuality \Rector \Class_ \TypeNullableEntityFromDocblockRector \Fixture ;
4+
5+ use Doctrine \ORM \Mapping as ORM ;
6+
7+ /**
8+ * @ORM\Entity()
9+ */
10+ class DocblockEntityWithParamReturnDescription
11+ {
12+ /**
13+ * @var string
14+ * @ORM\Id
15+ * @ORM\Column(type="string")
16+ * @ORM\GeneratedValue
17+ */
18+ private $ name ;
19+
20+ /**
21+ * @return string some description
22+ */
23+ public function getName ()
24+ {
25+ return $ this ->name ;
26+ }
27+
28+ /**
29+ * @param string $name some description
30+ */
31+ public function setName ($ name ): void
32+ {
33+ $ this ->name = $ name ;
34+ }
35+ }
36+
37+
38+ ?>
39+ -----
40+ <?php
41+
42+ namespace Rector \Doctrine \Tests \CodeQuality \Rector \Class_ \TypeNullableEntityFromDocblockRector \Fixture ;
43+
44+ use Doctrine \ORM \Mapping as ORM ;
45+
46+ /**
47+ * @ORM\Entity()
48+ */
49+ class DocblockEntityWithParamReturnDescription
50+ {
51+ /**
52+ * @ORM\Id
53+ * @ORM\Column(type="string")
54+ * @ORM\GeneratedValue
55+ */
56+ private ?string $ name = null ;
57+
58+ /**
59+ * @return string some description
60+ */
61+ public function getName (): ?string
62+ {
63+ return $ this ->name ;
64+ }
65+
66+ /**
67+ * @param string $name some description
68+ */
69+ public function setName (?string $ name ): void
70+ {
71+ $ this ->name = $ name ;
72+ }
73+ }
74+
75+
76+ ?>
Original file line number Diff line number Diff line change @@ -267,6 +267,11 @@ private function removeParamDocblock(ClassMethod $classMethod): void
267267 return ;
268268 }
269269
270+ $ paramTagValueNode = $ classMethodPhpDocInfo ->getParamTagValueNodes ()[0 ] ?? null ;
271+ if ($ paramTagValueNode instanceof ParamTagValueNode && $ paramTagValueNode ->description !== '' ) {
272+ return ;
273+ }
274+
270275 $ classMethodPhpDocInfo ->removeByType (ParamTagValueNode::class);
271276 $ this ->docBlockUpdater ->updateRefactoredNodeWithPhpDocInfo ($ classMethod );
272277 }
@@ -282,6 +287,10 @@ private function removeReturnDocblock(ClassMethod $classMethod): void
282287 return ;
283288 }
284289
290+ if ($ classMethodPhpDocInfo ->getReturnTagValue ()->description !== '' ) {
291+ return ;
292+ }
293+
285294 $ classMethodPhpDocInfo ->removeByType (ReturnTagValueNode::class);
286295 $ this ->docBlockUpdater ->updateRefactoredNodeWithPhpDocInfo ($ classMethod );
287296 }
You can’t perform that action at this time.
0 commit comments