8000 [Inflector][String] Fix Notice when argument is empty string · symfony/symfony@b9f26f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9f26f8

Browse files
committed
[Inflector][String] Fix Notice when argument is empty string
1 parent 586f5b7 commit b9f26f8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Component/String/Inflector/EnglishInflector.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ public function singularize(string $plural): array
325325
$lowerPluralRev = strtolower($pluralRev);
326326
$pluralLength = \strlen($lowerPluralRev);
327327

328-
// Check if the word is one which is not inflected, return early if so
329-
if (\in_array($lowerPluralRev, self::$uninflected, true)) {
328+
// Check if the word is one which is not inflected or is an empty string, return early if so
329+
if (\in_array($lowerPluralRev, self::$uninflected, true) || 0 === $pluralLength) {
330330
return [$plural];
331331
}
332332

@@ -404,8 +404,8 @@ public function pluralize(string $singular): array
404404
$lowerSingularRev = strtolower($singularRev);
405405
$singularLength = \strlen($lowerSingularRev);
406406

407-
// Check if the word is one which is not inflected, return early if so
408-
if (\in_array($lowerSingularRev, self::$uninflected, true)) {
407+
// Check if the word is one which is not inflected or is an empty string, return early if so
408+
if (\in_array($lowerSingularRev, self::$uninflected, true) || 0 === $singularLength) {
409409
return [$singular];
410410
}
411411

0 commit comments

Comments
 (0)
0