PHPackages                             gamegos/php-code-sniffer - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. gamegos/php-code-sniffer

ActiveLibrary[Testing &amp; Quality](/categories/testing)

gamegos/php-code-sniffer
========================

Gamegos PHP Code Sniffer

0.8.0(2y ago)54.4k↓90%16MITPHPPHP &gt;=5.3.10

Since Dec 18Pushed 2y ago13 watchersCompare

[ Source](https://github.com/gamegos/php-code-sniffer)[ Packagist](https://packagist.org/packages/gamegos/php-code-sniffer)[ RSS](/packages/gamegos-php-code-sniffer/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (10)Used By (6)

Gamegos PHP Code Sniffer
========================

[](#gamegos-php-code-sniffer)

Gamegos PHP Code Sniffer is a PHP code standard checker/beautifier/fixer tool based on [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) and includes [custom sniffs](#custom-sniffs) used in PHP projects developed by Gamegos.

Requirements
------------

[](#requirements)

Gamegos PHP Code Sniffer requires PHP 5.3 or later.

Install via Composer
--------------------

[](#install-via-composer)

```
{
    "require-dev": {
        "gamegos/php-code-sniffer": "*"
    }
}
```

Binaries
--------

[](#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
---------------

[](#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.

```
#!/bin/sh
./COMPOSER_BIN_DIR/phpcs-pre-commit
```

Make sure the hook script is executable.

```
chmod +x .git/hooks/pre-commit
```

Customize
---------

[](#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

[](#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
------------------

[](#imported-standards)

### PSR2

[](#psr2)

All PSR2 sniffs except `Squiz.WhiteSpace.ControlStructureSpacing` are imported by default.

- `PSR2.ControlStructures.ElseIfDeclaration.NotAllowed` rule type is considered as `error` instead of `warning`.

### Generic

[](#generic)

Imported sniffs:

- All sniffs in `Generic.Formatting` category except:
    - `DisallowMultipleStatements` (replaced by [`Gamegos.Formatting.DisallowMultipleStatements`](#gamegosformattingdisallowmultiplestatements))
    - `NoSpaceAfterCast`
    - `SpaceAfterNot`
- `Generic.Arrays.DisallowLongArraySyntax`

### Squiz

[](#squiz)

Imported sniffs:

- `Squiz.Commenting.DocCommentAlignment`
- `Squiz.Commenting.InlineComment`
    - `InvalidEndChar` rule type is considered as `warning` instead of `error`.
- `Squiz.WhiteSpace.SuperfluousWhitespace`
- `Squiz.WhiteSpace.OperatorSpacing`

Custom Sniffs
-------------

[](#custom-sniffs)

### Gamegos.Arrays.ArrayDeclaration

[](#gamegosarraysarraydeclaration)

- 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:
    - `NoKeySpecified`
    - `KeySpecified`
    - `MultiLineNotAllowed`
    - `NoCommaAfterLast`
    - `NoComma`

### Gamegos.Commenting.DocComment

[](#gamegoscommentingdoccomment)

- Extended from `Generic.Commenting.DocComment`.
- Ignored `MissingShort` rule for override methods and PHPUnit test class methods [\[1\]](#fn1).
- Changed `MissingShort` rule type from `error` to `warning`.
- Removed rules for comments with long descriptions:
    - `SpacingBetween`
    - `LongNotCapital`
    - `SpacingBeforeTags`
    - `ParamGroup`
    - `NonParamGroup`
    - `SpacingAfterTagGroup`
    - `TagValueIndent`
    - `ParamNotFirst`
    - `TagsNotGrouped`

### Gamegos.Commenting.FunctionComment

[](#gamegoscommentingfunctioncomment)

- Extended from `PEAR.Commenting.FunctionComment`.
- Allowed override methods and PHPUnit test class methods without doc comments [\[1\]](#fn1).
- Added `{@inheritdoc}` validation for override methods [\[1\]](#fn1).
- Removed `MissingParamComment`, `MissingReturn`, `SpacingAfterParamType` and `SpacingAfterParamName` rules.
- Ignored `MissingParamTag` rule for PHPUnit test class methods [\[1\]](#fn1).

### Gamegos.Commenting.VariableComment

[](#gamegoscommentingvariablecomment)

- Extended from `Squiz.Commenting.VariableComment`.
- Added `bool` and `int` into allowed variable types.

### Gamegos.Formatting.DisallowMultipleStatements

[](#gamegosformattingdisallowmultiplestatements)

- Extended from `Generic.Formatting.DisallowMultipleStatements`.
- Fixed adding 2 blank lines when applying `SameLine` fixer with `Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace` fixer together.

### Gamegos.Strings.ConcatenationSpacing

[](#gamegosstringsconcatenationspacing)

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

[](#gamegoswhitespacefunctionspacing)

- 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

[](#gamegoswhitespacemembervarspacing)

- 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
-----------

[](#development)

### Live Testing

[](#live-testing)

You can test any modifications by running [phpcs.php](scripts/phpcs.php), [phpcbf.php](scripts/phpcbf.php) and [phpcs-pre-commit.php](scripts/phpcs-pre-commit.php) scripts under `scripts` directory.

### Building Binaries

[](#building-binaries)

Run the command below to re-build binaries:

```
php scripts/build.php
```

### PHP\_CodeSniffer Dependency

[](#php_codesniffer-dependency)

Current version is built on [PHP\_CodeSniffer 2.9.2](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/2.9.2)which is locked in [composer.lock](composer.lock) file. To import new versions; edit [composer.json](composer.json) file if required and run `composer update` command, then commit the modified [composer.lock](composer.lock) file. Updating [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version may break some of [Gamegos sniffs](#custom-sniffs), so you must carefully track any changes on [PHP\_CodeSniffer](https://github.com/squizlabs/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. [↩](#fn1c1) [↩](#fn1c2) [↩](#fn1c3) [↩](#fn1c4)

---

#### License Notices

[](#license-notices)

[PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is licensed under the [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) license.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~350 days

Recently: every ~656 days

Total

9

Last Release

1035d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5402895fce341eb0254bd5312d8458d6c85e28cb5f088a6d7f962d4ea4047f0a?d=identicon)[glkz](/maintainers/glkz)

![](https://www.gravatar.com/avatar/f0070858f99354fde68177f3b2604e3d3dec2e9d93f18797059afeaf8f710b94?d=identicon)[gudubeth](/maintainers/gudubeth)

![](https://avatars.githubusercontent.com/u/6543464?v=4)[Safak Ozpinar](/maintainers/sozpinar)[@sozpinar](https://github.com/sozpinar)

---

Top Contributors

[![sozpinar](https://avatars.githubusercontent.com/u/6543464?v=4)](https://github.com/sozpinar "sozpinar (64 commits)")[![radekhubner](https://avatars.githubusercontent.com/u/5550455?v=4)](https://github.com/radekhubner "radekhubner (1 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gamegos-php-code-sniffer/health.svg)

```
[![Health](https://phpackages.com/badges/gamegos-php-code-sniffer/health.svg)](https://phpackages.com/packages/gamegos-php-code-sniffer)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M340](/packages/dms-phpunit-arraysubset-asserts)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8219.1M69](/packages/orchestra-workbench)[roquie/laravel-dusk-select2

Select2.js support for the Laravel Dusk testing.

41356.2k5](/packages/roquie-laravel-dusk-select2)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)[kunicmarko/graphql-test

GraphQL Test Cases

1359.0k](/packages/kunicmarko-graphql-test)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
