Skip to content

Commit dede762

Browse files
[Inflector] remove "internal" marker from the component
1 parent 9bcea2e commit dede762

File tree

3 files changed

+176
-197
lines changed

3 files changed

+176
-197
lines changed

src/Symfony/Component/Inflector/Inflector.php

Lines changed: 58 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515
* Converts words between singular and plural forms.
1616
*
1717
* @author Bernhard Schussek <bschussek@gmail.com>
18-
*
19-
* @internal
2018
*/
2119
final class Inflector
2220
{
2321
/**
2422
* Map English plural to singular suffixes.
2523
*
26-
* @var array
27-
*
2824
* @see http://english-zone.com/spelling/plurals.html
2925
*/
3026
private static $pluralMap = [
@@ -142,175 +138,171 @@ final class Inflector
142138
/**
143139
* Map English singular to plural suffixes.
144140
*
145-
* @var array
146-
*
147141
* @see http://english-zone.com/spelling/plurals.html
148142
*/
149-
private static $singularMap = array(
143+
private static $singularMap = [
150144
// First entry: singular suffix, reversed
151145
// Second entry: length of singular suffix
152146
// Third entry: Whether the suffix may succeed a vocal
153147
// Fourth entry: Whether the suffix may succeed a consonant
154148
// Fifth entry: plural suffix, normal
155149

156150
// criterion (criteria)
157-
array('airetirc', 8, false, false, 'criterion'),
151+
['airetirc', 8, false, false, 'criterion'],
158152

159153
// nebulae (nebula)
160-
array('aluben', 6, false, false, 'nebulae'),
154+
['aluben', 6, false, false, 'nebulae'],
161155

162156
// children (child)
163-
array('dlihc', 5, true, true, 'children'),
157+
['dlihc', 5, true, true, 'children'],
164158

165159
// prices (price)
166-
array('eci', 3, false, true, 'ices'),
160+
['eci', 3, false, true, 'ices'],
167161

168162
// services (service)
169-
array('ecivres', 7, true, true, 'services'),
163+
['ecivres', 7, true, true, 'services'],
170164

171165
// lives (life), wives (wife)
172-
array('efi', 3, false, true, 'ives'),
166+
['efi', 3, false, true, 'ives'],
173167

174168
// selfies (selfie)
175-
array('eifles', 6, true, true, 'selfies'),
169+
['eifles', 6, true, true, 'selfies'],
176170

177171
// movies (movie)
178-
array('eivom', 5, true, true, 'movies'),
172+
['eivom', 5, true, true, 'movies'],
179173

180174
// lice (louse)
181-
array('esuol', 5, false, true, 'lice'),
175+
['esuol', 5, false, true, 'lice'],
182176

183177
// mice (mouse)
184-
array('esuom', 5, false, true, 'mice'),
178+
['esuom', 5, false, true, 'mice'],
185179

186180
// geese (goose)
187-
array('esoo', 4, false, true, 'eese'),
181+
['esoo', 4, false, true, 'eese'],
188182

189183
// houses (house), bases (base)
190-
array('es', 2, true, true, 'ses'),
184+
['es', 2, true, true, 'ses'],
191185

192186
// geese (goose)
193-
array('esoog', 5, true, true, 'geese'),
187+
['esoog', 5, true, true, 'geese'],
194188

195189
// caves (cave)
196-
array('ev', 2, true, true, 'ves'),
190+
['ev', 2, true, true, 'ves'],
197191

198192
// drives (drive)
199-
array('evird', 5, false, true, 'drives'),
193+
['evird', 5, false, true, 'drives'],
200194

201195
// objectives (objective), alternative (alternatives)
202-
array('evit', 4, true, true, 'tives'),
196+
['evit', 4, true, true, 'tives'],
203197

204198
// moves (move)
205-
array('evom', 4, true, true, 'moves'),
199+
['evom', 4, true, true, 'moves'],
206200

207201
// staves (staff)
208-
array('ffats', 5, true, true, 'staves'),
202+
['ffats', 5, true, true, 'staves'],
209203

210204
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
211-
array('ff', 2, true, true, 'ffs'),
205+
['ff', 2, true, true, 'ffs'],
212206

213207
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
214-
array('f', 1, true, true, array('fs', 'ves')),
208+
['f', 1, true, true, ['fs', 'ves']],
215209

216210
// arches (arch)
217-
array('hc', 2, true, true, 'ches'),
211+
['hc', 2, true, true, 'ches'],
218212

219213
// bushes (bush)
220-
array('hs', 2, true, true, 'shes'),
214+
['hs', 2, true, true, 'shes'],
221215

222216
// teeth (tooth)
223-
array('htoot', 5, true, true, 'teeth'),
217+
['htoot', 5, true, true, 'teeth'],
224218

225219
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
226-
array('mu', 2, true, true, 'a'),
220+
['mu', 2, true, true, 'a'],
227221

228222
// echoes (echo)
229-
array('ohce', 4, true, true, 'echoes'),
223+
['ohce', 4, true, true, 'echoes'],
230224

231225
// men (man), women (woman)
232-
array('nam', 3, true, true, 'men'),
226+
['nam', 3, true, true, 'men'],
233227

234228
// people (person)
235-
array('nosrep', 6, true, true, array('persons', 'people')),
229+
['nosrep', 6, true, true, ['persons', 'people']],
236230

237231
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
238-
array('noi', 3, true, true, 'ions'),
232+
['noi', 3, true, true, 'ions'],
239233

240234
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
241-
array('no', 2, true, true, 'a'),
235+
['no', 2, true, true, 'a'],
242236

243237
// atlases (atlas)
244-
array('salta', 5, true, true, 'atlases'),
238+
['salta', 5, true, true, 'atlases'],
245239

246240
// irises (iris)
247-
array('siri', 4, true, true, 'irises'),
241+
['siri', 4, true, true, 'irises'],
248242

249243
// analyses (analysis), ellipses (ellipsis), neuroses (neurosis)
250244
// theses (thesis), emphases (emphasis), oases (oasis),
251245
// crises (crisis)
252-
array('sis', 3, true, true, 'ses'),
246+
['sis', 3, true, true, 'ses'],
253247

254248
// accesses (access), addresses (address), kisses (kiss)
255-
array('ss', 2, true, false, 'sses'),
249+
['ss', 2, true, false, 'sses'],
256250

257251
// syllabi (syllabus)
258-
array('suballys', 8, true, true, 'syllabi'),
252+
['suballys', 8, true, true, 'syllabi'],
259253

260254
// buses (bus)
261-
array('sub', 3, true, true, 'buses'),
255+
['sub', 3, true, true, 'buses'],
262256

263257
// fungi (fungus), alumni (alumnus), syllabi (syllabus), radii (radius)
264-
array('su', 2, true, true, 'i'),
258+
['su', 2, true, true, 'i'],
265259

266260
// news (news)
267-
array('swen', 4, true, true, 'news'),
261+
['swen', 4, true, true, 'news'],
268262

269263
// feet (foot)
270-
array('toof', 4, true, true, 'feet'),
264+
['toof', 4, true, true, 'feet'],
271265

272266
// chateaux (chateau), bureaus (bureau)
273-
array('uae', 3, false, true, array('eaus', 'eaux')),
267+
['uae', 3, false, true, ['eaus', 'eaux']],
274268

275269
// oxen (ox)
276-
array('xo', 2, false, false, 'oxen'),
270+
['xo', 2, false, false, 'oxen'],
277271

278272
// hoaxes (hoax)
279-
array('xaoh', 4, true, false, 'hoaxes'),
273+
['xaoh', 4, true, false, 'hoaxes'],
280274

281275
// indices (index)
282-
array('xedni', 5, false, true, array('indicies', 'indexes')),
276+
['xedni', 5, false, true, ['indicies', 'indexes']],
283277

284278
// indexes (index), matrixes (matrix)
285-
array('x', 1, true, false, array('cies', 'xes')),
279+
['x', 1, true, false, ['cies', 'xes']],
286280

287281
// appendices (appendix)
288-
array('xi', 2, false, true, 'ices'),
282+
['xi', 2, false, true, 'ices'],
289283

290284
// babies (baby)
291-
array('y', 1, false, true, 'ies'),
285+
['y', 1, false, true, 'ies'],
292286

293287
// quizzes (quiz)
294-
array('ziuq', 4, true, false, 'quizzes'),
288+
['ziuq', 4, true, false, 'quizzes'],
295289

296290
// waltzes (waltz)
297-
array('z', 1, true, false, 'zes'),
298-
);
291+
['z', 1, true, false, 'zes'],
292+
];
299293

300294
/**
301295
* A list of words which should not be inflected.
302-
*
303-
* @var array
304296
*/
305-
private static $uninflected = array(
297+
private static $uninflected = [
306298
'data',
307299
'deer',
308300
'feedback',
309301
'fish',
310302
'moose',
311303
'series',
312304
'sheep',
313-
);
305+
];
314306

315307
/**
316308
* This class should not be instantiated.
@@ -327,10 +319,7 @@ private function __construct()
327319
*
328320
* @param string $plural A word in plural form
329321
*
330-
* @return string|array The singular form or an array of possible singular
331-
* forms
332-
*
333-
* @internal
322+
* @return string|array The singular form or an array of possible singular forms
334323
*/
335324
public static function singularize(string $plural)
336325
{
@@ -339,7 +328,7 @@ public static function singularize(string $plural)
339328
$pluralLength = \strlen($lowerPluralRev);
340329

341330
// Check if the word is one which is not inflected, return early if so
342-
if (in_array(strtolower($plural), self::$uninflected, true)) {
331+
if (\in_array(strtolower($plural), self::$uninflected, true)) {
343332
return $plural;
344333
}
345334

@@ -416,19 +405,16 @@ public static function singularize(string $plural)
416405
*
417406
* @param string $singular A word in plural form
418407
*
419-
* @return string|array The plural form or an array of possible plural
420-
* forms
421-
*
422-
* @internal
408+
* @return string|array The plural form or an array of possible plural forms
423409
*/
424410
public static function pluralize(string $singular)
425411
{
426412
$singularRev = strrev($singular);
427413
$lowerSingularRev = strtolower($singularRev);
428-
$singularLength = strlen($lowerSingularRev);
414+
$singularLength = \strlen($lowerSingularRev);
429415

430416
// Check if the word is one which is not inflected, return early if so
431-
if (in_array(strtolower($singular), self::$uninflected, true)) {
417+
if (\in_array(strtolower($singular), self::$uninflected, true)) {
432418
return $singular;
433419
}
434420

@@ -474,8 +460,8 @@ public static function pluralize(string $singular)
474460
// the singular suffix too
475461
$firstUpper = ctype_upper($singularRev[$j - 1]);
476462

477-
if (is_array($newSuffix)) {
478-
$plurals = array();
463+
if (\is_array($newSuffix)) {
464+
$plurals = [];
479465

480466
foreach ($newSuffix as $newSuffixEntry) {
481467
$plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);

src/Symfony/Component/Inflector/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ Inflector Component
33

44
Inflector converts words between their singular and plural forms (English only).
55

6-
Disclaimer
7-
----------
8-
9-
This component is currently marked as internal. Do not use it in your own code.
10-
Breaking changes may be introduced in the next minor version of Symfony, or the
11-
component itself might even be removed completely.
12-
136
Resources
147
---------
158

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy