From 88c2b9be6294356e0a239e7506e3557af5f7176a Mon Sep 17 00:00:00 2001 From: moldman Date: Tue, 1 Dec 2020 17:34:07 +0200 Subject: [PATCH] [String] Fix Notice when argument is empty string --- .../Component/String/Inflector/EnglishInflector.php | 1 + .../Component/String/Tests/EnglishInflectorTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Symfony/Component/String/Inflector/EnglishInflector.php b/src/Symfony/Component/String/Inflector/EnglishInflector.php index 4cd05434d1772..71e6a90db687a 100644 --- a/src/Symfony/Component/String/Inflector/EnglishInflector.php +++ b/src/Symfony/Component/String/Inflector/EnglishInflector.php @@ -305,6 +305,7 @@ final class EnglishInflector implements InflectorInterface * A list of words which should not be inflected, reversed. */ private static $uninflected = [ + '', 'atad', 'reed', 'kcabdeef', diff --git a/src/Symfony/Component/String/Tests/EnglishInflectorTest.php b/src/Symfony/Component/String/Tests/EnglishInflectorTest.php index 51b362bb2f768..04935568cde69 100644 --- a/src/Symfony/Component/String/Tests/EnglishInflectorTest.php +++ b/src/Symfony/Component/String/Tests/EnglishInflectorTest.php @@ -306,4 +306,16 @@ public function testPluralize(string $singular, $plural) { $this->assertSame(\is_array($plural) ? $plural : [$plural], (new EnglishInflector())->pluralize($singular)); } + + public function testPluralizeEmptyString() + { + $plural = (new EnglishInflector())->pluralize(''); + $this->assertSame([''], $plural); + } + + public function testSingularizeEmptyString() + { + $singular = (new EnglishInflector())->singularize(''); + $this->assertSame([''], $singular); + } }