Git Product home page Git Product logo

coding-standards-3's Introduction

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 are built for usage with PHP Codesniffer.

Installation - Composer

Add the package to the development dependencies in your project's composer.json

{
    "require-dev": {
        "kohana/coding-standards": "*",
    }
}

Run composer --dev update to update your composer.lock file and install the package. The sniffs will be installed in vendor/kohana/coding-standards in your project root directory and the phpcs command will be installed to bin/phpcs.

Installation - Manually or with PEAR

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`/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

If you installed with composer, reference the standard from your vendor directory:

bin/phpcs --standard=vendor/kohana/coding-standards/Kohana modules/

Or, from a raw clone, you can simply reference the local copy:

phpcs --standard=path/to/coding-standards/Kohana kohana/core

If installed globally (symlinked into PEAR), you can reference the standard like so:

phpcs --standard=Kohana application/

Customising your project standard

It is also possible to extend the rules in use for your project, or to include some but not all of the Kohana standards (for example, if you are working on something that is not intended as a kohana module). You do this by adding a coding_standard.xml to your project root which specifies which rules to include and customises any variables. See the PHP_CodeSniffer docs for more details.

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"

coding-standards-3's People

Contributors

brmatt avatar cbandy avatar kiall avatar elazar avatar acoulton avatar bobeagan avatar mintbridge avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.