Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

PHPCS rules for the Kohana framework

branch: master
README.md

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.

Requirements

These tests require PHP Codesniffer

Installation - PEAR (recommended)

Standard PEAR install:

sudo pear channel-discover pear.kohanaframework.org
sudo pear install kohana/PHP_CodeSniffer_Standards_Kohana

Installation - If you intened to make changes to the sniff's

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

git clone https://github.com/kohana/coding-standards.git 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

Running

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

Testing

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"

Something went wrong with that request. Please try again.