Skip to content

Update README with newer rules #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
Doctrine PHP_CodeSniffer Coding Standard
========================================
Doctrine Coding Standard
========================

[![Build Status](https://img.shields.io/travis/doctrine/coding-standard/master.svg?style=flat-square)](http://travis-ci.org/doctrine/coding-standard)
[![Total Downloads](https://img.shields.io/packagist/dt/doctrine/coding-standard.svg?style=flat-square)](https://packagist.org/packages/doctrine/coding-standard)
[![Latest Stable Version](https://img.shields.io/packagist/v/doctrine/coding-standard.svg?style=flat-square)](https://packagist.org/packages/doctrine/coding-standard)


The [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) ruleset to check that repositories are
following the standards defined by the our team.
The [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) ruleset to check that
repositories are following the standards defined by the Doctrine team.

Standards
---------

We use [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
and [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) with some
exceptions/differences (:white_check_mark: are the implemented sniffs):
Doctrine Coding Standard is based on [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
and [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), with some noticeable
exceptions/differences/extensions (:white_check_mark: are the implemented sniffs):

- Keep the nesting of control structures per method as small as possible
- Add spaces between assignment, control and return statements
- Prefer early exit over nesting conditions
- :white_check_mark: Align equals (=) signs
- Prefer early exit over nesting conditions or using else
- :white_check_mark: Align equals (`=`) signs in assignments
- :white_check_mark: Add spaces around a concatenation operator `$foo = 'Hello ' . 'World!';`
- :white_check_mark: Add spaces around a negation if condition `if ( ! $cond)`
- :white_check_mark: Add spaces around a return type declaration `function () : void {}`
- :white_check_mark: Add spaces between assignment, control and return statements
- :white_check_mark: Add spaces after a negation operator `if (! $cond)`
- :white_check_mark: Add spaces around a colon in return type declaration `function () : void {}`
- :white_check_mark: Add spaces after a type cast `$foo = (int) '12345';`
- :white_check_mark: Use apostrophes for enclosing strings
- :white_check_mark: Always use strict comparisons
- :white_check_mark: Always add `declare(strict_types=1)` at the beginning of a file
- :white_check_mark: Always add native types where possible
- :white_check_mark: Omit phpDoc for parameters/returns with native types, unless adding description
- :white_check_mark: Don't use `@author`, `@since` and similar annotations that duplicate Git information
- :white_check_mark: Assignment in condition is not allowed

For full reference of enforcements, go through `lib/Doctrine/ruleset.xml` where each sniff is briefly described.

Installation
------------
Expand Down