Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Singular form of generated methods should end with 'y' when property ends with 'ies' #530

wants to merge 1 commit into from

8 participants


The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
This change is related to



thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:


Oh btw, I just (automatically) realized that you are not creating this pull request against the master branch.

Unless there are good reasons for this, i would suggest to close and rebase the Pull Request against master and then create it again. Sorry!


Wasn't the last suggestion about using a more advanced inflector?


Which suggestion do you mean?


I would take the code from cakephp that does singularize and pluralize including tests
and move it to Doctrine\Common\Util\Inflector - then use that API to do this singular/plural changes.


@beberlei I have already created PR against Doctrine\Common\Util\Inflector here

I should also add that those changes use the code from CakePHP and I think I have a PR ready to push which makes the changes here to utilise the Util class once its been committed.


Okay, so I'll close this pull request ;)

@naitsirch naitsirch closed this

@naitsirch @jbergler running 2.3.4 these issues with generated Entity method names ending 'ie' are remaining.

I am using yaml notation and from this kind of notation in yaml:

        targetEntity: Security
        mappedBy: tradingCountry

This kind of (wrongly named) method gets generated:

public function addTradedSecuritie(\X\Y\Entity\Security $tradedSecurities)
    $this->tradedSecurities[] = $tradedSecurities;

    return $this;

If this bug was resolved then I would have expected these issues to disappear ?


Yes, I am experiencing this behaviour in latest 2.3.x, too, but haven't looked into the code again. It seems like doctrine/common#227 should have fixed this issue. Maybe it has not been merged into 2.3.x?

@beberlei What is the current status?


@naitsirch including doctrine/common#227 into 2.3 is a no-go in my opinion, that's quite a break (and a new feature)


In my opinion it's a bug fix ^^ because the current behaviour is not correct.
But I just wanted to know where the fix will be applied to


@naitsirch Short answer, looks like the changes are in 2.4 to use doctrine/inflector
see doctrine/common@18b2c6e


My "categories" are still generating "addCategorie"


@afilina this with the new inflector?


@Ocramius My mistake, I had <2.4-dev in my composer file. I changed to the higher version and updated dependencies. My function names are now correct. Thanks.

@k-przybyszewski k-przybyszewski referenced this pull request in lexik/LexikMailerBundle

Requirements update #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/Doctrine/ORM/Tools/EntityGenerator.php
6 lib/Doctrine/ORM/Tools/EntityGenerator.php
@@ -930,7 +930,11 @@ private function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $f
$methodName = $type . Inflector::classify($fieldName);
if (in_array($type, array("add", "remove")) && substr($methodName, -1) == "s") {
- $methodName = substr($methodName, 0, -1);
+ if (substr($methodName, -3) == "ies") {
+ $methodName = substr($methodName, 0, -3) . "y";
+ } else {
+ $methodName = substr($methodName, 0, -1);
+ }
if ($this->hasMethod($methodName, $metadata)) {
Something went wrong with that request. Please try again.