File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
rules-tests/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/Doctrine
rules/TypeDeclaration/Rector/Property Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclaration \Rector \Property \TypedPropertyFromAssignsRector \Fixture \Doctrine ;
4+
5+ use Doctrine \ORM \Mapping as ORM ;
6+
7+ final class SkipColumn
8+ {
9+ /**
10+ * @ORM\Column(name="userID", type="integer", nullable=false)
11+ * @ORM\Id
12+ */
13+ private $ someId = '0 ' ;
14+ }
Original file line number Diff line number Diff line change 1919use Rector \Contract \Rector \ConfigurableRectorInterface ;
2020use Rector \DeadCode \PhpDoc \TagRemover \VarTagRemover ;
2121use Rector \Doctrine \CodeQuality \Enum \CollectionMapping ;
22+ use Rector \Doctrine \Enum \MappingClass ;
2223use Rector \Doctrine \NodeAnalyzer \AttrinationFinder ;
2324use Rector \Php74 \Guard \MakePropertyTypedGuard ;
2425use Rector \PhpParser \Node \Value \ValueResolver ;
@@ -135,8 +136,7 @@ public function refactor(Node $node): ?Node
135136 continue ;
136137 }
137138
138- // doctrine colleciton is handled in doctrine rules
139- if ($ this ->attrinationFinder ->hasByMany ($ property , CollectionMapping::TO_MANY_CLASSES )) {
139+ if ($ this ->isDoctrineMappedProperty ($ property )) {
140140 continue ;
141141 }
142142
@@ -217,4 +217,18 @@ private function decorateTypeWithNullableIfDefaultPropertyNull(Property $propert
217217
218218 return TypeCombinator::addNull ($ inferredType );
219219 }
220+
221+ /**
222+ * Doctrine properties are handled in doctrine rules
223+ */
224+ private function isDoctrineMappedProperty (Property $ property ): bool
225+ {
226+ $ mappingClasses = array_merge (
227+ CollectionMapping::TO_MANY_CLASSES ,
228+ CollectionMapping::TO_ONE_CLASSES ,
229+ [MappingClass::COLUMN ]
230+ );
231+
232+ return $ this ->attrinationFinder ->hasByMany ($ property , $ mappingClasses );
233+ }
220234}
You can’t perform that action at this time.
0 commit comments