Skip to content

Instantly share code, notes, and snippets.

@BrynM
Last active July 14, 2018 00:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrynM/99bbf5648a7d8e51510eced34441dfdb to your computer and use it in GitHub Desktop.
Save BrynM/99bbf5648a7d8e51510eced34441dfdb to your computer and use it in GitHub Desktop.
Sublime Snippets - PHP Documentor

Sublime Snippets - PHP Documentor

Some completions for basic PHPDoc templates. Drop these into your Sublime Packages->User folder.

The completions are as follows (assuming your auto-complete key is [TAB]). Place your cursor on the first character of the first line of the declaration for the thing you're documenting for best results.

  • /**c[TAB] - doc block for a Class
  • /**co[TAB] - doc block for a constant
  • /**ff[TAB] - doc block for a file (should be done on the line after the opening <?php tag)
  • /**f[TAB] - doc block for a function
  • /**m[TAB] - a nag block for missing doc blocks because I can be a jerk
  • /**v[TAB] - doc block for a variable
<snippet>
<content><![CDATA[/**
* Class_Name
*
* A description of my class.
*
* @package foo
* @subpackage subfoo
* @see some_class::use_some_var()
* @filesource
*/]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>/**c</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Bryn's PHPDocumentor Variable Docblock</description>
</snippet>
<snippet>
<content><![CDATA[/**
* SOME_CONST
*
* A description of my constant.
*
* @const string SOME_CONST
* @see some_class::some_func()
* @filesource
*/]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>/**co</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Bryn's PHPDocumentor Constant Docblock</description>
</snippet>
<snippet>
<content><![CDATA[/**
* $TM_FILENAME
*
* Long description.
*
* @todo Finish
* @package foo
* @subpackage subfoo
* @version v0.000
* @license Proprietary.
* @filesource
*/]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>/**ff</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Bryn's PHPDocumentor File Docblock</description>
</snippet>
<snippet>
<content><![CDATA[/**
* function_name()
*
* Description of function_name().
*
* @param string \$stringParm The string to get funky with
* @return mixed Some oddball return val.
* The type of return val that you can specify are mixed, bool, object, string, int, etc...
* @static
* @access public
* @see some_class::some_func()
* @filesource
*/]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>/**f</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Bryn's PHPDocumentor Function Docblock</description>
</snippet>
<snippet>
<content><![CDATA[/**
* DOCUMENT ME!
*
* @todo DOCUMENT ME!
* @see lazy mofos
* @filesource
*/]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>/**m</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Bryn's PHPDocumentor Missing Docblock</description>
</snippet>
<snippet>
<content><![CDATA[/**
* \$some_var
*
* A description of my var.
*
* @var string \$someVar
* @static
* @access public
* @see some_class::use_some_var()
* @filesource
*/]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>/**v</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Bryn's PHPDocumentor Variable Docblock</description>
</snippet>
@loganintech
Copy link

loganintech commented Jul 14, 2018

Slap this badboy in VSCode's php.json usersnippet file for the same snippet functionality:

{
	"Doc Class": {
		"prefix": "docc",
		"body": [
			"/**",
			" * Class_Name$1",
			" *",
			" * A description of the class$2",
			" *",
			" * @package foo$3",
			" * @subpackage subfoo$4",
			" * @see some_class::use_some_var()$5",
			" * @filesource$6",
			" */$0",
		],
		"description": "Logan's VSCode version of Bryn's PHPDocumentor Variable Docblock"
	},

	"Doc Constant": {
		"prefix": "docco",
		"body": [
			"/**",
			" * Some_Const$1",
			" *",
			" * A description of the const$2",
			" *",
			" * @const string SOME_CONST$3",
			" * @see some_class::some_func()$4",
			" * @filesource$5",
			" */$0",
		],
		"description": "Logan's VSCode version of Bryn's PHPDocumentor Constant Docblock"
	},

	"Doc File": {
		"prefix": "docff",
		"body": [
			"/**",
			" * TM_FILENAME$1",
			" *",
			" * Long file description$2",
			" *",
			" * @todo finish$3",
			" * @package foo$4",
			" * @subpackage subfoo$5",
			" * @version v0.0.0$6",
			" * @license Proprietary$7",
			" * @filesource$8",
			" */$0",
		],
		"description": "Logan's VSCode version of Bryn's PHPDocumentor File Docblock"
	},

	"Doc Function": {
		"prefix": "docf",
		"body": [
			"/**",
			" * function_name()$1",
			" *",
			" * Description of function_name()$2",
			" *",
			" * @param string \\$stringParam The string you want get funky with$3",
			" * @return mixed Some return val$4",
			" * @static$5",
			" * @access public$6",
			" * @see some_class::some_func()$7",
			" * @filesource$8",
			" */$0",
		],
		"description": "Logan's VSCode version of Bryn's PHPDocumentor Function Docblock"
	},

	"Doc Missing": {
		"prefix": "docm",
		"body": [
			"/**",
			" * DOCUMENT ME$1",
			" *",
			" * @todo DOCUMENT ME$2",
			" * @see lazy people$3",
			" * @filesource$4",
			" */$0",
		],
		"description": "Logan's VSCode version of Bryn's PHPDocumentor Missing Docblock"
	},

	"Doc Variable": {
		"prefix": "docv",
		"body": [
			"/**",
			" * \\$some_var$1",
			" *",
			" * A description, perhaps?$2",
			" *",
			" * @var string \\$some_var$2",
			" * @static$3",
			" * @access public$4",
			" * @see some_class::use_some_var()$5",
			" * @filesource$6",
			" */$0",
		],
		"description": "Logan's VSCode version of Bryn's PHPDocumentor Missing Docblock"
	},
}

@BrynM
Copy link
Author

BrynM commented Jul 14, 2018

Fuckyeah! Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment