Alphpetize
PHP Method Sorting Plugin for Sublime Text 2 and 3
Details
Installs
- Total 4K
- Win 2K
- Mac 1K
- Linux 587
Feb 5 | Feb 4 | Feb 3 | Feb 2 | Feb 1 | Jan 31 | Jan 30 | Jan 29 | Jan 28 | Jan 27 | Jan 26 | Jan 25 | Jan 24 | Jan 23 | Jan 22 | Jan 21 | Jan 20 | Jan 19 | Jan 18 | Jan 17 | Jan 16 | Jan 15 | Jan 14 | Jan 13 | Jan 12 | Jan 11 | Jan 10 | Jan 9 | Jan 8 | Jan 7 | Jan 6 | Jan 5 | Jan 4 | Jan 3 | Jan 2 | Jan 1 | Dec 31 | Dec 30 | Dec 29 | Dec 28 | Dec 27 | Dec 26 | Dec 25 | Dec 24 | Dec 23 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Alphpetize for Sublime
Dealing with large volumes of unorganized code? Do you have Organizational OCD like me? Party people, your dreams have now been fulfilled.
The Alphpetize plugin for Sublime Text scans your PHP file for class methods and organizes them by visibility and function name.
Installation
Using Sublime Package Control
If you are using the Sublime Package Manager, you can install Alphpetize by selecting Package Control: Install Package
under the Sublime Text > Preferences > Package Control
menu item. Type Alphpetize
and install!
With Git
Clone the package into your Sublime Text 2/3 Packages directory:
git clone https://github.com/foxxyz/sublime_alphpetize.git Alphpetize
Without Git
Grab the source from Github, copy the whole directory into the Packages directory and rename it to “Alphpetize”.
Package Directory locations:
- OSX:
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
- Linux:
~/.Sublime\ Text\ 2/Packages/
or~/.config/sublime-text-2/Packages/
- Windows:
%APPDATA%/Sublime Text 2/Packages/
The locations for Sublime Text 3 should be identical, disregarding the version number change. The plugin should be picked up automatically. If not, restart Sublime Text.
Usage
After installation, select Sort Methods
from the Edit
menu.
Example
Consider the following file:
class Test {
private function bottom() {
}
/**
* This function rocks
* @return void
*/
public function middle() {
}
public function atTheTop() {
}
protected function leaveMe() {
}
}
After running Alphpetize, it should look at follows:
class Test {
public function atTheTop() {
}
/**
* This function rocks
* @return void
*/
public function middle() {
}
protected function leaveMe() {
}
private function bottom() {
}
}
And yes, Alphpetize can also handle files with multiple class definitions.
What about static methods?
Static methods are placed at the top of their visibility group.
What about comments?
DocBlocks and single //
-style comments preceding their functions will be preserved during sorting.
What about traits and interfaces?
Methods defined inside of traits and interfaces are also sorted.
What about everything else?
Anything else found floating in-between function definitions will be collected at the top of the class.
Testing
Tests can be run using the nice UnitTesting plugin in Package Control.