update v1.0.4
This commit is contained in:
12
vendor/doctrine/inflector/.travis.yml
vendored
12
vendor/doctrine/inflector/.travis.yml
vendored
@@ -1,11 +1,21 @@
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directory:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
|
||||
install:
|
||||
- composer --prefer-source install
|
||||
- composer install -n
|
||||
|
||||
script:
|
||||
- phpunit
|
||||
|
||||
2
vendor/doctrine/inflector/LICENSE
vendored
2
vendor/doctrine/inflector/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2006-2013 Doctrine Project
|
||||
Copyright (c) 2006-2015 Doctrine Project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
2
vendor/doctrine/inflector/composer.json
vendored
2
vendor/doctrine/inflector/composer.json
vendored
@@ -23,7 +23,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,11 +56,12 @@ class Inflector
|
||||
'/(p)erson$/i' => '\1eople',
|
||||
'/(m)an$/i' => '\1en',
|
||||
'/(c)hild$/i' => '\1hildren',
|
||||
'/(buffal|tomat)o$/i' => '\1\2oes',
|
||||
'/(f)oot$/i' => '\1eet',
|
||||
'/(buffal|her|potat|tomat|volcan)o$/i' => '\1\2oes',
|
||||
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
|
||||
'/us$/i' => 'uses',
|
||||
'/(alias)$/i' => '\1es',
|
||||
'/(ax|cris|test)is$/i' => '\1es',
|
||||
'/(analys|ax|cris|test|thes)is$/i' => '\1es',
|
||||
'/s$/' => 's',
|
||||
'/^$/' => '',
|
||||
'/$/' => 's',
|
||||
@@ -70,27 +71,42 @@ class Inflector
|
||||
),
|
||||
'irregular' => array(
|
||||
'atlas' => 'atlases',
|
||||
'axe' => 'axes',
|
||||
'beef' => 'beefs',
|
||||
'brother' => 'brothers',
|
||||
'cafe' => 'cafes',
|
||||
'chateau' => 'chateaux',
|
||||
'child' => 'children',
|
||||
'cookie' => 'cookies',
|
||||
'corpus' => 'corpuses',
|
||||
'cow' => 'cows',
|
||||
'criteria' => 'criterion',
|
||||
'criterion' => 'criteria',
|
||||
'curriculum' => 'curricula',
|
||||
'demo' => 'demos',
|
||||
'domino' => 'dominoes',
|
||||
'echo' => 'echoes',
|
||||
'foot' => 'feet',
|
||||
'fungus' => 'fungi',
|
||||
'ganglion' => 'ganglions',
|
||||
'genie' => 'genies',
|
||||
'genus' => 'genera',
|
||||
'graffito' => 'graffiti',
|
||||
'hippopotamus' => 'hippopotami',
|
||||
'hoof' => 'hoofs',
|
||||
'human' => 'humans',
|
||||
'iris' => 'irises',
|
||||
'leaf' => 'leaves',
|
||||
'loaf' => 'loaves',
|
||||
'man' => 'men',
|
||||
'medium' => 'media',
|
||||
'memorandum' => 'memoranda',
|
||||
'money' => 'monies',
|
||||
'mongoose' => 'mongooses',
|
||||
'motto' => 'mottoes',
|
||||
'move' => 'moves',
|
||||
'mythos' => 'mythoi',
|
||||
'niche' => 'niches',
|
||||
'nucleus' => 'nuclei',
|
||||
'numen' => 'numina',
|
||||
'occiput' => 'occiputs',
|
||||
'octopus' => 'octopuses',
|
||||
@@ -98,11 +114,19 @@ class Inflector
|
||||
'ox' => 'oxen',
|
||||
'penis' => 'penises',
|
||||
'person' => 'people',
|
||||
'plateau' => 'plateaux',
|
||||
'runner-up' => 'runners-up',
|
||||
'sex' => 'sexes',
|
||||
'soliloquy' => 'soliloquies',
|
||||
'son-in-law' => 'sons-in-law',
|
||||
'syllabus' => 'syllabi',
|
||||
'testis' => 'testes',
|
||||
'thief' => 'thieves',
|
||||
'tooth' => 'teeth',
|
||||
'tornado' => 'tornadoes',
|
||||
'trilby' => 'trilbys',
|
||||
'turf' => 'turfs',
|
||||
'volcano' => 'volcanoes',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -120,9 +144,10 @@ class Inflector
|
||||
'/(vert|ind)ices$/i' => '\1ex',
|
||||
'/^(ox)en/i' => '\1',
|
||||
'/(alias)(es)*$/i' => '\1',
|
||||
'/(buffal|her|potat|tomat|volcan)oes$/i' => '\1o',
|
||||
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
|
||||
'/([ftw]ax)es/i' => '\1',
|
||||
'/(cris|ax|test)es$/i' => '\1is',
|
||||
'/(analys|ax|cris|test|thes)es$/i' => '\1is',
|
||||
'/(shoe|slave)s$/i' => '\1',
|
||||
'/(o)es$/i' => '\1',
|
||||
'/ouses$/' => 'ouse',
|
||||
@@ -143,6 +168,7 @@ class Inflector
|
||||
'/(p)eople$/i' => '\1\2erson',
|
||||
'/(m)en$/i' => '\1an',
|
||||
'/(c)hildren$/i' => '\1\2hild',
|
||||
'/(f)eet$/i' => '\1oot',
|
||||
'/(n)ews$/i' => '\1\2ews',
|
||||
'/eaus$/' => 'eau',
|
||||
'/^(.*us)$/' => '\\1',
|
||||
@@ -159,10 +185,15 @@ class Inflector
|
||||
'.*ss',
|
||||
),
|
||||
'irregular' => array(
|
||||
'criterion' => 'criteria',
|
||||
'curves' => 'curve',
|
||||
'foes' => 'foe',
|
||||
'waves' => 'wave',
|
||||
'criteria' => 'criterion',
|
||||
'curves' => 'curve',
|
||||
'emphases' => 'emphasis',
|
||||
'foes' => 'foe',
|
||||
'hoaxes' => 'hoax',
|
||||
'media' => 'medium',
|
||||
'neuroses' => 'neurosis',
|
||||
'waves' => 'wave',
|
||||
'oases' => 'oasis',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -236,6 +267,42 @@ class Inflector
|
||||
return lcfirst(self::classify($word));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uppercases words with configurable delimeters between words.
|
||||
*
|
||||
* Takes a string and capitalizes all of the words, like PHP's built-in
|
||||
* ucwords function. This extends that behavior, however, by allowing the
|
||||
* word delimeters to be configured, rather than only separating on
|
||||
* whitespace.
|
||||
*
|
||||
* Here is an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* $string = 'top-o-the-morning to all_of_you!';
|
||||
* echo \Doctrine\Common\Inflector\Inflector::ucwords($string);
|
||||
* // Top-O-The-Morning To All_of_you!
|
||||
*
|
||||
* echo \Doctrine\Common\Inflector\Inflector::ucwords($string, '-_ ');
|
||||
* // Top-O-The-Morning To All_Of_You!
|
||||
* ?>
|
||||
* </code>
|
||||
*
|
||||
* @param string $string The string to operate on.
|
||||
* @param string $delimiters A list of word separators.
|
||||
*
|
||||
* @return string The string with all delimeter-separated words capitalized.
|
||||
*/
|
||||
public static function ucwords($string, $delimiters = " \n\t\r\0\x0B-")
|
||||
{
|
||||
return preg_replace_callback(
|
||||
'/[^' . preg_quote($delimiters, '/') . ']+/',
|
||||
function($matches) {
|
||||
return ucfirst($matches[0]);
|
||||
},
|
||||
$string
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears Inflectors inflected value caches, and resets the inflection
|
||||
* rules to the initial values.
|
||||
|
||||
@@ -16,52 +16,131 @@ class InflectorTest extends DoctrineTestCase
|
||||
{
|
||||
Inflector::reset();
|
||||
|
||||
// in the format array('singular', 'plural')
|
||||
// In the format array('singular', 'plural')
|
||||
return array(
|
||||
array('categoria', 'categorias'),
|
||||
array('house', 'houses'),
|
||||
array('powerhouse', 'powerhouses'),
|
||||
array('Bus', 'Buses'),
|
||||
array('bus', 'buses'),
|
||||
array('menu', 'menus'),
|
||||
array('news', 'news'),
|
||||
array('food_menu', 'food_menus'),
|
||||
array('Menu', 'Menus'),
|
||||
array('FoodMenu', 'FoodMenus'),
|
||||
array('quiz', 'quizzes'),
|
||||
array('matrix_row', 'matrix_rows'),
|
||||
array('matrix', 'matrices'),
|
||||
array('vertex', 'vertices'),
|
||||
array('index', 'indices'),
|
||||
array('Alias', 'Aliases'),
|
||||
array('Media', 'Media'),
|
||||
array('NodeMedia', 'NodeMedia'),
|
||||
array('alumnus', 'alumni'),
|
||||
array('bacillus', 'bacilli'),
|
||||
array('cactus', 'cacti'),
|
||||
array('focus', 'foci'),
|
||||
array('fungus', 'fungi'),
|
||||
array('nucleus', 'nuclei'),
|
||||
array('octopus', 'octopuses'),
|
||||
array('radius', 'radii'),
|
||||
array('stimulus', 'stimuli'),
|
||||
array('syllabus', 'syllabi'),
|
||||
array('terminus', 'termini'),
|
||||
array('virus', 'viri'),
|
||||
array('person', 'people'),
|
||||
array('glove', 'gloves'),
|
||||
array('crisis', 'crises'),
|
||||
array('tax', 'taxes'),
|
||||
array('wave', 'waves'),
|
||||
array('bureau', 'bureaus'),
|
||||
array('cafe', 'cafes'),
|
||||
array('roof', 'roofs'),
|
||||
array('foe', 'foes'),
|
||||
array('cookie', 'cookies'),
|
||||
array('identity', 'identities'),
|
||||
array('criteria', 'criterion'),
|
||||
array('curve', 'curves'),
|
||||
array('', ''),
|
||||
array('Alias', 'Aliases'),
|
||||
array('alumnus', 'alumni'),
|
||||
array('analysis', 'analyses'),
|
||||
array('aquarium', 'aquaria'),
|
||||
array('arch', 'arches'),
|
||||
array('atlas', 'atlases'),
|
||||
array('axe', 'axes'),
|
||||
array('baby', 'babies'),
|
||||
array('bacillus', 'bacilli'),
|
||||
array('bacterium', 'bacteria'),
|
||||
array('bureau', 'bureaus'),
|
||||
array('bus', 'buses'),
|
||||
array('Bus', 'Buses'),
|
||||
array('cactus', 'cacti'),
|
||||
array('cafe', 'cafes'),
|
||||
array('calf', 'calves'),
|
||||
array('categoria', 'categorias'),
|
||||
array('chateau', 'chateaux'),
|
||||
array('cherry', 'cherries'),
|
||||
array('child', 'children'),
|
||||
array('church', 'churches'),
|
||||
array('circus', 'circuses'),
|
||||
array('city', 'cities'),
|
||||
array('cod', 'cod'),
|
||||
array('cookie', 'cookies'),
|
||||
array('copy', 'copies'),
|
||||
array('crisis', 'crises'),
|
||||
array('criterion', 'criteria'),
|
||||
array('curriculum', 'curricula'),
|
||||
array('curve', 'curves'),
|
||||
array('deer', 'deer'),
|
||||
array('demo', 'demos'),
|
||||
array('dictionary', 'dictionaries'),
|
||||
array('domino', 'dominoes'),
|
||||
array('dwarf', 'dwarves'),
|
||||
array('echo', 'echoes'),
|
||||
array('elf', 'elves'),
|
||||
array('emphasis', 'emphases'),
|
||||
array('family', 'families'),
|
||||
array('fax', 'faxes'),
|
||||
array('fish', 'fish'),
|
||||
array('flush', 'flushes'),
|
||||
array('fly', 'flies'),
|
||||
array('focus', 'foci'),
|
||||
array('foe', 'foes'),
|
||||
array('food_menu', 'food_menus'),
|
||||
array('FoodMenu', 'FoodMenus'),
|
||||
array('foot', 'feet'),
|
||||
array('fungus', 'fungi'),
|
||||
array('glove', 'gloves'),
|
||||
array('half', 'halves'),
|
||||
array('hero', 'heroes'),
|
||||
array('hippopotamus', 'hippopotami'),
|
||||
array('hoax', 'hoaxes'),
|
||||
array('house', 'houses'),
|
||||
array('human', 'humans'),
|
||||
array('identity', 'identities'),
|
||||
array('index', 'indices'),
|
||||
array('iris', 'irises'),
|
||||
array('kiss', 'kisses'),
|
||||
array('knife', 'knives'),
|
||||
array('leaf', 'leaves'),
|
||||
array('life', 'lives'),
|
||||
array('loaf', 'loaves'),
|
||||
array('man', 'men'),
|
||||
array('matrix', 'matrices'),
|
||||
array('matrix_row', 'matrix_rows'),
|
||||
array('medium', 'media'),
|
||||
array('memorandum', 'memoranda'),
|
||||
array('menu', 'menus'),
|
||||
array('Menu', 'Menus'),
|
||||
array('mess', 'messes'),
|
||||
array('moose', 'moose'),
|
||||
array('motto', 'mottoes'),
|
||||
array('mouse', 'mice'),
|
||||
array('neurosis', 'neuroses'),
|
||||
array('news', 'news'),
|
||||
array('NodeMedia', 'NodeMedia'),
|
||||
array('nucleus', 'nuclei'),
|
||||
array('oasis', 'oases'),
|
||||
array('octopus', 'octopuses'),
|
||||
array('pass', 'passes'),
|
||||
array('person', 'people'),
|
||||
array('plateau', 'plateaux'),
|
||||
array('potato', 'potatoes'),
|
||||
array('powerhouse', 'powerhouses'),
|
||||
array('quiz', 'quizzes'),
|
||||
array('radius', 'radii'),
|
||||
array('reflex', 'reflexes'),
|
||||
array('roof', 'roofs'),
|
||||
array('runner-up', 'runners-up'),
|
||||
array('scarf', 'scarves'),
|
||||
array('scratch', 'scratches'),
|
||||
array('series', 'series'),
|
||||
array('sheep', 'sheep'),
|
||||
array('shelf', 'shelves'),
|
||||
array('shoe', 'shoes'),
|
||||
array('son-in-law', 'sons-in-law'),
|
||||
array('species', 'species'),
|
||||
array('splash', 'splashes'),
|
||||
array('spy', 'spies'),
|
||||
array('stimulus', 'stimuli'),
|
||||
array('stitch', 'stitches'),
|
||||
array('story', 'stories'),
|
||||
array('syllabus', 'syllabi'),
|
||||
array('tax', 'taxes'),
|
||||
array('terminus', 'termini'),
|
||||
array('thesis', 'theses'),
|
||||
array('thief', 'thieves'),
|
||||
array('tomato', 'tomatoes'),
|
||||
array('tooth', 'teeth'),
|
||||
array('tornado', 'tornadoes'),
|
||||
array('try', 'tries'),
|
||||
array('vertex', 'vertices'),
|
||||
array('virus', 'viri'),
|
||||
array('volcano', 'volcanoes'),
|
||||
array('wash', 'washes'),
|
||||
array('watch', 'watches'),
|
||||
array('wave', 'waves'),
|
||||
array('wharf', 'wharves'),
|
||||
array('wife', 'wives'),
|
||||
array('woman', 'women'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -206,5 +285,25 @@ class InflectorTest extends DoctrineTestCase
|
||||
$this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
|
||||
$this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic ucwords functionality.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUcwords()
|
||||
{
|
||||
$this->assertSame('Top-O-The-Morning To All_of_you!', Inflector::ucwords( 'top-o-the-morning to all_of_you!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ucwords functionality with custom delimeters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUcwordsWithCustomDelimeters()
|
||||
{
|
||||
$this->assertSame('Top-O-The-Morning To All_Of_You!', Inflector::ucwords( 'top-o-the-morning to all_of_you!', '-_ '));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user