PEAR's December Bug Triage Day was alright, if somewhat quiet. It was actually more spread out over the preceding weeks rather than much on the day itself.
Christian got a new version of Services_Blogging out earlier in the month, while Console_GetArgs and Numbers_Words got updated and increased unit test coverage - just about everyone under the sun chipped in and wrote translated unit tests for Numbers_Words - Igor, Christian, Lorenzo, Kouber, David and anyone else I missed.
Payment_DTA got a new owner in Martin Schutte, which saw a good few bug fixes applied.
I fixed up Text_Figlet, which broke PHP 4 compatibility, and got out a release of it and Services_Yadis.
Finally, Validate got back in the unit test good books, with almost all unit test failures resolved.
The next one is calendared for December 28th, so we'll see how that goes :)
Half person, half home automation, an under loved blog for all things Ruby, python and more in Adelaide
Showing posts with label quality. Show all posts
Showing posts with label quality. Show all posts
Wednesday, December 10, 2008
Sunday, June 08, 2008
How to customise PHP_CodeSniffer (writing custom coding standards)
PHP_CodeSniffer is a PEAR package which detects potential coding problems and enforces your style guide.
The default is the PEAR coding standard, but you can easily change that.
First,
Second, create a new folder somewhere -
Third, you'll want to make a
It should look somewhat like:
Spend a little time searching for the sniffs you want to use - some can be a huge help, or a huge pain.
Next, use the CLI tool
Once you have your package.xml; you just want to type
Testing it:
To set it to your default coding standard:
What next?
You could set it up to run via Cron across your entire project, or you could integrate it with an SVN post commit hook.
The default is the PEAR coding standard, but you can easily change that.
First,
pear install PHP_CodeSnifferand
pear install PEAR_PackageFileManager_Cli.
Second, create a new folder somewhere -
PHP/CodeSniffer/Standards/Foo
Third, you'll want to make a
FooCodingStandard.phpin that directory.
It should look somewhat like:
<?php
if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) {
throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_CodingStandard not found');
}
class PHP_CodeSniffer_Standards_Foo_FooCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard
{
public function getIncludedSniffs()
{
return array(
'Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php',
'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
'Generic/Sniffs/Metrics/NestingLevelSniff.php',
'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
'Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php',
'Generic/Sniffs/PHP/LowerCaseConstantSniff.php',
'Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php',
'PEAR/Sniffs/Files/IncludingFileSniff.php',
'PEAR/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php',
'PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php',
'PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php',
);
}//end getIncludedSniffs()
}//end class
Spend a little time searching for the sniffs you want to use - some can be a huge help, or a huge pain.
Next, use the CLI tool
pfmto create a package.xml in
PHP/. You want to set the base install directory to PHP/; and you want to watch out for case senstivity and the like.
Once you have your package.xml; you just want to type
pear packagein the same directory - if it works, you should have a new .tgz with you can install -
pear install PHP_CodeSniffer_Standards_Foo-0.0.1.tgz
Testing it:
phpcs -ishould show your new coding standard listed here if everything is working correctly.
To set it to your default coding standard:
phpcs --config-set default_standard Foo
What next?
You could set it up to run via Cron across your entire project, or you could integrate it with an SVN post commit hook.
Subscribe to:
Posts (Atom)