Giter VIP home page Giter VIP logo

php-code-validator's Introduction

Flyeralarm PHP Coding Guideline Validator

This repository contains the ruleset for the PHP code we develop at FLYERALARM. It mostly consists of PSR-2 with some custom additions. The rules are enforced with the help of squizlabs/PHP_CodeSniffer

Custom Rules in addition to PSR-2

  • Variable names must be in lowerCamelCase
  • Yoda conditions are forbidden
  • Unit tests with @expectedException must contain @expectedExceptionMessage annotation
  • Return type annotations (@return) must only contain one of scalar type or object (e.g. no "@return string|null")
  • Exceptions messages must not contain exclamation marks or full stops
  • Keywords GOTO and EVAL are forbidden
  • Underscores in namespaces are forbidden
  • Classtype suffixes like Interface, Abstract or Trait are forbidden (e.g. LoggerInterface)

How-To work within this project

To prepare run command:

make

To test ruleset run command:

make test

Embed into your project

Add as composer dev dependency:

composer config repositories.flyeralarm/php-code-validator git https://github.com/flyeralarm/php-code-validator.git
composer require --dev flyeralarm/php-code-validator

Embed code sniffer in your Makefile. To intend please use tabs instead of spaces.
Usage: vendor/bin/php-code-validator <...>

Example Makefile:

test:
	vendor/bin/php-code-validator src/ tests/

Update to latest stable

composer update flyeralarm/php-code-validator

Run sniffer

make test

Use within PHPStorm

  1. Ensure the path to PHP Code Sniffer is configured - open configuration manual
  2. Open settings:
    Mac: PhpStorm > Preferences > Editor > Inspections > PHP
    Windows & Linux: File > Settings > Editor > Inspections > PHP \
  3. Activate/Tick checkbox for PHP Code Sniffer validation
  4. Click on the item PHP Code Sniffer validation to open its settings on the right hand side
  5. Choose "Custom" for „Coding standard:“ and click on ... on the right hand side
  6. Select Path to ruleset. This would be something like <YOUR_APP_ROOT>/vendor/flyeralarm/coding-guidelines/ruleset.xml
  7. Confirm dialogs by pressing ok

On a side note: We are searching for talented people to join our various teams of developers in multiple locations

php-code-validator's People

Contributors

daniel-mueller avatar fa-grosch avatar

Watchers

 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.