I am looking for plugin for NetBeans PHP (or it can be some external tool) that would do something like that:
- When run it asks for a class name and the names of private attributes (and their types) of this class
- Then it generates this class with:
- all listed attributes with types in vdoc format,
- constructor that takes all the attributes as parameters and initialize class attributes with those values,
- default getters and setters.
I know it’s not difficult to write such tool, but maybe it already exists.
Netbeans has some built-in functionality similar to this already. In any PHP project, create a new PHP Class (right click a folder in the project, New -> PHP Class). Enter your properties, such as:
Alt+Insert will bring up a menu that allows you to generate a constructor, getters, and setters to assign values to your properties.
If you want to do more, you can look at this Netbeans article on code generation.