DDC-2184: [GH-530] Singular form of generated methods should end with 'y' when property ends with 'ies' #2749

Closed
opened 2026-01-22 14:02:22 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 4, 2012).

Originally assigned to: @Majkl578 on GitHub.

Jira issue originally created by user @beberlei:

In Doctrine 2.3 the 'add' and 'remove' methods in oneToMany associations have another problem (in earlier versions like 2.2 this worked correct). The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
I have this YAML definition:

Archive:
  type: entity
  fields:
    id:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: IDENTITY
  oneToMany:
    entries:
      targetEntity: Entry
      mappedBy: archive

This generates these methods:

public function addEntrie(\Entry $entries) { ... }
public function removeEntrie(\Entry $entries) { ... }

Because in the EntityGenerator only the plural 's' is removed. It would be nice if an ending of 'ies' could be replaced by 'y'. So that we get these methods

public function addEntry(\Entry $entries) { ... }
public function removeEntry(\Entry $entries) { ... }

My fork already has the changes a3adfccb49
I have opened a pull request here https://github.com/doctrine/doctrine2/pull/530

Originally created by @doctrinebot on GitHub (Dec 4, 2012). Originally assigned to: @Majkl578 on GitHub. Jira issue originally created by user @beberlei: In Doctrine 2.3 the 'add' and 'remove' methods in oneToMany associations have another problem (in earlier versions like 2.2 this worked correct). The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'. I have this YAML definition: ``` Archive: type: entity fields: id: id: true type: integer unsigned: false nullable: false generator: strategy: IDENTITY oneToMany: entries: targetEntity: Entry mappedBy: archive ``` This generates these methods: ``` public function addEntrie(\Entry $entries) { ... } public function removeEntrie(\Entry $entries) { ... } ``` Because in the EntityGenerator only the plural 's' is removed. It would be nice if an ending of 'ies' could be replaced by 'y'. So that we get these methods ``` public function addEntry(\Entry $entries) { ... } public function removeEntry(\Entry $entries) { ... } ``` My fork already has the changes https://github.com/naitsirch/doctrine-orm2/commit/a3adfccb4927d61da7debae46ed0fff61e4212f8 I have opened a pull request here https://github.com/doctrine/doctrine2/pull/530
admin added the ImprovementWon't Fix labels 2026-01-22 14:02:22 +01:00
admin closed this issue 2026-01-22 14:02:23 +01:00
Author
Owner
@doctrinebot commented on GitHub (Dec 4, 2012): - duplicates [DDC-2150: EntityGenerator.php - Guessing singular too simple generateEntityStubMethod()](http://www.doctrine-project.org/jira/browse/DDC-2150) - duplicates [DDC-2160: [GH-520] Fix for Doctrine\ORM\Tools\EntityGenerator not picking the correct singular of some plurals](http://www.doctrine-project.org/jira/browse/DDC-2160)
Author
Owner

@doctrinebot commented on GitHub (Dec 4, 2012):

Comment created by naitsirch:

Sorry, I accidently clicked on the button 'Request Feedback' :-(
Now the status has changed to 'Awaiting Feedback'

@doctrinebot commented on GitHub (Dec 4, 2012): Comment created by naitsirch: Sorry, I accidently clicked on the button 'Request Feedback' :-( Now the status has changed to 'Awaiting Feedback'
Author
Owner

@doctrinebot commented on GitHub (Jan 6, 2013):

Comment created by @beberlei:

Mark as improvement

@doctrinebot commented on GitHub (Jan 6, 2013): Comment created by @beberlei: Mark as improvement
Author
Owner

@doctrinebot commented on GitHub (Jul 4, 2013):

Comment created by stockopede:

Is this issue going to be resolved? It's a major problem for our project - a stock market application that uses properties like 'securities' and entities of name 'Security'.

@doctrinebot commented on GitHub (Jul 4, 2013): Comment created by stockopede: Is this issue going to be resolved? It's a major problem for our project - a stock market application that uses properties like 'securities' and entities of name 'Security'.
Author
Owner

@doctrinebot commented on GitHub (Mar 5, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-530] was closed:
https://github.com/doctrine/dbal/pull/530

@doctrinebot commented on GitHub (Mar 5, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-530] was closed: https://github.com/doctrine/dbal/pull/530
Author
Owner

@Majkl578 commented on GitHub (Dec 19, 2017):

CLosing, codegen to be removed in Doctrine 3.0.

@Majkl578 commented on GitHub (Dec 19, 2017): CLosing, codegen to be removed in Doctrine 3.0.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2749