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

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

wants to merge 1 commit into from

Conversation

TomasVotruba
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets no
License MIT
Doc PR n/a

Fixes misspelling of words like:

  • street => stroot
  • fleet => floot

See exception:

screenshot from 2015-02-17 13 35 37

Is this proper way to fix this?

Can add tests if required.

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| Fixed tickets | [no]
| License       | MIT
| Doc PR        | [n/a]

Fixes misspelling of words like:

- street => stroot
- fleet => floot

Is this proper way to fix this?

Can add tests if required.
@@ -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 &&

@stof
Copy link
Member

stof commented Feb 17, 2015

yes, tests are needed

@SpacePossum
Copy link
Contributor

Wouldn't it be cheeper to list the expections; teeth and foot then the otherway around (street, sheep, fleet)?

@jakzal
Copy link
Contributor

jakzal commented Feb 17, 2015

@SpacePossum a PR related to the word feedback was already merged into the 2.3 branch: #13618. It didn't get to 2.7 yet. I think you should take those changes into account, and probably send a PR against 2.3, just like the other PR.

@TomasVotruba
Copy link
Contributor Author

@SpacePossum I agree with you: #13714 (comment)

@jakzal I can prepare PR with tests to 2.3 branch. What do you think about "convert only" over "convert all with 'ee' excluding"?

@TomasVotruba
Copy link
Contributor Author

Ping @jakzal @stof - my last comment pls

@TomasVotruba
Copy link
Contributor Author

Not relevant anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants