vim-scripts / phpcs.vim Goto Github PK
View Code? Open in Web Editor NEWPHP coding rules checking utility
Home Page: http://www.vim.org/scripts/script.php?script_id=3928
PHP coding rules checking utility
Home Page: http://www.vim.org/scripts/script.php?script_id=3928
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3928 This plugin relies on PHP_CodeSniffer package.It parse the result of phpcs and redirect it into vim's quickfix buffer. So users can navigate the codding rule error place use ':cnext' and ':cprev'. PHP_CodeSniffer is a utility developed for checking codding rules for PHP scripts. For more information about PHP_CodeSniffer, see http://pear.php.net/package/PHP_CodeSniffer/ To use this plugin, you must have these global variables set: 1. The list of coding rule standards to follow, with each one seperated by comma. let g:phpcs_std_list="Zend, PEAR" 2. Your VCS type(Only needed when running 'Phpcs commit') let g:phpcs_vcs_type = 'svn' Currently only support 'svn' or 'cvs'. 3. Set the max allowed output lines. This is useful in case there are too many errors and memory is running out. let g:phpcs_max_output = 0 " Unlimited output. or let g:phpcs_max_output = 2000 " Output limited to 2000 line Following command are provided: :Phpcs " Check the current file, if not in DIFF mode. " Check the modified lines only, if in DIFF mode. And in DIFF mode, call :Phpcs twice, it will switch back and update the DIFF view. :Phpcs commit " Checking PHP files to be commited in the directory recursively :Phpcs all " Checking PHP files in the current directory recursively You can map shortcuts for your convenience. For example, in my working environment, we do following mappings: " input mode map inoremap <F5> <ESC>:Phpcs<CR> inoremap <F7> <ESC>:cprev<CR> inoremap <F8> <ESC>:cnext<CR> "normal mode map noremap <F5> <ESC>:Phpcs<CR> noremap <F7> <Esc>:cprev<CR> noremap <F8> <ESC>:cnext<CR> Note for the Phpcs in DIFF mode: 1. Why support Phpcs in DIFF mode? Due to historical reasons, there exist a lot of old codes not following the new coding standards. Our policy is that, for the new codes added, must following the coding standards; but keep the old codes as it is. So we only need to check the new codes to be committed. 2. Which scenario does this mode work? In this scenario, we use vimdiff for the extra diff command of svn diff. Before we commit the codes, we run svn diff, which in turn will call vimdiff to show what has been changed in codes. Here we call :Phpcs command, to do the checking, and that will only output errors/warning in the lines modified in this commit. 3. The Phpcs in DIFF mode is not flexible! You should make sure that: ONLY TWO WINDOWS EXIST IN DIFF VIEW, THE 1ST ONE IS THE ORIGINAL FILE, THE 2ND ONE IS THE MODIFIED FILE. If you use other plugins and they open windows automatically in vimdiff mode, you should close it first manually or add codes to do this in phpcs.vim. In the 1.1 version, I added codes to detect MiniBufExpl plugin, and close it automatically. Just for your reference.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.