10000 [PropertyAccess] StringUtil miss-singularize some "ee" words by TomasVotruba · Pull Request #13714 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PropertyAccess] StringUtil miss-singularize some "ee" words #13714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Symfony/Component/PropertyAccess/StringUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class StringUtil
array('xuae', 4, false, true, 'eau'),
);

/**
* @var string[]
*/
private static $allowedEes = array('Fleet', 'Street');

/**
* This class should not be instantiated.
*/
Expand Down Expand Up @@ -197,7 +202,7 @@ public static function singularify($plural)
}

// Convert teeth to tooth, feet to foot
if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3) {
if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3 ! in_array($plural, self::$allowedEes)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is invalid code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and your in_array check is broken because it is case sensitive so you don't always match it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you suggest then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomasVotruba for the second comment ? Use an array with lowercase strings in it, and apply strtolower on the plural before the check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof Yes, sorry, I'll be more specific next time.
Thanks, I'll implement the changes.

On second thought, maybe it would be easier to specify all "teeth, feet"-kind of words, than to allow all that include "ee" + exclude others. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, you forgot &&

return substr_replace($plural, 'oo', $pos, 2);
}

Expand Down
0