Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3152

Generating methods does not check for existing methods with different case

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4
    • Fix Version/s: 2.5
    • Component/s: Tools
    • Labels:

      Description

      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`

      Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
      /**
       * @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

      Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
      /**
       * @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;
          }
      }
      

        Activity

        Hide
        Steve Müller added a comment -

        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.

        Show
        Steve Müller added a comment - 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.
        Hide
        Steve Müller added a comment -
        Show
        Steve Müller added a comment - Patch supplied in PR: https://github.com/doctrine/doctrine2/pull/1049
        Hide
        Jacob Walker added a comment -

        Thanks for looking in to this so quickly, Steve.

        Show
        Jacob Walker added a comment - Thanks for looking in to this so quickly, Steve.
        Hide
        Doctrine Bot added a comment -

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

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-1049] was closed: https://github.com/doctrine/doctrine2/pull/1049
        Show
        Marco Pivetta added a comment - Merged @ https://github.com/doctrine/doctrine2/commit/d71159c6c57bce5b83f9a2ddbb16ff5a289c30f1

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Jacob Walker
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: