Integrating CodeSniffer with PHPEd |
|
http://pear.php.net/package/PHP_CodeSniffer
Script allows to jump to the error number line from the log window (read this) Command line: "c:\Program Files\NuSphere\PhpED\php5\php.exe" "c:\Program Files\NuSphere\PhpED\scripts\codesnifferwrapper.php" "@FName@"
|
||||||||||||||
|
|
Everything works deduces
But in the graph log: Location shows first error and then in the other files it displays the same mistake (Location hang) screenshot url: clip2net.com/s/2uLMo use phped 8.1 (8108) -------- also, this is the kind of code that causes hang log: Location <?php echo "D:\\WebServer\\domains\\project1.ru\\test1.php (2) \n"; echo "D:\\WebServer\\domains\\project1.ru\\test1.php (3) \n"; echo "D:\\WebServer\\domains\\project1.ru\\test1.php (4) \n"; ?> ------------------------------ File location regexp: ^([^ ]+) (\([0-9]*\)) .*$ (or say Output location regexp) by applying this regexp on each line in the output, IDE will get array of two elements (when matched, of course). And one of the elements will be file name and the other is line number. ----------------------------------- who knows how to solve the problem? |
||||||||||||
|
How I made PhpEd work with the CodeSniffer |
|
This article describe installation for Windows (XP) system.
I wasn't able to install actual version of a Pear in a PhpEd/php directory (there was a lots of problems with Pear), so I use the a xampp/php directory.
And for example I use CakePHP framework - download a file: - uzip the file into a directory: xampp\php\PEAR\PHP\CodeSniffer\Standards - rename a cakephp-codesniffer-master directory to CakePHP - go to the Tools -> Settings -> Integration menu - use "AddMenu" button and set the "Menu Name" to CodeSniff - set "Command Line" to: <full_path>\xampp\php\php.exe" -d include_path="'<full_path>\xampp\php\pear'" -f "<full_path>\xampp\php\phpcs" -- --standard=CakePHP "@FName@" - set Options:
- CHECK - Show this command in File Bar popup - CHECK - Redirect Error stream to log window - SET - Save Output to file C:\Temp\CodeSniff.log - CHECK - Show this command for local files only - SET - Open file in editor/browser C:\Temp\CodeSniff.log also You can use the CodeSnifferWrapper improvement - save the script code above to <full_path>\xampp\php\codesnifferwrapper.php - change the PATH_TO_PHP to the value const PATH_TO_PHP = "<full_path>\\xampp\\php\\"; - set "Command Line" to: <full_path>\xampp\php\php.exe" -d include_path="'<full_path>\xampp\php\pear'" -f "<full_path>\xampp\php\codesnifferwrapper" "@FName@" - set Options:
- CHECK - Show this command in Tools menu - CHECK - Show this command in File Bar popup - CHECK - Redirect Output stream to log window - CHECK - Redirect Error stream to log window Good luck. |
||||||||||||||
|
Another CodeSniffer integration approach |
|
In my case CodeSniffer runs on dev server when code is about to get merged. It is generating a report file which must be processed before code ia accepted.
As you see I don't need to run CodeSniffer from PhpED IDE, but rather need a tool for CS log processing. I wrote a small script to process an open in editor CS log and output errors to Log window with clickable error messages. Clicking on the error message jumps to the referring file/line.
To setup: Tools->Settings->Integration Click "Add menu" Name it as you wish. I named mine "CodeSniffer digest" Execute with: Shell Command line: @php53cli@ "/path/to/script/above/script.php" "/path/to/remove/from/log/" Little comment on "/path/to/remove/from/log/": CS outputs errors like this
and "/home/dev/code/" must be removed to make PhpED correctly find local file. What's left must be a relative path to your local project/file CHECK Show this command in File Bar popup CHECK Work with editor CHECK Take input from CHECK Whole file CHECK Redirect Output stream to log window CHECK Redirect Error stream to log window That's all. Now open CS log file in PhpED editor and right-click on the file name (tabs above editing area). Select "CodeSniffer digest". Enjoy |
||||||||||||||||
|
Integrating CodeSniffer with PHPEd |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by