Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
doctrinebot opened this issue Jun 4, 2014 · 6 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

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
Copy link
Author

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
Copy link
Author

Comment created by @deeky666:

Patch supplied in PR: #1049

@doctrinebot
Copy link
Author

Comment created by jacobwalker0814:

Thanks for looking in to this so quickly, Steve.

@doctrinebot
Copy link
Author

Comment created by @doctrinebot:

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

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

Merged @ d71159c

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.5 milestone 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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants