[DDC-2287] Getter/Setter: generate "isEnabled()" instead of "getEnabled()" for boolean field in entity classes Created: 08/Feb/13 Updated: 10/Nov/14
|Project:||Doctrine 2 - ORM|
|Reporter:||Sukhrob Khakimov||Assignee:||Benjamin Eberlei|
It would be better if doctrine generated "isEnabled()" instead of "getEnabled()" for boolean field in entity classes. Because, it is more meaningful.
|Comment by Marco Pivetta [ 08/Feb/13 ]|
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
|Comment by Joshua thijssen [ 31/Oct/14 ]|
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)
|Comment by Marco Pivetta [ 10/Nov/14 ]|
Getting back to this, I don't think we should alter codegen based on DBAL types, as per previous discussions in
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.