This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 223690

Summary: Generate Getters and Setters
Product: php Reporter: zburnham
Component: EditorAssignee: Ondrej Brejla <obrejla>
Status: NEW ---    
Severity: normal    
Priority: P1    
Version: 7.2.1   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: The Generate Getters and Setters dialog actually says "Remove underscore: ..." but it doesn't remove the score.

Description zburnham 2012-12-12 04:09:04 UTC
The PSR-1 Basic Coding Standard (https://github.com/pmjones/fig-standards/blob/psr-1-style-guide/proposed/PSR-1-basic.md) says the following with regard to method naming:

"4.3. Methods

Method names MUST be declared in camelCase()."

However, it also says the following:

"4.2. Properties

This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names."

More specifically, what I'm trying to ask for is this:  Given the flexibility of property naming conventions, could the Generate Getters and Setters function have an option to generate the following getter and setter from a property called $my_property:

public function getMyProperty() {...}

public function setMyProperty($value) {...}

Obviously this could be avoided if one were to name class properties with camelCase formatting, but PSR-1 allows for the use of underscores in property names, and there can be good stylistic reasons for doing so.  However, that renders the Generate Getters and Setters function in Netbeans less valuable, because you then have to go through and change functions from getMy_property and setMy_property to getMyProperty and setMyProperty, respectively.  

Alternately, the ability to customize the templates that Generate Getters and Setters functions use would be useful, as it's kind of a drag to go through and add "return $this;" to every generated setter.
Comment 1 BullfrogBlues 2013-02-16 23:25:22 UTC
Created attachment 131475 [details]
The Generate Getters and Setters dialog actually says "Remove underscore: ..." but it doesn't remove the score.

The Generate Getters and Setters dialog actually says "Remove underscore: ..." but it doesn't remove the score.
Comment 2 gameshas 2013-02-27 07:57:03 UTC
Tested on Netbeans 7.3 stable
Method naming style: Remove Underscore

Result:
underscores where not removed ex.: public function getStarted_at()

Expected result:
public function getStartedAt()
Comment 3 Ondrej Brejla 2013-02-27 08:19:55 UTC
Please, don't change version. It's the first version, when an issue occured.
Comment 4 Ondrej Brejla 2013-02-27 09:23:20 UTC
"Remove Underscore" works fust for leading underscore (many years ago someone used it for "private/protected" fields...). To don't generate get_foo(); from $_foo; It never worked for underscored inside a field name. So it's definitely an enhancement. But I understand you and I'll try to rewrite it to remove all underscores. Thanks.
Comment 5 curli 2014-12-12 11:21:03 UTC
I need this new enhancement, always i use underscore into my vars .   

Thanks.
Comment 6 tiancris 2018-07-03 23:47:47 UTC
I'm using Netbeans 8.2 fully updated and just right now I'm manually modifying every generated getter/setter, removing extra underscores :(