PHPackages                             vicimus/standard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vicimus/standard

ActivePhpcodesniffer-standard[Utility &amp; Helpers](/categories/utility)

vicimus/standard
================

v6.3.0(3mo ago)110.1k27MITPHPPHP &gt;=7.1

Since Jul 13Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/Vicimus/Standard)[ Packagist](https://packagist.org/packages/vicimus/standard)[ RSS](/packages/vicimus-standard/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (6)Versions (70)Used By (7)

Vicimus Standard
================

[](#vicimus-standard)

This is a phpcs implementation of the Vicimus Coding Standard. Combined with [the PSR2 coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), the Vicimus Coding Standard fills in some holes that PSR2 does not cover (mainly PHP 7 related things, but a few others).

*It's worth noting that many of these rules/sniffs are from existing phpcs code standard sniffs, and thus many of the rule descriptions are directly taken from their documentation.*

Rules/Sniffs
============

[](#rulessniffs)

The following rules expand upon PSR2s coding standards.

Arrays
------

[](#arrays)

### Disallow Long Array Syntax

[](#disallow-long-array-syntax)

Ensures that all array definitions use the short syntax `[]` instead of long `array()`.

### Trailing Array Comma

[](#trailing-array-comma)

Commas after last element in an array make adding a new element easier and result in a cleaner versioning diff.

This sniff enforces trailing commas in multi-line arrays and requires short array syntax `[]`.

Classes
-------

[](#classes)

### Class Constant Visibility

[](#class-constant-visibility)

In PHP 7.1 it's possible to declare visibility of class constants. In a similar vein to optional declaration of visibility for properties and methods which is actually required in sane coding standards, this sniff also requires to declare visibility for all class constants.

```
const FOO = 1; // visibility missing!
public const BAR = 2; // correct

```

### Doc Comment

[](#doc-comment)

Ensures doc blocks follow basic formatting. This checks to make sure there is proper spacing, line breaks, etc. on all docblock content.

### Function Call Argument Spacing

[](#function-call-argument-spacing)

Ensures proper spacing between function arugments.

### Lowercase Constants

[](#lowercase-constants)

Kind of redunant but included, ensures constants are not lowercase.

### Unused Private Elements

[](#unused-private-elements)

Checks for unused methods, unused or write-only properties in a class and unused private constants. Reported unused elements are safe to remove.

This is very useful during refactoring to clean up dead code and injected dependencies.

### Uppercase Constants

[](#uppercase-constants)

Ensures constants are declared in uppercase.

Formatting
----------

[](#formatting)

### Disallow Tab Indents

[](#disallow-tab-indents)

Ensures all indenting is done with spaces not tabs

### Doc Comment Alignment

[](#doc-comment-alignment)

Ensures all doc comments use proper alignment and spacing between params and return values, with type, name and descriptions.

```
// Good --
/**
 * A method!
 *
 * @param string $value  This is the value to pass
 * @param int    $number Another parameter here
 *
 * @return Response
 */

 // Bad --
 /**
  * A method!
  *
  * @param  string $value
  * @param int $number Another parameter here
  *
  * @return Response
  */

```

### Function Comments

[](#function-comments)

Ensures all methods are commented with accurate doc blocks.

### Inline Doc Comment Declaration

[](#inline-doc-comment-declaration)

Reports invalid format of inline phpDocs with @var.

### Line Length Limits

[](#line-length-limits)

Enforces a soft character limit of 80 characters, and will throw an error if it exceeds 120.

Type Hints
----------

[](#type-hints)

### Declare Strict Types

[](#declare-strict-types)

Enforces having declare(strict\_types = 1) at the top of each PHP file. Should follow this example:

```
