DDC-3152: Generating methods does not check for existing methods with different case #3909

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

Originally created by @doctrinebot on GitHub (Jun 4, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user jacobwalker0814:

When I use orm:generate-entities --generate-methods=true to add methods to an existing entity (such as when I add new properties) the generator will redeclare methods if my existing entity is using different case. This is a fatal error because PHP method names are treated as case insensitive.

I have not tested this in 2.4.

Here is a minimal example entity before running the generator. Not the case of getID

/****
 * @ORM\Entity
 */
class Employee
{
    /****
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    public function getID()
    {
        return $this->id;
    }
}

And after running the generator

/****
 * @ORM\Entity
 */
class Employee
{
    /****
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    public function getID()
    {
        return $this->id;
    }

    /****
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
}
Originally created by @doctrinebot on GitHub (Jun 4, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user jacobwalker0814: When I use `orm:generate-entities --generate-methods=true` to add methods to an existing entity (such as when I add new properties) the generator will redeclare methods if my existing entity is using different case. This is a fatal error because PHP method names are treated as case insensitive. I have not tested this in 2.4. Here is a minimal example entity before running the generator. Not the case of `getID` ``` php /**** * @ORM\Entity */ class Employee { /**** * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; public function getID() { return $this->id; } } ``` And after running the generator ``` php /**** * @ORM\Entity */ class Employee { /**** * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; public function getID() { return $this->id; } /**** * Get id * * @return integer */ public function getId() { return $this->id; } } ```
admin added the Bug label 2026-01-22 14:31:17 +01:00
admin closed this issue 2026-01-22 14:31:17 +01:00
Author
Owner

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

Comment created by @deeky666:

Hmm yeah it seems the EntityGenerator does not use reflection to determine whether a method/property already exists but instead tokenizes the source file and compares the methods/properties case-sensitive.
I will have a look at it.

@doctrinebot commented on GitHub (Jun 5, 2014): Comment created by @deeky666: Hmm yeah it seems the EntityGenerator does not use reflection to determine whether a method/property already exists but instead tokenizes the source file and compares the methods/properties case-sensitive. I will have a look at it.
Author
Owner

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

Comment created by @deeky666:

Patch supplied in PR: https://github.com/doctrine/doctrine2/pull/1049

@doctrinebot commented on GitHub (Jun 5, 2014): Comment created by @deeky666: Patch supplied in PR: https://github.com/doctrine/doctrine2/pull/1049
Author
Owner

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

Comment created by jacobwalker0814:

Thanks for looking in to this so quickly, Steve.

@doctrinebot commented on GitHub (Jun 5, 2014): Comment created by jacobwalker0814: Thanks for looking in to this so quickly, Steve.
Author
Owner

@doctrinebot commented on GitHub (Jun 6, 2014):

Comment created by @doctrinebot:

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

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

@doctrinebot commented on GitHub (Jun 6, 2014):

Comment created by @ocramius:

Merged @ d71159c6c5

@doctrinebot commented on GitHub (Jun 6, 2014): Comment created by @ocramius: Merged @ https://github.com/doctrine/doctrine2/commit/d71159c6c57bce5b83f9a2ddbb16ff5a289c30f1
Author
Owner

@doctrinebot commented on GitHub (Jun 6, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jun 6, 2014): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3909