Skip to content

Instantly share code, notes, and snippets.

@alexandresalome
Created February 5, 2014 14:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandresalome/8824509 to your computer and use it in GitHub Desktop.
Save alexandresalome/8824509 to your computer and use it in GitHub Desktop.
PHP - Getters and Setters for SublimeText
This SublimeText macro will generate your PHP getters and setters automatically.
Just create a list of attributes you want to generate getters and setters for:
class User
{
firstname
lastname
}
Create a vertical selection at the beginning of attributes (text cursor is "|"):
class User
{
|firstname
|lastname
}
And execute the macro!
wow, such sublime
[
{ "command": "move", "args": {"by": "word_ends", "extend": true, "forward": true}},
{ "command": "cut", "args": null},
{ "command": "insert", "args": {"characters": "public"}},
{ "command": "insert", "args": {"characters": " function"}},
{ "command": "insert", "args": {"characters": " get"}},
{ "command": "paste", "args": null},
{ "command": "move", "args": {"by": "words", "forward": false}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "move", "args": {"by": "characters", "extend": true, "forward": true}},
{ "command": "upper_case", "args": null},
{ "command": "move_to", "args": {"extend": false, "to": "eol"}},
{ "command": "insert_snippet", "args": {"contents": "($0)"}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "insert", "args": {"characters": "\n"}},
{ "command": "insert_snippet", "args": {"contents": "{$0}"}},
{ "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}},
{ "command": "insert", "args": {"characters": "return"}},
{ "command": "insert", "args": {"characters": " $this->"}},
{ "command": "paste", "args": null},
{ "command": "insert", "args": {"characters": ";"}},
{ "command": "move", "args": {"by": "lines", "forward": true}},
{ "command": "insert", "args": {"characters": "\n\npublic"}},
{ "command": "insert", "args": {"characters": " funti"}},
{ "command": "left_delete", "args": null},
{ "command": "left_delete", "args": null},
{ "command": "insert", "args": {"characters": "ction"}},
{ "command": "insert", "args": {"characters": " set"}},
{ "command": "paste", "args": null},
{ "command": "move", "args": {"by": "words", "forward": false}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "move", "args": {"by": "characters", "extend": true, "forward": true}},
{ "command": "upper_case", "args": null},
{ "command": "move_to", "args": {"extend": false, "to": "eol"}},
{ "command": "insert_snippet", "args": {"contents": "($0)"}},
{ "command": "insert", "args": {"characters": "$"}},
{ "command": "paste", "args": null},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "insert", "args": {"characters": "\n"}},
{ "command": "insert_snippet", "args": {"contents": "{$0}"}},
{ "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}},
{ "command": "insert", "args": {"characters": "$this->"}},
{ "command": "paste", "args": null},
{ "command": "insert", "args": {"characters": " ="}},
{ "command": "insert", "args": {"characters": " $"}},
{ "command": "paste", "args": null},
{ "command": "insert", "args": {"characters": ";"}},
{ "command": "insert", "args": {"characters": "\n\nreturn"}},
{ "command": "insert", "args": {"characters": " $this;"}},
{ "command": "move", "args": {"by": "lines", "forward": true}},
{ "command": "move", "args": {"by": "characters", "forward": true}},
{ "command": "insert", "args": {"characters": "\n"}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment