mercoledì 10 ottobre 2012

Emacs: creating PHP getters and setters easily

Following the initial work on the GNU Emacs and PHP class generator,  I developed a lisp function to create the getter/setter methods, and since I was developing, I thought it would be much more powerful to have the definition of the whole property. The function php-prop does all the stuff: it prompts the user for a property name (that is the name of the internal variable) and for an optional comment to place on the property. After that the function places a private property at the cursor current point, and then scans the current class for a getter and a setter for the same property. If one or both of the previous methods are not found, the function generates the code for them at the very end of the class. The function also places comments in doxygen format using also the current username and e-mail (that have to be set in the Emacs configuration). 
Loading the function allows you to insert a PHP property just hitting M-x php-prop.

Nessun commento: