Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-2287

Getter/Setter: generate "isEnabled()" instead of "getEnabled()" for boolean field in entity classes

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ORM
    • Labels:
      None

      Description

      It would be better if doctrine generated "isEnabled()" instead of "getEnabled()" for boolean field in entity classes. Because, it is more meaningful.

        Issue Links

          Activity

          Hide
          ocramius Marco Pivetta added a comment -

          Getting back to this, I don't think we should alter codegen based on DBAL types, as per previous discussions in DDC-2924.

          We're trying to decouple code generation from that, while this sort of approach increases coupling.

          I'm inclined to reject the proposal until we split out the code generator into its own component.

          Show
          ocramius Marco Pivetta added a comment - Getting back to this, I don't think we should alter codegen based on DBAL types, as per previous discussions in DDC-2924 . We're trying to decouple code generation from that, while this sort of approach increases coupling. I'm inclined to reject the proposal until we split out the code generator into its own component.
          Hide
          jthijssen2 Joshua thijssen added a comment -

          I agree that it would be hard to figure out which prefix to use (isEnabled() or hasEnabled() are both valid, depending on context).

          However, it might be easy enough to check for a is<fieldname> or has<fieldname> method already present inside the entity, (https://github.com/doctrine/doctrine2/blob/f12c311a795b69a5f4853b079b3f8ad2c9867181/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1360). If present, we could skip creating the getter as well.

          This allows to (manually) change the getEnabled() into an isEnabled(), and future generations will not add the getEnabled() anymore.

          It also makes it easier to confirm to PMD's booleanGetMethodName rule (http://phpmd.org/rules/naming.html#booleangetmethodname)

          Show
          jthijssen2 Joshua thijssen added a comment - I agree that it would be hard to figure out which prefix to use (isEnabled() or hasEnabled() are both valid, depending on context). However, it might be easy enough to check for a is<fieldname> or has<fieldname> method already present inside the entity, ( https://github.com/doctrine/doctrine2/blob/f12c311a795b69a5f4853b079b3f8ad2c9867181/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1360 ). If present, we could skip creating the getter as well. This allows to (manually) change the getEnabled() into an isEnabled(), and future generations will not add the getEnabled() anymore. It also makes it easier to confirm to PMD's booleanGetMethodName rule ( http://phpmd.org/rules/naming.html#booleangetmethodname )
          Hide
          ocramius Marco Pivetta added a comment -

          Not sure this kind of check should be handled. Starting to add all this kind of rules makes me think that it is becoming a big ball of mud

          Show
          ocramius Marco Pivetta added a comment - Not sure this kind of check should be handled. Starting to add all this kind of rules makes me think that it is becoming a big ball of mud

            People

            • Assignee:
              beberlei Benjamin Eberlei
              Reporter:
              sukhrob Sukhrob Khakimov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: