4. Get Changes
svnlook changed /svn/repository
●
Returns file list prefixed with action (no xml)
–
A = added, U = updated
●
Create a list of changes
●
Filter for action and files extension
–
Filter for external code files
–
5. Get File Content
svnlook cat
●
/svn/repository/trunk/project/file.php
--transaction 123
No local file, just the content
●
6. PHPCodeSniffer
PEAR package
●
Check files, directories or a string
●
Parses php source to tokens
●
ext/tokenizer
–
JS support
–
Runs checks on token tree
●
Default checks for several coding standards
●
Outputs text or xml
●
7. Use PHPCodeSniffer: Source
//init code sniffer
include('PHP/CodeSniffer.php');
$phpcs = new PHP_CodeSniffer(1, 1, array(), TRUE);
//run the codesniffer
ob_start();
$phpcs->process($phpFiles, 'PAPAYA');
ob_end_clean();
ob_start();
$phpcs->printXMLErrorReport(FALSE);
$xml = ob_get_clean();
8. Use PHPCodeSniffer
Block output during process()
●
Catch output from printXMLErrorReport()
●
Parse XML messages
●
Extract/map file name
●
Output error messages to php://stderr
●
9. Problem: No local files
Call PHPCodesniffer for each file providing its
●
content
Performance
–
Write temporary files
●
Performance
–
Different file names
–
PHP stream wrapper
●
Different file names
–
10. PHP Stream Wrapper
Define a location syntax
●
svnlook:///svn/repository/.../file.php|transaction|123
–
Register your own stream wrapper
●
include(dirname(__FILE__).'/svnlookstreamwrapper.php');
stream_wrapper_register(
'svnlook',
'SVNLookStreamWrapper'
);
11. SVNLookStreamWrapper
PHP class
●
Read only
●
Public methods
●
url_stat()
–
Used by file_exists()
●
stream_open() / stream_read() / stream_seek()
–
stream_tell() / stream_eof()
–