File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed
app/helpers/MetaFormats/AnnotationConversion Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -226,11 +226,15 @@ public static function convertRegexCapturesToParenthesesBuilder(array $annotatio
226
226
}
227
227
$ validation = $ annotationParameters ["validation " ];
228
228
229
- if (Utils::checkValidationNullability ($ validation )) {
230
- // remove the '|null' from the end of the string
231
- $ validation = substr ($ validation , 0 , -5 );
229
+ // check nullability
230
+ // validation strings contain the 'null' qualifier always at the end of the string.
231
+ $ nullabilitySuffix = "|null " ;
232
+ if (str_ends_with ($ validation , $ nullabilitySuffix )) {
233
+ // remove the '|null'
234
+ $ validation = substr ($ validation , 0 , -strlen ($ nullabilitySuffix ));
232
235
$ nullable = true ;
233
236
}
237
+
234
238
// this will always produce a single validator (the annotations do not contain multiple validation fields)
235
239
$ validator = self ::convertAnnotationValidationToValidatorString ($ validation );
236
240
$ parenthesesBuilder ->addValue (value: $ validator );
Original file line number Diff line number Diff line change @@ -29,17 +29,6 @@ public static function shortenClass(string $className)
29
29
return end ($ tokens );
30
30
}
31
31
32
- /**
33
- * Checks whether the validation string ends with the "|null" suffix.
34
- * Validation strings contain the "null" qualifier always at the end of the string.
35
- * @param string $validation The validation string.
36
- * @return bool Returns whether the validation ends with "|null".
37
- */
38
- public static function checkValidationNullability (string $ validation ): bool
39
- {
40
- return str_ends_with ($ validation , "|null " );
41
- }
42
-
43
32
/**
44
33
* Splits a string into lines.
45
34
* @param string $fileContent The string to be split.
You can’t perform that action at this time.
0 commit comments