Skip to content

Commit 1c285f1

Browse files
committed
[String][Inflector] Fix edge cases
Fixed both singularization and pluralization for: - passersby <-> passerby (compound word) - insignia/insignias <-> insigne (Latin singular) - rattles <-> rattle (already worked, added test coverage)
1 parent ece4f3e commit 1c285f1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/Symfony/Component/String/Inflector/EnglishInflector.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ final class EnglishInflector implements InflectorInterface
2525
// Fourth entry: Whether the suffix may succeed a consonant
2626
// Fifth entry: singular suffix, normal
2727

28+
// insignias (insigne), insignia (insigne)
29+
['saingisni', 9, true, true, 'insigne'],
30+
['aingisni', 8, true, true, 'insigne'],
31+
32+
// passersby (passerby)
33+
['ybsressap', 9, true, true, 'passerby'],
34+
2835
// nodes (node)
2936
['sedon', 5, true, true, 'node'],
3037

@@ -205,6 +212,12 @@ final class EnglishInflector implements InflectorInterface
205212
// Fourth entry: Whether the suffix may succeed a consonant
206213
// Fifth entry: plural suffix, normal
207214

215+
// passerby (passersby)
216+
['ybressap', 8, true, true, 'passersby'],
217+
218+
// insigne (insignia, insignias)
219+
['engisni', 7, true, true, ['insignia', 'insignias']],
220+
208221
// nodes (node)
209222
['edon', 4, true, true, 'nodes'],
210223

src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,15 @@ public static function singularizeProvider()
171171
['waltzes', ['waltz', 'waltze']],
172172
['wives', 'wife'],
173173
['zombies', 'zombie'],
174+
['passersby', 'passerby'],
175+
['rattles', 'rattle'],
176+
['insignia', 'insigne'],
177+
['insignias', 'insigne'],
174178

175179
// test casing: if the first letter was uppercase, it should remain so
176180
['Men', 'Man'],
177181
['GrandChildren', 'GrandChild'],
178182
['SubTrees', 'SubTree'],
179-
180-
// Known issues
181-
// ['insignia', 'insigne'],
182-
// ['insignias', 'insigne'],
183-
// ['rattles', 'rattle'],
184183
];
185184
}
186185

@@ -262,6 +261,7 @@ public static function pluralizeProvider()
262261
['house', 'houses'],
263262
['icon', 'icons'],
264263
['index', ['indicies', 'indexes']],
264+
['insigne', ['insignia', 'insignias']],
265265
['ion', 'ions'],
266266
['iris', 'irises'],
267267
['issue', 'issues'],
@@ -287,6 +287,7 @@ public static function pluralizeProvider()
287287
['objective', 'objectives'],
288288
['ox', 'oxen'],
289289
['party', 'parties'],
290+
['passerby', 'passersby'],
290291
['person', ['persons', 'people']],
291292
['phenomenon', 'phenomena'],
292293
['photo', 'photos'],
@@ -298,6 +299,7 @@ public static function pluralizeProvider()
298299
['quiz', 'quizzes'],
299300
['quorum', ['quora', 'quorums']],
300301
['radius', 'radii'],
302+
['rattle', 'rattles'],
301303
['roof', ['roofs', 'rooves']],
302304
['rose', 'roses'],
303305
['sandwich', 'sandwiches'],

0 commit comments

Comments
 (0)