Download the PHP package devbeta/psr12-strict-rules without Composer
On this page you can find all versions of the php package devbeta/psr12-strict-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devbeta/psr12-strict-rules
More information about devbeta/psr12-strict-rules
Files in devbeta/psr12-strict-rules
Package psr12-strict-rules
Short Description PSR-12 strict coding standard
License BSD-3-Clause
Informations about the package psr12-strict-rules
PSR-12 Strict Coding Standard
This specification extends and expands PSR-12, the extended coding style guide and requires adherence to PSR-1, the basic coding standard.
Contributors have different coding styles and so do the maintainers. During code reviews there are regularly discussions about spaces and alignments, where and when was said that a function needs to be imported. And that's where this coding standard comes in: To have internal consistency in a component and between components.
Installation
Install the module via composer by running:
`
Usage
Create file phpcs.xml
on base path of your repository with this content:
`
You can add or exclude some locations in that file. For a reference please see: Annotated Ruleset
Coding Style Guide
Basic Coding Standard
- Code MUST follow all rules outlined in PSR-12.
Arrays
- All values in multiline arrays must be indented with 4 spaces.
- The short array syntax MUST be used to define arrays.
Classes
- There MUST NOT be duplicate class names.
- Checks the declaration of the class and its inheritance is correct.
- The file name MUST match the case of the terminating class name.
- For self-reference a class lower-case
self::
MUST be used without spaces around the scope resolution operator.
Code Analysis
- The final keyword on methods MUST be omitted in final classes.
- Detects unnecessary overridden methods that simply call their parent.
Control Structures
- Verifies that control statements conform to their coding standards.
- Ensure multi-line
if
conditions are defined correctly.
Formatting
- There MUST be one whitespace after a type casting operator.
- There MUST be one whitespace after unary not.
- If an assignment goes over two lines, ensure the equal sign is indented.
Functions
- Ensure single and multi-line function declarations are defined correctly.
Metrics
- Checks the cyclomatic complexity (McCabe) for functions.
- Checks the nesting level for methods.
Naming Conventions
- Checks that abstract classes are prefixed by Abstract.
- Ensures method and functions are named correctly.
- Checks that interfaces are suffixed by Interface.
- Checks that traits are suffixed by Trait.
Operators
- The
&&
and||
operators SHOULD be used instead ofand
andor
.
PHP
- The backtick operator MUST NOT be used.
- Deprecated PHP functions MUST be avoided.
- The PHP
goto
language construct SHOULD NOT be used. - Alias functions SHOULD NOT be used.
- Throws an error or warning when any code prefixed with an asperand is encountered.
- Checks that the
strict_types
has been declared. - The constant
PHP_SAPI
SHOULD be used instead of thephp_sapi_name()
function. - The
global
keyword MUST NOT be used. - PHP function calls MUST be in lowercase.
- Non executable code MUST be removed.
Scope
- The pseudo-variable
$this
MUST NOT be called inside a static method or function.
Strings
- Checks that two strings are not concatenated together; suggests using one string instead.
- Makes sure there are no spaces around the concatenation operator.
WhiteSpace
- Check & fix whitespace on the inside of arbitrary parentheses.
- Verifies spacing between the spread operator and the variable/function call it applies to.
- Checks that object operators are indented correctly.
- Checks that the closing braces of scopes are aligned correctly.
- Checks the separation between functions and methods.
- There MUST be a single space after language constructs.
- There MUST NOT be any white space around the object operator UNLESS multilines are used.
- Verifies that class members are spaced correctly.
- Ensure there is no whitespace before/after an object operator.
- Verifies that operators have valid spacing surrounding them.
- There MUST NOT be a space before a semicolon. Redundant semicolons SHOULD be avoided.
All versions of psr12-strict-rules with dependencies
dealerdirect/phpcodesniffer-composer-installer Version ^0.7
squizlabs/php_codesniffer Version ^3.6