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

Closed
doctrinebot opened this Issue Jun 4, 2014 · 6 comments

2 participants

@doctrinebot

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;
    }
}
@doctrinebot

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

Comment created by @deeky666:

Patch supplied in PR: #1049

@doctrinebot

Comment created by jacobwalker0814:

Thanks for looking in to this so quickly, Steve.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1049] was closed:
#1049

@doctrinebot

Comment created by @ocramius:

Merged @ d71159c

@doctrinebot

Issue was closed with resolution "Fixed"

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.5 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment