Commaaa2
This commit is contained in:
124
vendor/symfony/string/Inflector/EnglishInflector.php
vendored
124
vendor/symfony/string/Inflector/EnglishInflector.php
vendored
@@ -21,12 +21,36 @@ 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
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
['a', 1, true, true, ['on', 'um']],
|
||||
// bacteria (bacterium)
|
||||
['airetcab', 8, true, true, 'bacterium'],
|
||||
|
||||
// corpora (corpus)
|
||||
['aroproc', 7, true, true, 'corpus'],
|
||||
|
||||
// criteria (criterion)
|
||||
['airetirc', 8, true, true, 'criterion'],
|
||||
|
||||
// curricula (curriculum)
|
||||
['alucirruc', 9, true, true, 'curriculum'],
|
||||
|
||||
// genera (genus)
|
||||
['areneg', 6, true, true, 'genus'],
|
||||
|
||||
// media (medium)
|
||||
['aidem', 5, true, true, 'medium'],
|
||||
|
||||
// memoranda (memorandum)
|
||||
['adnaromem', 9, true, true, 'memorandum'],
|
||||
|
||||
// phenomena (phenomenon)
|
||||
['anemonehp', 9, true, true, 'phenomenon'],
|
||||
|
||||
// strata (stratum)
|
||||
['atarts', 6, true, true, 'stratum'],
|
||||
|
||||
// nebulae (nebula)
|
||||
['ea', 2, true, true, 'a'],
|
||||
@@ -55,6 +79,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// indices (index), appendices (appendix), prices (price)
|
||||
['seci', 4, false, true, ['ex', 'ix', 'ice']],
|
||||
|
||||
// codes (code)
|
||||
['sedoc', 5, false, true, 'code'],
|
||||
|
||||
// selfies (selfie)
|
||||
['seifles', 7, true, true, 'selfie'],
|
||||
|
||||
@@ -64,6 +91,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// movies (movie)
|
||||
['seivom', 6, true, true, 'movie'],
|
||||
|
||||
// names (name)
|
||||
['seman', 5, true, false, 'name'],
|
||||
|
||||
// conspectuses (conspectus), prospectuses (prospectus)
|
||||
['sesutcep', 8, true, true, 'pectus'],
|
||||
|
||||
@@ -88,6 +118,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// accesses (access), addresses (address), kisses (kiss)
|
||||
['sess', 4, true, false, 'ss'],
|
||||
|
||||
// statuses (status)
|
||||
['sesutats', 8, true, true, 'status'],
|
||||
|
||||
// analyses (analysis), ellipses (ellipsis), fungi (fungus),
|
||||
// neuroses (neurosis), theses (thesis), emphases (emphasis),
|
||||
// oases (oasis), crises (crisis), houses (house), bases (base),
|
||||
@@ -132,6 +165,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// shoes (shoe)
|
||||
['se', 2, true, true, ['', 'e']],
|
||||
|
||||
// status (status)
|
||||
['sutats', 6, true, true, 'status'],
|
||||
|
||||
// tags (tag)
|
||||
['s', 1, true, true, ''],
|
||||
|
||||
@@ -150,10 +186,13 @@ 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
|
||||
|
||||
// axes (axis)
|
||||
['sixa', 4, false, false, 'axes'],
|
||||
|
||||
// criterion (criteria)
|
||||
['airetirc', 8, false, false, 'criterion'],
|
||||
|
||||
@@ -223,7 +262,10 @@ final class EnglishInflector implements InflectorInterface
|
||||
// teeth (tooth)
|
||||
['htoot', 5, true, true, 'teeth'],
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
// albums (album)
|
||||
['mubla', 5, true, true, 'albums'],
|
||||
|
||||
// bacteria (bacterium), curricula (curriculum), media (medium), memoranda (memorandum), phenomena (phenomenon), strata (stratum)
|
||||
['mu', 2, true, true, 'a'],
|
||||
|
||||
// men (man), women (woman)
|
||||
@@ -232,17 +274,11 @@ final class EnglishInflector implements InflectorInterface
|
||||
// people (person)
|
||||
['nosrep', 6, true, true, ['persons', 'people']],
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
['noi', 3, true, true, 'ions'],
|
||||
// criteria (criterion)
|
||||
['noiretirc', 9, true, true, 'criteria'],
|
||||
|
||||
// coupon (coupons)
|
||||
['nop', 3, true, true, 'pons'],
|
||||
|
||||
// seasons (season), treasons (treason), poisons (poison), lessons (lesson)
|
||||
['nos', 3, true, true, 'sons'],
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
['no', 2, true, true, 'a'],
|
||||
// phenomena (phenomenon)
|
||||
['nonemonehp', 10, true, true, 'phenomena'],
|
||||
|
||||
// echoes (echo)
|
||||
['ohce', 4, true, true, 'echoes'],
|
||||
@@ -253,6 +289,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// atlases (atlas)
|
||||
['salta', 5, true, true, 'atlases'],
|
||||
|
||||
// aliases (alias)
|
||||
['saila', 5, true, true, 'aliases'],
|
||||
|
||||
// irises (iris)
|
||||
['siri', 4, true, true, 'irises'],
|
||||
|
||||
@@ -273,6 +312,15 @@ final class EnglishInflector implements InflectorInterface
|
||||
// circuses (circus)
|
||||
['suc', 3, true, true, 'cuses'],
|
||||
|
||||
// hippocampi (hippocampus)
|
||||
['supmacoppih', 11, false, false, 'hippocampi'],
|
||||
|
||||
// campuses (campus)
|
||||
['sup', 3, true, true, 'puses'],
|
||||
|
||||
// status (status)
|
||||
['sutats', 6, true, true, ['status', 'statuses']],
|
||||
|
||||
// conspectuses (conspectus), prospectuses (prospectus)
|
||||
['sutcep', 6, true, true, 'pectuses'],
|
||||
|
||||
@@ -328,15 +376,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',
|
||||
|
||||
@@ -348,11 +411,17 @@ final class EnglishInflector implements InflectorInterface
|
||||
|
||||
// species
|
||||
'seiceps',
|
||||
|
||||
// traffic
|
||||
'ciffart',
|
||||
|
||||
// aircraft
|
||||
'tfarcria',
|
||||
|
||||
// hardware
|
||||
'erawdrah',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function singularize(string $plural): array
|
||||
{
|
||||
$pluralRev = strrev($plural);
|
||||
@@ -384,14 +453,14 @@ final class EnglishInflector implements InflectorInterface
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $pluralLength) {
|
||||
$nextIsVocal = false !== strpos('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;
|
||||
}
|
||||
@@ -429,9 +498,6 @@ final class EnglishInflector implements InflectorInterface
|
||||
return [$plural];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pluralize(string $singular): array
|
||||
{
|
||||
$singularRev = strrev($singular);
|
||||
@@ -464,14 +530,14 @@ final class EnglishInflector implements InflectorInterface
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $singularLength) {
|
||||
$nextIsVocal = false !== strpos('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;
|
||||
}
|
||||
|
||||
@@ -110,9 +110,6 @@ final class FrenchInflector implements InflectorInterface
|
||||
*/
|
||||
private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sans|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function singularize(string $plural): array
|
||||
{
|
||||
if ($this->isInflectedWord($plural)) {
|
||||
@@ -130,9 +127,6 @@ final class FrenchInflector implements InflectorInterface
|
||||
return [$plural];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pluralize(string $singular): array
|
||||
{
|
||||
if ($this->isInflectedWord($singular)) {
|
||||
|
||||
Reference in New Issue
Block a user