dev-master
9999999-devPHP Code Sniffer
MIT
The Requires
- php >=5.5.9
The Development Requires
by Safak Ozpinar
0.6.1
0.6.1.0PHP Code Sniffer
MIT
The Requires
- php >=5.5.9
The Development Requires
by Safak Ozpinar
Wallogit.com
2017 © Pedro Peláez
PHP Code Sniffer
PHP Code Sniffer is a PHP code standard checker/beautifier/fixer tool based on PHP_CodeSniffer and includes custom sniffs used in PHP projects developed by I2ct., (*1)
PHP Code Sniffer requires PHP 5.6 or later., (*2)
{
"require-dev": {
"tavy315/php-code-sniffer": "*"
}
}
Binaries are located in bin directory but composer installer creates links under
your vendor binary directory depending on your composer configuration., (*3)
Save the following script as .git/hooks/pre-commit by replacing COMPOSER_BIN_DIR
as your vendor binary directory name depending on your composer configuration., (*4)
#!/bin/sh ./COMPOSER_BIN_DIR/phpcs-pre-commit
Make sure the hook script is executable., (*5)
chmod +x .git/hooks/pre-commit
You can customize configuration by adding a file called phpcs.xml file into
the root directory of your project. The phpcs.xml file has exactly the same
format as a normal ruleset.xml file, so all the same options are available in
it. You need to define I2ct rule to import all the I2ct rules., (*6)
<?xml version="1.0" encoding="UTF-8"?>
<ruleset>
<rule ref="I2ct" />
</ruleset>
You can add custom bootstrap files to be included before beginning the run. Some sniffs need to load classes from your project; so adding a autoload file will allow sniffs to do this., (*7)
<?xml version="1.0" encoding="UTF-8"?>
<ruleset>
<rule ref="I2ct" />
<arg name="bootstrap" value="vendor/autoload.php" />
</ruleset>
All PSR2 sniffs except Squiz.WhiteSpace.ControlStructureSpacing are imported by default.
* PSR2.ControlStructures.ElseIfDeclaration.NotAllowed rule type is considered as error instead of warning., (*8)
Imported sniffs:
* All sniffs in Generic.Formatting category except:
* DisallowMultipleStatements (replaced by I2ct.Formatting.DisallowMultipleStatements)
* NoSpaceAfterCast
* SpaceAfterNot
* Generic.Arrays.DisallowLongArraySyntax, (*9)
Imported sniffs:
* Squiz.Commenting.DocCommentAlignment
* Squiz.Commenting.InlineComment
* InvalidEndChar rule type is considered as warning instead of error.
* Squiz.WhiteSpace.SuperfluousWhitespace
* Squiz.WhiteSpace.OperatorSpacing, (*10)
Squiz.Arrays.ArrayDeclaration.NoKeySpecifiedKeySpecifiedMultiLineNotAllowedNoCommaAfterLastNoCommaGeneric.Commenting.DocComment.MissingShort rule for PHPUnit test class methods [1].MissingShort rule type from error to warning.SpacingBetweenLongNotCapitalSpacingBeforeTagsParamGroupNonParamGroupSpacingAfterTagGroupTagValueIndentParamNotFirstTagsNotGroupedPEAR.Commenting.FunctionComment.{@inheritdoc} validation for overrided methods [1].MissingParamComment, MissingReturn, SpacingAfterParamType and SpacingAfterParamName rules.MissingParamTag rule for PHPUnit test class methods [1].Squiz.Commenting.VariableComment.bool and int into allowed variable types.Generic.Formatting.DisallowMultipleStatements.SameLine fixer with Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace fixer together.This sniff has two rules and fixes.
* PaddingFound: There must be only one space between the concatenation operator (.) and the strings being concatenated.
* NotAligned: Multiline string concatenations must be aligned., (*11)
Squiz.WhiteSpace.FunctionSpacing.Squiz.WhiteSpace.MemberVarSpacing.You can test any modifications by running phpcs.php, phpcbf.php and
phpcs-pre-commit.php scripts under scripts directory., (*12)
Run the command below to re-build binaries:, (*13)
php scripts/build.php
Current version is built on PHP_CodeSniffer 2.8.1
which is locked in composer.lock file. To import new versions; edit composer.json file if required and
run composer update command, then commit the modified composer.lock file. Updating PHP_CodeSniffer version may
break some of I2ct sniffs, so you must carefully track any changes on PHP_CodeSniffer before updating., (*14)
[1] A class loader is required (eg. via a bootstrap file),
otherwise a warning (Internal.I2ct.NeedClassLoader) will be generated.
You can override this rule in phpcs.xml file in your project to prevent warnings.
↩ ↩ ↩ ↩, (*15)
PHP_CodeSniffer is licensed under the BSD 3-Clause license., (*16)
PHP Code Sniffer
MIT
PHP Code Sniffer
MIT