Download the PHP package zenify/coding-standard without Composer
On this page you can find all versions of the php package zenify/coding-standard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zenify/coding-standard
More information about zenify/coding-standard
Files in zenify/coding-standard
Package coding-standard
Short Description Set of rules for PHP_CodeSniffer preferring tabs and based on Nette coding standard.
License MIT
Informations about the package coding-standard
Coding Standard
Set of rules for PHP_CodeSniffer preferring tabs and based on Nette coding standard.
Check rules overview for examples.
Install
Usage
Run with Php_CodeSniffer:
That's all!
How to be both Lazy and Safe
Composer hook
In case you don't want to use Php_CodeSniffer manually for every change in the code you make, you can add pre-commit hook via composer.json
:
Every time you try to commit, Php_CodeSniffer will run on changed .php
files only.
This is much faster than checking whole project, running manually or wait for CI.
Pretty cool, huh?
Testing
Contributing
Rules are simple:
- new feature needs tests
- all tests must pass
- 1 feature per PR
We would be happy to merge your feature then!
Rules Overview
Rules uses default numeric parameters (some can be changed to match your needs).
TOC:
- 1 Classes
- 2 Commenting
- 3 Control Structures
- 4 Debug
- 5 Namespaces
- 6 Naming
1 Classes
ClassDeclarationSniff
- Opening brace for the class should be followed by 1 empty line
- Closing brace for the class should be preceded by 1 empty line
Correct
Wrong
FinalInterfaceSniff
- Non-abstract class that implements interface should be final.
- Except for Doctrine entities, they cannot be final.
Correct
Wrong
2 Commenting
BlockPropertyCommentSniff
- Block comment should be used instead of one liner
Correct
Wrong
ComponentFactoryCommentSniff
- CreateComponent* method should have a doc comment
- CreateComponent* method should have a return tag
- Return tag should contain type
Correct
Wrong
VarPropertyCommentSniff
- Property should have docblock comment.
Correct
Wrong
MethodCommentSniff
- Method without parameter typehints should have docblock comment.
Correct
Wrong
MethodCommentReturnTagSniff
- Getters should have @return tag or return type.
Correct
Wrong
3 Control Structures
NewClassSniff
- New class statement should not have empty parentheses
Correct
Wrong
SwitchDeclarationSniff
Correct
Wrong
YodaConditionSniff
- Yoda condition should not be used; switch expression order
Correct
Wrong
4 Debug
DebugFunctionCallSniff
- Debug functions should not be left in the code
Wrong
5 Namespaces
NamespaceDeclarationSniff
- There must be 2 empty lines after the namespace declaration or 1 empty line followed by use statement.
Correct
or
Wrong
or
UseDeclarationSniff
- There must be one USE keyword per declaration
- There must be 2 blank lines after the last USE statement
Correct
Wrong
6 Naming
AbstractClassNameSniff
- Abstract class should have prefix "Abstract"
Correct
Wrong
InterfaceNameSniff
- Interface should have suffix "Interface"
Correct
Wrong
7 WhiteSpace
DocBlockSniff
- DocBlock lines should start with space (except first one)
Correct
Wrong
ExclamationMarkSniff
- Not operator (!) should be surrounded by spaces
Correct
Wrong
IfElseTryCatchFinallySniff
- Else/elseif/catch/finally statement should be preceded by 1 empty line
Correct
Wrong
InBetweenMethodSpacingSniff
- Method should have 2 empty lines after itself
Correct
Wrong
PropertiesMethodsMutualSpacingSniff
- Between properties and methods should be 2 empty lines
Correct
Wrong