GithubHelp home page GithubHelp logo

chefsplate / sniffer-rules Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 12 KB

Official ChefsPlate Sniffer Rules for the PHP Dev Team.

License: MIT License

PHP 100.00%
php codesniffer codestyle chefsplate

sniffer-rules's Introduction

phpcs 2.0+ Laravel 4/5 Command

Build Status Latest Stable Version License

This is a Laravel 4/5 package that hooks up SquizLabs CodeSniffer 2 into Laravel-based apps. It can also be used manually, so read on.

Detect violations of a defined coding standard. It helps your code remain clean and consistent. Available options are: PSR2, PSR1, Zend, PEAR, Squiz, PHPCS and ChefsPlate.

Setup

Require this package in composer:

$ composer require chefsplate/sniffer-rules

Laravel 4/5

In your config/app.php add ChefsPlate\SnifferRules\ServiceProvider:class to $providers array:

'providers' => [
    ...

    ChefsPlate\SnifferRules\ServiceProvider::class,

    ...
],

Laravel 5: Publish the configuration file

$ php artisan vendor:publish

Laravel 4: Manually create config

Copy config to app/config/sniffer-rules.php

Edit configuration file config/sniffer-rules.php to tweak the sniffer behavior.

Manual

Install our Standard by configuring PHP_CodeSniffer to look for it.

$ php ./vendor/bin/phpcs --config-set installed_paths ./vendor/chefsplate/src/ChefsPlate/SnifferRules/Standard/

Usage

Laravel

$ php artisan sniff

To run the sniffer in a CI environment, the -n option should be set to remove interaction:

$ php artisan sniff -n

Manual

$ php ./vendor/bin/phpcs --standard=ChefsPlate path/to/code

It's encouraged to add a Makefile to your project that makes it trivial for other developers. Use Makefile in this directory and adjust as needed to fit your project requirements.

ChefsPlate Coding Standards

Coding standards

Addendum and Clarifications

  • namespace should be on the same line as opening php tag. e.g.: <?php namespace ChefsPlate\Amazing
  • Property names should be snake_case
  • Test names should use underscores, not camelCase. e.g.: test_cats_love_catnip

License

MIT

sniffer-rules's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sniffer-rules's Issues

Allow for compound operators

A few compound operators such as =& trip the rule that enforces spaces around equal signs. It should support all such compound assignment operators.

Add automatic fix for operator spacing sniff

It should be a matter of parsing and adding spaces before and after an operator token as it's found. Since it's really easy to slip off of the spacebar, an automatic fix could help with mass styling issues.

Allow passing --no-patch option

Some environments don't have access to a fully featured patch implementation e.g. Alpine Linux. We should allow users to pass the --no-patch option and then pass that along to the phpcbf process when we execute it so that fixes can be auto-applied even if their environment's patch implementation lacks the required behaviour and functionality.

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.