34
34
class EntityColumnRule implements Rule
35
35
{
36
36
37
- /** @var ObjectMetadataResolver */
38
- private $ objectMetadataResolver ;
37
+ private ObjectMetadataResolver $ objectMetadataResolver ;
39
38
40
- /** @var DescriptorRegistry */
41
- private $ descriptorRegistry ;
39
+ private DescriptorRegistry $ descriptorRegistry ;
42
40
43
- /** @var ReflectionProvider */
44
- private $ reflectionProvider ;
41
+ private ReflectionProvider $ reflectionProvider ;
45
42
46
- /** @var bool */
47
- private $ reportUnknownTypes ;
43
+ private bool $ reportUnknownTypes ;
48
44
49
- /** @var bool */
50
- private $ allowNullablePropertyForRequiredField ;
45
+ private bool $ allowNullablePropertyForRequiredField ;
51
46
52
- /** @var bool */
53
- private $ bleedingEdge ;
47
+ private bool $ bleedingEdge ;
54
48
55
49
public function __construct (
56
50
ObjectMetadataResolver $ objectMetadataResolver ,
@@ -106,7 +100,7 @@ public function processNode(Node $node, Scope $scope): array
106
100
'Property %s::$%s: Doctrine type "%s" does not have any registered descriptor. ' ,
107
101
$ className ,
108
102
$ propertyName ,
109
- $ fieldMapping ['type ' ]
103
+ $ fieldMapping ['type ' ],
110
104
))->identifier ('doctrine.descriptorNotFound ' )->build (),
111
105
] : [];
112
106
}
@@ -128,7 +122,7 @@ public function processNode(Node $node, Scope $scope): array
128
122
$ propertyName ,
129
123
$ backedEnumType ->describe (VerbosityLevel::typeOnly ()),
130
124
$ enumReflection ->getDisplayName (),
131
- $ writableToDatabaseType ->describe (VerbosityLevel::typeOnly ())
125
+ $ writableToDatabaseType ->describe (VerbosityLevel::typeOnly ()),
132
126
))->identifier ('doctrine.enumType ' )->build ();
133
127
}
134
128
}
@@ -151,20 +145,20 @@ public function processNode(Node $node, Scope $scope): array
151
145
$ backedEnumType ->describe (VerbosityLevel::typeOnly ()),
152
146
$ enumReflection ->getDisplayName (),
153
147
$ writableToDatabaseType ->getIterableValueType ()->describe (VerbosityLevel::typeOnly ()),
154
- $ writableToDatabaseType ->describe (VerbosityLevel::typeOnly ())
155
- )
148
+ $ writableToDatabaseType ->describe (VerbosityLevel::typeOnly ()),
149
+ ),
156
150
)->identifier ('doctrine.enumType ' )->build ();
157
151
}
158
152
}
159
153
}
160
154
161
155
$ writableToPropertyType = TypeCombinator::intersect (new ArrayType (
162
156
$ writableToPropertyType ->getIterableKeyType (),
163
- $ enumType
157
+ $ enumType,
164
158
), ...TypeUtils::getAccessoryTypes ($ writableToPropertyType ));
165
159
$ writableToDatabaseType = TypeCombinator::intersect (new ArrayType (
166
160
$ writableToDatabaseType ->getIterableKeyType (),
167
- $ enumType
161
+ $ enumType,
168
162
), ...TypeUtils::getAccessoryTypes ($ writableToDatabaseType ));
169
163
170
164
}
@@ -211,23 +205,23 @@ public function processNode(Node $node, Scope $scope): array
211
205
$ className ,
212
206
$ propertyName ,
213
207
$ writableToPropertyType ->describe (VerbosityLevel::getRecommendedLevelByType ($ propertyTransformedType , $ writableToPropertyType )),
214
- $ propertyType ->describe (VerbosityLevel::getRecommendedLevelByType ($ propertyTransformedType , $ writableToPropertyType ))
208
+ $ propertyType ->describe (VerbosityLevel::getRecommendedLevelByType ($ propertyTransformedType , $ writableToPropertyType )),
215
209
))->identifier ('doctrine.columnType ' )->build ();
216
210
}
217
211
218
212
if (
219
213
!$ writableToDatabaseType ->isSuperTypeOf (
220
214
$ this ->allowNullablePropertyForRequiredField || (in_array ($ propertyName , $ identifiers , true ) && !$ nullable )
221
215
? TypeCombinator::removeNull ($ propertyType )
222
- : $ propertyType
216
+ : $ propertyType,
223
217
)->yes ()
224
218
) {
225
219
$ errors [] = RuleErrorBuilder::message (sprintf (
226
220
'Property %s::$%s type mapping mismatch: property can contain %s but database expects %s. ' ,
227
221
$ className ,
228
222
$ propertyName ,
229
223
$ propertyTransformedType ->describe (VerbosityLevel::getRecommendedLevelByType ($ writableToDatabaseType , $ propertyType )),
230
- $ writableToDatabaseType ->describe (VerbosityLevel::getRecommendedLevelByType ($ writableToDatabaseType , $ propertyType ))
224
+ $ writableToDatabaseType ->describe (VerbosityLevel::getRecommendedLevelByType ($ writableToDatabaseType , $ propertyType )),
231
225
))->identifier ('doctrine.columnType ' )->build ();
232
226
}
233
227
return $ errors ;
0 commit comments