Created
September 1, 2016 06:11
-
-
Save mishbah/08d4e7a72ebeb06b024181ca4998d5f1 to your computer and use it in GitHub Desktop.
Snippet for php getter and setter for sublimetext (tested at sublimetext v3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[/** | |
* Getter for ${1:$SELECTION} | |
* | |
* @return ${2:mixed} | |
*/ | |
public function get${1/^(\w)|(?:_(\w))|(?:_)/(?1\u$1:)(?2\u$2:)/g}() | |
{ | |
return \$this->$1; | |
} | |
/** | |
* Setter for $1 | |
* | |
* @param ${2:mixed} \$${1/_(w)/U$1/g$1} Value to set | |
* @return self | |
*/ | |
public function set${1/^(\w)|(?:_(\w))|(?:_)/(?1\u$1:)(?2\u$2:)/g}(\$$1) | |
{ | |
\$this->$1 = \$${1/_(w)/U$1/g$1}; | |
return \$this; | |
} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>fgs</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.php</scope> | |
<description>Create getter and setter methods</description> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[/** | |
* Getter for ${1:$SELECTION} | |
* | |
* @return ${2:mixed} | |
*/ | |
public function get${1/(?:^|_)(w)/U$1$2/g$1}() | |
{ | |
return \$this->$1; | |
} | |
]]></content> | |
<!-- Optional: Tab trigger to activate the snippet --> | |
<tabTrigger>fg</tabTrigger> | |
<!-- Optional: Scope the tab trigger will be active in --> | |
<scope>source.php</scope> | |
<!-- Optional: Description to show in the menu --> | |
<description>Create getter methods</description> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[/** | |
* Setter for ${1:$SELECTION} | |
* | |
* @param ${2:mixed} \$${1/_(w)/U$1/g$1} Value to set | |
* @return self | |
*/ | |
public function set${1/(?:^|_)(w)/U$1$2/g$1}(\$${1/_(w)/U$1/g$1}) | |
{ | |
\$this->$1 = \$${1/_(w)/U$1/g$1}; | |
return \$this; | |
} | |
]]></content> | |
<!-- Optional: Tab trigger to activate the snippet --> | |
<tabTrigger>fs</tabTrigger> | |
<!-- Optional: Scope the tab trigger will be active in --> | |
<scope>source.php</scope> | |
<!-- Optional: Description to show in the menu --> | |
<description>Create setter methods</description> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go to
Tools
->Developer
->New Snippet...
Paste the code (above)
Each snippet each code (file)
inspiring from Jarret Byrne and Rob Allen