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 Improvement
    • Status: Open
    • Priority: Minor 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.

        Activity

        Sukhrob Khakimov created issue -
        Hide
        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
        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
        Marco Pivetta made changes -
        Field Original Value New Value
        Security All [ 10000 ]
        Hide
        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
        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 )

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2287, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

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

            Dates

            • Created:
              Updated: