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

Open
opened 2026-01-22 14:31:13 +01:00 by admin · 0 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:13 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3907