Skip to content

Commit a86d53b

Browse files
committed
inlined a function
1 parent 74eba85 commit a86d53b

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

app/helpers/MetaFormats/AnnotationConversion/NetteAnnotationConverter.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,15 @@ public static function convertRegexCapturesToParenthesesBuilder(array $annotatio
226226
}
227227
$validation = $annotationParameters["validation"];
228228

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));
232235
$nullable = true;
233236
}
237+
234238
// this will always produce a single validator (the annotations do not contain multiple validation fields)
235239
$validator = self::convertAnnotationValidationToValidatorString($validation);
236240
$parenthesesBuilder->addValue(value: $validator);

app/helpers/MetaFormats/AnnotationConversion/Utils.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ public static function shortenClass(string $className)
2929
return end($tokens);
3030
}
3131

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-
4332
/**
4433
* Splits a string into lines.
4534
* @param string $fileContent The string to be split.

0 commit comments

Comments
 (0)