[Inflector] remove "internal" marker from the component
This commit is contained in:
parent
9bcea2e9f4
commit
164b45b79c
@ -15,16 +15,12 @@ namespace Symfony\Component\Inflector;
|
|||||||
* Converts words between singular and plural forms.
|
* Converts words between singular and plural forms.
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
final class Inflector
|
final class Inflector
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Map English plural to singular suffixes.
|
* Map English plural to singular suffixes.
|
||||||
*
|
*
|
||||||
* @var array
|
|
||||||
*
|
|
||||||
* @see http://english-zone.com/spelling/plurals.html
|
* @see http://english-zone.com/spelling/plurals.html
|
||||||
*/
|
*/
|
||||||
private static $pluralMap = [
|
private static $pluralMap = [
|
||||||
@ -142,11 +138,9 @@ final class Inflector
|
|||||||
/**
|
/**
|
||||||
* Map English singular to plural suffixes.
|
* Map English singular to plural suffixes.
|
||||||
*
|
*
|
||||||
* @var array
|
|
||||||
*
|
|
||||||
* @see http://english-zone.com/spelling/plurals.html
|
* @see http://english-zone.com/spelling/plurals.html
|
||||||
*/
|
*/
|
||||||
private static $singularMap = array(
|
private static $singularMap = [
|
||||||
// First entry: singular suffix, reversed
|
// First entry: singular suffix, reversed
|
||||||
// Second entry: length of singular suffix
|
// Second entry: length of singular suffix
|
||||||
// Third entry: Whether the suffix may succeed a vocal
|
// Third entry: Whether the suffix may succeed a vocal
|
||||||
@ -154,163 +148,168 @@ final class Inflector
|
|||||||
// Fifth entry: plural suffix, normal
|
// Fifth entry: plural suffix, normal
|
||||||
|
|
||||||
// criterion (criteria)
|
// criterion (criteria)
|
||||||
array('airetirc', 8, false, false, 'criterion'),
|
['airetirc', 8, false, false, 'criterion'],
|
||||||
|
|
||||||
// nebulae (nebula)
|
// nebulae (nebula)
|
||||||
array('aluben', 6, false, false, 'nebulae'),
|
['aluben', 6, false, false, 'nebulae'],
|
||||||
|
|
||||||
// children (child)
|
// children (child)
|
||||||
array('dlihc', 5, true, true, 'children'),
|
['dlihc', 5, true, true, 'children'],
|
||||||
|
|
||||||
// prices (price)
|
// prices (price)
|
||||||
array('eci', 3, false, true, 'ices'),
|
['eci', 3, false, true, 'ices'],
|
||||||
|
|
||||||
// services (service)
|
// services (service)
|
||||||
array('ecivres', 7, true, true, 'services'),
|
['ecivres', 7, true, true, 'services'],
|
||||||
|
|
||||||
// lives (life), wives (wife)
|
// lives (life), wives (wife)
|
||||||
array('efi', 3, false, true, 'ives'),
|
['efi', 3, false, true, 'ives'],
|
||||||
|
|
||||||
// selfies (selfie)
|
// selfies (selfie)
|
||||||
array('eifles', 6, true, true, 'selfies'),
|
['eifles', 6, true, true, 'selfies'],
|
||||||
|
|
||||||
// movies (movie)
|
// movies (movie)
|
||||||
array('eivom', 5, true, true, 'movies'),
|
['eivom', 5, true, true, 'movies'],
|
||||||
|
|
||||||
// lice (louse)
|
// lice (louse)
|
||||||
array('esuol', 5, false, true, 'lice'),
|
['esuol', 5, false, true, 'lice'],
|
||||||
|
|
||||||
// mice (mouse)
|
// mice (mouse)
|
||||||
array('esuom', 5, false, true, 'mice'),
|
['esuom', 5, false, true, 'mice'],
|
||||||
|
|
||||||
// geese (goose)
|
// geese (goose)
|
||||||
array('esoo', 4, false, true, 'eese'),
|
['esoo', 4, false, true, 'eese'],
|
||||||
|
|
||||||
// houses (house), bases (base)
|
// houses (house), bases (base)
|
||||||
array('es', 2, true, true, 'ses'),
|
['es', 2, true, true, 'ses'],
|
||||||
|
|
||||||
// geese (goose)
|
// geese (goose)
|
||||||
array('esoog', 5, true, true, 'geese'),
|
['esoog', 5, true, true, 'geese'],
|
||||||
|
|
||||||
// caves (cave)
|
// caves (cave)
|
||||||
array('ev', 2, true, true, 'ves'),
|
['ev', 2, true, true, 'ves'],
|
||||||
|
|
||||||
// drives (drive)
|
// drives (drive)
|
||||||
array('evird', 5, false, true, 'drives'),
|
['evird', 5, false, true, 'drives'],
|
||||||
|
|
||||||
// objectives (objective), alternative (alternatives)
|
// objectives (objective), alternative (alternatives)
|
||||||
array('evit', 4, true, true, 'tives'),
|
['evit', 4, true, true, 'tives'],
|
||||||
|
|
||||||
// moves (move)
|
// moves (move)
|
||||||
array('evom', 4, true, true, 'moves'),
|
['evom', 4, true, true, 'moves'],
|
||||||
|
|
||||||
// staves (staff)
|
// staves (staff)
|
||||||
array('ffats', 5, true, true, 'staves'),
|
['ffats', 5, true, true, 'staves'],
|
||||||
|
|
||||||
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
|
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
|
||||||
array('ff', 2, true, true, 'ffs'),
|
['ff', 2, true, true, 'ffs'],
|
||||||
|
|
||||||
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
|
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
|
||||||
array('f', 1, true, true, array('fs', 'ves')),
|
['f', 1, true, true, ['fs', 'ves']],
|
||||||
|
|
||||||
// arches (arch)
|
// arches (arch)
|
||||||
array('hc', 2, true, true, 'ches'),
|
['hc', 2, true, true, 'ches'],
|
||||||
|
|
||||||
// bushes (bush)
|
// bushes (bush)
|
||||||
array('hs', 2, true, true, 'shes'),
|
['hs', 2, true, true, 'shes'],
|
||||||
|
|
||||||
// teeth (tooth)
|
// teeth (tooth)
|
||||||
array('htoot', 5, true, true, 'teeth'),
|
['htoot', 5, true, true, 'teeth'],
|
||||||
|
|
||||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||||
array('mu', 2, true, true, 'a'),
|
['mu', 2, true, true, 'a'],
|
||||||
|
|
||||||
// echoes (echo)
|
|
||||||
array('ohce', 4, true, true, 'echoes'),
|
|
||||||
|
|
||||||
// men (man), women (woman)
|
// men (man), women (woman)
|
||||||
array('nam', 3, true, true, 'men'),
|
['nam', 3, true, true, 'men'],
|
||||||
|
|
||||||
// people (person)
|
// people (person)
|
||||||
array('nosrep', 6, true, true, array('persons', 'people')),
|
['nosrep', 6, true, true, ['persons', 'people']],
|
||||||
|
|
||||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||||
array('noi', 3, true, true, 'ions'),
|
['noi', 3, true, true, 'ions'],
|
||||||
|
|
||||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||||
array('no', 2, true, true, 'a'),
|
['no', 2, true, true, 'a'],
|
||||||
|
|
||||||
|
// echoes (echo)
|
||||||
|
['ohce', 4, true, true, 'echoes'],
|
||||||
|
|
||||||
|
// heroes (hero)
|
||||||
|
['oreh', 4, true, true, 'heroes'],
|
||||||
|
|
||||||
// atlases (atlas)
|
// atlases (atlas)
|
||||||
array('salta', 5, true, true, 'atlases'),
|
['salta', 5, true, true, 'atlases'],
|
||||||
|
|
||||||
// irises (iris)
|
// irises (iris)
|
||||||
array('siri', 4, true, true, 'irises'),
|
['siri', 4, true, true, 'irises'],
|
||||||
|
|
||||||
// analyses (analysis), ellipses (ellipsis), neuroses (neurosis)
|
// analyses (analysis), ellipses (ellipsis), neuroses (neurosis)
|
||||||
// theses (thesis), emphases (emphasis), oases (oasis),
|
// theses (thesis), emphases (emphasis), oases (oasis),
|
||||||
// crises (crisis)
|
// crises (crisis)
|
||||||
array('sis', 3, true, true, 'ses'),
|
['sis', 3, true, true, 'ses'],
|
||||||
|
|
||||||
// accesses (access), addresses (address), kisses (kiss)
|
// accesses (access), addresses (address), kisses (kiss)
|
||||||
array('ss', 2, true, false, 'sses'),
|
['ss', 2, true, false, 'sses'],
|
||||||
|
|
||||||
// syllabi (syllabus)
|
// syllabi (syllabus)
|
||||||
array('suballys', 8, true, true, 'syllabi'),
|
['suballys', 8, true, true, 'syllabi'],
|
||||||
|
|
||||||
// buses (bus)
|
// buses (bus)
|
||||||
array('sub', 3, true, true, 'buses'),
|
['sub', 3, true, true, 'buses'],
|
||||||
|
|
||||||
|
// circuses (circus)
|
||||||
|
['suc', 3, true, true, 'cuses'],
|
||||||
|
|
||||||
// fungi (fungus), alumni (alumnus), syllabi (syllabus), radii (radius)
|
// fungi (fungus), alumni (alumnus), syllabi (syllabus), radii (radius)
|
||||||
array('su', 2, true, true, 'i'),
|
['su', 2, true, true, 'i'],
|
||||||
|
|
||||||
// news (news)
|
// news (news)
|
||||||
array('swen', 4, true, true, 'news'),
|
['swen', 4, true, true, 'news'],
|
||||||
|
|
||||||
// feet (foot)
|
// feet (foot)
|
||||||
array('toof', 4, true, true, 'feet'),
|
['toof', 4, true, true, 'feet'],
|
||||||
|
|
||||||
// chateaux (chateau), bureaus (bureau)
|
// chateaux (chateau), bureaus (bureau)
|
||||||
array('uae', 3, false, true, array('eaus', 'eaux')),
|
['uae', 3, false, true, ['eaus', 'eaux']],
|
||||||
|
|
||||||
// oxen (ox)
|
// oxen (ox)
|
||||||
array('xo', 2, false, false, 'oxen'),
|
['xo', 2, false, false, 'oxen'],
|
||||||
|
|
||||||
// hoaxes (hoax)
|
// hoaxes (hoax)
|
||||||
array('xaoh', 4, true, false, 'hoaxes'),
|
['xaoh', 4, true, false, 'hoaxes'],
|
||||||
|
|
||||||
// indices (index)
|
// indices (index)
|
||||||
array('xedni', 5, false, true, array('indicies', 'indexes')),
|
['xedni', 5, false, true, ['indicies', 'indexes']],
|
||||||
|
|
||||||
// indexes (index), matrixes (matrix)
|
// indexes (index), matrixes (matrix)
|
||||||
array('x', 1, true, false, array('cies', 'xes')),
|
['x', 1, true, false, ['cies', 'xes']],
|
||||||
|
|
||||||
// appendices (appendix)
|
// appendices (appendix)
|
||||||
array('xi', 2, false, true, 'ices'),
|
['xi', 2, false, true, 'ices'],
|
||||||
|
|
||||||
// babies (baby)
|
// babies (baby)
|
||||||
array('y', 1, false, true, 'ies'),
|
['y', 1, false, true, 'ies'],
|
||||||
|
|
||||||
// quizzes (quiz)
|
// quizzes (quiz)
|
||||||
array('ziuq', 4, true, false, 'quizzes'),
|
['ziuq', 4, true, false, 'quizzes'],
|
||||||
|
|
||||||
// waltzes (waltz)
|
// waltzes (waltz)
|
||||||
array('z', 1, true, false, 'zes'),
|
['z', 1, true, true, 'zes'],
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of words which should not be inflected.
|
* A list of words which should not be inflected, reversed.
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
private static $uninflected = array(
|
private static $uninflected = [
|
||||||
'data',
|
'atad',
|
||||||
'deer',
|
'reed',
|
||||||
'feedback',
|
'kcabdeef',
|
||||||
'fish',
|
'hsif',
|
||||||
'moose',
|
'ofni',
|
||||||
'series',
|
'esoom',
|
||||||
'sheep',
|
'seires',
|
||||||
);
|
'peehs',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class should not be instantiated.
|
* This class should not be instantiated.
|
||||||
@ -327,10 +326,7 @@ final class Inflector
|
|||||||
*
|
*
|
||||||
* @param string $plural A word in plural form
|
* @param string $plural A word in plural form
|
||||||
*
|
*
|
||||||
* @return string|array The singular form or an array of possible singular
|
* @return string|array The singular form or an array of possible singular forms
|
||||||
* forms
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
public static function singularize(string $plural)
|
public static function singularize(string $plural)
|
||||||
{
|
{
|
||||||
@ -339,7 +335,7 @@ final class Inflector
|
|||||||
$pluralLength = \strlen($lowerPluralRev);
|
$pluralLength = \strlen($lowerPluralRev);
|
||||||
|
|
||||||
// Check if the word is one which is not inflected, return early if so
|
// Check if the word is one which is not inflected, return early if so
|
||||||
if (in_array(strtolower($plural), self::$uninflected, true)) {
|
if (\in_array($lowerPluralRev, self::$uninflected, true)) {
|
||||||
return $plural;
|
return $plural;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,19 +412,16 @@ final class Inflector
|
|||||||
*
|
*
|
||||||
* @param string $singular A word in plural form
|
* @param string $singular A word in plural form
|
||||||
*
|
*
|
||||||
* @return string|array The plural form or an array of possible plural
|
* @return string|array The plural form or an array of possible plural forms
|
||||||
* forms
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
public static function pluralize(string $singular)
|
public static function pluralize(string $singular)
|
||||||
{
|
{
|
||||||
$singularRev = strrev($singular);
|
$singularRev = strrev($singular);
|
||||||
$lowerSingularRev = strtolower($singularRev);
|
$lowerSingularRev = strtolower($singularRev);
|
||||||
$singularLength = strlen($lowerSingularRev);
|
$singularLength = \strlen($lowerSingularRev);
|
||||||
|
|
||||||
// Check if the word is one which is not inflected, return early if so
|
// Check if the word is one which is not inflected, return early if so
|
||||||
if (in_array(strtolower($singular), self::$uninflected, true)) {
|
if (\in_array($lowerSingularRev, self::$uninflected, true)) {
|
||||||
return $singular;
|
return $singular;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,8 +467,8 @@ final class Inflector
|
|||||||
// the singular suffix too
|
// the singular suffix too
|
||||||
$firstUpper = ctype_upper($singularRev[$j - 1]);
|
$firstUpper = ctype_upper($singularRev[$j - 1]);
|
||||||
|
|
||||||
if (is_array($newSuffix)) {
|
if (\is_array($newSuffix)) {
|
||||||
$plurals = array();
|
$plurals = [];
|
||||||
|
|
||||||
foreach ($newSuffix as $newSuffixEntry) {
|
foreach ($newSuffix as $newSuffixEntry) {
|
||||||
$plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
|
$plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
|
||||||
|
@ -3,13 +3,6 @@ Inflector Component
|
|||||||
|
|
||||||
Inflector converts words between their singular and plural forms (English only).
|
Inflector converts words between their singular and plural forms (English only).
|
||||||
|
|
||||||
Disclaimer
|
|
||||||
----------
|
|
||||||
|
|
||||||
This component is currently marked as internal. Do not use it in your own code.
|
|
||||||
Breaking changes may be introduced in the next minor version of Symfony, or the
|
|
||||||
component itself might even be removed completely.
|
|
||||||
|
|
||||||
Resources
|
Resources
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class InflectorTest extends TestCase
|
|||||||
['crises', ['cris', 'crise', 'crisis']],
|
['crises', ['cris', 'crise', 'crisis']],
|
||||||
['criteria', ['criterion', 'criterium']],
|
['criteria', ['criterion', 'criterium']],
|
||||||
['cups', 'cup'],
|
['cups', 'cup'],
|
||||||
['data', ['daton', 'datum']],
|
['data', 'data'],
|
||||||
['days', 'day'],
|
['days', 'day'],
|
||||||
['discos', 'disco'],
|
['discos', 'disco'],
|
||||||
['devices', ['devex', 'devix', 'device']],
|
['devices', ['devex', 'devix', 'device']],
|
||||||
@ -159,124 +159,124 @@ class InflectorTest extends TestCase
|
|||||||
{
|
{
|
||||||
// see http://english-zone.com/spelling/plurals.html
|
// see http://english-zone.com/spelling/plurals.html
|
||||||
// see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English
|
// see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English
|
||||||
return array(
|
return [
|
||||||
array('access', 'accesses'),
|
['access', 'accesses'],
|
||||||
array('address', 'addresses'),
|
['address', 'addresses'],
|
||||||
array('agenda', 'agendas'),
|
['agenda', 'agendas'],
|
||||||
array('alumnus', 'alumni'),
|
['alumnus', 'alumni'],
|
||||||
array('analysis', 'analyses'),
|
['analysis', 'analyses'],
|
||||||
array('antenna', 'antennas'), //antennae
|
['antenna', 'antennas'], //antennae
|
||||||
array('appendix', array('appendicies', 'appendixes')),
|
['appendix', ['appendicies', 'appendixes']],
|
||||||
array('arch', 'arches'),
|
['arch', 'arches'],
|
||||||
array('atlas', 'atlases'),
|
['atlas', 'atlases'],
|
||||||
array('axe', 'axes'),
|
['axe', 'axes'],
|
||||||
array('baby', 'babies'),
|
['baby', 'babies'],
|
||||||
array('bacterium', 'bacteria'),
|
['bacterium', 'bacteria'],
|
||||||
array('base', 'bases'),
|
['base', 'bases'],
|
||||||
array('batch', 'batches'),
|
['batch', 'batches'],
|
||||||
array('beau', array('beaus', 'beaux')),
|
['beau', ['beaus', 'beaux']],
|
||||||
array('bee', 'bees'),
|
['bee', 'bees'],
|
||||||
array('box', array('bocies', 'boxes')),
|
['box', ['bocies', 'boxes']],
|
||||||
array('boy', 'boys'),
|
['boy', 'boys'],
|
||||||
array('bureau', array('bureaus', 'bureaux')),
|
['bureau', ['bureaus', 'bureaux']],
|
||||||
array('bus', 'buses'),
|
['bus', 'buses'],
|
||||||
array('bush', 'bushes'),
|
['bush', 'bushes'],
|
||||||
array('calf', array('calfs', 'calves')),
|
['calf', ['calfs', 'calves']],
|
||||||
array('car', 'cars'),
|
['car', 'cars'],
|
||||||
array('cassette', 'cassettes'),
|
['cassette', 'cassettes'],
|
||||||
array('cave', 'caves'),
|
['cave', 'caves'],
|
||||||
array('chateau', array('chateaus', 'chateaux')),
|
['chateau', ['chateaus', 'chateaux']],
|
||||||
array('cheese', 'cheeses'),
|
['cheese', 'cheeses'],
|
||||||
array('child', 'children'),
|
['child', 'children'],
|
||||||
array('circus', 'circuses'),
|
['circus', 'circuses'],
|
||||||
array('cliff', 'cliffs'),
|
['cliff', 'cliffs'],
|
||||||
array('committee', 'committees'),
|
['committee', 'committees'],
|
||||||
array('crisis', 'crises'),
|
['crisis', 'crises'],
|
||||||
array('criteria', 'criterion'),
|
['criteria', 'criterion'],
|
||||||
array('cup', 'cups'),
|
['cup', 'cups'],
|
||||||
array('data', 'data'),
|
['data', 'data'],
|
||||||
array('day', 'days'),
|
['day', 'days'],
|
||||||
array('disco', 'discos'),
|
['disco', 'discos'],
|
||||||
array('device', 'devices'),
|
['device', 'devices'],
|
||||||
array('drive', 'drives'),
|
['drive', 'drives'],
|
||||||
array('driver', 'drivers'),
|
['driver', 'drivers'],
|
||||||
array('dwarf', array('dwarfs', 'dwarves')),
|
['dwarf', ['dwarfs', 'dwarves']],
|
||||||
array('echo', 'echoes'),
|
['echo', 'echoes'],
|
||||||
array('elf', array('elfs', 'elves')),
|
['elf', ['elfs', 'elves']],
|
||||||
array('emphasis', 'emphases'),
|
['emphasis', 'emphases'],
|
||||||
array('fax', array('facies', 'faxes')),
|
['fax', ['facies', 'faxes']],
|
||||||
array('feedback', 'feedback'),
|
['feedback', 'feedback'],
|
||||||
array('focus', 'foci'),
|
['focus', 'focuses'],
|
||||||
array('foot', 'feet'),
|
['foot', 'feet'],
|
||||||
array('formula', 'formulas'), //formulae
|
['formula', 'formulas'], //formulae
|
||||||
array('fungus', 'fungi'),
|
['fungus', 'fungi'],
|
||||||
array('garage', 'garages'),
|
['garage', 'garages'],
|
||||||
array('goose', 'geese'),
|
['goose', 'geese'],
|
||||||
array('half', array('halfs', 'halves')),
|
['half', ['halfs', 'halves']],
|
||||||
array('hat', 'hats'),
|
['hat', 'hats'],
|
||||||
array('hero', 'heroes'),
|
['hero', 'heroes'],
|
||||||
array('hippopotamus', 'hippopotami'), //hippopotamuses
|
['hippopotamus', 'hippopotami'], //hippopotamuses
|
||||||
array('hoax', 'hoaxes'),
|
['hoax', 'hoaxes'],
|
||||||
array('hoof', array('hoofs', 'hooves')),
|
['hoof', ['hoofs', 'hooves']],
|
||||||
array('house', 'houses'),
|
['house', 'houses'],
|
||||||
array('index', array('indicies', 'indexes')),
|
['index', ['indicies', 'indexes']],
|
||||||
array('ion', 'ions'),
|
['ion', 'ions'],
|
||||||
array('iris', 'irises'),
|
['iris', 'irises'],
|
||||||
array('kiss', 'kisses'),
|
['kiss', 'kisses'],
|
||||||
array('knife', 'knives'),
|
['knife', 'knives'],
|
||||||
array('lamp', 'lamps'),
|
['lamp', 'lamps'],
|
||||||
array('leaf', array('leafs', 'leaves')),
|
['leaf', ['leafs', 'leaves']],
|
||||||
array('life', 'lives'),
|
['life', 'lives'],
|
||||||
array('louse', 'lice'),
|
['louse', 'lice'],
|
||||||
array('man', 'men'),
|
['man', 'men'],
|
||||||
array('matrix', array('matricies', 'matrixes')),
|
['matrix', ['matricies', 'matrixes']],
|
||||||
array('mouse', 'mice'),
|
['mouse', 'mice'],
|
||||||
array('move', 'moves'),
|
['move', 'moves'],
|
||||||
array('movie', 'movies'),
|
['movie', 'movies'],
|
||||||
array('nebula', 'nebulae'),
|
['nebula', 'nebulae'],
|
||||||
array('neurosis', 'neuroses'),
|
['neurosis', 'neuroses'],
|
||||||
array('news', 'news'),
|
['news', 'news'],
|
||||||
array('oasis', 'oases'),
|
['oasis', 'oases'],
|
||||||
array('objective', 'objectives'),
|
['objective', 'objectives'],
|
||||||
array('ox', 'oxen'),
|
['ox', 'oxen'],
|
||||||
array('party', 'parties'),
|
['party', 'parties'],
|
||||||
array('person', array('persons', 'people')),
|
['person', ['persons', 'people']],
|
||||||
array('phenomenon', 'phenomena'),
|
['phenomenon', 'phenomena'],
|
||||||
array('photo', 'photos'),
|
['photo', 'photos'],
|
||||||
array('piano', 'pianos'),
|
['piano', 'pianos'],
|
||||||
array('plateau', array('plateaus', 'plateaux')),
|
['plateau', ['plateaus', 'plateaux']],
|
||||||
array('poppy', 'poppies'),
|
['poppy', 'poppies'],
|
||||||
array('price', 'prices'),
|
['price', 'prices'],
|
||||||
array('quiz', 'quizzes'),
|
['quiz', 'quizzes'],
|
||||||
array('radius', 'radii'),
|
['radius', 'radii'],
|
||||||
array('roof', array('roofs', 'rooves')),
|
['roof', ['roofs', 'rooves']],
|
||||||
array('rose', 'roses'),
|
['rose', 'roses'],
|
||||||
array('sandwich', 'sandwiches'),
|
['sandwich', 'sandwiches'],
|
||||||
array('scarf', array('scarfs', 'scarves')),
|
['scarf', ['scarfs', 'scarves']],
|
||||||
array('schema', 'schemas'), //schemata
|
['schema', 'schemas'], //schemata
|
||||||
array('selfie', 'selfies'),
|
['selfie', 'selfies'],
|
||||||
array('series', 'series'),
|
['series', 'series'],
|
||||||
array('service', 'services'),
|
['service', 'services'],
|
||||||
array('sheriff', 'sheriffs'),
|
['sheriff', 'sheriffs'],
|
||||||
array('shoe', 'shoes'),
|
['shoe', 'shoes'],
|
||||||
array('spy', 'spies'),
|
['spy', 'spies'],
|
||||||
array('staff', 'staves'),
|
['staff', 'staves'],
|
||||||
array('story', 'stories'),
|
['story', 'stories'],
|
||||||
array('stratum', 'strata'),
|
['stratum', 'strata'],
|
||||||
array('suitcase', 'suitcases'),
|
['suitcase', 'suitcases'],
|
||||||
array('syllabus', 'syllabi'),
|
['syllabus', 'syllabi'],
|
||||||
array('tag', 'tags'),
|
['tag', 'tags'],
|
||||||
array('thief', array('thiefs', 'thieves')),
|
['thief', ['thiefs', 'thieves']],
|
||||||
array('tooth', 'teeth'),
|
['tooth', 'teeth'],
|
||||||
array('tree', 'trees'),
|
['tree', 'trees'],
|
||||||
array('waltz', 'waltzes'),
|
['waltz', 'waltzes'],
|
||||||
array('wife', 'wives'),
|
['wife', 'wives'],
|
||||||
|
|
||||||
// test casing: if the first letter was uppercase, it should remain so
|
// test casing: if the first letter was uppercase, it should remain so
|
||||||
array('Man', 'Men'),
|
['Man', 'Men'],
|
||||||
array('GrandChild', 'GrandChildren'),
|
['GrandChild', 'GrandChildren'],
|
||||||
array('SubTree', 'SubTrees'),
|
['SubTree', 'SubTrees'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,9 +300,9 @@ class InflectorTest extends TestCase
|
|||||||
public function testPluralize($plural, $singular)
|
public function testPluralize($plural, $singular)
|
||||||
{
|
{
|
||||||
$single = Inflector::pluralize($plural);
|
$single = Inflector::pluralize($plural);
|
||||||
if (is_string($singular) && is_array($single)) {
|
if (\is_string($singular) && \is_array($single)) {
|
||||||
$this->fail("--- Expected\n`string`: ".$singular."\n+++ Actual\n`array`: ".implode(', ', $single));
|
$this->fail("--- Expected\n`string`: ".$singular."\n+++ Actual\n`array`: ".implode(', ', $single));
|
||||||
} elseif (is_array($singular) && is_string($single)) {
|
} elseif (\is_array($singular) && \is_string($single)) {
|
||||||
$this->fail("--- Expected\n`array`: ".implode(', ', $singular)."\n+++ Actual\n`string`: ".$single);
|
$this->fail("--- Expected\n`array`: ".implode(', ', $singular)."\n+++ Actual\n`string`: ".$single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user