From e9e32ed4f45770feecb6ba810784392eea85f236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Votruba?= Date: Tue, 17 Feb 2015 13:30:33 +0100 Subject: [PATCH] [PropertyAccess] StringUtil miss-singularize some "ee" words | Q | A | ------------- | --- | Bug fix? | [yes] | New feature? | [no] | BC breaks? | [no] | Deprecations? | [no] | Tests pass? | [yes] | Fixed tickets | [no] | License | MIT | Doc PR | [n/a] Fixes misspelling of words like: - street => stroot - fleet => floot Is this proper way to fix this? Can add tests if required. --- src/Symfony/Component/PropertyAccess/StringUtil.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 29da09755cd14..0ca6198019c11 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -111,6 +111,11 @@ class StringUtil array('xuae', 4, false, true, 'eau'), ); + /** + * @var string[] + */ + private static $allowedEes = array('Fleet', 'Street'); + /** * This class should not be instantiated. */ @@ -197,7 +202,7 @@ public static function singularify($plural) } // Convert teeth to tooth, feet to foot - if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3) { + if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3 ! in_array($plural, self::$allowedEes)) { return substr_replace($plural, 'oo', $pos, 2); }