inflector icon indicating copy to clipboard operation
inflector copied to clipboard

<anything>_data singularization returns unexpected result (<anything>_datum)

Open peter-bolemant opened this issue 5 years ago • 4 comments

Singularization of foo_data returns foo_datum

Even if datum can be considered to be the singular form of data, I think in the case of the lib use it can be quite confusing. Singularization of data returns data, as one would expect.

peter-bolemant avatar Feb 18 '20 16:02 peter-bolemant

AFAICT Inflector is designed to work with single words. Trying to make it work with two words (separated by either space or whatever else like _ in your case) is outside of the scope of interest of this library.

malarzm avatar Feb 18 '20 17:02 malarzm

That's possible, however I opened this topic in Laravel and they referenced me here, it can cause big problems in some cases - https://github.com/laravel/framework/issues/31517#event-3047630118

peter-bolemant avatar Feb 18 '20 17:02 peter-bolemant

If you could come up with some tests or a list of expected behaviour I can take a look.

alcaeus avatar Feb 19 '20 07:02 alcaeus

looks like the behaviour has changed or Laravel's making some further string manipulation (not quite likely according to their response), however tested doctrine/inflector: 1.3.1

echo Inflector::singularize('data'); // results in datum - I'd expect data echo Inflector::singularize('personal_data'); // results in personal_datum - I'd expect personal_data

echo Inflector::pluralize('data'); // results in data as expected echo Inflector::pluralize('personal_data'); // results in personal_datas - I'd expect personal_data

peter-bolemant avatar Mar 24 '20 10:03 peter-bolemant