PHPCS rules for the Kohana framework
Pull request Compare This branch is 22 commits behind kohana:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PHP Codesniffer standard for the Kohana Framework

This package contains a set of coding standard tests for the kohana PHP framework.
The original tests were written by Matthew Turland, see his github repo for more info.

These tests are meant to be a guide and may not be 100% accurate. If you find a bug please report it on the kohana issue tracker.


These tests require PHP Codesniffer


If you want the standard to be available system wide you can symlink them into the code sniffer dir like so:

git clone kohana-coding-standards
cd kohana-coding-standards
sudo ln -sfn `pwd`/PHP/CodeSniffer/Standards/Kohana `pear config-get php_dir`/PHP/CodeSniffer/Standards/Kohana 
sudo ln -sfn `pwd`/test/PHP_CodeSniffer/CodeSniffer/Standards/Kohana `pear config-get test_dir`/PHP_CodeSniffer/CodeSniffer/Standards/Kohana


You can reference the standard like so:

phpcs --standard=Kohana system/classes/kohana

Or, if you don't want to install it system wide you can simply reference the local copy

phpcs --standard=path/to/coding-standard/PHP/CodeSniffer/Standards/Kohana system/classes/kohana


Like all things code related, sniffs need to be tested! To run the tests they need to be in the codesniffer dir (i.e. you should run the above commands to symlink the sniffs / tests in) and you need to patch phpcs' AllSniffs.php

Then just run the tests like so:

phpunit --bootstrap=`pear config-get php_dir`/PHP/CodeSniffer.php `pear config-get test_dir`/PHP_CodeSniffer/CodeSniffer/Standards/AllSniffs.php

Known issues

  • There are some problems with expressions in ternary operators

Please report any new issues to the K3 bug tracker and file it under "PHPCS Coding Standards"