Download the PHP package gamegos/php-code-sniffer without Composer
On this page you can find all versions of the php package gamegos/php-code-sniffer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-code-sniffer
Gamegos PHP Code Sniffer
Gamegos 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 Gamegos.
Requirements
Gamegos PHP Code Sniffer requires PHP 5.3 or later.
Install via Composer
Binaries
Binaries are located in bin directory but composer installer creates links under
your vendor binary directory depending on your composer configuration.
- phpcs : Checks PHP files against defined coding standard rules.
- phpcbf : Corrects fixable coding standard violations.
- phpcs-pre-commit : Runs phpcs for modified files in git repository.
Pre-Commit Hook
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.
Make sure the hook script is executable.
Customize
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 Gamegos rule to import all the Gamegos rules.
Using a custom bootstrap file
You can add custom bootstap 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.
Imported Standards
PSR2
All PSR2 sniffs except Squiz.WhiteSpace.ControlStructureSpacing are imported by default.
PSR2.ControlStructures.ElseIfDeclaration.NotAllowedrule type is considered aserrorinstead ofwarning.
Generic
Imported sniffs:
- All sniffs in
Generic.Formattingcategory except:DisallowMultipleStatements(replaced byGamegos.Formatting.DisallowMultipleStatements)NoSpaceAfterCastSpaceAfterNot
Generic.Arrays.DisallowLongArraySyntax
Squiz
Imported sniffs:
Squiz.Commenting.DocCommentAlignmentSquiz.Commenting.InlineCommentInvalidEndCharrule type is considered aswarninginstead oferror.
Squiz.WhiteSpace.SuperfluousWhitespaceSquiz.WhiteSpace.OperatorSpacing
Custom Sniffs
Gamegos.Arrays.ArrayDeclaration
- Extended from
Squiz.Arrays.ArrayDeclaration. - Arranged array element indents by start position of the first (declaration) line.
- Number of spaces before array elements is increased from 1 to 4.
- Removed rules:
NoKeySpecifiedKeySpecifiedMultiLineNotAllowedNoCommaAfterLastNoComma
Gamegos.Commenting.DocComment
- Extended from
Generic.Commenting.DocComment. - Ignored
MissingShortrule for override methods and PHPUnit test class methods [1]. - Changed
MissingShortrule type fromerrortowarning. - Removed rules for comments with long descriptions:
SpacingBetweenLongNotCapitalSpacingBeforeTagsParamGroupNonParamGroupSpacingAfterTagGroupTagValueIndentParamNotFirstTagsNotGrouped
Gamegos.Commenting.FunctionComment
- Extended from
PEAR.Commenting.FunctionComment. - Allowed override methods and PHPUnit test class methods without doc comments [1].
- Added
{@inheritdoc}validation for override methods [1]. - Removed
MissingParamComment,MissingReturn,SpacingAfterParamTypeandSpacingAfterParamNamerules. - Ignored
MissingParamTagrule for PHPUnit test class methods [1].
Gamegos.Commenting.VariableComment
- Extended from
Squiz.Commenting.VariableComment. - Added
boolandintinto allowed variable types.
Gamegos.Formatting.DisallowMultipleStatements
- Extended from
Generic.Formatting.DisallowMultipleStatements. - Fixed adding 2 blank lines when applying
SameLinefixer withSquiz.Functions.MultiLineFunctionDeclaration.ContentAfterBracefixer together.
Gamegos.Strings.ConcatenationSpacing
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.
Gamegos.WhiteSpace.FunctionSpacing
- Extended from
Squiz.WhiteSpace.FunctionSpacing. - Expected no blank lines before the method which is the first defined element of a class.
- Expected no blank lines after the method which is the last defined element of a class.
- Fixed fixing spaces before method definitions.
Gamegos.WhiteSpace.MemberVarSpacing
- Extended from
Squiz.WhiteSpace.MemberVarSpacing. - Expected no blank lines before the property which is the first defined element of a class.
- Fixed fixing spaces before property definitions.
Development
Live Testing
You can test any modifications by running phpcbf.php and
phpcs-pre-commit.php scripts under scripts directory.
Building Binaries
Run the command below to re-build binaries:
PHP_CodeSniffer Dependency
Current version is built on PHP_CodeSniffer 2.9.2
which is locked in composer.json file if required and
run composer update command, then commit the modified PHP_CodeSniffer version may
break some of PHP_CodeSniffer before updating.
[1] A class loader is required (eg. via a bootstrap file),
otherwise a warning (Internal.Gamegos.NeedClassLoader) will be generated.
You can override this rule in phpcs.xml file in your project to prevent warnings.
↩
License Notices
PHP_CodeSniffer is licensed under the BSD 3-Clause license.