Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  [Cache][Lock] Fix PDO store not creating table + add tests
  Closes #51936-Added Missing translations for Czech (cs) in validators.cs.xlf file
  Added missing translations in turkish and updated validators.tr.xlf
  [Serializer] Fix denormalizing date intervals having both weeks and days
  [Validator] updated Turkish translation
  [Serializer] Fix denormalize constructor arguments
  Add some more non-countable English nouns
  Add hint that changing input arguments has no effect
  [DomCrawler] Revert "bug #52579 UriResolver support path with colons"
  [VarExporter] Fix handling mangled property names returned by __sleep()
  Update Github template for 7.1
  • Loading branch information
nicolas-grekas committed Nov 20, 2023
2 parents 13880a8 + 241641a commit de72e41
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions Inflector/EnglishInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class EnglishInflector implements InflectorInterface
private const PLURAL_MAP = [
// First entry: plural suffix, reversed
// Second entry: length of plural suffix
// Third entry: Whether the suffix may succeed a vocal
// Third entry: Whether the suffix may succeed a vowel
// Fourth entry: Whether the suffix may succeed a consonant
// Fifth entry: singular suffix, normal

Expand Down Expand Up @@ -162,7 +162,7 @@ final class EnglishInflector implements InflectorInterface
private const SINGULAR_MAP = [
// First entry: singular suffix, reversed
// Second entry: length of singular suffix
// Third entry: Whether the suffix may succeed a vocal
// Third entry: Whether the suffix may succeed a vowel
// Fourth entry: Whether the suffix may succeed a consonant
// Fifth entry: plural suffix, normal

Expand Down Expand Up @@ -343,15 +343,30 @@ final class EnglishInflector implements InflectorInterface
// deer
'reed',

// equipment
'tnempiuqe',

// feedback
'kcabdeef',

// fish
'hsif',

// health
'htlaeh',

// history
'yrotsih',

// info
'ofni',

// information
'noitamrofni',

// money
'yenom',

// moose
'esoom',

Expand All @@ -363,6 +378,9 @@ final class EnglishInflector implements InflectorInterface

// species
'seiceps',

// traffic
'ciffart',
];

public function singularize(string $plural): array
Expand Down Expand Up @@ -396,14 +414,14 @@ public function singularize(string $plural): array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $pluralLength) {
$nextIsVocal = str_contains('aeiou', $lowerPluralRev[$j]);
$nextIsVowel = str_contains('aeiou', $lowerPluralRev[$j]);

if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
if (!$map[2] && $nextIsVowel) {
// suffix may not succeed a vowel but next char is one
break;
}

if (!$map[3] && !$nextIsVocal) {
if (!$map[3] && !$nextIsVowel) {
// suffix may not succeed a consonant but next char is one
break;
}
Expand Down Expand Up @@ -473,14 +491,14 @@ public function pluralize(string $singular): array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $singularLength) {
$nextIsVocal = str_contains('aeiou', $lowerSingularRev[$j]);
$nextIsVowel = str_contains('aeiou', $lowerSingularRev[$j]);

if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
if (!$map[2] && $nextIsVowel) {
// suffix may not succeed a vowel but next char is one
break;
}

if (!$map[3] && !$nextIsVocal) {
if (!$map[3] && !$nextIsVowel) {
// suffix may not succeed a consonant but next char is one
break;
}
Expand Down

0 comments on commit de72e41

Please sign in to comment.