@@ -116,18 +116,12 @@ private function isAbstractType(TypeDoc $doc) : bool
116
116
private function guessPrimaryTypeFromConstraint (Constraint $ constraint ) : ?TypeDoc
117
117
{
118
118
// Try to guess primary types
119
- if (null !== $ this ->getMatchingClassNameIn ($ constraint , self ::STRING_CONSTRAINT_CLASS_LIST )) {
120
- return new StringDoc ();
121
- } elseif (null !== $ this ->getMatchingClassNameIn ($ constraint , self ::BOOLEAN_CONSTRAINT_CLASS_LIST )) {
122
- return new BooleanDoc ();
119
+ if (null !== ($ type = $ this ->guessSimplePrimaryTypeFromConstraint ($ constraint ))) {
120
+ return $ type ;
123
121
} elseif ($ constraint instanceof Assert \DateTime) {
124
122
return $ this ->guessDateTimeType ($ constraint );
125
123
} elseif ($ constraint instanceof Assert \Collection) {
126
124
return $ this ->guestCollectionType ($ constraint );
127
- } elseif ($ constraint instanceof Assert \Regex) {
128
- return new ScalarDoc ();
129
- } elseif ($ this ->isArrayConstraint ($ constraint )) {
130
- return new ArrayDoc ();
131
125
}
132
126
133
127
return null ;
@@ -175,4 +169,24 @@ private function isArrayConstraint(Constraint $constraint): bool
175
169
&& true === $ constraint ->multiple // << expect an array multiple choices
176
170
);
177
171
}
172
+
173
+ /**
174
+ * @param Constraint $constraint
175
+ *
176
+ * @return TypeDoc|null
177
+ */
178
+ private function guessSimplePrimaryTypeFromConstraint (Constraint $ constraint ) : ?TypeDoc
179
+ {
180
+ if (null !== $ this ->getMatchingClassNameIn ($ constraint , self ::STRING_CONSTRAINT_CLASS_LIST )) {
181
+ return new StringDoc ();
182
+ } elseif (null !== $ this ->getMatchingClassNameIn ($ constraint , self ::BOOLEAN_CONSTRAINT_CLASS_LIST )) {
183
+ return new BooleanDoc ();
184
+ } elseif ($ constraint instanceof Assert \Regex) {
185
+ return new ScalarDoc ();
186
+ } elseif ($ this ->isArrayConstraint ($ constraint )) {
187
+ return new ArrayDoc ();
188
+ }
189
+
190
+ return null ;
191
+ }
178
192
}
0 commit comments